12v input (not for running)

crazynight

Senior Member
As some of you may know I am building a timing system for my dogs flyball team, the day job has got in the way but have managed to make some progress.

The lights are now sorted. :D

As Texasclodhopper said at the beginning the human/k9 interface is proving problematic, I have had to remove all the original circuitry which has resulted in the only freed from the they gates being 12v. the issue I have is how to connect the 12v to a picaxe input pin (object there 0v object not there 12v)

I have tried a voltage divider which worked fine on the breadboard for 1 input but once I wired more then one divider up it stopped working.
1 - I have done something wrong with my circuit build?
2 - You can not have more then 1 divider in a circuit?

would a LM7805 be better than a voltage divider?

Sorry for multiple questions in one thread but they are all linked. :rolleyes:
 

bfgstew

Senior Member
Why not have the 12v connected to a relay coil, with 5v going across a N/O contact on it to your Picaxe?
 

crazynight

Senior Member
I already had that idea but the 12v trigger will operate a timer which needs to be accurate so the switching delay will cause me a problem.

would a ULN2003 in reverse work?
 

eclectic

Moderator
snipped

, I have had to remove all the original circuitry which has resulted in the only freed from the they gates being 12v. the issue I have is how to connect the 12v to a picaxe input pin (object there 0v object not there 12v)

snip.
Please can you supply a full,
up-to-date schematic?

e
 

nick12ab

Senior Member
I don't know about reversing a darlington, but what about a IRF510FET, pretty quick?
Connecting a MOSFET or another transistor to the 12V output will not produce a 5V output. How is it supposed to know you want a 5V output?

An LM7805 will not be a good idea because it needs input and output capacitors which will 'slow down' the signal.

As well as a schematic you also need to provide a photo of the non-working setup with voltage dividers so that it can be checked too.
 

crazynight

Senior Member
drawing of what I built this evening attached although I did not connect it to the picaxe as I was not seeing any voltage output from the resistors.

The blocks on the left represent reflective photoelectric switches which run off 12v and give a 12v output when an object is placed between the switch and reflector. from memory the resistors I used where 150 and 330, its all in the shed so will post a photo in the morning.
2013-09-26 22.52.16.jpg

ps ignore the pin locations on the picaxe artistic license :D
 

lbenson

Senior Member
There's no reason why multiple (appropriate) voltage dividers would not work. What are the 4 3-pin devices on the left of your drawing?
 

SAborn

Senior Member
Your resistors are rather low value for a voltage divider and you should be up in the Kohm range like around 10K.

The other option is to use a pullup resistor on the picaxe input, and a simple old garden type NpN transistor (BC 548, BC 337, etc) to pull the pin low with the 12v switching the transistor base.
 

crazynight

Senior Member
There's no reason why multiple (appropriate) voltage dividers would not work. What are the 4 3-pin devices on the left of your drawing?
The blocks on the left represent reflective photoelectric switches which run off 12v and give a 12v output when an object is placed between the switch and reflector.
 

crazynight

Senior Member
Your resistors are rather low value for a voltage divider and you should be up in the Kohm range like around 10K.

The other option is to use a pullup resistor on the picaxe input, and a simple old garden type NpN transistor (BC 548, BC 337, etc) to pull the pin low with the 12v switching the transistor base.
intput 14v (assumed the battery could have a range of 11-14v so took the worst case)
R1 330 Ohm
R2 110 Ohm
Output 4.375v

The NPN transistor would seem an easier method as I recall these are like a mini relays any chance of a quick schematic?
 

Dippy

Moderator
I agree with Ibenson and also agree with SAborn to play a little power-safe with higher value resistors.

You should have no problems at all if wired correctly.
Tell us exactly what goes wrong?
It really can't get much simpler so you've probably slipped up somewhere.

Edit: how can adding components be 'easier' when this circuit should work?
 

SAborn

Senior Member
I would think a 10K resistor to 12v+ and a 4K7 resistor to Gnd as a voltage divider should give you a exceptable voltage to the input pin.

At least with a voltage divider you are reasonably safe, because we dont really know what is switching the 12v or if it goes open circuit (as in a relay or switch), and a voltage divider will pull the picaxe pin low should the 12v be removed and no logic input on the 12v supply.

Where a transistor will work, but we need to design it so the base pin is not left floating, easy enough to do but we need more information.

Myself and i would just use a voltage divider as its only 2 resistors and dont see the circuit needing any more than that.
 

noelnelson

New Member
As above, increase the resistor values, at least x10. i.e. 3300 and 1500.
Placing a 4.7V zener diode in parallel with the input resistor, will provide a safety measure for the picaxe input. (cathode to input pin)
 

crazynight

Senior Member
right went back to basics this morning built a divider resistor on my breadboard and yes it works so i know what I have built is fine. (~12v in from a battery and ~4v out from the centre of the resistors.)

Connected up the output from the photo reflective sensors C18P-AN-1A to a multi meter yes 12v. output when there is no object there.

Disconnect all power from the bread board apart from the 0v and connect the 12v output to the breadboard.

Zero nothing diddle squat.

I am new to all this and kinda puzzled as logically its all fine but when the +12v is coming from the sensor the divider resistor fails to work.?
 

SAborn

Senior Member
Have you actually considered the voltage divider resistors you are using could be overloading the sensors output power capabilities.
I dont know what you have for the sensor and its output, but if you insist on using what resistors you have lying around, and not what should be used then expect strange results and even damage to the sensor.
 

crazynight

Senior Member
Have you actually considered the voltage divider resistors you are using could be overloading the sensors output power capabilities.
I dont know what you have for the sensor and its output, but if you insist on using what resistors you have lying around, and not what should be used then expect strange results and even damage to the sensor.
I as far as I am aware I am using the correct resistors as the output when using a 12v input is correct.

http://www.motioncontrolsystems.co.uk/productdetails/14899/18mm-polarized-reflective-photo-sensor-axial-optics-npn-sink-no-output-2m-sensi.aspx is the sensor I am using (C18P-AN-1A)
 

hippy

Technical Support
Staff member
Looking at the data sheet the C18P-AN-1A seems to have an open-collector output with an internal 100K pull-up to its +UB power rail.

It does not seem to me to be an active 0V/12V output, just a 'short-to-0V when active' arrangement, so there would seem to be no need to have a potential divider, nor to read the input as analogue.

It would seem directly compatible with a PICAXE digital input though a 1K current limiting resistor in series would add additional protection for the PICAXE.
 

crazynight

Senior Member
Looking at the data sheet the C18P-AN-1A seems to have an open-collector output with an internal 100K pull-up to its +UB power rail.

It does not seem to me to be an active 0V/12V output, just a 'short-to-0V when active' arrangement, so there would seem to be no need to have a potential divider, nor to read the input as analogue.

It would seem directly compatible with a PICAXE digital input though a 1K current limiting resistor in series would add additional protection for the PICAXE.
Hippy I am puzzled I did not think you could put 12v directly into the picaxe? just to confirm you are suggestion this:

12v ---------
|
---------12v from sensor (switched) --------------1k ohm resistor ---------picaxe pin
|
0v-----------
 
Last edited:

Dippy

Moderator
Just to prevent Forum ping-pong ;)

Is this the circuit we're looking at?

OptoRefOP.JPG

If so, you'll see that the 'Operating Voltage' (in this case 12V) can get to PICAXE pin via 100K resistor.
A clamp may protect PIC input, but an opto setup or 2ndry transistor stage would be safer.
Some simple maths may allow a p/d thanks to high impedance PIC inputs.

Edit: Ah, I see crazynight has modified his drawing since I started typing (obv. very slowly).
 

SAborn

Senior Member
Just a diode to 5v after the 1k resistor would clamp the voltage, and is what i suspect would be done with the internal diode, allowing for the direct connection through the 1k resistor.
 

hippy

Technical Support
Staff member
Hippy I am puzzled I did not think you could put 12v directly into the picaxe?
Unfortunately there is no simple answer to what seems to be a simple question.

The question comes down to what happens when a particular current limited voltage outside of the recommended range is continuously or continually applied to a PICAXE, PICmicro or other semiconductor device. Some will argue this will not cause an adverse effect and some will argue it does or potentially can. There is no universally agreed, definitive answer.

If prepared to adopt the position that a higher voltage suitably current limited will not adversely affect the device there would seem to be no reason not to allow and do that.

If not prepared to accept that, or wanting to be on the absolutely safe side, the best course is to stay within the device's documented specification.
 

crazynight

Senior Member
after much reading and getting very confused i believe although not the cheapest answer 4 opto-couplers will solve my problem 2 for each pair of sensors which is what i believe Dippy suggested "opto setup" but I did not know what "opto setup" meant until now!

and thanks to Dippy as never spotted that diagram in the data sheet explains a lot as the 100k resistor would effect the divider resistor setup.
 

noelnelson

New Member
If you want input buffering and Picaxe input protection at minimal cost, think about a ULN2803. The input is to the a base of a transistor, in your case, the 100k of the C18P-AN-1A may be a bit large to reliably operate the ULN2803 input, so add 10K resistors. I use resistor networks, they are easier to build and as cheap as multiple discrete resistors.
The output of the ULN2803 is basically an open collector, so simple 10k pullup resistor to 5V
Very useful IC, very cheap, and less complicated than multiple Optocouplers.
Sorry about the small pic in the pdf, I just selected it from one of my circuits.
 

Attachments

crazynight

Senior Member
If you want input buffering and Picaxe input protection at minimal cost, think about a ULN2803. The input is to the a base of a transistor, in your case, the 100k of the C18P-AN-1A may be a bit large to reliably operate the ULN2803 input, so add 10K resistors. I use resistor networks, they are easier to build and as cheap as multiple discrete resistors.
The output of the ULN2803 is basically an open collector, so simple 10k pullup resistor to 5V
Very useful IC, very cheap, and less complicated than multiple Optocouplers.
Sorry about the small pic in the pdf, I just selected it from one of my circuits.
I have a ULN2003A and from looking at the data sheets will work just fine.
 
Top