Arduino Forum

Using Arduino => Project Guidance => Topic started by: JoeJosefo on Oct 05, 2017, 03:22 am

Title: noise 4-20 ma output transducers, question about capacitors, (added schematic)
Post by: JoeJosefo on Oct 05, 2017, 03:22 am
Hi,

Im trying to build this livestock cattle scale from farmhack: http://farmhack.org/tools/livestock-weigh-scales. For this project it is necessary to read signals from 4 pressure transducers that support a weight deck before and after putting some object on top of it to calculate the weight by transforming the analogread values of pressure into weight with the ohms law, etc, before digressing further...

According to my transducers manual (626 dwyer series), the sensors require "An external power supply delivering 13-30 VDC with minimum current capability of 40 mA DC (per transmitter) is required to power the control loop." however I am using two nine 9 volts rechargeable batteries in series (the project requires 1 but with 1 battery I got absurd values from the analogread)

Problem is:
My signals are not stable for any reasonable lenght of time, analogreads tend to shift up and down around a certain value and stay there only to shift up or down around another value for no reason and it is impossible to calibrate the scale: if I leave a 40 pound object on top of the deck, I start getting readings of around 13 pounds for the first 15 minutes, and after an hour or so  I start to get values around 45pounds!
For my needs precision is not super important, even a 10 pounds error or so is ok, but this behavior is too unrealible to even calibrate.

I suspect that 1) the lack of power supply is making the 4-20 loop behave unreliably, 2) that I dont wait enough delay time between readings and that somewhat messes up the values or 3) some error when Im soldering and and wiring everything (first project, and much more complex than I thought). I am using 180 ohm resistors and using a moteino (which works with 3.3v)

Im debugging everything right now, but since I have no idea about power supplies I though to ask before exploring furter possibilities.

I would really appreciate any advice on this subject (analogread values where some precision is required or with 4-20 current output sensors in diy electronic projects, etc) Thanks in advance!

Josefo
Title: Re: trouble with analogread noise (maybe) and 4-20 ma output pressure transducers
Post by: TomGeorge on Oct 05, 2017, 03:41 am
Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html (http://forum.arduino.cc/index.php/topic,148850.0.html)

How are you reading the 4-20mA loop?
What controller are you using?
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom.. :)
Title: Re: trouble with analogread noise (maybe) and 4-20 ma output pressure transducers
Post by: JayMan on Oct 05, 2017, 05:38 am
Can you please show a schematic of your circuit?
Title: Re: trouble with analogread noise (maybe) and 4-20 ma output pressure transducers
Post by: JoeJosefo on Oct 05, 2017, 04:16 pm
Hi!

I am using a moteino, which has a ATmega328p microcontroller and has an operating voltage of 3.3 instaed of 5V  (https://lowpowerlab.com/guide/moteino/specifications/)

This is the schematic I used from farmhack:

http://farmhack.org/sites/default/files/tools/image-gallery/transmitter_0.jpg

I followed everything failry closely, except that I used 3 batteries instead of 2, and used 180 ohm resistors instead of 200 for the transducers loop. Also, I soldered both the negative wires of the batteries to the last row (negative) of the perfboard and the schematic shows only the transducers batterys wire soldered there, does it affect where I solder the batteries black wire to the readings of the transmitters? Sorry Im a newbie in diy electronics, I was a python developer then I became a farmer hehe :)

Thanks!
Title: Re: trouble with analogread noise (maybe) and 4-20 ma output pressure transducers
Post by: hammy on Oct 05, 2017, 05:29 pm
Couple of things 180 ohm and 20mA gives 3.6 volts , this is too high for a 3.3v board.

I would look at the voltage across this resistor and measure the voltage - is it steady ? Is it stable ?
Run a simple example of reading the analog in to see if you get a stable value . This will tell you where the probkem lies.

If it is noisy have a look at taking averages to smooth stuff down : reading = 0.8x reading + 0.2x new reading.
Title: Re: trouble with analogread noise (maybe) and 4-20 ma output pressure transducers
Post by: JoeJosefo on Oct 05, 2017, 05:46 pm
thanks! I will do that, simplfy my test cases to isolate the problem better
Title: Re: trouble with analogread noise (maybe) and 4-20 ma output pressure transducers
Post by: TomGeorge on Oct 06, 2017, 02:14 am
Hi,
Sorry, a circuit diagram please, not an image of component layout.
I see no bypass capacitors anywhere.
Place a 0.1uF cap from each analog input to gnd.
OP's image
(http://farmhack.org/sites/default/files/tools/image-gallery/transmitter_0.jpg)

Please post your code.
I would say you are reading your analog inputs consecutively like this?
Code: [Select]

val1 = analogRead(A1);
val2 = analogRead(A2);
val3 = analogRead(A3);
val4 = analogRead(A4);


try this;

Code: [Select]

val1 = analogRead(A1);
val1 = analogRead(A1);
val2 = analogRead(A2);
val2 = analogRead(A2);
val3 = analogRead(A3);
val3 = analogRead(A3);
val4 = analogRead(A4);
val4 = analogRead(A4);


The controller has only one AtoD, so it is switched from input to input, the AtoD has a capacitor on its input that is charged to the analog level it is switched too.
This change in level from one input to the other takes time, and consecutive switch and reads can be too quick.
By reading each input twice and using the last value, you make sure the capacitor and hence the AtoD input is following your input voltages.

Tom... :)
Title: Re: trouble with analogread noise (maybe) and 4-20 ma output pressure transducers
Post by: JoeJosefo on Oct 06, 2017, 07:17 pm
ok! will place the resistors, not sure exactly where in the perfboard its best to place them but will do some research,

I will try to get resistors with better range of error, Im using some that I got from my local electronics shop but not sure about the precision.

Thanks
Title: Re: trouble with analogread noise (maybe) and 4-20 ma output pressure transducers
Post by: JoeJosefo on Oct 07, 2017, 12:04 am
Hehe I added the capacitors, averaged with 10 samples each signal and the results look much more stable! The discrepances now come from different cylinder heights which make the weight distribution not uniform across the deck

Thanks!!!  8)

Josefo
Title: Re: trouble with analogread noise (maybe) and 4-20 ma output pressure transducers
Post by: allanhurst on Oct 07, 2017, 12:37 am
You show two 9v batteries as your power supply.

If you're using 4 load cells they will require at up to at least 80mA.

Ordinary pp3 cells won't do this for long - perhaps a seperate mains supply would be a good idea?

Allan-
Title: Re: trouble with analogread noise (maybe) and 4-20 ma output pressure transducers
Post by: JoeJosefo on Oct 07, 2017, 12:52 am
Ahh, I had  that same question myself, but I will be needing to be using this outdoors in my farm, which is "off the grid", was thinking about a power supply that connects to my trucks battery or something like that, but not sure

thanks!



Title: Re: trouble with analogread noise (maybe) and 4-20 ma output pressure transducers
Post by: allanhurst on Oct 07, 2017, 12:55 am
If you've got a truck battery to play with you've got  loads of power! - look at 'boost convertors' on eg ebay to get the higher voltage you need.

Only a few quid/bucks

You may have to add some extra capacitors across this higher voltage supply's output  as they can be quite noisy. Suggest 1000uF and 100nF in parallel.

Allan
Title: Re: trouble with analogread noise (maybe) and 4-20 ma output pressure transducers
Post by: JoeJosefo on Oct 07, 2017, 10:21 pm
I will certainly look into that! after I finish with this first try with 1 9v battery for the sensors, by the way, does it matter if I use inexpensive capacitors from my local electronics shop? and what is the reason to use 0.1uF in this case?
Title: Re: trouble with analogread noise (maybe) and 4-20 ma output pressure transducers
Post by: allanhurst on Oct 08, 2017, 12:18 am
Large electrolytic capacitors stablise the voltage and absorb low-frequency ripple, but aren't much good for high frequency noise.  A 0.1uF ceramic capacitor is , so a combination of the 2 provides wideband noise absorbtion.

Allan
Title: Re: trouble with analogread noise (maybe) and 4-20 ma output pressure transducers
Post by: JoeJosefo on Oct 08, 2017, 02:07 am
Hello again, I made my first schematic! beacuse I would like to ask the optimal placement of a capacitor in the 4-20 ma sensor loops of this project Im wrking on. This is my first schematic, it should describe part of the component layout shown on the image above. If anybody sees any errors (or if it does not make sense at all haha) please any correction is more than appreciated!

The question is, should I place the capacitor closer to the analog pin and/or to ground, after or before the 280 ohm resistor? I dont have a lot of space left on each sensors column of the perfboard but if it will improve things, Im considering doing again some of the wiring when the precision resistors Ill order arrive.

Thanks again! this community is awesome  8) 
Title: Re: noise 4-20 ma output transducers, question about capacitors, (added schematic)
Post by: allanhurst on Oct 08, 2017, 02:30 am
Don't put your capacitor there! - it won't let ANY current through!

Put it in parallel with your load resistor ie between the arduino analog input and ground, close to the arduino pin. And a series 4k7 or so would be an even better noise filter - see enclosed.

A higher resistor value - eg 220 or 240, would make better use of the arduino's dynamic range.

EDIT - sorry - overlooked you were using a 3.3v Arduino. So that should be about 150 or 160 ohms.  nedit.

You should calibrate against known weights ( and none!) to make sure......


Allan


Title: Re: noise 4-20 ma output transducers, question about capacitors, (added schematic)
Post by: TomGeorge on Oct 08, 2017, 04:11 am
Hi,
@allanhurst  diag.
(https://forum.arduino.cc/index.php?action=dlattach;topic=503880.0;attach=228911)
Tom... :)
Title: Re: noise 4-20 ma output transducers, question about capacitors, (added schematic)
Post by: JoeJosefo on Oct 08, 2017, 09:32 pm
great! thanks again

