How to connect higher voltage to input reliably

nz-tdm

New Member
I have been working on my 3000mW handheld laser monitoring system for ages. It is a picaxe 08M2 connected to an LED, a buzzer through a transistor, a thermistor, and an 8.4V input.
It is almost perfect, the problem I have isn't really serious, but I want to make it perfect.

Now read carefully what happens:
The picaxe comes on when the laser's "armed" keyswitch is turned. An on/off pushbutton then controls turning the laser on/off, all the while the picaxe is still on.
The PICAXE runs off a 78L05 connected to 8.4V. If I turn on the PICAXE, it works all fine as usual. When I turn on the laser (1.5A load), it is still perfectly fine due to the 0.22uF capacitor I put on the PICAXE 5V rail!

BUT, if the laser pushbutton had been left on, and you turn the armed switch on, the laser comes on as usual, but the PICAXE doesn't boot. If I turn the laser pushbutton off then on, even for a millisecond, the PICAXE boots and works fine from then on.

Now here is how it is wired up, I want the PICAXE to know when the laser is on, so I connected the pushbutton to INPUT3 on the PICAXE so INPUT3 gets power along with the laser when the pushbutton is pressed.
I realise that the 8.4V input is too high for the PICAXE, so I experimented with resistors and discovered that a 47K resistor between the 8.4V and the INPUT3 worked fine (with a 10K pulldown).

I have checked and it is not a software problem.

What I don't get is why the PICAXE stays working fine when the laser load is turned on, but not if they are both turned on at the same time.

Here is a drawing to help explain the set-up:
d.png

See how the PICAXE only fails to boot if the laser on/off switch was already on when the main keyswitch is turned on. If I turn the laser pushbutton off then on, even for a millisecond, the PICAXE boots and works fine from then on.

I hope it wasn't too hard to understand...
 

AllyCat

Senior Member
Hi,

Your power supply arrangements are not really clear from the diagram, but it appears that you do not have the expected potential divider from the laser supply to input 3.

What is possibly happening is that the voltage on Pin3 is passing through the "electrostatic protection" diode in the PICaxe to its supply rail. If the overall load on the rail is quite light then the PICaxe could boot from that supply and then "crash", or the Brown Out Detector operate, when the PICaxe runs and pulls down the supply rail. What happens if you put a resistor of between say 1k and 4k7 from the PICaxe supply to ground?

Cheers, Alan.

EDIT: As pointed out below, Pin3 (Leg 4) on an 8M2 is the one Input pin which does not have an ESD protection diode, so the voltage can be driven significantly above the normal supply rail. That's unlikely to actually erase or corrupt the program memory, but it might well lock up or Reset the processor in an unpredictable manner, which is certainly bad practice. And above 9 volts could easily destroy the chip.
 
Last edited:

inglewoodpete

Senior Member
There are a couple of areas of concern. Firstly, I don't think input 3 on an 08M2 has any internal input protection diode so there is a chance of damaging the input if the voltage divider is not right.

The other is that the 0v return path for 1.5 amp laser diode should be kept as a separate feed from the supply's 0v for the 78L05 and the PICAXE.

Pehaps a circuit diagram will help us to better help you.

Finally, I hope you're going to be really careful, sensible (and legal) with that laser. 3 watts is a very powerful laser. Don't aim it at Australia: it might be considered to be an act of war :):)
 

westaust55

Moderator
so I experimented with resistors and discovered that a 47K resistor between the 8.4V and the INPUT3 worked fine (with a 10K pulldown).

It should not require experimentation. Think in terms of a potential divider using 2 resistors.
As a TTL input, the 08M2 input will indicate a HIGH state with a voltage form 2.0 V to 5.5 V.
So in case your battery when fully charged is a little higher than 8.4 Volts, and based on having your 10 KOhm pull down resistor on INPUT3,
use a 12 k Ohm resistor in series with the 10 kOhm giving a total of 22 kOhm with the nominal 8.4 V across to total 22 kOhm.

To calculate:
Having the 10 kOhm as the bottom (pull down) resistor

Rtop = Rbottom * Vinput / (Vbatt - Vinput)

Lets make the Input voltage (Vbatt) = 4 Volts, so then

