Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Grounding issues affects ADC reading of microcontroller

Status
Not open for further replies.

lloydi12345

Member
Hi again ETO,

I am having this grounding issue on my PCB. My project here is a simulator box and a temperature controller PCB enclosed in an aluminum box.

The simulator box is powered up through 220VAC and it has a transformer that converts 220 to 24VAC. It also has one relay in it that controls 220VAC solenoid Valve. The simulator box has 4 output pins and 3 input pins.

OUTPUT Pins:
1&2 are connected to the 24VAC of the tranformer
3&4 are connected to a thermistor which when gets hot changes the resistance reading on 3&4 pins

INPUT Pins:
5 is 32Vdc coming from the temperature controller PCB connected to the +pin of relay which controls solenoid valve 220vac and gas valve (but there is no gas valve attached just LED for indicator)
6 is input pin coming from the temperature controller PCB which is connected to the -pin of relay which controls solenoid valve 220vac
7 is input pin coming from the temperature controller PCB which is connected to the -pin of relay which controls gas valve (but there is no gas valve attached just LED for indicator)

------
The Temperature Controller PCB consists of many components. PIC18F4620, Switching regulator circuit (MC34063 circuit), ULN2803 for controlling the solenoid and gas valves, speaker, two dual 7 segment LED, 12 push buttons, 8 LEDs and bunch of discrete components.

INPUT Pins:
1&2 are connected to 1n4007 diode rectifying 24VAC to ~32VDC
3&4 are connected to the microcontroller using Steinhart-hart circuit for calculating temperature

OUTPUT Pins:
5 is connected to 32VDC which is the output of the rectifier bridge 1n4007
6 is connected to PIC18F4620's pin through ULN2803 which controls the solenoid valve. Turning off the solenoid valve, the PIC should produce 32VDC so the relay would not turn on to activate the solenoid valve. When I turn it on, I just produce 0VDC from the pin to turn the relay on.
7 is connected to PIC18F5620's pin through ULN2803 also.(same principle as for solenoid valve pin)


----
Problem:
Now, there's no problem actually at the start. Turning on the simulator box everything works fine. Everything is functioning. The problem occurs whenever I move the bundle of wires that connects the controller and simulator box.

For example, with the wires untouched the reading would be 363F but when moved or hit heavily the temperature reading drops to 340F+(the temperature here varies depending on the intensity the wires got moved)

----
Solution:
Whenever I turn on the solenoid valve the reading of the temperature quickly jumps back to the proper reading. BUT! this is just for one time. While the solenoid valve is currently on, if I move again the bundle of wires, the temperature goes down again and I have to turn off the solenoid valve and turn it on again for the reading to go back up normally. If the solenoid valve is just always ON it will not help the temperature reading go back to its normal reading when wires are moved again. (Turning the solenoid valve on and off every few seconds definitely fixes the temperature reading but I can't do that since the solenoid valve has its purpose and it should be only turned on or off at a certain time.)

Another thing I have observed, I soldered a long wire on the GND of my PCB and whenever there is an abnormal reading on the temperature, i just connect the other end of the wire to any piece of metal like for example on its casing aluminum box. I even tried it connecting to the usb port of the laptop and strangely the reading came back normally. BUT! when I clip the wire permanently to the any metal object and when I move the wires, the reading goes down again and I HAVE TO RE-ATTACH it to the metal object just to pull it back to its proper temperature reading.

I really really think this is a grounding issue. I didn't forgot the bypass capacitors beside the microcontroller, flyback diodes for the valves(they're placed on the pcb), capacitors at the end of regulators, I checked them with the oscilloscope and they are really good. I don't know how to use oscilloscope to detect the problem on the ground though.

Btw, I also tried using other power source instead of switching regulator, I used Bench power supply (+32VDC & +5VDC) and the problem also still occured so it must not be the noise on the switching regulator. Or I really don't know.

I hope someone could help me with this one.
 
Last edited:
Could you post screenshots of the schematics and pcb.. or a pdf file.
 
Hi misterT, thank you for your interest :)

I posted the whole PCB schematics and layout here.
 

Attachments

  • Schematic.pdf
    26.3 KB · Views: 323
  • Top Copper.pdf
    68.8 KB · Views: 191
  • Bottom Copper.pdf
    41.2 KB · Views: 320
  • Top Components.pdf
    45.2 KB · Views: 142
  • Bottom Components.pdf
    37.6 KB · Views: 159
