Function Dir


im working on a project where i control 3 stepper motors using raspberry and picoborgreverse, i was modifying the basic program that comes with the library for controlling a singol stepper motor but i encountered a problem, because i want to control all the three motors at once im having a problem with the function "dir" wich gives the direction of spin to the motor basically having 2+ motor when i run my cycle if one motor has a positive spin and the other a negative they will move all positive because the function dir can't have at the same time the value 1 and -1, so i was wondering if there was another function that works the same but has different name like a dir2,dir3 ecc .

Thanks in advance !

piborg's picture

The dir value in the MoveStep function is not actually a function, just a variable which either holds the value -1 or 1.

What you can do is copy the section of code which sets what the value is:

    # Choose direction based on sign (+/-)
    if count < 0:
        dir = -1
        count *= -1
        dir = 1

and create another copy based on a different value:

    # Choose direction based on sign (+/-)
    if count2 < 0:
        dir2 = -1
        count2 *= -1
        dir2 = 1
Subscribe to Comments for &quot;Function Dir&quot;