loading

How to connect higher voltage to PIC chip input reliably ?

The PICAXE 08M2+ IC is just an 8-pin flash PIC with nanowatt...

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.

The attached drawing is to help explain my set up.

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...

Picture of How to connect higher voltage to PIC chip input reliably ?
sort by: active | newest | oldest
It could be that when the system powers up with the laser load already connected, the 5V from the regulator doesn't ramp up the same as when it is unloaded, and the picaxe gets into some weird state. If you have a scope, see if there is any difference in the rise on the 5V output in each case.

As for interfacing the picaxe to the 8.4v to monitor the laser pushbutton, you should just need to scale it down from 8.4V to 5V. The way it is shown in the diagram above isn't really a voltage divider. It should work though, as the 47k limits the current below what would overdrive the input pin. Does the issue with power up still happen whether the pushbutton monitor feature is connected or not?

One approach to consider would be to have the laser load turned on by a transistor that is controlled by the picaxe. The picaxe would then monitor the pushbutton switch, and if it is pressed , turn on the transistor and the laser. That way you could prevent the laser from being powered on until after the picaxe has booted up.
jdorne (author)  LargeMouthBass4 years ago
I thought about that, but this is what happens.
After I turn on the keyswitch WITH the laser button already on, the laser and picaxe get power at the same time and the picaxe refuses to boot. However... If i turn the laser pushbutton off, the picaxe boots, and works fine from then on, even when turning the laser pushbutton on/off.

I think it cannot boot because of noise maybe?? The laser is powered by a small switchmode power supply witch could make noise am I right?
Where would capacitors be placed to reduce noise if that is interfering with startup? Somewhere on the input pin?

And can the 10K pulldown be increased to 100K? Will 147K pull the pin to low correctly?


Thanks for your help. :)
iceng jdorne4 years ago
Caution
As the value of the 10K goes up so does the input to the Pic.
You want to reduce the value down.

A
jdorne (author)  iceng4 years ago
Are you sure? I didn't have a voltage divider in mind, just a 47K resistor, but the 10K was needed to pull the input low.
iceng jdorne4 years ago
Actually you need to wire the voltage divider as per the figure # 2
  1. R1=47K  and  R2=100K  feeding 5.7 VDC to the uP input pin.
  2. R1=47K  and  R2 = 68K  feeding 4.9 VDC to the uP input pin.
  3. R1=47K  and  R2 = 47K  feeding 4.2 VDC to the uP input pin.
The R2=68K is the proper divider.

You may have already damaged the input pin except for the fact that
Microchip protects their inputs with a resistor and diodes.

You can see why increasing R2 is the wrong way even in your ckt.
Divider8.4.JPG
jdorne (author)  iceng4 years ago
If you look at my drawing properly, you can see that I am not using a voltage divider. I am using just a 47K resistor by itself. It looks like a divider but as you can see, the 8.4V is going into the MIDDLE of the two resistors. It isn't a voltage divider, it is just a 47K resistor with 10K pulldown. I always measure <5.7V at the input pin.

Ignore the 10K resistor too see what I mean.
iceng jdorne4 years ago
I do see what you are saying .
I also messed up reading the value 100K really 10K sorry about that.

Ignoring the 10K pull down is even harder on the input pin.

Sending more then 5 volts to a ( 5Volt Micro ) input pin is wrong and can
harm the the IC because it ( the IC ) has to try to lower the voltage
internally and that is only supposed to happen for a moment NOT continuous.

Try this ... putting a series 47K resistor to the input pin from a higher
voltage with the idea to reduce the input voltage is a natural reaction.

Ask yourself how a resistor absorbs voltage ?

It takes a current flowing through the resistor to make the voltage drop.

Where is that current going ?

The uP must be pulling input current to drop that voltage in the resistor.
.
Pulling current is not the normal job of an input pin.

I don't know what else to say.
Sorry to bend your ear :-)
jdorne (author)  iceng4 years ago
What do I do then? Actually try a voltage divider? Like the one you posted with 47K/68K?
iceng jdorne4 years ago
Sure
BTW you have an impressive web site.

Here is how I do the math ;
  1. The total resistance is 47K + 68K = 115K
  2. Current then is V/R = 8.4 / 115K = o.000073 Amps
  3. For the Input voltage is on the 68K resistor
  4. We know the current through the resistor = o.073 ma
  5. Volts = I * R = o.000073 x 68000 = 4.9V

This assumes the resistors are exact though they could be +-10%
or 5% depending which you purchased and the input pin takes no
current but this is close enough.

The micro processor accepts a low zero input as ( 0V - o.8V )
and accepts a High One input as ( 2.0V - 5.0V ) leaving a gray
range between [ o.8v and 2.0v ] where the digital input is unsure.

So if you use a two 47K - 47K voltage divider, it still guarantees the
uP will interpret the laser is ON at 4.2 volts as a digital one.
jdorne (author)  iceng4 years ago
Thanks for the info. So you recommend using a 47K/47K voltage divider instead of just one 47K like i've been doing? I will try it anyway with my next build, should be a few weeks as the current laser has sold.
iceng jdorne4 years ago
Just giving you options in case you don't have a 68K on hand.
jdorne (author)  iceng4 years ago
Ok thanks. I have anything on hand. What would you do with anything on hand? 47K/68K??
iceng jdorne4 years ago
I would do 47k - 47k ... :-)
I suspect the following:

On startup the 08 takes a short amount of time to boot up.

Depending on how you have written the software this may mean it misses the input that is already there - ie there is no change to detect.

You could try a simple short prog to test eg..

start:
if input 3=1 then alarm
goto start

Alarm:
high 1 ; this is an LED to show the alarm.

end


This is a one shot that activates of pin 3 is high so should see the input - you need to change the voltage divider as well as other have said what you have isn't a voltage divider.

a) Why not simply put an LED & resistor on the switch line to indicate it is on and b) for safety sake you should not be able to leave the laser on button pressed so that it comes on when the arm switch is operated this is an accident waiting to happen.


iceng4 years ago
A momentary current draw making the 78L05 drop out could be the cause.

Use a Low forward schottky diode and start experiment with a 1 uF cap.

A
iceng iceng4 years ago
Sorry here is the picture of the ckt change.
pic2.jpg
jdorne (author)  iceng4 years ago
Thanks. I will try the diode. The schottky diode is one with 0.3V drop instead of 0.7V am i right?

The only schottky diodes at my local store are 1N5819 and BAT46/48. Will any work? Otherwise I will need to wait for an eBay order...
iceng jdorne4 years ago
The reason for a low forward voltage drop diode is to leave as much
voltage as possible for the 78L05 regulator as the battery discharges in
running that 1.5 amp laser.

The 78L05 works down to low of 7 VDC when I read the PDF

And if you click on the pointers provided you will get more info.