Hello everyone! I am working on arduino and trying to interface a 2-axis accelerometer with it. I am running a 12v High torque and current DC motor which I want to control with accelerometer tilt. Now the problem is.. When I run the motor taking input signal from accelerometer using analogwrite() function (500Hz), the motor runs in jerky motion ( I want it smooth). When I use potentiometer inplace of accelerometer, it runs perfectly smooth. Should I use some capacitor at the sensor output to ground. Now I am assuming this problem is occuring due to noise (EM interference) EM waves being generated from Motor coil at 500Hz, which are adversely affecting the accelerometer output signal. Am I thinking right.?? Pls enlighten me. Thanks!
You get the input from the accelerometer using analogRead() , not analogWrite(). ( assuming that it is an
accelerometer which produces an analog output ).
You need to consider your problem as three separate problems.
(1) Be able to read and understand the accelerometer reading.
(2) Be able to control the motor properly.
(3) Be able to use the reading from the acceleroment, to properly control
the motor, according to a proper control strategy.
You need to verify each of these stages properly instead of doing confused, random, things.
What is your accelerometer mounted on , and what are you trying to measure with it ? You need to understand
the “noise” behaviour of the accelerometer. It is very unlikely to be affected by any electromagnetic radiation from
the motor, however it will be strongly affected by any actual vibration.
Hey Thanks for replying. Here I go with the exact explanation of my problem:
- I am trying to run a bot on vertical steel wall, thus when it will deviate/tilt from horizontal plane while being in motion, the accelerometer will sense the angle of tilt and will send appropriate signal to the Analog input pin of Arduino. And accordingly I can change the dutycycle in analogWrite() register for respective motor.
-Pardon! (wrongly typed) I used analogRead() to take the input analog value and sending pulses via analogWrite().
- When I used the serial monitor to see how the output value of sensor is changing while I tilt it manually, it shows linear variation to both sides from the vertical position. But when I control the motors ( switch on the motor driving circuit) according the sensor value, I see a considerable amount of fluctuation in the value of sensor output on serial monitor and ofcourse the jerky motion of motors. To check whether the output from sensor is actually varying, I used multimeter to check the output volts, but I didn’t observed any change in output volt signal from the sensor even when the values on serial monitor were varying.
-When I use a simple potentiometer to control the motion of motors ( using same code , same setup and everything) , It works as expected.
-Also, just now I observed that, even on taking the multimeter probes close to the sensor output pin changes the values on serial monitor.
Please guide in this electronics issue.
The motor is causing interference. You need supply decoupling. Google it.
Thanks for the reply!! But yesterday I applied hit and trial technique. I used small dc motors instead of bigger dc motors ( although the nominal votage rating of both the motors is same but wattage is different) and they were working pretty fine. Then I got more doubtful that the jerky motion of motor ( which I was using earlier) must be due to interference between motors and sensor.
I did one thing more. I took the sensor out of the PCB and used a long ribbon wire(~1m long) to connect it to the main circuit so that interference effect on sensor could be minimized and guess what??! It worked. I observed considerable amount of improvement in the motion of higher wattage motors, which I was trying to run earlier, they were running smoother.
Now the question is, how to eliminate this interference????? Because I have to used accelerometer sensor on the PCB (i.e. on the Machine itself). Pl shut my mouth.
Now the question is, how to eliminate this interference?
It is still down to decoupling. http://aedownloads.com/pdf/solder_caps.pdf