Detecting a Negative Pulse (Alarm accessory)

rmtucker

Member
I have a Std car alarm shock sensor which has 3 wires.
How would i connect this to a picaxe 28x2?

Wire 1 = 12V supply
Wire 2 = Gnd
Wire 3 = Negative pulse trigger

If the Shock sensor and picaxe are both being driven from a computer power supply(12v and 5v) ,Can i just connect wire 3 to an input pin or do i need some components in there?
 

John West

Senior Member
Can you provide a datasheet for the sensor? If by "negative pulse" you mean a logic low level near zero volts, then I'd advise a resistor voltage divider to reduce the 12V (possible) from the sensor would be sufficient input protection for the PICAXE.

I'd take a look at a roughly 10K Ohm/5K Ohm divider. The 10K end goes to the sensor device. The middle connection goes to the PICAXE input and the 5K end to ground.
 
Last edited:

Dippy

Moderator
Please supply a Data Sheet link as suggested by John above.

There is a BIG , and potentially destructive, difference between a driven and 'open' output. We don't want to see you pop your PICAXE.

Tell us your electronics skill level.
 

rmtucker

Member
I do not have a schematic for the sensor,just a wiring diagram.
This would normally be connected to a car alarm,just like a door switch.
So i summize when it says negative pulse it means that wire 3 goes to gnd when triggered.
Is there something i can check with my multimeter?
I have very little or limited electronic skills.
If i check from gnd to the negative pulse line with a meter and it is open until triggered,would this be ok to connect to the picaxe?
 

eclectic

Moderator
I do not have a schematic for the sensor,just a wiring diagram.
This would normally be connected to a car alarm,just like a door switch.
So i summize when it says negative pulse it means that wire 3 goes to gnd when triggered.
Is there something i can check with my multimeter?
I have very little or limited electronic skills.
If i check from gnd to the negative pulse line with a meter and it is open until triggered,would this be ok to connect to the picaxe?
So,
what IS the sensor?

And what's the "wiring diagram"?

e
 

hippy

Ex-Staff (retired)
I's say an educated guess would be that the trigger is open collector, shorts to GND when activated, quite possibly with a reed relay than a transistor or FET.

First measure voltage - When not activated and activated. If it shows voltage it's not open collector.

Connect a LED, anode to 12V, cathode to a 2K2 resistor, other end of resistor to the trigger. Does the LED light when the sensor is activated ? If so it's probably open collector.
 

Dippy

Moderator
If Wire3 is definitely open then yes, but you will need a pullup from that to PICAXE +V otherwise it will float.

I would suggest starting with a 10K between sensor o/p Wire3 and PICAXE input, if there is a 12V leakage this will be taken away by the PICaxe clamp.
Or for greater safety connect via a simple transistor and trigger the transistor to swith the PICAXE I/O. i.e. a transistor buffer.

To test:
Connect power to sensor. No PICAXE connection.
Measure between ground/0V and sensor output.
Measure it over a few seconds.
What numbers do you get?(Volts).
 

BeanieBots

Moderator
If the output is a 12v signal then you will need a potential divider between sensor and PICAXE.
If the signal is OPEN, then you will need a pull-up resistor to 5v and direct connection to PICAXE.

Get it wrong, and you will need a new PICAXE.

You can test with your multimeter.
Hook up the sensor to 12v supply and check output with meter.
If the sensor is OPEN, your meter should not read anything even when the sensor is activated. If it EVER reads ANYTHING in that condition, then it is NOT OPEN and will require a divider.
If there is no obvious output, fit a 10k resistor between output and 12v.
If the meter does then read a value, try with 10k to 5v.
If the meter confirms that the signal is now 5v, it is safe to connect to the PICAXE direct (with 10k pull-up).

A datasheet would of course tell you without doubt what type of output it has.

EDIT:
I obviously type slower than Dippy.
 

hippy

Ex-Staff (retired)
I'd go with this ...


Code:
       +12V -.-              -.- +5V
             |               .|.
.--------.   |           10K |_|   .-----------.
|   +12V |---'   1N4148       |    |           |
|   Trig |---------|<|--------^----| Input     |
|    Gnd |---.                     |           |
`--------'  _|_ 0V                 `-----------'
 

rmtucker

Member
"To test:
Connect power to sensor. No PICAXE connection.
Measure between ground/0V and sensor output.
Measure it over a few seconds.
What numbers do you get?(Volts)."

I powered the sensor up today and checked as above.
I get around 3.2v Wandering a little.
When triggered i get 0 volts.
 

hippy

Ex-Staff (retired)
Not an open-collector which is not what I'd have expected.

You could forgo the diode and remove the 10K pull-up if confident that the voltage won't ever go above the PICAXE supply, or replace the diode with a 22K and remove the pull-up if not entirely confident.
 

John West

Senior Member
Actually, it does sound like an open collector to me. A high impedance meter reading could well be picking up a couple of volts "wandering around" from an open collector (drain) output.