Josefo
Title: Re: noise 4-20 ma output transducers, question about capacitors, (added schematic)
Post by: JoeJosefo on Oct 09, 2017, 04:49 am
another 2 questions to add to the noobness of my thread to try to understand some things better:

Im trying to understand how the 4k7 resistor would (not) alter the analogread that corresponds with the current drawn by the transducer (I thought that  for example when the transducer senses 0 psi, it would draw 4 ma of current from the battery, then because of the resistor in the circuit and ohms law, I will get a reading of .66 volts (with 165 ohm resistors) on the corresponding pin, etc but I must not be getting the real idea behind this reasoning fully

Im getting that the current will come from the capacitor instead of the battery, but the capacitor and the 4k7 are connected anyway, is it then that the capacitor and the 165 ohm resistor are connected to the battery ground directly but not the 4k7 resistor?

Also, I have read that the 4k7 resistor can protect the arduino in case I turn it off but not the power supply for the sensors, so in that case would a 4k7 resistor for each sensor be necessary?


thanks in advance have a nice monday,

Josefo

:)
Title: Re: noise 4-20 ma output transducers, question about capacitors, (added schematic)
Post by: allanhurst on Oct 09, 2017, 04:10 pm
The input impedance of an arduino analog input is effectively infinite.

The 4k7 and 100nF make a single pole low-pass filter which is 3dB down ( half power ) at about 340 Hz.

At dc it has no effect whatsoever.

So long as your signal doesn't vary significantly in <5mS ( 10 time-constants)  , this will be fine. Unlikely in your application, unless your animal is leaping around a lot, in which case you will have more pressing problems!


The 4k7 does indeed protect the arduino from many transients. Internal diodes in the AT chip clamp the voltage to within about 0.7 volt of the rails if the current isn't too high. The 4k7 limits this current. Anything up to about 10k would be OK - it isn't critical.

If worried it may be worth adding a 4.7v zener in parallel with R1. I wouldn't bother.

My circuit is correct.

Repeat it ( using seperate analog inputs of course ) for each sensor.

165 ohms is theoretically the correct value for R1, but in practise because of the variations in the arduino's
3.3v regulator ( a few percent) you will have to calibrate anyway, so it's not too important. 150 or 160 would do.

Allan
Title: Re: noise 4-20 ma output transducers, question about capacitors, (added schematic)
Post by: JoeJosefo on Oct 10, 2017, 04:53 am
Ok! I will repeat it for each sensor like you kindly suggested, I thought of asking my last question just in case I was interpreting the schematic wrong, 

Thank you Allanhurst!

Josefo

Title: Re: noise 4-20 ma output transducers, question about capacitors, (added schematic)
Post by: JoeJosefo on Oct 13, 2017, 04:09 am
Hello all I'm adding a picture of my Permaproto board with the capacitors and resistances in parallel, just in case anybody in the future will want to see it for any reason. Hope I didn't make any big mistake

Resistances are 165 ohms .1% error and capacitors are .1uf 10% error

In the picture, at G9 I soldered underneath the wire that goes to analogpin1 and at G14 I soldered the wire that goes to the negative of the rca male adaptar where you plug in the the pressure transducer. Similarly for the other 3 transducers.

The results im getting are much more stable than before, i take 10 samples and the average remains almost constant, Ill try to calibrate it tomorrow. Thanks to allanhurst for the schematic corrections!

Josefo
Title: Re: noise 4-20 ma output transducers, question about capacitors, (added schematic)
Post by: TomGeorge on Oct 13, 2017, 08:24 am
Hi,
We need a schematic, picture do not show the whole picture.
Where do the wires go, where and what is your power supply, what pins of your controller are the components connected to.

I know that this can be tedious for some but its necessary, especially if sometime in the future you want to build another or need to trouble shoot a fault.

Thanks.. Tom.. :)
Title: Re: noise 4-20 ma output transducers, question about capacitors, (added schematic)
Post by: JoeJosefo on Oct 13, 2017, 04:34 pm
Hi!

Well the schematic was is two posts above but I will update the previous post to include it as well. I understand what you say, however when I was about to build this I couldnt find an example, people would just say put a capacitor from the analog pin to ground, which was very cryptic to me because this is my first project.

Title: Re: noise 4-20 ma output transducers, question about capacitors, (added schematic)
Post by: TomGeorge on Oct 14, 2017, 03:07 am
Hi,
Sorry, but a schematic shows ALL your power supplies, labels pins and components.

It needs to explain to anyone looking through this thread, one day or 12 months from now, for some answers to their query using how your project was put together.

This is were you give back to the forum, by showing your working solution.

Tom... :)