Why does my ADC reading stop when my motor starts?

dr_robert

New Member
Hi there,

I have been researching over the last few days how to detect a motor stall. There is a fair bit written and the method I wanted to try was simply to read the voltage drop when the motor starts to work harder. I'd read the value on an ADC channel and when it fell below a set level assume it was stalled and kill the power. I tested the theory by sticking my multi-meter across the contacts of my motor and watching what happened as I squeezed the motor shaft harder. Bingo - the more pressure, the harder the motor worked and the lower the voltage I read on the multimeter (dropped from ~ 4.2V to 3.8v as it laboured).

So I thought all I would have to do is hook up to my 08M2 ADC and I'd be there. But when I start the motor my ADC stops reading. Here is the set up:

10k resistor between C.4 and ground
C.4 hooked into +4.5v

Picaxe code:
main:
readadc C.4, b0
pause 100
serout 0,N2400,(#b0)
pause 2000
goto main
This set up gives me a reading of 255 (ie 100% of the input voltage), and I am pretty happy with the logic as I can stick different resistors between +4.5v and C.4 to get different ADC readings.

However as soon as I start the motor up, I don't get any reading at all...it doesn't read 0, it doesn't output anything. The moment I disconnect the motor it starts to read again. I thought that maybe it was noise from the motor, so I ran the motor off a separate supply to the chip (connecting the grounds) and got the same results - 255 (or less if I add a resistor) but as soon as I connect the motor no output at all.

I'd like to understand the principle that is affecting this, even if I learn that this isn't an effective way to manage motor stalls (although if I do learn that, I'd love to know what the best way is...Hall Effect Sensors seem popular, but I haven't been able to find anything for a comparative noob).

Thanks for taking the time to read my ramblings,

Rob

PS - saw the earlier post today which looked promising but didn't quite do it for me
 

nick12ab

Senior Member
Do you have decoupling capacitors fitted?

Do you have a suppression capacitor fitted to the motor as shown in PICAXE Manual 3?

Can you post your circuit?
 

chipwich

Member
... The moment I disconnect the motor it starts to read again. I thought that maybe it was noise from the motor, so I ran the motor off a separate supply to the chip (connecting the grounds) and got the same results - 255 (or less if I add a resistor) but as soon as I connect the motor no output at all.
It does sound like noise is interfering with PICAXE function. Using 2 supplies is a great start, along with noise-filtering hardware (eg, filtering caps).

I'd bet that your PICAXE becomes nonfunctional during motor stall, and then starts running the code from the beginning again after stall. But it's better to confirm that this is what is happening in the code than to assume. Try the following, to see if "init" appears again after motor stall. If so, you need to do a better job isolating the PICAXE from pesky motor noise.


init:
serout 0,N2400,("init")

main:
readadc C.4, b0
pause 100
serout 0,N2400,(#b0)
pause 2000
goto main
 

dr_robert

New Member
Just tried your code and it is most revealing!

motor disconnected: ADC reading of 255
motor connected: no ADC reading
motor disconnected: ADC reading of "init" followed by repeating 255

So as you suggest, as soon as I connect the motor the PICAXE doesn't run at all and when I disconnect it starts the programme from the beginning.

I will add the decoupling capacitors - I thought you either added those OR ran from a separate power supply, so will spark up the soldering iron in the morning and let you know how I get on. At least I can go to bed having made some progress - thanks for your help and thanks also to Nick.

Rob

***EDIT*** Just gone back to RTFM as Nick suggested and I realise I've got suppression capacitors and de-coupling capacitors confused (as it happens I had neither). So I will add the suppression capacitor (200nf polyester) across the contacts of my motor and then add a 0.1uf ceramic between V+ and pin 1 on my chip...does that sound right? Thanks
 
Last edited:

Goeytex

Senior Member
It is always a good practice to have a decoupling capacitor across the Picaxe power pins, regardless of the circuit. When I am bread boarding a Picaxe Circuit, the decoupling capacitor is the first thing added after the Picaxe. IMO it is not optional.

Any DC motor used around electronics should have a noise suppression capacitor added unless there is already one fitted from the factory. A unidirectional motor can also use a diode for extra noise suppression.
 

SAborn

Senior Member
I'd love to know what the best way is...Hall Effect Sensors seem popular, but I haven't been able to find anything for a comparative noob).
The same as i posted a link to yesterday in a different thread, i dont think monitoring current with a picaxe gets much simpler than using a module like this.

http://www.ebay.com.au/itm/1pcs-ACS712-5A-range-module-current-sensor-module-/251042028107?pt=LH_DefaultDomain_0&hash=item3a73455a4b

Although you do need to fix the motor noise problem you have first before any method will work.
 

Dippy

Moderator
As per goeytex; Decouple/bypass caps should be 'standard issue' on PICAXE - especially with circuits that have the vaguest hint of noise and also when ADCing.
For wobbly supplies try using 2 caps; a reservoir electrolytic/tant and ceramic in parallel.

If your sample voltage is likely to be noisy then consider some filtering.
If you are measuring stall voltage on a PWM'd motor you have to have a little think about that.
Current sensing (possibly more reliable) can be Hall or shunt (using a £1.50 diff current sensing amp).

Is your stall current so high that it's affecting the PSU voltage such that PICAXE is going into BOR?
Or, with some S/M supplies an overload can cause enormous noise as the the switcher is madly trying to supply oomph.
And some cheap S/M can be utter crap.

Many of these problems (sorry, 'issues')can be captured on a 'scope which can save hours/days of fumbling.

Post your schematic as it stands right now - inlcuding all the caps and things. Describe your PSU and, if shared, show us your wiring.
 

fernando_g

Senior Member
A brush DC motor produces brutal amount of noise. The noise levels can easily exceed the supply rails. Fed directly into an input, can create all sorts of nasties...

In addition to all the comments above, please add a 10k resistor in series between the picaxe ADC input and the motor voltage you are sensing.
 

dr_robert

New Member
Getting there...

Thanks to everyone for your responses so far. I have made some progress that I'm pretty pleased with. I put a 100nf metalised polyester capactor between the motor contacts (a la picaxe manual 3 - I know it should be 220nf but 100 was all I had and figured it was worth a shot).

I now have a circuit that will detect when the motor strains (ie I grab the rotor shaft). typical ADC10 reading is 550 when running, logic set to alert when that drops below 525.

I will tidy it up and post a pic + schematic + basic code, but so far it does look like it's doing what I'd hoped, albeit in a test bed rather than real life situation ie it may all fall apart when I hook up two motors via an L293D!

Anyway, lots of new stuff learned so thanks again,

Rob
 
Top