GPIO, PWM, TB6600, and the BBBW

Hello,

Currently, I am trying to interface a TB6600 stepper (microstep) driver to/from the BBBW. So far, I have used a lib. I found here: sysfs_pwm.py - Pastebin.com .

My source is this currently: configure PWM/GPIO for Motor - Pastebin.com .

I am using a Logic Level Shifter and a 12v battery to test things so far.

W/out the level shifter, I can make the motor turn in one direction only. Then, switching up some of the source can give, but only when the source errors out, the motor two different rotations which cause the linear movement to work one way and then the opposite way.

My main reason for trying these drivers…

  1. Cheap and inexpensive
  2. Some paperwork on them: https://dfimg.dfrobot.com/nobody/wiki/0bcc0b661ce7750ff7d0134bfc3e88b3.pdf
  3. But…I still wonder:

a. How can I make the lib. along w/ the source make this motor listen?
b. Do I need two PWM channels and one GPIO?
c. I have tried two GPIO pins and one PWM pin (no go) and I have tried two PWM pins and one GPIO pin (works at times).

Anyway, any ideas on what I am doing that is incorrect could be helpful. I will keep trying. I also found this page online for wiring ideas: This is from dfrobot online at TB6600_Stepper_Motor_Driver_SKU__DRI0043-DFRobot

Seth

P.S. If anyone has ideas on wiring and/or source, please be my guest and jump on in!

Okay,

I figured it out…

gpiod in Python3 needs to be 0 and not 1 when altering the source for use…why?

Why does gpiod need to have the output as 0 instead of 1 for use in this circuit?

Seth

P.S. And the pwm outputs work at times but only when, it seems, they want to work. I have not configured things correctly obviously. config-pin works, PWM works, GPIO works, and the commands in the source returns movement but differently.

I can run the source in a while loop and the machine will behave differently w/in the same run.

What is the model number for the drive that you are using, I need to clarify how EN- PUL- is being used before posting corrections if they are needed.

Looks like you have it wired incorrectly, from board to drive.

Also,

When connecting hardware its best to first test the stepper drive standalone using a pulse generator, and a power supply with current limiting capability. Make sure it actually works first so you will not be chasing your tail for a few hours.

If that checks out do a temp connection and use
/sys/class/gpio to enable pins from CLI to make sure you have correct pins selected in the device tree overlay.

If that works move onto your py code and debug that.

1 Like

Hello…

It is a TB6600 driver w/ insides. It is basically just a box to me so far. The level shifter is this one: Pololu - Logic Level Shifter, 4-Channel, Bidirectional .

I do not have a pulse generator. I used gpiod to test the GPIO on the BBBW.

It seems their methods of connecting the driver are two PWM peripherals and one GPIO. I am not too familiar w/ the DR RObot Uno. So, I am basically guessing. I need to research their board more, duh.

Ha.

Okay…the source works. My source on the other hand is what is at fault. I know it.

# Use for PWM on /dev/bone/pwm/
from sysfs_pwm import Pwm   # see https://pastebin.com/R70P1wAn
... 
try:
    while True:
...
        proto = int(input("Please enter in a 0 or 1: "))
        pwm1b = Pwm('pwm/1/b', frequency=20000)
        pwm1b.value = 0.5
...

except KeyboardInterrupt:
    pwm1b.enabled = False
    print("Doyle did it!")

I am not sure about the frequency at 20000 since I only got it to work at 2000.

Seth

P.S. Thank you for your reply. I will get back to you on the rest of the source later…

The GPIO works and so does the PWM peripherals but there is something iffy still. I cannot put my finger on it yet… Anyway, thank you for the advice. Please remember, I do not have a pulse generator.

I know you have one.

/sys/class/pwm

@foxsquirrel ,

Oh! Yeppers…got it. I use /dev/bone/pwm/* instead for PWM usage for now. Um, the motor goes back and forth but I cannot describe why it does go back and forth…

If that makes sense, thank you. If that does not make sense, I can try to explain better.

  1. The motion of the motor is working w/ two, separate PWM signals from the BBBW.
  2. GPIO is “working” enough so that things can be turned “on” or “off.”
  3. My source on the other hand needs to explain to me what it is I am doing…
    a. B/c of this fact, I cannot push in comments…
    b. And…I cannot understand what is actually taking place where or when…

I know this is more of my issue than anyone else’s issue now. Hand outs like when I did not have lunch money would be nice!

Seth

P.S. Seriously. I mean, I can sort of grasp the concept of the PWM class at times. I can read it, see it, and visualize what it will do when I write my own source code for it…

But…things are happening that are not being explained or that I cannot explain well enough for now. I will try later. Thank you for helping so far. Advice and concern rule in my book, e.g. as I am out of understanding for whatever reason. I know…issues.