Adafruit DC & Stepper Motor HAT for Raspberry Pi

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
pbgorman
 
Posts: 3
Joined: Thu Aug 13, 2015 8:16 pm

Adafruit DC & Stepper Motor HAT for Raspberry Pi

Post by pbgorman »

So I just ordered my first Raspberry Pi with the intent on building a CNC router. My question is regarding the Adafruit DC & Stepper Motor HAT for Raspberry Pi. Will this work with GRBL or LinuxCNC or will I have to code through Python? I'm a total noob with this so forgive my ignorance if this is a dumb question. I am a professional CAD guy and I'm wanting to design and create stuff. Nothing too serious just yet as I get my feet wet with this project.

Thanks!
P

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: Adafruit DC & Stepper Motor HAT for Raspberry Pi

Post by adafruit_support_mike »

The Motor Hat doesn't support any of the NC dialects, but more importantly, it can only handle about 1.6A per channel. That will limit you to a light duty CNC rig unless you use the Hat's output to control external H-bridges.

User avatar
pbgorman
 
Posts: 3
Joined: Thu Aug 13, 2015 8:16 pm

Re: Adafruit DC & Stepper Motor HAT for Raspberry Pi

Post by pbgorman »

adafruit_support_mike wrote:The Motor Hat doesn't support any of the NC dialects, but more importantly, it can only handle about 1.6A per channel. That will limit you to a light duty CNC rig unless you use the Hat's output to control external H-bridges.
So then my best bet would probably be an Arduino and a stepper shield then?

User avatar
adafruit_support_bill
 
Posts: 88096
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit DC & Stepper Motor HAT for Raspberry Pi

Post by adafruit_support_bill »

For CNC applications I'd recommend an Arduino and a gShield. https://www.adafruit.com/products/1750
The gShield is designed for CNC applications running the tinyG G-code interpreter on Arduinos. It can handle larger motors than the stepper shield and has current limiting.

https://learn.adafruit.com/all-about-st ... he-stepper

User avatar
pbgorman
 
Posts: 3
Joined: Thu Aug 13, 2015 8:16 pm

Re: Adafruit DC & Stepper Motor HAT for Raspberry Pi

Post by pbgorman »

Excellent Bill! I have read that and am absorbing all I can about them.

Thanks so much!

User avatar
rafoid
 
Posts: 10
Joined: Fri Oct 02, 2015 3:36 pm

Re: Adafruit DC & Stepper Motor HAT for Raspberry Pi

Post by rafoid »

I just received mine and planning to use it with 2 stepper motors. But I have a slightly different question - since the HAT goes over all of the GPIO pins on the PI, how can I access other pins that I am planning to use? My guess is I can simply solder wires on top of the HAT, since the HAT itself doesn't utilize all GPIO pins, or does it?

User avatar
adafruit_support_bill
 
Posts: 88096
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit DC & Stepper Motor HAT for Raspberry Pi

Post by adafruit_support_bill »

Other than power and ground, the HAT only uses the SDA and SCL pins. And these can be shared with other I2C devices. All other GPIO pins are accessible via the breakout holes in the HAT.

User avatar
rafoid
 
Posts: 10
Joined: Fri Oct 02, 2015 3:36 pm

Re: Adafruit DC & Stepper Motor HAT for Raspberry Pi

Post by rafoid »

I connected two steppers I purchased from Adafruit which were recommended for this project and modified sample code to test them out. What I see is with step set to 1, the FORWARD direction doesn't work properly - it goes forward and then immediately backward. When direction is BACKWARD, it works as expected. Here is my code:

Code: Select all

mtr2 = mh.getStepper(1, 1)  # steps/rev, motor port #1
mtr2.setSpeed(1)            # RPM
mtr1 = mh.getStepper(1, 2)  # steps/rev, motor port #2
mtr1.setSpeed(1)            # RPM

step = 1
stepType = Adafruit_MotorHAT.MICROSTEP

# move motor 2 forward 1 step
mtr2.step(step, Adafruit_MotorHAT.FORWARD,  stepType)

# move motor 1 forward 10 steps
j = 0
while (j <= 10): 
    mtr1.step(step, Adafruit_MotorHAT.FORWARD, stepType)
    j += step