Processor w/ ADC on two layer PCB = ground bootstrapping problems causing ADC analog input errors.
 
Processor w/ ADC on two layer PCB = ground bootstrapping problems causing ADC analog input errors.

Hi RCinFLA, can you furthermore explain the problem? Do I need another PCB for ADC circuit?

BTW, SV1 is the connector for thermistor. SV2 is for the ICSP connector SV3 is as follows (24VAC,24VAC,~32VDC,-pin of speaker,-pin of relay for gas valve,-pin of relay for solenoid valve)
 
And you have a switcher on the board.

You might stand a chance using the Vref+ and Vref- as isolated supplies with ADC input ground referenced to Vref-.

Read the PIC info on achieving best ADC performance.
 
Hi
You might try adding a complete ground plane on both sides of the pcb.
The top looks like it has many copper islands (copper areas that are not connected to form a single plane on the board)
The bottom has no ground plane at all..
 
Where are your 0.1µF decoupling caps (I see only one, try another). Also one across D10 wouldn't hurt.
You should have use driving transistors on the seven segment displays else the segment brightness will be uneven.
Don't need those resistors on the ULN2803 inputs.
Why add resistors and other stuff to the ULN2803 outputs? Are they supposed to be snubbers? Try driving the 24V solenoids directly.
D15 seems unnecessary as you've got the clamp diodes enabled in the ULN2803.
Why not use the switching as the 5V supply, why add the 7805?
What's the resistance range of the thermistor on RA0? PICs like low impedance on their analog inputs.
If you need an accurate VREF use a precision voltage reference on VREF+ a 4.096V is pretty handy for a microcontroller.
The 18F4620 internal oscillator is about 1% accurate, if that's good enough you could probably omit the crystal and caps.
Are all unused inputs setup as outputs? (never leave floating inputs).
What connects to the SV3-1,6 pins? I assume three solenoids and 24VAC.
What happens if you press S5 and S9 at the same time?
Are all the wire bundles in one big bunch, they're probably picking up current spikes from the solenoids. Try a choke on the power input.

Me I would have made the 8 LEDs part of the seven segment matrix and keyboard scan, also would have added diodes plus transistor column drivers similar to the dragonfly schematic I've attached. This would have used 8 outputs for the segments + LEDs, 5 outputs for the column drivers and keyboard scan (5x2), and two inputs for the keyboard rows. Total of 15 I/O pins and no need for aggressive I/O routines. 5 transistors, 10 diodes, 13 resistors.
I would try to use the internal PORTB pullups for the keyboard. I'd also use a LM2575 switcher as it's just an inductor & a couple of caps. They make 500mA to 5A versions.

3868-Dragonfly_Schematic.png
 
Last edited:
And you have a switcher on the board.

You might stand a chance using the Vref+ and Vref- as isolated supplies with ADC input ground referenced to Vref-.

Read the PIC info on achieving best ADC performance.

Hi RCinFLA, I tried changing Vref+ and Vref- and it improved the performance a bit but still there are times that the temperature reading doesn't go back to its proper reading. Thanks for your suggestion.

Hi
You might try adding a complete ground plane on both sides of the pcb.
The top looks like it has many copper islands (copper areas that are not connected to form a single plane on the board)
The bottom has no ground plane at all..

Hi eTech, does it matter if I have copper islands of ground? How can having so many ground planes help? Thanks for your suggestion.

Where are your 0.1µF decoupling caps (I see only one, try another). Also one across D10 wouldn't hurt.
You should have use driving transistors on the seven segment displays else the segment brightness will be uneven.
Don't need those resistors on the ULN2803 inputs.
Why add resistors and other stuff to the ULN2803 outputs? Are they supposed to be snubbers? Try driving the 24V solenoids directly.
D15 seems unnecessary as you've got the clamp diodes enabled in the ULN2803.
Why not use the switching as the 5V supply, why add the 7805?
What's the resistance range of the thermistor on RA0? PICs like low impedance on their analog inputs.
If you need an accurate VREF use a precision voltage reference on VREF+ a 4.096V is pretty handy for a microcontroller.
The 18F4620 internal oscillator is about 1% accurate, if that's good enough you could probably omit the crystal and caps.
Are all unused inputs setup as outputs? (never leave floating inputs).
What connects to the SV3-1,6 pins? I assume three solenoids and 24VAC.
What happens if you press S5 and S9 at the same time?
Are all the wire bundles in one big bunch, they're probably picking up current spikes from the solenoids. Try a choke on the power input.
View attachment 74863

