Unstable ReadADC10 on 28X1

luminastrum

New Member
I'm using a 28X1 chip and readadc10 to input a signal from my infrared range sensor (Sharp GP2D120). The signal is proportional to distance. The unused readadc inputs are tied to ground with 10K resistors. Everything works as expected. What is not expected is how noisy and unstable the signal reads. Any suggestions as to how to stabilize the signal? Thanks.
 

ylp88

Senior Member
I suppose you might need to consider exactly how errant your reading are. If there are a lot of very errant readings, you might consider making your program discard them. You might also be able to smooth things out by taking several readings and then averaging them.

ylp88
 

slurp

Senior Member
Do you have any motors in the circuit that might be influencing the over all noise on the supply rails?

regards,
colin
 

Dippy

Moderator
Last 2 posts ... EXACTLY. How noisy? +/- 3V spikes or +/-3mV spikes.

Have you determined whether the Sharp sensor is giving a 'noisy' output with nothing else on the circuit?

Have you tried just powering up sensor in a minimum circuit config and checking output on a scope?

What else is on your circuit?

Is it on a well designed pcb / breadboard or have you got 2 metres of spaghetti wire connecting everything.

Is the ground good? (Electrical , not your back garden).

Is your power supply good? Is it batteries? Is it some shakey old SMPSU from a 20 year old PC?

Check with a 'scope. Haven't got a scope? Borrow one or buy one.
 
Last edited:

Peter M

Senior Member
Yes all of the above.

You could also add a capacitor between the adc input and ground (yeah, yeah, and a resistor between that and the input to minimise current into the input on power down), this will slow the response time, but will help stablise it

Code:
-----*-----\/\/\/\---- ADC
     |
     |
    ---
    ---
     |
     |
   -----
    ---
     -
 

luminastrum

New Member
Regarding motors, I still get noisy readadc10 signals when I shutoff power to the motors. The noise increases as I approach the limit of the Sharp range sensor (12 inches max). At 9 inches, the average readace10 signal is roughly 100 units (from picaxe debug window) and can vary +/- 50 units. Power source is a 9V battery with a 5-V voltage regulator. Regarding the circuit, 95% of all wires are 1 to 2 inches long. Wires leading to the range sensors are roughly 10 inches long.

I will try adding capacitors to the readadc10 inputs to dampen & smooth the signal.


Thanks for all your comments.
 

Dippy

Moderator
BEFORE smoothing the signal...
I say this because those numbers you give sound terrible if the sensor is simply aiming at something plain in the lab.

Have you tried putting a few microfarads (ie a medium sized cap) across Vsupply to the Sharp (as physically close as possible to the module's pins).

I don't know the detail of the Sharp but if it had AGC then any extraneous noise/unwanted signal would be gained up as it reached limit. That is merely a suggestion i.e. total guess.


You using it anywhere near Fluorescent lights /CFLs or near anything electrically noisy?
 

hippy

Ex-Staff (retired)
Also, check your battery isn't running down and that you are getting 5V out the regulator.
 

BeanieBots

Moderator
One of favourite sensors because the output is so CLEAN.
It does a good clean supply though. This is one of those occaisions when the mandatory PICAXE decoupling cap is to prevent PICAXE noise getting on the supply as apposed to supply noise getting into the PICAXE.
As already suggested 10~20uF on the device itself and at the regulator output. Also check your layout. Make sure none of the sensor power cables share any current that is used by other components such as motors.
 

luminastrum

New Member
Thanks Beanie. I will definitely include the capacitors. Question for you... is the Sharp range sensor clean without the capacitors per your experience? Did it become your favorite sensor after the capacitors? Is there a cleaner infrared range sensor beyond the Sharp model?
 

Dippy

Moderator
By the way, did you read the Data Sheet on the Sharp range detector?

"Please use a power supply which can output 350mA or ... peak current to LED"

"... we recommend to connect a by-pass capacitor of 10uF or more between Vcc and GND* near this product"



* Sorry if this upsets the GND anoraks.
 

BeanieBots

Moderator
To be honest, I've never tried without capacitors. It wouldn't enter my mind to do such a thing. It's a bit like designing a car, finding the ride to be a bit rough and then deciding to add suspension!
As for other sensors, I've never found one which gives analog output over a similar range for a similar price.
If you know of any, please let me know. The only real alternatives are home-brew, laser or ultra-sonic. The later will intorduce all sorts of noise problems if care is not taken. If you have a look at the SRF0XX range, they actually switch off all the drive and power circuitry during the receive phase to help cut down on noise.
 

Dippy

Moderator
vss... cough
You only use FET stuff DPG? You forgot Vee... this may explain why DPG's shift key doesn't work :)

What happens if the product contains BJT and FET components... oh my... hence the use of GND - the arbitrary zero of potential which, in some apps, may also be connected to 'earth'. But it's not always the case, but that's another tedious story.

Anyway... meanwhile back in the thread.
 

moxhamj

New Member
I use GND *ducks for cover*, as my circuits all have GND connected to GND. Indeed, I ran a thick 5mm wire out into the garden, hammered in a ground stake and put a sprinkler on it for good measure to help the ions flow. Habit I guess using GND.

Re the noisy signal, I think a CRO is going to be the only answer. A multimeter will probably give a smooth value, but the noise on a CRO trace will give lots of clues about where it is coming from. You can turn on and off flouro lights and computers and other devices and watch the signal change and you will see dips if it is drawing too much current from the power supply. Cheap CROs are only $130 or so.
 
Last edited:

demonicpicaxeguy

Senior Member
You only use FET stuff DPG? You forgot Vee... this may explain why DPG's shift key doesn't work :)

What happens if the product contains BJT and FET components... oh my... hence the use of GND - the arbitrary zero of potential which, in some apps, may also be connected to 'earth'. But it's not always the case, but that's another tedious story.

Anyway... meanwhile back in the thread.
Just being cheeky..... *faint's at own use of shift key*
 
Last edited:

Dippy

Moderator
"Just being cheeky" ... I know, so was I.

*faint's at your use of shift key* :)

Has luminastrum tried the caps yet?
 

luminastrum

New Member
I tried the resistor & capacitor to dampen the range sensor signal. Judging from the picaxe debug window, I did not see an appreciable difference in the noisy signal. Perhaps noisy is not the right term; spikey is more appropriate. Trying different capacitors didn't make a difference. If I owned an oscilloscope, maybe I'd see a difference. Overall, the capacitor did not fix the problem, although I did notice a lag in the system. I'll try re-wiring the circuit with less spaghetti on a different breadboard. Then I'll try a new 28X1 chip. Then I'll try a new Sharp range sensor. Otherwise, I'll just live with the spikey signal and compensate with a PID algorithm. Cheerio…
 

Dippy

Moderator
Ok, maybe I missed a bit.
Did you try a 10uF to 100uF capacitor directly across the power supply pins to the Sharp module ? (As it says in the Data Sheet).

Obv this is a much cheaper test than buying/trying new modules/PICAXEs.
Obv tidying up birds-nest wiring may help too :)
 

luminastrum

New Member
The power supply includes a 20uF capacitor. I swapped in a different capacitor with the same value but no luck. Then I tried another capacitor from a different package (i.e., different manufacturing lot) but no luck. The I tried 47uF from different packages but no luck. Capacitors make me sick.
 

Dippy

Moderator
"The power supply includes a 20uF capacitor."

Good, but did you try a 22uF cap (for example) directly and in close contact on the + and - power pins of the module??
AND by that I mean right-next-to the power pins.
AS IN butted-up-against-it close.

I thought you said your module was dangling on some longish wires??

Remember to check polarity of capacitor!! (+ and -)

It may or may not be a solution but its easy to try.

Capacitors should only make you sick if you eat them :)
Sadly, it's usually the lack of experience that makes them appear useless.
(I'm sounding just like my Dad did).

Finally, what BACKGROUND lighting do you have in the room?
FLUORESCENT tubes or similar? Try it with the lights off.

Even more finally, and I think deep down you know it, GET a 'scope.
 

luminastrum

New Member
Problem solved thanks to the Tinman.

The reason for the noisy and spikey range sensor signals was not capacitors, although they did help and I will include them from now on. The problem was that my circuit had 2 range sensors adjacent to each other and cross-contaminating each other. The infrared reflection from one sensor was being sensed by both sensors and vice versa. Moving them apart and aiming the beams away (i.e., no parallel beams) solved the problem.

Another solution... if the range sensors need to be adjacent and need to have parallel beams, then you can divert the range sensor power from Vss to a picaxe output. Then you can switch the sensors one at a time, then "readadc" the signal, switch off, pause for .05sec, and repeat process for the other sensor. Why pause for .05sec? The range sensor calculates distance 25 times per seconds via triangulation (not by measuring the speed of sound), so that equates to .04sec per calculation. I added .01sec for margin. This solution works, but adds another lag to the system. Luckily, the "pwmout" command will still control the motors (this is why I converted from parallax to picaxe).

Thanks for all your comments.

Mistakes are the best teachers.
 

Dippy

Moderator
lumi: "Mistakes are the best teachers. " - so true.

....and also telling everyone your EXACT circuit sometimes helps to save everyone's time yeah? :) (Please in future etc. etc. as this could have been sorted by post #2 if you'd mentioned it)

A lesson learnt all round.
 

moxhamj

New Member
Yes Dippy, I'll second that. 1st post, 1st line "I'm using a 28X1 chip and readadc10 to input a signal from my infrared range sensor'. That was sensor, singular, not plural. Clearly if there are two they will interfere :) One trick is to fire IR leds in sequence, or have an IR Tx that goes in all directions at once and lots of sensors all focussed in different directions (eg with metal tubes). At least with picaxe one can have a degree of control over the IR pulses and it may end being cheaper and easier to use IR leds under direct control of a picaxe rather than commercial modules.
 
Top