Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loop control #27

Open
MichalMihalik869 opened this issue Apr 29, 2021 · 0 comments
Open

Loop control #27

MichalMihalik869 opened this issue Apr 29, 2021 · 0 comments

Comments

@MichalMihalik869
Copy link

Hi, I use this library to control a 3-wheeled robot and I want to incorporate a PID controller into the control. And here I got stuck. I control two drive wheels using PWM. in order to use the PID I have to process the speed data in the loop. but when I add a loop to the PS4controler function, it stops responding to further keystrokes. Can you help me ? as an example I give the function after pressing the circle

def on_circle_press(self): #trojuholnik dopredu
    print("idem do predu")
    GPIO.output(revL, GPIO.HIGH)
    GPIO.output(revR, GPIO.LOW)
    chri.ChangeDutyCycle(65)
    chle.ChangeDutyCycle(65)
    nebrzdi()
    pidL.setpoint = 3.5
    pidR.setpoint = 3.5
    #chri.ChangeDutyCycle(65)
    #chle.ChangeDutyCycle(65)
    while True:
        offset_L = pidL(calculateL(10))
        offset_R = pidR(calculateR(10))
        PWM_L = offset_L / 4
        PWM_R = offset_R / 4
        PWM_L = int( 45 + (40*PWM_L))
        PWM_R = int( 45 + (40*PWM_R))
        chri.ChangeDutyCycle(PWM_R)
        chle.ChangeDutyCycle(PWM_L)
        print (PWM_L,"-",calculateL(10),"/", offset_L)
        print (PWM_R, "-",calculateR(10),"/", offset_R,"\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant