Brandon92
Posts: 775
Joined: Wed Jul 25, 2018 9:29 pm
Location: Netherlands

Re: GPIO.input voltage levels vs edge detection

Sun Mar 10, 2019 11:38 am

You could indeed use a level shifter between the 3.3V and the 5V. So that you can play safely with the 5v without damaging the Rpi. You could use something like this and you could also made it by yourself. If you use it without the level shifter it is possible. As long as you connect the pullup resistors to the 3,3v rail and not to the 5v rail. And the atmega will not set his output to high. Then the 5v is going to the rpi.

Did you study my comments about the zener diode, and how to use them? And why in your case the zener diode will not give you the correct voltage that you want. (tip: it is in serie (draw it on paper and see the result), when the output of the NE555 is "loaded" the voltage will drop (Figure 4).

petermeigs
Posts: 96
Joined: Thu Mar 23, 2017 1:34 pm
Location: Los Altos, California

Re: GPIO.input voltage levels vs edge detection

Mon Mar 11, 2019 7:57 pm

I (finally) see what you are saying about the zener. I am effectively placing 4.x vdc on ch0 of the adc (MCP3008). The adc (MCP3008) is running on 3.3 v and so I am just reading the max possible 10 bit result.

I'm not totally clear on how to correct it. What I'm trying to do is make it so that I present at most 3.3v on CH0 of the ADC. Perhaps moving the 100ohm resistor elsewhere will do the trick.

I purchased level shifters similar to those you suggested and am trying these out on the MCP3008. It is an SPI device so there are 4 channels I need.

Brandon92
Posts: 775
Joined: Wed Jul 25, 2018 9:29 pm
Location: Netherlands

Re: GPIO.input voltage levels vs edge detection

Mon Mar 11, 2019 8:54 pm

petermeigs wrote:
Mon Mar 11, 2019 7:57 pm
I (finally) see what you are saying about the zener. I am effectively placing 4.x vdc on ch0 of the adc (MCP3008). The adc (MCP3008) is running on 3.3 v and so I am just reading the max possible 10 bit result.
Yes, and the the R4 (10k) resistor is kind of protecting the your 3.3V rail. And the internal diodes of the MCP3008 (FIGURE 4-1) is protection the input. And the overvoltage is dumped into the 3.3V rail. And this is not a wanted situation.
petermeigs wrote:
Mon Mar 11, 2019 7:57 pm
I'm not totally clear on how to correct it. What I'm trying to do is make it so that I present at most 3.3v on CH0 of the ADC. Perhaps moving the 100ohm resistor elsewhere will do the trick.
The correct why of connection a zener diode is this diagram. Where Vin is the output of the NE555 and the Vout is going to CH0:
Image

petermeigs
Posts: 96
Joined: Thu Mar 23, 2017 1:34 pm
Location: Los Altos, California

Re: GPIO.input voltage levels vs edge detection

Mon Mar 11, 2019 9:28 pm

Got it! Thanks. It looks like I just have to move the 100 ohm resistor to between NE555 pin 3 and the first junction before the 10k ohm resistor.

petermeigs
Posts: 96
Joined: Thu Mar 23, 2017 1:34 pm
Location: Los Altos, California

Re: GPIO.input voltage levels vs edge detection

Wed May 15, 2019 4:16 am

Well, I am back at this. I took a bit of time off to wait for the weather to be pleasant enough to install my first water meter. It was not too much trouble. What was not fun was crawling the length of of my home in the crawl space underneath the house. It is about 3 ft or 1 meter high, very dusty and quite unpleasant. This is traditional construction for older homes in California and is quite sound for earthquake stability. Newer home have basements which gives more space and more headroom but time will tell how well the perform when a not trivial earthquake strikes.

Anyway, I strung 80 ft (25m) of 3 conductor shielded cable from the meter to where the controller was. The meter is enclosed in a buried plastic valve box next to the house. I'll have a second meter in another part of the garden so I'll have to deal with that later. I'll upload some photos later.

I have been testing the software and breadboard circuit for the flow meter and that has been working to my expectations so I am going to let it run a while just counting water volume as it goes by.

Meanwhile, I need to finish my circuit board that integrates the 24v detection with the flow meter. Following our previous discussion, I am using a more or less separate (I'm using a 2 USB port, 5v power dongle) 5v circuit for the reed switch in the flow meter and I have this input going into an HCPL3700 (actually an A3700) through through two 47 ohm resistors into the dc inputs on pins 2 and 3. This brings up a question that someone with more experience than I might answer: Should I have the reed switch interrupt the ground side of the 5v circuit with the +5v going directly through a 47 ohm resistor to pin 2 of the A3700 or should I interrupt the +5v side? I'm thinking interrupt the ground side but also it probably makes no difference.

Return to “Python”