# How can I control position and time profile of a linear actuator motor using PWM, arduino, simulink?

36 views (last 30 days)
Eoin Walsh on 28 Apr 2019
Commented: May Allall on 21 Apr 2021 at 18:21
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
%Total Stroke Length
stroke = 50;
% set points in mm
pos = [10, 30, 20, 30, 10, 40, 20, 10];
%calculate duty cycle percentage
duty = pos/stroke;
for n = 1:length(duty)
writePWMDutyCycle(a, 'D5', duty(n));
pause(2)
end
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?
##### 2 CommentsShowHide 1 older comment
May Allall on 21 Apr 2021 at 18:21
Hi, were you able to control the actuator to move to different positions? I have a feedback linear actuator and I am trying to do the same thing