Author Topic: Grounding issue  (Read 5451 times)

0 Members and 1 Guest are viewing this topic.

Offline cdacunha71Topic starter

  • Newbie
  • Posts: 8
Grounding issue
« on: May 21, 2014, 01:19:05 pm »
Hi,

I have a question regarding proper grounding of a circuit board.

I made a circuit to automatically close/open my chicken coop at dusk/dawn. It's based on an arduino pro micro board an had H bridge driver chip. It also has three indicator leds, two push buttons and a temperature sensor that I will use later on to enable a heat lamp when it's freezing. For the power supply I bought a quality 7.5V/1A wall adapter (switching supply) and to get the correct voltage level I use a LM317

I breadboarded the whole thing, developed the sketch and everything was running fine. Since the coop is located outside, in the cold moist Belgian weather, I decided to make a proper PCB and a and buy a proper case to keep everything well protected.

I repeated all my tests once the PCB was finished and started calibrating the photo transistor, so it would operate at the correct time. Until then, since I had to look at the value of the ADC, I had been working over the USB connection in order to have the serial monitor and powering the circuit over USB.

The problems started as soon as I disconnected the USB cable and started working with the external power supply, my ADC was getting erratic readings and the circuit wouldn't work. Every time I connected back the USB cable (only the GND, RxD,TxD and DTR pin) to debug the problem, the damn thing would work without a glitch. I tried all kinds of solutions but in the end I figured out that it was the GND connection over USB, that fixed the problem. Of course that GND connection is connected to the ground of my PC, which on it's turn is also connected to mains ground.

Once I figured that out, a simple connection to mains to my ground plane got the circuit working. I don't understand why it's working with the mains ground. I made sure to connect the LM317 with proper capacitors and protection diodes as depicted in the datasheet, the arduino pro micro board has it's own bypass cap. The leds, buttons and photosensor are located in a different casing connected with a 1 m cable, the pcb inside that case also has a decoupling cap (electrolytic + ceramic). The H-bridge IC chip doesn't have any decoupling, it's located on the same board as the arduino pro mini and it only works twice a day for a couple of seconds. I'll post some pictures. I'm trying to get hold of an oscilloscope so I can actually monitor what is wrong with the power supply.

What's the most likely cause of this issue? Bypass caps are too small? Wall power supply isn't up to spec? ...

Thanks

Carlos
« Last Edit: May 21, 2014, 01:21:42 pm by cdacunha71 »
 

Offline Richard Crowley

  • Super Contributor
  • ***
  • Posts: 4317
  • Country: us
  • KJ7YLK
Re: Grounding issue
« Reply #1 on: May 21, 2014, 01:47:58 pm »
My first guess would be NOISE.  You have an un-shielded box, and wires going here and there, none of which are shielded. Now, it may actually work out as built in the chicken coop, assuming it is rather remote from potential electrical noise sources.  But then, when you add the mains-powered heat source, you might run into the problems you are seeing now. So, maybe having this problem on the bench is a benefit so you can solve the problem now, and not de-bug it later.

When using non-conductive case material, I have frequently glued some aluminum foil around the interior, using spray-on adhesive (3M brand "77" spray or equivalent)

You didn't mention how you are determining "sunrise" and "sunset"?  Are you using a photo-sensor?  All of those components that are outside the box have wires that are acting like receiving antennas for noise unless they are shielded. I do mostly audio and video stuff, so perhaps I am hyper-sensitive to noise because you can actually HEAR it, but I use shielded cable and conductive enclosures for all inputs. And of course, the shield ("screen" in BrEnglish) is grounded ("earthed" in BrEnglish) at least to the ground-plane of the board and the enclosure.
 

Offline Thor-Arne

  • Supporter
  • ****
  • Posts: 500
  • Country: no
  • tinker - tinker, little noob.....
Re: Grounding issue
« Reply #2 on: May 21, 2014, 01:50:04 pm »
You need to post the schematic to get good answers.

But my guess is that it's not a grounding issue but a supply issue.
 

Offline cdacunha71Topic starter

  • Newbie
  • Posts: 8
Re: Grounding issue
« Reply #3 on: May 21, 2014, 05:23:03 pm »
Here are the schematics. The biggest one is the innermodule, it contains the arduino pro mini board, the LM317, SN754410NE Quad Half Bridge and a Low-Power Linear Active Temperature Sensor  MCP9700A-E/TO.
The second one is the door module, it's a small control panel were all leds are located, both push buttons and the TEPT5700 phototransistor, in the schematic it's represented as a led too. Just because my PCB cad program didn't have the component and it's the exact same housing and pins as a LED. On the second picture it's the small case on top of the CD drive

