I have a motor controller that is designed to be controlled with a potentiometer. How would I instead control it with an arduino? I know a pot is just variable resistance, and the arduino UNO can only output digital output. What is the simplest solution?
Maybe a 5K digital pot?
That's a very expensive board for what it does. You could have bought a 7-15V 10A PWM-controlled motor shield for 1/3 the cost:-
10A DC Motor Driver Arduino Shield
-
The user manual doesn't give a circuit diagram - its hard to say without more information,
but it might just be a 0 to 5V control voltage. -
That module supports PWM at 100Hz and 200Hz, it will buzz loudly. There are much more
capable devices out there including ultrasonic PWM (silent). Pololu have lots of good MOSFET
drivers and controllers designed for microcontroller interfacing - your unit simply isn't.
So can you provide good quality photos of both sides of the board? That might make it clear
where the potentiometer is wired (I suspect it is simply routed into an analog input of the PIC
chip).
I'll just use one of these:
https://www.dimensionengineering.com/products/sabertooth2x25
It is what I should have used in the first place...
The simplest solution is the digital pot but I have a feeling the voltage across the pot exceeds the operating voltage of digital pots. If that's the case then the alternative is analog switches.
If you had any voltage information for the pot it might be possible to determine if a resistor network switched with analog switches would work. The voltage across the pot has to be less than the maximum operating voltage of the analog switch . The ADG511 can operate with up to 50 V from Vdd to Vss for a signal that is both positive and negative. For a case like yours where the signal does not go negative the maximum operating voltage is 30 Vdc. The switches take a 3.3V or 5V TTL logic signal as the control input to open or close the switches. All the switches can be controlled with any arduino digital output pin. The resistor network is a combination of high values to low values that are switched in parallel to obtain a desired resistance. Since a pot has three terminals, in order to create a digital pot using analog switches, the software has to switch the resistor network from the virtual wiper to the positive supply at the same time it switches the network from the virtual wiper to the ground. Realistically, while this scheme may work, it is simply not practical due to the amount of work necessary to make it work. It would make much more sense to simply find an off the shelf product that does what you want. You would have to be pretty stubborn to attempt the above method.
raschemmel:
The simplest solution is the digital pot but I have a feeling the voltage across the pot exceeds the operating voltage of digital pots.
Possibly, but the pot is read by a PIC chip which generates PWM and direction control signals, so my bet is that there's 5V across the pot.
so my bet is that there's 5V across the pot.
Well wouldn't that be convenient ? Fortunately , it is easy to verify with a DMM.
If that were true , the OP could use one of these
or
these:
raschemmel:
Well wouldn't that be convenient ?
Yes.
Fortunately , it is easy to verify with a DMM.
Yes.
Yes.
That was too easy.
raschemmel:
That was too easy.
Except for one thing - David isn't going to use that board now. He's decided to go with the $125 Sabertooth 6-30V 25A driver instead.
As he probably should.
This is an excellent example of absolute and absurd irony. Asking how to use a digital device to produce an analog voltage to feed to an ADC on another digital device which is then generating a pseudo-analog control output.
If you know what sort of control you wish to implement, you should either use the corresponding version of the motor controller which will respond to your digital commands (as the company offers), or generate your own PWM and use a suitable H-bridge module.
Paul__B:
As he probably should.This is an excellent example of absolute and absurd irony. Asking how to use a digital device to produce an analog voltage to feed to an ADC on another digital device which is then generating a pseudo-analog control output.
If you know what sort of control you wish to implement, you should either use the corresponding version of the motor controller which will respond to your digital commands (as the company offers), or generate your own PWM and use a suitable H-bridge module.
Too true, Paul.
There is a further - and very dangerous problem here.
The potentiometer zeroes the motor speed at centre position. Not only does this mean that any form of PWM-analog or "digital potentiometer" needs to be calibrated for this position, but it means that with a code crash or indeed at reset, the motor will be commanded to full speed in the (presumably) reverse direction.
Need I say more?
Paul__B:
There is a further - and very dangerous problem here.The potentiometer zeroes the motor speed at centre position. Not only does this mean that any form of PWM-analog or "digital potentiometer" needs to be calibrated for this position, but it means that with a code crash or indeed at reset, the motor will be commanded to full speed in the (presumably) reverse direction.
Need I say more?
I'd overlooked that aspect altogether. It could possibly be 'worked around', but there's no point.
Ok now you're scaring me. I think I'm going to have nightmares about code crashes and motors spinning iut of controll...,. (;" Motors Gone Willd !"...)
From user's manual:
The controller allows controlling both the Speed and
Direction of a DC motor using a Pulse-Width-Modulated (PWM)
DC voltage with a Duty Cycle fully adjustable from 0 to 100%
Pot ?
The controller allows controlling both the Speed and
Direction of a DC motor using a Pulse-Width-Modulated (PWM)
DC voltage with a Duty Cycle fully adjustable from 0 to 100%
outsider:
From user's manual:Pot ?
That's the controller's output, not it's input.
I don't know what chip is used on that board but with an arduino you would use a pot and the MAP function to MAP the analogWrite PWM value to the pot voltage so full CW = 255 , CCW = 0/1.
I knew that! :-[
Couldn't PWM from Arduino control a mosfet then filter its output?
raschemmel:
I don't know what chip is used on that board but with an arduino you would use a pot and the MAP function to MAP the analogWrite PWM value to the pot voltage so full CW = 255 , CCW = 0/1.
It's definitely a PIC, but no information on which one.
And there's a little more to it. The pot keeps the motor stationary at half-travel, spins the motor in one direction when the pot is rotated counterclockwise from there, and in the other direction when it's rotated clockwise from the centre.
I did a similar thing with a stepper last week:-
if(potVal>511)
{
direction=CW;
stepDelay=map(potVal,512,1023,200,1);
}
else
{
direction=CCW;
stepDelay=map(potVal,0,511,1,200);
}