The last few days i have been tinkering with a linear actuator for a system that will raise and lower a cleaning head above a surface depending on the height of the surface. I am using a IR sensor which is linked to an arduino which uses a PWM signal to send a setpoint to a motor controller which drives a linear actuator. This is the stuff i am using:
Arduino UNO (powered from my pc)
Industrial devices IDM3 actuator (the option with build in potentiometer) (datasheet IDM3 actuator)
The problem is that the linear actuator performance is very poor when controlled using the PWM. It has poor reproduciblity (+ - 5 mm) and also shows hunting (moving back and forth) and is "jittering".
However the LAC i am using also has an option to control the board and actuator using a usb interface and a program on the PC. This program is also capable of changing some internal settings on the board (like Kp values and limits etc.). When using the PC and USB to control the actuator it works much better and doesn't show any of the problems the PWM control shows.
I think it might be a problem with my PWM signal (since it should be 3.3v but is 5v since the documentation says it should be 5v compliant).
I attached a picture of my wiring
And this is the code I am using to test the setup
const int analogInPin = A1; // Analog input pin that the potentiometer is attached to
int pos = 170;//0 to 255
int minp = 100;
int maxp = 250;
int inc = 1;
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(115200);
}
void loop() {
// read the analog in value:
int val = analogRead(analogInPin);
//
//
//
if (Serial.available() > 0) {
int key = Serial.read();
if (key == 113){ // letter q
pos = pos + 10;
analogWrite(5,pos);
Serial.println(pos);
}
if (key == 101){ // letter e
pos = pos - 10;
analogWrite(5,pos);
Serial.println(pos);
}
}
}
Do you guys think it would be worth it for stability to change to a 3.3V signal (I could do it but would have to order some parts)?
teunman:
Do you guys think it would be worth it for stability to change to a 3.3V signal...
Not really. The Arduino can output a pseudo-analog voltage using PWM. The range in the code that the analogWrite() command can use is 0-255. That means that there are 256 "analog" voltage values that the output can provide. If you took the total possible travel distance of the actuator and divided it by 256, I imagine you would get something close to the 5mm you mentioned. The computer is most likely controlling a PWM generator on the LAC board that has a higher resolution than the Arduino has, which results in more accuracy and more possible positions.
One possible reason for the "jitter" is that the desired position is inbetween two PWM spots, and the Arduino can't go between the two, and continuously jumps between the position directly below and directly above the desired spot.
3.3V logic (using an Arduino) may be more efficient. Since there are still only 256 possible analog voltage points, but a smaller range, each range is smaller and can result in a smaller increase/decrease in position.
The actuator only has a stroke of 50 mm, so the resolution of the arduino pwm should be able to get better results than 5mm right?
One possible reason for the "jitter" is that the desired position is inbetween two PWM spots, and the Arduino can't go between the two, and continuously jumps between the position directly below and directly above the desired spot.
Im not sure what you mean by that. I send a PWM signal from my arduino to the board and the board reads this as a percentage of extension and controls the actuator by sending it a voltage and reading the potentiometer. So what would be the desired position you mention?
Would just using a voltage divider made from some resistor be sufficient to go down to 3.3v or would I need a logic level shifter?
teunman:
The actuator only has a stroke of 50 mm, so the resolution of the arduino pwm should be able to get better results than 5mm right?
It would make sense that that each PWM value from the Arduino would result in increments far smaller than 5mm.
teunman:
Im not sure what you mean by that. I send a PWM signal from my arduino to the board and the board reads this as a percentage of extension and controls the actuator by sending it a voltage and reading the potentiometer. So what would be the desired position you mention?
Since my original hypothesis about the total stroke is wrong, please disregard my gibberish there.
teunman:
Would just using a voltage divider made from some resistor be sufficient to go down to 3.3v or would I need a logic level shifter?
Since we are just looking for high/low values (from the PWM) either should be okay. Keep in mind that the PWM frequency of the Arduino is 1.2kHz, so the total period of each high-low pulse is 833 microseconds. It you decide to go with a level shifter, make sure it can handle quick transitions by looking in the datasheet for whatever shifter you find.
max stall current of actuator is 2.2 A, max current the board can handle is 4 A. So that shouldnt be a problem. might pick up some resistors over the weekend and have a fiddle with that.
Yup I have tried smaller steps. But even then the same behavior applies. Also when i just set the position to say "180" then move it around a bit and then set it to "180" again it does not go to the same position (off by like 5-10 mm). And there is feedback, but this is all done on the side of the motor controller (which has a PD controller). I could use the USB interface to change Kp and Kd values for this controller, however when i just use the USB to set the position it always goes there smoothly and is very repeatable (error of less then 1 mm), which leads me to believe that the standard settings are okay, but that there is something wrong with my pwm signal.
Yeah i have looked at the datasheets. (just realized that the links are broken in the first post, I will fix that).
I have tried playing with the sensitivity a bit, but by the time it starts to make my actuator move smoothly it is too insensitive to perform (it only moves if the setpoint is like 2 cm away, which is a bit far).
I am indeed using pin 5 and im guessing 20Hz shouldn't make that much difference. The voltage divider is indeed something I was considering. Theoretically it shouldn't make a difference but i will try and see.