I tried adding another 0.1uF on another side of mcu and another paralleled to D10.
I could try adding driving transistors and omit the input resistors to ULN2803 next time if I would rebuild it again but as of now, the board is already done and I am troubleshooting it as far as I could go.

R79,R83 and R84 which is located at the output of ULN2803 are current limiting resistors to limit the current that goes in the relay.

R81 100 ohms in series with C26 0.1uF & R82 100 ohms in series with C27 0.1uF are snubber circuits. I forgot to tell you I replaced the varistor there with 1n4148.

It looks like this https://i.stack.imgur.com/i7DqY.jpg

Without these snubber circuits, my microcontroller resets everytime I switch on the solenoid valve or sometimes if it makes it, when I turn it off it resets.

Yeah D15 looks unnecessary I think I am just getting paranoid on resetting circuits so I placed it. I'll omit it next time.

I actually just copied the Switching regulator circuit from one of the factory boards I have seen. It used MC33603A and is connected to the old school 5V regulator.

The thermistor's resistance varies from ~500 ohms to 10K ohms depending on the heat applied to it.

I'd like to ask why Vref+ of a 4.096V not 5v??

I am quite unsure if there is an internal oscillator for PIC18F4620. Are external oscillator circuits really that messy?

I have set all unused pins to output.

You're right about SV3, they are two 24VAC, 32VDC, output to speaker and two output to two relays for solenoid valve and for gas valve.

Pressing S5 and S9 at the same time clears some digit on the 7 segment because they are getting shorted. I could have redesigned it in another way but for now this thing is already done. The brightness of the seven segments are actually same to each although they are just a lil bit dim but it's completely fine with me.

The wires are in a bundle and individually are as thick as pasta. The wires are inside a power choke but the hole inside gives a lot more space like twice as much of another set of wires and I am not sure if that matters.

Me I would have made the 8 LEDs part of the seven segment matrix and keyboard scan, also would have added diodes plus transistor column drivers similar to the dragonfly schematic I've attached. This would have used 8 outputs for the segments + LEDs, 5 outputs for the column drivers and keyboard scan (5x2), and two inputs for the keyboard rows. Total of 15 I/O pins and no need for aggressive I/O routines. 5 transistors, 10 diodes, 13 resistors.
I would try to use the internal PORTB pullups for the keyboard. I'd also use a LM2575 switcher as it's just an inductor & a couple of caps. They make 500mA to 5A versions.
Thanks for these suggestions. I'll note them next time if I have to redesign the system. I am actually also considering next time using LM2576 (I don't know if it is better than LM2575) if it is a lot better than MC34603A and 7805.



------


I am really still trying to give it another shot for this circuit without redesigning it since another time would be spent on redesigning everything on layout and also it might take two PCBs to do the newer design.

EDIT: I don't think the wires are picking up current spikes from solenoid because I tried disconnecting the wire that connects to the -pin of the relay that controls solenoid valve and the same thing happens. So it means even without the circuit that controls the solenoid valve the temperature would still do some unusual reading.
 
Last edited:
Try setting the switchmode regulator to 5V and bypass the 7805.
There is an internal oscillator in the 4620, settable for several frequencies including 4MHz OSCCON will let you select. The 4xPLL will get you up to 32MHz internally.
A 24V relay won't need current limiting. Your resistors may be keeping the clamp diodes in the ULN2803 from working properly.
Try bypassing the snubbers, connect the ULN2803 directly to the relay.
4.096 is a power of two, makes scaling your A/D readings easy. Your 5V regulator is not going to be that accurate.
The LM2576 is an excellent regulator, just make sure you get the right inductor.
 