Don't worry about the dodgy wiring on the second picture, this is just a test setup. I use an old CD drive to open/close the door by activating the tray and using the end switches inside the drive. In the coop it's properly cabled. The blue/white wires that go to the front goes to a 2.1mm jack in order to connect the power supply. Once the cover is in place it will be neatly installed. The LM317 doesn't have a heatsink yet, I removed it at this moment just that the USB - serial cable is easier to install for debugging.

Regards,

Carlos
 

Offline Thor-Arne

  • Supporter
  • ****
  • Posts: 500
  • Country: no
  • tinker - tinker, little noob.....
Re: Grounding issue
« Reply #4 on: May 21, 2014, 08:51:19 pm »
It's a bit difficult to read the pins on U1, I assume you have another pinout than in the Arduino Pro Mini schematic ?

What is U1 pin number 21?


I can see that this is connected to the LM317, what is the voltage supposed to be?
A quick calculation gives about 27V with the values you have selected.


Anyway, as far as I can see you should supply the RAW input with the 7,5V Vcc and leave the Vcc pin on the Arduino unconnected.
 

Offline cdacunha71Topic starter

  • Newbie
  • Posts: 8
Re: Grounding issue
« Reply #5 on: May 21, 2014, 09:58:04 pm »
Yes, I had to make my own model of the arduino pro mini board inside my CAD program, so the pinout is not matching. The actual values on the resistor pair for the LM317 is 820 and 270 Ohm (I'll correct this on the schematic). When I measure the voltage it's 5.1V

U1 pin 21 is VCC, I don't use the regulator on arduino board itself. It can only deliver about 150mA and it's not enough to drive the other (future) components, that's the reason I don't use the RAW input. I've attached the schematic for the Arduino board too
 

Offline Dinsdale

  • Regular Contributor
  • *
  • Posts: 77
  • Country: us
    • pretzelogic
Re: Grounding issue
« Reply #6 on: May 21, 2014, 11:45:13 pm »
I'm really not clear on your circuit even with the provided schematics.
So I'll just give a guess.
The CD has a power connection from somewhere related to the PC.
The wall-wart ground is probably floating.
Pluging in the USB provides the same ground reference as the CD.
To test, leave the USB cable off and connect a 'scope probe ground.
This can't be happening.
 

Offline Thor-Arne

  • Supporter
  • ****
  • Posts: 500
  • Country: no
  • tinker - tinker, little noob.....
Re: Grounding issue
« Reply #7 on: May 22, 2014, 06:08:18 am »
I usually use the internal regulator on the Arduino to power the Arduino itself by connecting the RAW/VIN pin to the psu, I leave the Vcc on the Arduino unconnected.

This ensures that the supply for the micro is correct and as close as possible to the micro as possible to eliminate noise.


The rest of the circuit can be powered by a regulator similar to what you did in your schematic.


The supply voltages doesn't need to be from the same source, but all the GND must be connected together.

As Dinsdale said, try connecting the GND on your circuit to the GND on you CD/PC.
 

Offline cdacunha71Topic starter

  • Newbie
  • Posts: 8
Re: Grounding issue
« Reply #8 on: May 22, 2014, 05:24:32 pm »
Hi Dinsdale,

I'll post a block diagram in order to clarify. The CD is actually driven by the circuit through the H bridge driver. But you're right the wall adapter is a floating power supply, it only has two pins and no ground pin.

The arduino pro mini has no USB interface, so I have to connect a serial to USB adapter to my PC (which is of course properly grounded to mains) if I want to program or DEBUG it over the serial monitor. So each time I connected my serial cable to the circuit to debug the darn thing, the problem would disappear because the serial cable made the connection to mains ground.

Thor-Arne,

My voltage regulator is less than a centimeter away from the board so very close. I doubt this is the cause but I will give your suggestion a try but it's not easy to achieve since I don't want to cut the path on the PCB. I'll see if I can breadboard the thing.

In the meanwhile I got hold of an oscilloscope so I can perform some measurements. I also found someone with a very similar problem with a regular arduino board and an external power supply. I suggested the same solution to connect it GND pin to mains ground and his issue was solved too.

Maybe I have to construct a simple circuit just to isolate the problem?

 

Offline Thor-Arne

  • Supporter
  • ****
  • Posts: 500
  • Country: no
  • tinker - tinker, little noob.....
Re: Grounding issue
« Reply #9 on: May 22, 2014, 06:34:17 pm »
I'm not thinking about how far away the regulator is, but how the supply voltage is connected to the Arduino.

Think of the Vcc pin as a output pin as it is connected to the on-board regulator output.
Supplying 7.5V on the RAW pin will give you a 5V (or 3.3V) out on the Vcc pin, also, this is a generally good idea as the regulation for the micro is separated from the rest of the circuit.



This is a common problem when powering the Arduinos with a external adapter.

I see two possible problems; Common ground for all the parts, and supplying the wrong voltage to the Arduino.


First; if you solve the problem by connecting GND til mains ground, there is a serious bug in your circuit and you introduce a long ground return path for the current in your circuit.

It's best to make sure all your GND nets is properly connected, and it should function perfectly regardless of mains ground.


Second; there is often a misunderstanding as the Arduino does have a internal regulator and for this reason it needs more than the 5V normally assumed.



Your circuit needs common gnd on all parts, but the supply voltage can be different between the different parts.


And please don't confuse the mains ground with the GND pin on the Arduino, they are not the same. See here for more explanation.

IMO it's good practice to construct you circuit to work floating (without mains ground), i.e. battery operated. After the prototyping is done you ground your circuit to the enclosure chassis at a single point which is also connected to mains ground.
 

Offline Shock

  • Super Contributor
  • ***
  • Posts: 4218
  • Country: au
Re: Grounding issue
« Reply #10 on: May 22, 2014, 11:19:10 pm »
IMO it's good practice to construct you circuit to work floating (without mains ground), i.e. battery operated. After the prototyping is done you ground your circuit to the enclosure chassis at a single point which is also connected to mains ground.

Yeah, and the first thing I would try to rule out a supply issue is try it on actual batteries.
Soldering/Rework: Pace ADS200, Pace MBT350
Multimeters: Fluke 189, 87V, 117, 112   >>> WANTED STUFF <<<
Oszilloskopen: Lecroy 9314, Phillips PM3065, Tektronix 2215a, 314
 

Offline cdacunha71Topic starter

  • Newbie
  • Posts: 8
Re: Grounding issue
« Reply #11 on: May 23, 2014, 07:35:56 am »
Hi, thanks for all the replies.

I made a smaller/simpler circuit just with the arduino board, power supply, three leds and the phototransistor.
Since I can't hook it up to my PC. I made a small sketch which measures the sensor and calculates the difference with the previous reading. If the delta is smaller than 2, no led will light up, between 2 and 5, one led will light up, 5 and 10 the second will light up, larger than 10 the last one.
It's quite crude but since I don't have an LCD display to hook up it's the best I can do

1st test:   with 9v battery connected to RAW: as expected , very stable from time to time the first led lights up
2nd test:  7.5V wall adapter connected to RAW, leds/sensor being fed by 7.5V: there it is, erratic readings on the ADC, leds flashing randomly
3rd test:  7.5V wall adapter connected to RAW,  leds/sensor being fed by VCC (so from arduino power regulator) : much better, slightly worse than 1st test

So I guess I have to improve the LM317 circuitry (larger caps?) and also hook up the arduino on it's own power regulator as suggested by Arne.
So it's clear the problem is related to the power supply. I attached a scope, there's a sawtooth ripple 20 mV peak to peak, on the rising slope I can see 4 spikes that measure 60mV. The frequency of the ripple is around 300Hz.

As a last test I repeated the 2nd test, but this time I hooked up ONE of the free GND pins to mains ground, meaning that the power supply/circuitry is no longer floating. The readings improve significantly, a little bit worse than test number 3. This is what I fail to understand, why does it improve? On the scope I see the same ripple, the peak to peak voltage is slightly smaller and the spikes are around 40mV (also slightly better)


 

 

Offline Thor-Arne

  • Supporter
  • ****
  • Posts: 500
  • Country: no
  • tinker - tinker, little noob.....
Re: Grounding issue
« Reply #12 on: May 23, 2014, 12:49:30 pm »
This sounds like you have a switch mode wall adapter since the ripple is not coming from the mains.

Try putting a large electrolytic capacitor (2200uF) on the 7.5V before the LM317, that should remove most of the ripple. Connect the Arduino RAW pin to the same place.

I think the solution in the 2nd test is the best one.
Power the leds/sensor from the Arduino Vcc, and the driver chip from the LM317.


As for the mains ground improving things, I think it might be the sensor is picking up some mains hum. Probably due to unstable supply voltage, you might need to experiment with decoupling on the sensor.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf