PDA

View Full Version : Not getting the full output from pins



Szczepaniec
- 31st July 2011, 20:59
I didn't think I would be back so soon but I am stumped again. I have a circuit that turns little Panasonic PCB 3v relays on and off. Their coils draw 16.8 ma so they are well under the PIC supply limit and they have internal diodes. When I have the 16F1827 attempt to turn the relay on, there is about 1.8v measured at the output pin and the relay doesn't quite have enough to click over. I have done the same circuit with 628As and 1320s with no problem. I am thinking it is something to do with a register setting I have yet to find but I have about 20 hours into finding it with no results. I have disabled the comparators, set the ports for digital, and played with just about every register I could find int the data sheet. I finally used the "All Digital.php" file from Mr. Taylor which has worked on everything for me in the past but not this. Any help with this would be much appreciated.



INCLUDE "ALLDIGITAL.pbp"
Include "modedefs.bas"
define OSC 16

OSCCON=%01111010 ' 1320


do
high porta.3
high portb.2
pause 500
low porta.3
low portb.2
pause 500
loop

HankMcSpank
- 31st July 2011, 22:45
The obvious question... What's the IO pin voltage measuring with no relay connected? (if it's 3V, yet you're only getting 1.8V when driving the relay, then it's your relay pulling too much current for one pin - try paralleling two pins & having them both drive the relay coil....if that doesn't work, then it's your power supply feeding the PIC (incidentally, is the PIC power supply pin holding up at 3V when connected to the relay coil?). The normal method is to drive a transistor from the IO pin which in turn drives the coil.

Szczepaniec
- 31st July 2011, 23:25
I should have included this and I apologize. I haven't measured the pin alone without a relay because the board is assembled but the other PICs bring the pin to 2.1v with the relay connected which seems about right. It is only the 1827 that seems to have issues. The supply voltage stays solid at 3.2v at the VSS and VDD pins when the relay is "on" or attempting to be on. I understand a transistor driving the relay is the preferred method but there are some other considerations that make that difficult which is why these relays were chosen. They appear to have been designed to be driven directly with a uC and they work wonderfully with everything but the 16F1827 which is what makes me think it has something to do with the setup of the PIC and not a hardware issue.

HankMcSpank
- 1st August 2011, 00:05
Well in your situation, I'd still be inclined to either desolder one side of the relay coil, cut the track feeding it etc (or if your 1827 is SOIC package, consider lifting the pin off the PCB with a scalpel while reflowing the pin with a soldering iron) ...just to prove you are getting 3V out of the particular pin (which pin is it by the way?) ....what's the DC resistance of the coil? Assuming it's spec'ed for 3V supply, then for @16.8mA it should be about 178Ω ? (if you've 1.8V being dropped across it, you can easily confirm the current flowing through the coil - which might be higher than your anticipated 16.8mA). If the DC resistance of the coil is any lower than 120Ω ...then the PIC @3V will likely baulk.

Szczepaniec
- 1st August 2011, 01:24
I didn't pull it off the board but I did set up an identical circuit on a breadboard and found the following:
Two pins together does power the relay but it sounds like a very lethargic actuation. It isn't as snappy of a sound as a relay with the other uCs.
A pin without relay does output 3.2V
When the pin is connected to the relay the relay is only drawing (or being supplied) 10 ma and the voltage drop is 1.8ish
The relay draws 17 ma when connected to the power supply.

It does appear for some reason the PIC cannot supply enough current for the relay. It is puzzling me because it is well within the PIC's capability and the other two PICs I have power it just fine.

I am inclined to just use a 1320 for the application but it leaves me wondering what I am doing wrong with the 1827.

Szczepaniec
- 1st August 2011, 02:25
I have also tried it with a 12HV615 at 3.2 volts and it works.

Bruce
- 1st August 2011, 08:51
What's the part # of the relay?

HankMcSpank
- 1st August 2011, 13:32
What's the DC resistance of the relay coil?

Szczepaniec
- 1st August 2011, 14:09
The coil resistance measures at 180 or 181 among three of them. The datasheet is here:
http://panasonic-denko.co.jp/ac/e_download/control/relay/signal/catalog/mech_eng_txs.pdf?via=ok
The p/n is TXS2-3V

I have tried pins most of the pins to no avail.

Charles Linquis
- 1st August 2011, 14:25
Most devices sink current much more readily than they source current. My guess is that if you connected the + side of the relay to 3.3V and the - side to your PIC pin, the PIC would drive the relay perfectly.

Charles Linquis
- 1st August 2011, 14:34
And here is some proof5812

Charles Linquis
- 1st August 2011, 14:58
If your relay draws 16.8mA at 3.3V, then it has a coil resistance of about 200 ohms (R=E/I). At 1.8V, it is sourcing 9mA. Looks like your device is slightly BETTER than specifications.

Szczepaniec
- 1st August 2011, 15:13
16.8 is off the data sheet which is probably based on 3 volts. It is far easier to change to a 18F1320 than change the board from sourcing to sinking the relay. I have already changed the code to use the 1320 but it still leaves me a little bothered like I am missing something. If it is just a quirk in the 1827 or in the lot I bought then that is what it is. However, that seems to be the least likely of scenarios which makes me think I have done something wrong in the setup. I am about out of hair and some pretty smart people have looked at this already with no results. I am pretty close to just going with the 1320 for everything and burying this issue in the book of unsolved mysteries.

Charles Linquis
- 1st August 2011, 15:50
Why do you think it is "unsolved". The datasheet shows what you can expect from the chip. Remember, the relay draws 16.8mA *when it has 3.3V across the coil* ( it is a 196 ohm resistance). If you put less than 3.3V across the coil, the draw will be less. If you measure 1.8V across the coil, then the PIC is sourcing 9 mA. Since the coil has 1.8V across it, the PIC has 3.3V - 1.8V = 1.5V.
The datasheet says that at 9mA, you aren't guaranteed to be able to source any current at all.

This is not "black magic".


And if you look at the datasheet for the PIC 18F1320, you will find that it is *NOT* guaranteed to work either. You may find some that do work, but the datasheet shows they wont. You need to SINK, not source the current from the relay to guarantee your circuit will work.


5813

Bruce
- 1st August 2011, 15:51
As Charles mentioned you would be better off going with the PIC as a low-side driver, but the best route would be to use some cheap low-side driver like a BS170 MOSFET.

Switching from one PIC type to the next may not always guarantee it's going to work from one to the next if it's operating border-line.

And a quick look at the relay datasheet does not show they have internal diodes. You will for sure want a flyback diode across those relay coils.

Szczepaniec
- 1st August 2011, 17:19
Unsolved is relative to my world. Until it makes sense in my pea brain, it is unsolved. However, it is solved now.

Thanks for all the help. I was unaware of the graphs posted here and when I went back to look for them I realized I had a preliminary datasheet for the 1827 that did not have them. I didn't even think to account for the internal resistance of the PIC when trying to understand why it wouldn't work.

Thanks for the catch on the diode Bruce. Thankfully the board was designed for a previously discontinued relay and a 1N4007 is installed for each of the relays. For some reason when I changed to the current relay I thought they had a diode installed. Luckily I never removed the clamping diode from the assembly instructions so they kept getting installed.

Thanks again for everybody's help.

Also, it does work as a low side driver.