Stepper Motor Control with Me Shiel for Raspberry Pi


#21

Hey dr-roboto !

Sorry I had no time to answer before.

I don’t have the DC motors with me as I’ve lent them to a friend.
Also, I have separate power to my Orion and my rpi but my motors are using the same power as the Orion, maybe it’s not enough ?


#22

http://docs.makeblock.com/diy-platform/en/electronic-modules/motors/42byg-stepper-motor.html

According to the specs, this is a 12V motor and 1.7A
https://www.robotshop.com/en/makeblock-12v-075oz-in-bipolar-stepper-motor.html

Even with a dedicated 12V power supply, not much else will run on the orion if you have two of these motors running.


#23

My power supplies 12VDC and 2.3Amp so that should be ok right ?


#24

When I look at the github code, this is the latest one
it uses slot 1 for the stepper motor (sorry indenting is lost)
from megapi import *

def onForwardFinish(slot):
sleep(0.4)
bot.stepperMotorMove(slot,3000,-3000,onBackwardFinish)

def onBackwardFinish(slot):
sleep(0.4)
print(slot)
bot.stepperMotorMove(slot,3000,3000,onForwardFinish)

if name == ‘main’:
bot = MegaPi()
bot.start()
sleep(1);
onForwardFinish(1)
while 1:
continue;


#25

Yes, this is the one I used to test my motors but actually it’s not working. Maybe the load on the motors can have an impact but they should still try to run no ?


#26

summary:

  • interface between orion and rpi work with both shield and usb cable as per ultrasonic test
  • if rpi is powered up on its on external power and the orion is powered up on its own external power and then the rj25 or usb cables are connecte, there should be no loss of power on each
  • your first message has you using stepperMotorRun which was last updated 3 years ago
  • my last msg has me using stepperMotorRun which was updated 2 years ago to “fix the bugs to support python3”

here is the actual github code
def stepperMotorRun(self,slot,speed):
deviceId = 76;
self.__writePackage(bytearray([0xff,0x55,0x07,0x00,0x02,deviceId,0x02,slot]+self.short2bytes(speed)))

def stepperMotorMove(self,port,speed,distance,callback):
    deviceId = 76;
    extId = ((port<<4)+deviceId)&0xff
    self.__doCallback(extId,callback)
    self.__writePackage(bytearray([0xff,0x55,0x0b,extId,0x02,deviceId,0x01,port]+self.long2bytes(distance)+self.short2bytes(speed)))

def stepperMotorMoveTo(self,port,speed,distance,callback):
    deviceId = 76;
    extId = ((port<<4)+deviceId)&0xff
    self.__doCallback(extId,callback)
    self.__writePackage(bytearray([0xff,0x55,0x0b,extId,0x02,deviceId,0x06,port]+self.long2bytes(distance)+self.short2bytes(speed)))

next steps

  • get the DC motors back from your friend
  • I have run out of ideas, maybe tech support has some ideas