4

It is my understanding that a Rasperry Pi cant handle 5V on the GND-pin. For that reason I got myself a level-shifter which is supposed to be able to change the output from 3.3V to 5V. I need it to be 5V because that's what the stepper driver operates on.

enter image description here

I don't know if the 5v-output is programmable or if its just a steady stream of power. If it's programmable i assume i could plug pin2 directly into the stepper driver and send it back through the level shifter making it 3.3v that i can connect to a GND-pin.

The connection from the stepper driver to the motor should be fine.

This is the code im using trying to activate the stepper driver

import RPi.GPIO as GPIO # Import Raspberry Pi GPIO library
from time import sleep # Import the sleep function from the time module
GPIO.setwarnings(False) # Ignore warning for now
GPIO.setmode(GPIO.BOARD) # Use physical pin numbering
GPIO.setup(3, GPIO.OUT, initial=GPIO.LOW) # Set pin 3 to be an output pin and 
set initial value to low (off)
for x in range(0,100):
GPIO.output(3, GPIO.HIGH) # Turn on
sleep(0.1) # Sleep for 0.1 second
GPIO.output(3, GPIO.LOW) # Turn off
sleep(0.1) # Sleep for 1 second

Stepper driver: Hybrid Servo Drive HB860H Datasheet

Level shifter: 4-channel I2C-safe Bi-directional Logic Level Converter - BSS138

StainlessSteelRat
  • 2,532
  • 1
  • 15
  • 20
Nlas
  • 63
  • 3

1 Answers1

1

The GND of the stepper motor, the GND of the level shifter and the GND of the raspberry pi GPIO needs to be connected together. Your diagram seems correct.

As 3.3V and 5V are quite similar, you "could" output GPIO to the stepper motor and it will most probably work. However as 3.3V is close to the shifting level of 5V digital electronic, you will experience issues with noises and eventually weird startup problems. I suggest you to keep the level shifter in middle.

I don't see the GPIO_5 setup. I am not aware of the internal implementation of the stepper driver neither the level shifter, but, be sure that a high-impedance input for "Dir+" can cause malfunction.

Also, driving the level-up and level-down by software will only work at low speed: Rapsberry pi (and any modern computer) has operating system multi-tasking, memory cache failures, etc. which causes the software to not run timely. Jitter of Raspberry pi is commonly over 1ms, which, for driving a stepper motor will become a problem. This is an other problem, but keep it in mind.

Adrian Maire
  • 348
  • 1
  • 14