Rtop = 10 * 4 / (8.8 - 4) = 12 k Ohms (we could use as low as 10 kOhm and it would in fact still be okay with a battery voltage as high as ~9.0 Volts.

where we have use (Vbatt = 8.8 in case of surface charge if it has just been charged.
Even when (Vbatt = 8 Volts, Vbatt will still be 3.6 Volts which will still be seen as a HIGH state.

As already mentioned, rather than somewhat vague block diagrams, can you please provide a full schematic showing all decoupling capacitors and bulk capacitors associated with the voltage regulator and PICAXE.
A diode in front of the 78L05 may be helpful to prevent momentary voltage dips when the laser is turned on - which could cause the PICAXE to reset.

You mention having a 0.22 uF capacitor. What type of capacitor is that? Ceramic, polyester, tantalum or aluminium electrolytic?
That value would be seen more as a decoupling capacitor but needs to be of the correct type.
 

Attachments

MartinM57

Moderator
To reduce 8.4v to PICAXE friendly voltage you would normally use a potential divider, as per WA55's diagram. That's not what you have done - check the difference.

You have built something more like the download circuit - an 'outside' 10K to ground and a current limiting 47K on the input. Although 'not normal' I suspect it works fine with your 8.4v signal from the button. What experiments did you do to determine that 47K was a good value? What happened when you did not have a good value?

+1 vote for a proper circuit diagram please, including all pin connections and capacitors.

What does the software actually do? As standard, I always put a pause of 100mS or so at the start of every program to let the 'electronics' settle down before the code starts running - it's habit now, and it must have solved some problem I had in the past. For testing you could even make it a 1 second pause so that it's obvious it's happening.

If you want the PICAXE to do something at EXACTLY the same time that it is powered up (maybe you are trying to build some sort of safety interlock?), then you MIGHT need to think again about the circuit design, but without more details, impossible to say

EDIT: why do you think the PICAXE is 'failing to boot'. Put some sertxd("I've started") debugging at the top of the code. Then test the switch-combinations and see when you get the message on the F8 Terminal window (in which case you definitely need a pause at the start to allow the window to open immediately after programming to catch it). I'd be surprised if the PICAXE is only 'booting' when you turn off and on the push switch
 
Last edited:

Svejk

Senior Member
The pin used (C.3) is the Vpp pin for a native PIC, does not have a diode as it needs to go to a higher voltage. I suspect the 08M goes into programming mode while the pin is high.
 

inglewoodpete

Senior Member
To reduce 8.4v to PICAXE friendly voltage you would normally use a potential divider, as per WA55's diagram. That's not what you have done - check the difference.

You have built something more like the download circuit - an 'outside' 10K to ground and a current limiting 47K on the input. Although 'not normal' I suspect it works fine with your 8.4v signal from the button.
I think that it is not fine: there is no ESD protection diode. While the 47k resistor will limit the current, it is applying a programming voltage to the PICAXE and may turn it back into a PIC.
 

MartinM57

Moderator
I only 'suspected', I wasn't definitive :)

So a proper potential divider with calculated resistors, as per WA55, is probably the solution
 

Goeytex

Senior Member
As has been correctly pointed out, there are no internal ESD diodes on input c.3 to clamp the voltage.

A simple solution may be to move the thermistor to input C.3 and the switch input to the pin that the thermistor
was connected to, leaving the resistors connected in the same manner on the different pin, but reducing the 47k to 22K as in the standard download circuit. Then, of course , modify the code according to the pin changes.

EDIT: On second thought, the above will likely not work properly using the internal diode clamps since the clamping is dependent upon the Picaxe having 5v applied. If the Laser switch is on and the Picaxe is not powered then the 8.4v will be seen at the input pin.

Much better to use a voltage divider as described by Westaust55 in this case.


A .22uf capacitor on the 5v rail my have helped but a larger electrolytic may be more appropriate. I would use something like a 100uf. I would also put a rather large 2200uf electrolytic capacitor across the battery to reduce voltage droop when the laser is turned on. Also Make sure there is a 100nf decoupling capacitor from the Picaxe +V pin to ground.
 
Last edited:

Captain Haddock

Senior Member
Rather than using a voltage divider would it not be better use an optocoupler and keep the 8.4v seperate from the picaxe alltogether, I have a project that checks the state of 12v lines done like this and works fine.
 

hippy

Ex-Staff (retired)
If I turn on the PICAXE, it works all fine as usual. When I turn on the laser (1.5A load), it is still perfectly fine due to the 0.22uF capacitor I put on the PICAXE 5V rail!
Reading between the lines it appears you are saying that the capacitor carries the PICAXE through a power brownout; perhaps that's not the case for a larger brownout but it's not clear to me what signals ( power or data ) are present and when. Unfortunately "turn on", "throw a switch", "push a button" doesn't fully indicate what the signals become.
 

Paix

Senior Member
Circuit diagram please, +1. The forum crystal work is being starved by the lack of pertinent graphical data.

Send us a picture do . . . to the tune of Dazy, Daisey. Be vague drink more Haig.

It's definitely a sequencing problem: Now read carefully for this is how it works:

You send circuit diagram and clear photo of the power, regulator and other wiring, give mAH capacity of the battery and the forum members save some time guessing by using the information to answer YOUR question. That;'s how it works properly and gets to anything better than a best guess in the dark answer that saves yourself and others a great deal of typing.

Smile your lappies camera is watching you and raising your eyebrows won't help - this time . . . :)

Click, click problem almost solved?
 
Last edited:
Top