I'd suggest a pull-up resistor of 10K or so be hooked from the sensor output to the 5V supply, (make sure you have a common ground between the 12V and 5V supplies,) then reread the output. If it toggles between 0 and 5 V it's good to go.

Just don't hook up to the PICAXE until you're sure it's toggling between 0 and 5V. Then add a 1K Ohm input resistor to the PICAXE input, just in case.
 
Last edited:

Dippy

Moderator
Sounds open drain , maybe collector to me too.
i.e. when not 'triggered' logic-low the pin goes floaty-floaty blowing in the breeze and afffected by a multimeter input imp.

If you put a 10K pullup to 5V and repeat the tests you could confirm.

I agree it appears that a simple resistor pullup to 5V (or, generally, whatever the PICAXE power supply is) and connect to the pin.
However, as I am not standing next to you I am not going to guarantee anything.

I will just add one thing;
if you are going to put a protective series resistor between PICAXE and sensor and then a pullup between PICAXE and 5V you MUST remember that you now have a potential divider. So, if your ratio of series res: Pullup res is inappropriate then it won't work.
I'll leave others to explain.
 

rmtucker

Member
I can confirm after putting a 10k pullup resistor to +5v,that it now toggle from +5v to 0v when triggered.
I will connect it to the picaxe and see what happens.
Thank you very much for everyones help.
And thank you for putting up with my ignorance when it comes to electronics.
 

BeanieBots

Moderator
I agree with John West, that is DOES sound like open collector.
To make sure, connect a 10k pull-up to 5v (but DO NOT connect to PICAXE) and repeat the test.
Hopefully, you will only see voltages between 0v and 5v.
If that is the case, then you are good to go to connect direct to the PICAXE input and start writing code:)
I'd still put a 22k in series between the sensor and the PICAXE input with the 10k pull-up at the sensor end of the 22k.

Hippy's circuit should also be fine.
 

hippy

Ex-Staff (retired)
I agree with John West, that is DOES sound like open collector.
Maybe my rationale is wrong, but I assumed ( maybe wrongly ) that open collector was with the collector not connected to anything when not active, 'shorts' towards 0V when it is.

I can't imagine how there'd be a voltage on an open collector output if there's not anything pulling that up to a voltage. To get any voltage one needs a pull-up, as per I2C etc. Reading anything far from 0V on a 'floating meter probe' seems very unusual to me.

I'm always prepared to be enlightened though.
 

Dippy

Moderator
Best you post a schematic hippy :) , but on the face of it yes.

When the BJT is not 'energised' the only electrical flow getting to the collector (or drain) is from 'leakage' and 'ambient' e.g. induced.
Current flow is statistical.

So, your measured voltage will vary hugely depending on your multimeter , supply voltages kicking around and anything nasty induced... maybe even temperature as that affects electron/hole flow.
The measured voltage level will be very weak as they are very high impedance.Thus , it is so feeble as to be useless as a pull-up.
And multimeters will affect the actual voltage as their input impedance will be significant compared to the other impedances.

The best way to view it is to play with various BJTs and MOSFEts on a drop of breadboard in an Open collector/drain config.
There may be other leak issues when it's part of an integrated circuit.
Try it....
 
Last edited:

John West

Senior Member
The simplest explanation for the phenomenon is that the open collector transistor is not a perfect resistance. It's a semiconductor and is still connected to other sources of voltage. Pico amps or Femto amps of current can still flow if there is a current path to ground. In fact, every point in a circuit is always connected to every other point in a circuit through some combination of resistances, albeit extremely high ones. Even capacitors leak current through their dielectric in tiny amounts, thus possessing a measurable resistance.

A good multimeter with input resistances in hundreds (or thousands or tens of thousands) of Mega-ohms will allow such a flow to ground but will not load down the voltage that appears on its input, so it gets read. An old, low impedance input meter will load down the tiny current and will read zero volts.

What you end up reading with a modern meter is the voltage across a voltage divider, (consisting of the transistor and the meter input) of hundreds (maybe thousands) of Mega-ohms. You're practically reading ghost voltages.

Pico amp and Femto amp circuits can drive one nuts until all of this is clearly understood. The rules are the same, but nothing else is. When the exact capacitance of traces is a big deal and the dielectric value of your circuit bd material becomes a big deal too, you know you've entered another world of electronics.
-
As an aside, my Fluke lab meter has such a high input impedance (>10,000 Mega ohms,) that the voltage taken from a reading won't even go away until I take another reading, except through the slowest of circuit leakage. I have to be careful when using it because if I take one reading, then take a different reading at a point that is actually an open circuit I will still read a value very close to the first one taken, instead of a new one.

I usually have a 10 Meg resistor across the meter input to avoid that occurrence, but must remove it for accurate high impedance readings.

As the input impedance of even cheapie meters has risen drastically over the last decade or two, folks sometimes run into such problems figuring out just exactly what it is they're reading. The best advice in that regard is to always remember that your meter is a part of the circuit you're measuring.
 
Last edited:
Top