# move motor 2 forward 1 step
mtr1.step(step, Adafruit_MotorHAT.FORWARD,  stepType)
        
# move motor 1 backward 10 steps
j = 0
while (j <= 10):
    mtr2.step(step, Adafruit_MotorHAT.BACKWARD, stepType)
    j += step
Is there a bug in Adafruit code? Is this a known issue? Please advise.
Last edited by adafruit_support_bill on Thu Oct 15, 2015 5:51 am, edited 1 time in total.
Reason: Please use [code] tags when submitting code to the forums

User avatar
adafruit_support_bill
 
Posts: 88096
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit DC & Stepper Motor HAT for Raspberry Pi

Post by adafruit_support_bill »

There is a github issue regarding microstepping problems. No ETA on a fix yet.
viewtopic.php?f=50&t=81479&p=411981&hil ... ep#p412963

User avatar
rafoid
 
Posts: 10
Joined: Fri Oct 02, 2015 3:36 pm

Re: Adafruit DC & Stepper Motor HAT for Raspberry Pi

Post by rafoid »

With two stepper motors connected to the hat, things work perfectly, until ...

I recently purchased another device which sits on I2C address 0x62. If I unplug this device from the hat, both steppers rotate as expected. As soon as I connect this device, steppers still rotate but frequently enough I get this error: "Error accessing 0x60: Check your I2C address". The program doesn't engage the newly connected device, it still only rotates steppers, but without 0x62 device I get no such errors and with the device connected, same exact program gives me errors. I see that one of the steppers is sitting on 0x60 address. Is this a known issue? Can this address be re-assigned somehow? I am ok with changing C code and recompiling it if needed. Any pointers are greatly appreciated.

User avatar
adafruit_support_bill
 
Posts: 88096
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit DC & Stepper Motor HAT for Raspberry Pi

Post by adafruit_support_bill »

As long as the addresses are different there should be no addressing conflict. It sounds like maybe a problem with bus loading, capacitance or noise when you connect the new device. If you post photos showing your soldering and wiring we can take a look.

User avatar
rafoid
 
Posts: 10
Joined: Fri Oct 02, 2015 3:36 pm

Re: Adafruit DC & Stepper Motor HAT for Raspberry Pi

Post by rafoid »

I'm connecting ground, 5V SCL and SDA. The image can be found here: https://goo.gl/photos/WsHwrBf92m56U5Kh7

User avatar
adafruit_support_bill
 
Posts: 88096
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit DC & Stepper Motor HAT for Raspberry Pi

Post by adafruit_support_bill »

How long are your wires? i2c was designed for communication between chips on the same board, so it works best when wires are kept short. Long wires can cause problems like too much capacitance which will affect the rise-time of the signals on the bus. Longer wires are also more susceptible to noise. This can be a real concern in a CNC type application with lots of high-current inductive loads being switched on and off.

User avatar
rafoid
 
Posts: 10
Joined: Fri Oct 02, 2015 3:36 pm

Re: Adafruit DC & Stepper Motor HAT for Raspberry Pi

Post by rafoid »

The wires to the device are about 5" long, but so are the wires to the steppers. When the device is connected, there is no communication happening on it - the program I execute is only designed to rotate both steppers. I see that the HAT board also has some I2C addresses marked in the middle (A0 through A4) - what are they intended for? Is it to change I2C addresses via hardware?

User avatar
adafruit_support_bill
 
Posts: 88096
Joined: Sat Feb 07, 2009 10:11 am

Re: Adafruit DC & Stepper Motor HAT for Raspberry Pi

Post by adafruit_support_bill »

When the device is connected, there is no communication happening on it -
It doesn't matter if you are communicating with the device or not. i2c is a bus so all devices on the bus - including the shield - see all of the communication and all of the noise.
The wires to the device are about 5" long, but so are the wires to the steppers.
So you have 2x 5" receiver antennae connected to the bus and 4x 5" antennae transmitting interference from the stepper motor windings. Any noise picked up on the receive side will impact i2c communication with the shield. Make sure that these wires are well separated. You can minimize noise pickup by using twisted pair and/or shielded wiring.

Locked
Please be positive and constructive with your questions and comments.

Return to “Microcontrollers”