Feedback issues from my power supply

Hey guys, I programmed my Arduino to act as a timer and temperature control device. All my tests were running fine, until I hooked an external power supply up.

My Arduino powers and trips a seeedstudio.com Electronic Brick (digital) 5v relay, relay is the He Li Shun HLS8L-DC5V-S-C

I'm using a PC power supply to send 12VDC into the comm. side of the relay, and then a wire comes out other side of relay to a 12VDC 30amp automotive style relay. So basically, I'm using the Arduino to trigger the 5VDC relay to relay 12VDC to trigger the larger relay. The larger automotive relay is grounded via the power supply, and the coil is also energized how I just described above.

Anyway, the weird thing is that when I have the PC power supply turned on, in order to make the 12V relay trigger, the Arduino stops communicating with my PC. Anything running in the serial monitor stops, and if I try to connect to the Arduino to upload an altered code, the IDE gives me an error saying that Com3 port is busy being used by another device/program! I should mention that the Arduino is being powered by my PC through the USB cable, the 12VDC PC power supply is only being used to trigger the 12V relay and nothing else. Funny thing is, if I have the Arduino running the program and then turn the PSU on, it keeps working fine... But if I unplug the Arduino and then plug it back in, bam won't work!

This 5V relay I am using supports up to 250VAC @ 7amps, so I really doubt that my 12VDC PSU is screwing with it... but it almost does seem like some kind of feedback issue. Like I said, the code keeps running but any communication with my PC, trying to upload new code to the Arduino or use the Serial Monitor, is stopped.

Any thoughts?

Binary sketch size: 6074 bytes (of a 32256 byte maximum)
processing.app.SerialException: Serial port 'COM3' already in use. Try quiting any programs that may be using it.
at processing.app.Serial.(Serial.java:144)
at processing.app.Serial.(Serial.java:76)
at processing.app.debug.Uploader.flushSerialBuffer(Uploader.java:75)
at processing.app.debug.AvrdudeUploader.uploadViaBootloader(AvrdudeUploader.java:93)
at processing.app.debug.AvrdudeUploader.uploadUsingPreferences(AvrdudeUploader.java:56)
at processing.app.Sketch.upload(Sketch.java:1603)
at processing.app.Sketch.exportApplet(Sketch.java:1568)
at processing.app.Sketch.exportApplet(Sketch.java:1524)
at processing.app.Editor$DefaultExportHandler.run(Editor.java:2293)
at java.lang.Thread.run(Thread.java:619)
processing.app.debug.RunnerException: Serial port 'COM3' already in use. Try quiting any programs that may be using it.
at processing.app.debug.Uploader.flushSerialBuffer(Uploader.java:99)
at processing.app.debug.AvrdudeUploader.uploadViaBootloader(AvrdudeUploader.java:93)
at processing.app.debug.AvrdudeUploader.uploadUsingPreferences(AvrdudeUploader.java:56)
at processing.app.Sketch.upload(Sketch.java:1603)
at processing.app.Sketch.exportApplet(Sketch.java:1568)
at processing.app.Sketch.exportApplet(Sketch.java:1524)
at processing.app.Editor$DefaultExportHandler.run(Editor.java:2293)
at java.lang.Thread.run(Thread.java:619)

** Ok, that's weird. I just double checked all my connections, switched the AC plug on the power supply to a different outlet, one that doesn't share the same power strip my PC is connected to, then I disconnected USB cable from Arduino and from my PC, then I turned the PSU on, then plugged the Arduino side of the USB cable in and then the PC side...

Everything worked fine for about a minute, then the com3 usb port stopped responding, the readout on the serial monitor stopped and now when I try to connect to the Arduino it gives me the Com3 error again lol. The program is still running, it just won't let me connect to the arduino lol.

Steve
Have you tied the negative of the 12v suply and the 5v ground together.

Most supplies are floating ion their output.

mark

No, I haven't. So I should take the -12vdc of the PSU and tie it to the -5v ground of the Arduino?

I'm not sure why that would do anything, but it's worth a try. Like I said before, the 12VDC PSU runs 12V through the digital relay in order to come back and trip a 12V relay... So the only possible way it would have back to the Arduino is through the relay, and I shouldn't be getting interference from a 12V source when this thing is rated to switch 30VDC and 250VAC, etc....

** Tied the grounds together and even put a diode on the 12v relay to stop any interference from coming back... still no worky lol

Turn the PSU off, unplug the USB cable and plug it back in and then bam Com3 comes back to life, what the hell haha

Aaaaand, turn the PSU back on with the Arduino running and Com3 working fine, dun dun dun! One more transmission is sent to the Serial Monitor and then after that it goes dead... Relays keep clicking on schedule but the Tx light on the arduino stops blinking and Com3 goes dark.

Steve
I looked up the relay board to double check http://www.wit.dk/Seeedstudio_Relay.pdf
So long as the 12v or ground don't connect with the 5v or the ground, they should be fine.

I wrongly assummed you had the 12v relay earthed using the arduino ground (or the brick board ground)..sorry.
You could try disconnecting the 12v at the common, and second, try disconnecting the 12v relay earth.

BTW You could use a transistor to simply switch the 12v relay.... thereby eliminating an extra board and relay.

mark

Mark, I'll try those suggestions. I was also going to power the Arduino using a 9v battery, thus eliminating the USB connection and see if the program keeps running (see if the Tx light keeps blinking as it should).

I tried using a TIP120, and I hooked it up as per the instructions but the Collector pin kept going up to like .7V and then dropping back to zero, then back up to .7v then dropping to zero. Any thoughts on that? I'm new to electronics and figured the easiest way would be to use these 5V relays to trigger 12V relays until I learned more and could do a better setup. I set the transistor up as per the instructions here, http://itp.nyu.edu/physcomp/Tutorials/HighCurrentLoads#toc6

Except I skipped the pot and wired the base to a pin set to high on the arduino, connected the emitter to arduino ground and the collector pin was giving me that rise and fall to .7v... Any thoughts?

Steve
I have trouble when the instructions use the uP to provide current limiting.....

Ok here goes. Lesson in GOOD DESIGN PRACTICE
The output pin should ALWAYS have a resisor in series with it.
Basically the transistor base only needs 0.6v to turn on.
When you supply it with 5v from the output pin (or something else), it draws heaps of current, and usually the smoke escapes from the transistor (they work on smoke, because when it gets out, they don't work).
The resistor limits the amount of current that the base can draw by dropping some of the 5v so that the smoke stays in.

Think of a hose filling a bucket with a leak.
If the hose is On at the tap, it has full flow and overflows the bucket.
If you restrict the hose with a valve or squash it, the flow drops because the valve (restriction) is limiting the flow....same as a resistor.
If the restriction is the right size, the leak and the flow are the same and everyone is dry and happy.

Same principle with the transistor.

Anyway the 328 outputs are limited to about 20mA each .....BUT ITS NOT GOOD PRACTICE PEOPLE.

So lesson over about that.

When the transistor is turned on (current flowing into the base) it makes the collector to emitter conduct/turn on/pass current however you wish to think of it.
Anything connected between the collector and the + 12v of your supply (with the negative/common of the 12v supply connected to the Arduino Ground) (discussion regarding the use of term -12v is for another time) it will light up/operate/turn on.
Unless you have something between the supply and the collector (referred to as a load), you won't actually see any voltage change when measuring at the collector.
You can use a LED (with a resistor) from the +5v to the collector to observe this, and when the transisor is On the collector should be about 0.5v or less. When it is off it should be about 5v.

Lesson2 Relays
When a relay switches off, there is a big spike of induced voltage that usually makes the smoke in the transistor escape, or goes back around the power supply, creating havoc.
A diode across the relay stops this (that is why there is one between the relay coil and +5v on your brick)by making the spike go back through the relay...effectively killing the spike.

Someone just pointed me to this site, and this example for relays.
Note the resitor in series with the base ..good design... and the diode across the relay
http://tronixstuff.wordpress.com/2010/04/20/getting-started-with-arduino-chapter-three/

The example in 4.2 should also work if you used the transistor (and a 47 ohm resistor in series with pin D9 and the base)
For your 12v automotive relay, a TIP120 should be fine, but remember the diode with the end with the band connecting to the supply.

I'd try with the LED first and get your head around it, make it work, then try the 12v and relay.

Cheers
Mark

Thanks Mark.

I followed this guys tutorial and just built this circuit using a diode, resistor and a Tip120 and using my PC power supply for the 5V signal and the 12V and she works fine. I would still like to know why my previous setup with the 5V relay and the 12V relay made the Arduino go nucking futs. I'd rather use transistors anyway, as it reduces the cost and the size of the total package.

Now just to clarify this... I connect one of the Arduino ground pins to the 12V ground, right? If so, why? Is that so the transistor has a "larger" ground source to go to?

I see how transistors work now... Basically when you energize the Base, it opens a gate which allows current to flow from the emitter to the collector. But in this case, it's a ground current. So basically it's just a little switch, right? Could I connect the emitter to a + voltage source and then have a higher voltage come out of the collector? I'm going to read this site tomorrow, Transistor Basics -- but if you care to chime on my questions, feel free.

Thanks for your help!

P.S. I come from an aviation background, specifically being a pilot, and since you let me in on the little secret of how electronics work (smoke lol) I'll let you in on the secret of how airplanes stay in the sky... Money and coffee. lol

Now just to clarify this... I connect one of the Arduino ground pins to the 12V ground, right? If so, why? Is that so the transistor has a "larger" ground source to go to?

Right, the two grounds need to be connected.

The need to connect grounds is that you have to think of a complete current path for the base current, from arduino ground, through the emitter, through the base, and on to the arduino output pin. Without that arduino ground connect to the transistor emitter lead there is no complete current path for base current. The emitter lead also needs to connect to the 12v negative because that also requires a complete current path from 12v negative, through emitter, through collector on to the load and then to +12vdc terminal. Always think in complete current paths.

That make sense?

Lefty

I always understood the general role of grounds, but I had this misguided thought in my head that you had to keep the grounds of different voltages separated and I see where I was wrong with that thinking now.

Now, should I connect this Tip120 Darlington to some type of heatsink via the tab with the hole in it? Or is it small enough that I can just solder it down on a breadboard? Basically, what's the best/usual way to mount these things?

Steve
The issue of seperating voltage is a case by case basis.
In the case of a transistor turning on a 12v relay, the grounds need to be tied together.

Heat dissipation in transistors is a good question. It depends on the amount the device is required to 'disipate'.
If the transistor is not fully turned ON and a large current is flowing through, it acts like a resistor (the word transistor is transfer and resistor) and disipates heat.

Transistors may not get fully turned ON due to either fast switching (PWM) or not enough current to fully turn it on (not enough current passing into the base).
hFE is the measure of 'gain' so a gain of 5 means that if you want to switch 5 Amps at the collector, you need 1Amp into the base. You can beat this one will get hot, as the heat from the base at 0.6v at 1 amp is 0.6watts alone.

If it has an hFE (or gain) of 50, it will ony need 100mA to switch On. (more than the 20mA out of a 328)
For your 12v relay, No it should be absolutely fine. the current through the relay coil will be maybe 100-200mA at most.
If you assume the voltage across the Collector to Emitter is 0.8v (in the On state when current will flow) thats only 0.8 x 0.1 or 0.8watts

A TIP120 has an hFE or gain of 1000 so for 1mA into the base, you should be able to switch 1Amp.

You need to be careful with heatsinking, as most of theses device have the collector joined to the heatsink.
So if you don't insulate it, and bolt it to the ground, it will short out the collector to ground and make the device ON.

Cheers
mark