For a college project I am controlling a linear actuator that must follow setpoints of a given length at a given time.
I have no experience using simulink, arduino or motor control.
I have an Actuonix L12-50-100-12 P series with linear potentiometer and an Actuonix LAC board to control it using an Arduino Uno.
The Uno is connected to Matlab via USB.
LAC and Uno have common ground.
Pin 5 PWM output is connected to LAC board.
Potentiometer connected to pin A0 on uno.
I have tried building from the basics of sending the actuator to positions and have been told PWM is the way to go.
The stroke length of the actuator is 50mm and is controlled using duty cycles of 3.3V PWM. 0V = 50mm, 3.3V = 0mm
Firstly I've sent positions to the motor and given it time to reach its destination eg
stroke = 50;
pos = [10, 30, 20, 30, 10, 40, 20, 10];
duty = pos/stroke;
for n = 1:length(duty)
writePWMDutyCycle(a, 'D5', duty(n));
I would now like to send position and time set points to that the motor follows the path that they describe.
I'm thinking that the way to do it is to set the speed of the motor for a certain time - based off the difference in current position, target position and the time until it needs to get there.
I have begun looking into PID control in Simulink but have not wrapped my head around the concept and whether it is necessary here.
One final thing:
To test whether the motor has correctly followed the path created I would like to map the desired path vs actual path. what is the best way to continually read the analog data of potentiometer length?