Try setting the switchmode regulator to 5V and bypass the 7805.
There is an internal oscillator in the 4620, settable for several frequencies including 4MHz OSCCON will let you select. The 4xPLL will get you up to 32MHz internally.
A 24V relay won't need current limiting. Your resistors may be keeping the clamp diodes in the ULN2803 from working properly.
Try bypassing the snubbers, connect the ULN2803 directly to the relay.
4.096 is a power of two, makes scaling your A/D readings easy. Your 5V regulator is not going to be that accurate.
The LM2576 is an excellent regulator, just make sure you get the right inductor.

Hi blueroomelectronics! I think I saw now the problem. I opened the simulator box and the wires. They are really messy and compressed to each other. The two sensor wires are near the transformer, 32VDC wires that turns on the relay for gas valve and solenoid valve, 220VAC line which is connected on the relay to power up the solenoid valve. I tried separating the two wires of thermistor from other cables and it worked fine now! Can somebody tell what is the problem here? I think the two wires are picking up something. Are there any ways I could remove the unwanted noise the thermistor wires are picking up before entering the PCB?
 
I dont know if your application will allow the extra time required, however if you take say 16 measurements and then calculate an average by adding together and shifting 4 times you will reduce the effects of noise on your adc, however it only works up to a point, I did this on a amp hour meter and it made a good improvement.
 
You could try a small cap 0.01µF across the AN0 to GND. It'll slow down your sample rate but might help snub the spikes.

I was thinking about the ULN2803 (I do like those). Did you remove the input resistors?
Just thinking aloud, I'd use the spare 5 drivers to run the LED columns, you would need common cathode displays though.
 
Thanks! gonna check out some of the solutions on the internet

I dont know if your application will allow the extra time required, however if you take say 16 measurements and then calculate an average by adding together and shifting 4 times you will reduce the effects of noise on your adc, however it only works up to a point, I did this on a amp hour meter and it made a good improvement.
Thanks! I know what you mean but the problem is that the crosstalk is not happening all the time. It only happens when the bundle of wires are moved. It also happens randomly in a certain time like once every few hours. I already have this averaging software for filtering the small dc signal noise. In fact, it was the very first segment of the whole software I made since there are really a lot of internal noise inside the PCB. I think I need to tweak up my hardware setup but if you still have some more ideas feel free to share it :)


You could try a small cap 0.01µF across the AN0 to GND. It'll slow down your sample rate but might help snub the spikes.

I was thinking about the ULN2803 (I do like those). Did you remove the input resistors?
Just thinking aloud, I'd use the spare 5 drivers to run the LED columns, you would need common cathode displays though.

Thanks! I removed those input resistors, added a small cap of 0.01uF and same thing still happened. I'll gonna try now some extra heavy twisting on the two sensor cables and see if it could solve the problem.

------

Guys, if you have some more suggestions please.. You could share it too :p
 
In the music industry they use 'noisless' cable, cheap screened cable can sound like a crispbag rustling if you are recording something with the gain turned up and you move the cable around like when playing an instrument, noisless cable has a conductive layer down the outside of the inner conductor to drain away any static noise.
I wonder if this is happening with your setup.
 
Hi

"Hi eTech, does it matter if I have copper islands of ground? How can having so many ground planes help? Thanks for your suggestion."

Islands can actually act as antennas, so should be removed. For a through hole board like yours, I think it will be ok with one ground plane.

So...the idea is to minimize emi and signal reflections by using a copper plane to help produce a capacitive coupling effect that helps reduce noise.
There a many schools of thought on how to do this, but generally, for a 2 layer board, you place signal and power traces on top layer, and ground (plane)
on bottom layer.

For a 2 layer board:
1. Try to keep +supply voltages traces on one side (top) and create a ground plane on bottom.
2. Try to keep all signal traces on the top side. Routing signal traces on the bottom side is ok, but should be kept to a minimum. Keep all traces as short as possible.

When routing traces, follow this order:
1. Route all +supply traces first, on top side, keeping traces as short as possible.
Sometimes routing on bottom is necessary to avoid long traces. But avoid it if possible.
2. Route all critical signal traces. Route on top, minimize on bottom.
3. Route all remaining signal traces. Route on top, minimize on bottom.
4. Create ground pour(plane) last, bottom side only.

After completing each routing step above, I would also perform a DRC (Design Rule Check) to be sure of no errors. Perform a DRC after each step, fix errors, then repeat.

Good luck...

eT
 
Last edited:
Status
Not open for further replies.

Latest threads

Back
Top