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

1 Answer

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Maya Lin-Takahashi

Maya Lin-Takahashi

Consumer Tech & Gadget Reviewer

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.

Share this article
Twitter Facebook Pinterest