'Move Linear Actuators using softPWM wiringpi

I am using softPWM from wiringpi library to control linear actuator speed and direction. I have raspberrypi 4b connected to BTN8982TA motor driver which is in-turn connected to linear actuator. I have created a python program to move forward and backward and 50% speed Program is as follows:

import wiringpi as s
from time import sleep
FPWM=0  #Pin No.11
RPWM=2  #Pin No.13 
s.wiringPiSetup()
s.softPwmCreate(FPWM,0,100)
s.softPwmCreate(RPWM,0,100)

while True:
    s.softPwmWrite(FPWM,0)
    s.softPwmWrite(RPWM,50)
    sleep(2)
    s.softPwmWrite(FPWM,50)
    s.softPwmWrite(RPWM,0)
    sleep(2)

Actuator should retract for 2 sec and again go forward for 2 sec. But I am not able to achieve it, when I run the program, my actuator moves forward and forward till it reaches the limit, I want to know what I am doing wrong and how can I change the direction of the actuator



Solution 1:[1]

It looks like you might need to call the Wiring PI's sleep functions

http://wiringpi.com/reference/timing/

https://github.com/WiringPi/WiringPi-Python

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1