alexbb
Posts: 1
Joined: Fri Sep 26, 2014 11:11 pm

how to read/detect an input voltage spike?

Fri Sep 26, 2014 11:37 pm

hi, how do you read/detect an input voltage spike?

I'm building a sensor to check if my dog gets in/out to the house using the backdoor. So I have an IR sensor with 3 wires (DC12v, GND, OUT) that I bought online. I notice that OUT pin has a 12v by default and it will become 0 when someone or something is standing in the sensor. I build a voltage divider (3v) so that I can put it as input on my GPIO. I know how to detect the high (3v) or low (0v) but I can't detect a voltage down spike when my dog runs into my sensor. the sensor will just read in between 12v to 11v.

What is the best approach on this and how should i wire the output pin? thanks for the advice.

User avatar
Burngate
Posts: 6181
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: how to read/detect an input voltage spike?

Sat Sep 27, 2014 11:01 am

... when my dog runs into my sensor. the sensor will just read in between 12v to 11v
How are you measuring that? How does a dog differ from a person?

What are the details of the IR sensor? Is its OUT fed from an open-collector, with a pull-up to 12v?

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12580
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: how to read/detect an input voltage spike?

Sat Sep 27, 2014 11:19 am

did you measure with an oscilloscope? a multimeter is usually far to slow to catch fast moving variations (fractions of a second).

If your PI doesn't see the "dip", it doesn't follow there is none, it may be you are not looking often enough. Using interrupts might be a solution to that, but we are then normally talking about signals a thousand times faster than this (milli or nano seconds).

If the PIR detector isn't catching the movement (verified by using an oscilloscope) its simply not up to the task, infrared detectors are by nature slow.

pksato
Posts: 295
Joined: Fri Aug 03, 2012 5:25 pm
Location: Brazil

Re: how to read/detect an input voltage spike?

Sat Sep 27, 2014 11:57 am

Hi,
Its is only sensor chip or a complete module (Sensor, control board and Fresnel lens)?
Module have a two adjust trim-pots, sensibility and duration of output pulse.
Set both to you needs.

On RPI, best way to detect quick transitions is using interrupts.
Other is using fast pooling, but it use lost of CPU.

User avatar
Ferdinand
Posts: 236
Joined: Sun Dec 01, 2013 2:24 pm
Location: Leiderdorp, NL

Re: how to read/detect an input voltage spike?

Sat Sep 27, 2014 3:12 pm

Hello Alexbb,
Use a d-flipflop (d-ff) to detect a spike. The toggle input can be set by the sensor.
The Q output of the d-ff will be set (high). Now you can read the status of the Q output. After reading reset the d-ff (Q output -> low) for the next change of the sensor.

Good luck with your project.
...fjk
Success with your project!
Ferdinand

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12580
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: how to read/detect an input voltage spike?

Sat Sep 27, 2014 11:48 pm

if you want to "stretch" a short logic pulse, the proper logic device to use would be a "one shot", specifically a 74HC123 comes to mind.

User avatar
Jessie
Posts: 1754
Joined: Fri Nov 04, 2011 7:40 pm
Location: C/S CO USA

Re: how to read/detect an input voltage spike?

Sun Sep 28, 2014 3:24 am

12 to 11 v difference isn't much. With your v divider the voltage isn't likely getting low enough. Try adjusting your divider to between 2.4 to 2.0V this will bring it down to the lower threshold of 3.3V CMOS logic.

With a simple 3V divider for 12V, 11V will output 2.75V (with a 3v divider) and still read high. You need to get it lower. May also need to use a zeiner diode in conjunction to make it work.

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 12580
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: how to read/detect an input voltage spike?

Sun Sep 28, 2014 5:35 pm

Jessie wrote:12 to 11 v difference isn't much. With your v divider the voltage isn't likely getting low enough. Try adjusting your divider to between 2.4 to 2.0V this will bring it down to the lower threshold of 3.3V CMOS logic.

With a simple 3V divider for 12V, 11V will output 2.75V (with a 3v divider) and still read high. You need to get it lower. May also need to use a zeiner diode in conjunction to make it work.
i'm guessing the multimeter is simply averaging the pulse, and in fact it doesn't dip just 1 volt, but you need something a tad faster than a multimeter to check it. The output almost certainly is digital, not analog.

Return to “General discussion”