Go Down

Topic: Motor Shield & Digital Potentiometer (Read 4789 times) previous topic - next topic

Jmok

Hey guys,

I am currently working with an Arduino Uno with a Motor Shield and I am able to control two 12V DC motors using pulse width modulation. However a problem arises when I try and measure the voltage using this method, it generates spikes and even negative voltages due to feedback from the motor.

I was thinking about using a digital potentiometer to control the motor instead of PWM, the datasheet for the one im looking at http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Components/General%20IC/22060b.pdf. Is it possible to interface the digiPot and the motor shield with the MOSI, CLK, & CS needing pins 11,13 & 10 while the motor shield uses pin 13 for motor direction?

Thanks, John

knut_ny

Pin 13, clk, cannot ne shared the way you want.
You will still need pwm to control motor. So why a digital potmeter?
Ny

Jmok

I am trying to measure the power running through the motor, so i am using the built in current sensor with the shield to measure the current and a voltage sensor across the motor to measure the voltage which produces the power. I am using PID to control the motor speed at a certain RPM and currently using PWM.

PWM is working great for controlling the speed but when I go to measure the power of the motor i recieve a non linear result (see attached). This is the result of the PWM not PID (I've given it a constant output & the result is the same). For the measurement of power it dopes not make sense to have the negative numbers (from the feedback) and the oscillations. Currently my best method of dealing with this is setting all negative numbers to zero and averaging the values. I have tested the voltage sensors and they are working fine and setup properly.

I wanted to use a digital potentiometer because it would give me more of a constant power which is much more reliable and accurate. Is there any way I could get this to work?

knut_ny

What is it you want to control?
Power? (wattage)  This will be proportional to the PWM-value.
Rotation speed? (rpm) This wil need som kind of techometer for your feedback loop.

A series, mechanical, power-potmeter can be used to control small motors.
The digital pot cannot be used is this manner
Ny

MarkT

With PWM the voltage across the motor is either 0V or the supply voltage....
thats why its efficient.

If you want to sense the back-EMF you'll have to arrange the drive to be shut off
long enough for the current to fall to zero and then sense the voltage, re-enabling
drive afterwards.

Is that what you want?   Or are you really seeking to measure speed?
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Jmok

I am able to measure the speed with a quadrature encoder and what I do is set it at a certain RPM. Once it is set I want to measure the power required to operate the motor, i do not want any of the feedback. The graph I showed before is what I get as a power when the motor is set to 1000 RPM and using PWM. For accuracy the oscillations are not good that is why I was looking into potentiometers.

raschemmel

The only way to measure the power of a motor that is switched using PWM is to use an RC LOW PASS filter (4.7 k ohm, 4.7uF ) to convert the PWM to an a steady state analog  voltage .  You will need to multiply this voltage times the current reading on a DMM on 10A current mode. In a lab they usually use a current probe and voltage probe with a scope  and select MATH mode and multiply ch-1 x ch-2.  I doubt you have that equipment so you'll have to make do with a meter reading current and a LP filter on your motor voltage. You can read the output of the LP filter with an analog input but if you want to do that for the current you'll have to buy a CT (current Transformer ) to measure the motor current and then you can use a LP filter on the output of that.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Jmok

I tried implementing the low pass filter today, with the resistance and capacitor values and the motor doesn't run, is it possible the resistance is too high?

raschemmel

A low pass filter with a 4.7k ohm resistor and 4.7uF capacitor should not affect the operation of the motor. Disconnect the LP filter and see if the motor runs. Post a schematic of the circuit you used. (RC values) and how you connected it. The LP filter impedance is too high to have any effect on the operation of the motor.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Grumpy_Mike

Quote
I wanted to use a digital potentiometer because it would give me more of a constant power which is much more reliable and accurate.

No that is not right.
The current available through a digital pot is very small in the order of about 25mA.
It is way more accurate and reliable to use PWM rather than introducing a resistor in the current path of a motor. Did you ever have an electric train set as a kid? You would slowly turn up the resistor and it would not move. Then all of a sudden it would start up at high speed.
Modern train controllers use PWM to get reliable low speed motion.

Quote
I tried implementing the low pass filter today, with the resistance and capacitor values and the motor doesn't run, is it possible the resistance is too high?

Wrong way round the resistance was too low and the capacitor too big. The resistor should go on the motor and the other end to the capacitor and then to ground. You measure at the point of the resistor and capacitor junction.

raschemmel

#10
Aug 06, 2014, 12:07 am Last Edit: Aug 06, 2014, 12:16 am by raschemmel Reason: 1
Quote
The only way to measure the power of a motor that is switched using PWM is to use an RC LOW PASS filter (4.7 k ohm, 4.7uF ) to convert the PWM to an a steady state analog  voltage .


In case I didn't make it clear. The above instructions were intended to mean connect two wires across the motor and "tap" off the motor voltage and feed it through a LP filter before reading it with an analog input. It does not mean put the LP filter BEFORE the motor.
If you don't know how to connect a LP filter (which is the input and where is the output) then try Googling RC LOW PASS FILTER.
If you use 4.7 k ohm and 1 uF to 4.7uF to convert the voltage across the motor , it should not affect the operation of the motor because the cap is isolated from the motor by the 4.7 k ohm resistor.
The motor is switched with a PWM signal which is why it needs to be filtered and converted to an analog voltage before measuring it.
 

Quote
The graph I showed before is what I get as a power when the motor is set to 1000 RPM and using PWM. For accuracy the oscillations are not good that is why I was looking into potentiometers. 


Your understanding of electronics is flawed.  The "oscillations" as you refer to them , are the PWM switching frequency which is exactly what it should be.  The fact that you cannot obtain a steady state voltage or current to measure because of that is exactly why I suggested filtering the voltage across the motor. I never thought you would interpret that to mean put the LP Filter before the motor, which is apparently what you did which is why the motor didn't work. Put everything back the way it was and get the motor working again. . Connect two wires across the motor and run those to your low pass filter . Run the output of the LP filter to your analog input.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Jmok

Thanks a lot for your help, I believe I have hooked up the low pass filter correctly as I am reading the voltage across the capacitor and receiving good results verified by a voltmeter. I do not have a very strong background in electronics, first time doing anything like this.

I am currently using the motor shield's current sensing capability for the channel but it is still varying a lot due to the PWM. Is there a way I can use the Low pass filter to turn the current into a more steady state?

raschemmel

Yes.
You can buy a Current Transformer (CT)
  https://www.sparkfun.com/search/results?term=current+transformer   

You can put a LPF on the output of this . Multiply the voltage in V from the one you already have times the current in Amps from the output of the LPF on the CT output but remember the units for this is A not V.  P= I x V (in W)
You might want to look for a smaller CT. Look for a 3A current sensor.
Arduino UNOs, Pro-Minis, ATMega328, ATtiny85, LCDs, MCP4162, keypads,<br />DS18B20s,74c922,nRF24L01, RS232, SD card, RC fixed wing, quadcopter

Grumpy_Mike

Quote
Is there a way I can use the Low pass filter to turn the current into a more steady state?

Yes in exactly the same way as you did with the voltage.

MarkT


The only way to measure the power of a motor that is switched using PWM is to use an RC LOW PASS filter (4.7 k ohm, 4.7uF )


You know the efficiency of the switches, monitor the supply voltage and average supply
current into the H-bridge, much easier (especially if the supply voltage is fixed...)

You sometimes need to monitor motor current (for instance if implementing closed-loop
torque control), but its not the best way to measure power.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Go Up