Please note: Friday June 18 is a holiday celebrating Juneteenth, please allow extra time for your order to arrive and plan accordingly.
0

How can I smooth out stepper motor operation
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

How can I smooth out stepper motor operation

by nlmara2036 on Mon Mar 22, 2021 4:14 pm

I am working on a project that uses a stepper motor to move a microscope stage up and down. I need the precision of the stepper motor, but the Crickit motor driver does not provide micro stepping and so when the motor moves the microscope stage the vibration makes the specimen bounce all over the place. The documentation seems to hint that micro stepping is possible. I'm using the Mu editor and Circuit Py to program the Playground Express and Crickit addon.

nlmara2036
 
Posts: 8
Joined: Thu Feb 06, 2020 9:31 pm

Re: How can I smooth out stepper motor operation

by adafruit_support_bill on Mon Mar 22, 2021 4:55 pm

The discrete stepping motion of the motors naturally does produce vibrations. Excessive system vibration usually happens when the motor vibrations excite natural resonances in the mechanical system to which it is attached.

Microstepping can help - partly by changing the step frequency - and partly by weakening the stepping force (yes, there is a tradeoff in torque there). The microstepping support in CircuitPython as noted in the documentation is quite slow. You might also try INTERLEAVE.

You can also try some changes in step frequency. Adding rigidity or redistributing mass in the mechanical system can also change its resonant frequencies. Vibration absorbing mounts for the motor can help as well.

adafruit_support_bill
 
Posts: 81319
Joined: Sat Feb 07, 2009 10:11 am

Re: How can I smooth out stepper motor operation

by nlmara2036 on Mon Mar 22, 2021 6:19 pm

I'm already using INTERLEAVE. I tried adding a heavy mass to the stage which should have changed the natural frequency a lot. The vibration is about the same.
I'm using a NEMA 17 stepper motor rated for 3.3V and 1.5A and 1.8 degree per step. Would a different stepper motor work better?

nlmara2036
 
Posts: 8
Joined: Thu Feb 06, 2020 9:31 pm

Re: How can I smooth out stepper motor operation

by franklin97355 on Mon Mar 22, 2021 6:24 pm

How is the stepper mounted? You might use a belt to isolate the motor from the stage.

franklin97355
 
Posts: 21888
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: How can I smooth out stepper motor operation

by nlmara2036 on Mon Mar 22, 2021 6:48 pm

The motor has a built-in lead screw which connects directly to the stage.

nlmara2036
 
Posts: 8
Joined: Thu Feb 06, 2020 9:31 pm

Re: How can I smooth out stepper motor operation

by adafruit_support_bill on Mon Mar 22, 2021 7:22 pm

I tried adding a heavy mass to the stage which should have changed the natural frequency a lot. The vibration is about the same.

Simply adding mass is not guaranteed to help. Depending on the location of the mass and the rigidity of the system, it can even make things worse. Some experimentation is often necessary.

Another source of vibration - often worse than the actual stepping - is the 'jerk' of sudden acceleration. Jerk (the first derivative of acceleration) can be minimized by implementing an acceleration curve. Search for 'jerkless acceleration algorithm' for some examples. The AccelStepper library for Arduino has a reasonably good implementation.

I'm using a NEMA 17 stepper motor rated for 3.3V and 1.5A and 1.8 degree per step. Would a different stepper motor work better?

Not sure how much motor you need to drive your stage. Most of the microscope systems I've worked with don't require a motor that large. Most are easily driven with a NEMA-8 or smaller motor.

The motor has a built-in lead screw which connects directly to the stage.

That pretty much rules out using timing belts for isolation and/or reduction. But you can probably still add some vibration damping motor mounts.
https://www.mcmaster.com/motor-mounts

adafruit_support_bill
 
Posts: 81319
Joined: Sat Feb 07, 2009 10:11 am

Re: How can I smooth out stepper motor operation

by nlmara2036 on Mon Mar 22, 2021 7:32 pm

Originally I thought I would be moving the camera up and down rather than the stage. Maybe I need to go back to that design.
Or is there a different motor driver I can use? The only other one I have is from Pololu and is designed to connect to a computer via USB. It runs the same stepper motor very smoothly.

nlmara2036
 
Posts: 8
Joined: Thu Feb 06, 2020 9:31 pm

Re: How can I smooth out stepper motor operation

by adafruit_support_bill on Tue Mar 23, 2021 6:21 am

Originally I thought I would be moving the camera up and down rather than the stage. Maybe I need to go back to that design.

I've seen it done both ways successfully. With appropriately sized linear slides and a rigid carriage design, either arrangement can work well.

Or is there a different motor driver I can use? The only other one I have is from Pololu and is designed to connect to a computer via USB. It runs the same stepper motor very smoothly.

The Crickit is sort of the Swiss Army Knife of interface boards. It can perform many functions, but does not really excel at any of them. The stepper drivers in particular are fairly basic dual H-bridge chips and rely on software to implement more advanced functions such as microstepping.

Pololu makes a wide variety of dedicated stepper drivers - many with microstepping and other advanced capabilities built into the hardware.
Their TIC controllers support USB as well as I2C or TTL Serial connection and have both microstepping and acceleration control.
https://www.pololu.com/category/212/tic ... ontrollers
The TIC T825 looks like it might be a good match for your needs:
https://www.pololu.com/product/3130

adafruit_support_bill
 
Posts: 81319
Joined: Sat Feb 07, 2009 10:11 am

Re: How can I smooth out stepper motor operation

by nlmara2036 on Tue Mar 23, 2021 12:32 pm

I have a TIC834. How do I connect it to the Crickit? I2C or TTL? I'm not familiar with those.

nlmara2036
 
Posts: 8
Joined: Thu Feb 06, 2020 9:31 pm

Re: How can I smooth out stepper motor operation

by adafruit_support_bill on Tue Mar 23, 2021 12:48 pm

The Playground Express communicates to the Crickit via I2C using the SDA and SCL pins (A4 and A5 on the CircuitPlayground):
https://learn.adafruit.com/adafruit-cri ... 2988018-36

You can talk to other I2C devices on the same bus as long as they have a unique address. You just connect them to the same SDA and SCL pins.

TTL Serial uses the Rx and Tx pins (A.K.A. A6 and A7). You can communicate over these pins using the Serial commands.

I'm not sure if Pololu has any CircuitPython support for communication with their TIC boards via I2C. Serial communication is pretty generic, so that might be an easier way to go.

adafruit_support_bill
 
Posts: 81319
Joined: Sat Feb 07, 2009 10:11 am

Re: How can I smooth out stepper motor operation

by nlmara2036 on Tue Mar 23, 2021 1:04 pm

According to the Tic manual:
The serial interface uses non-inverted TTL logic levels: a level of 0 V corresponds to a value of 0, and a level of 5 V corresponds to a value of 1. The input signal on the RX pin must reach at least 4 V to be guaranteed to be read as high, but 3.3 V signals on RX typically work anyway.

I assume the playground express is 3.3V?

Also the Tic requires a 5V power supply. Can I pull that from the Crickit? Using the 5V from the Drive controller and the Ground from the Motor controller?

nlmara2036
 
Posts: 8
Joined: Thu Feb 06, 2020 9:31 pm

Re: How can I smooth out stepper motor operation

by adafruit_support_bill on Tue Mar 23, 2021 1:18 pm

Yes. The CircuitPlayground Express is a 3.3v device. We've found that most 5v devices do accept 3.3v signals. But if you run into problems, you can use a logic level shifter to boost the signals up to 5v: https://www.adafruit.com/product/1875

And yes, you can power it using 5v and GND from the Crickit.

adafruit_support_bill
 
Posts: 81319
Joined: Sat Feb 07, 2009 10:11 am

Re: How can I smooth out stepper motor operation

by nlmara2036 on Fri Apr 16, 2021 2:24 pm

I am trying to use the serial communication between the playground express and Pololu TicT834 stepper motor control. There is a python module for USB communication, but for serial they use the pyserial library. I hoped I could use the busio library since it appears to do the same thing. I wrote a very short script to connect to the Tic and read the current position of the motor

import busio
import board

uart = busio.UART(board.TX, board.RX, baudrate=9600)
uart.write( bytes( [0xA1, 0x22, 0x04] ) )
data = uart.read(4)
print(data)

But all I get back is "None"

Any idea where I went wrong?

How can I use the pyserial library instead?

nlmara2036
 
Posts: 8
Joined: Thu Feb 06, 2020 9:31 pm

Re: How can I smooth out stepper motor operation

by adafruit_support_bill on Fri Apr 16, 2021 2:43 pm

I don't have any hands-on experience with that controller. But I would expect that the 'current position' is undefined until you have issued a Halt and Set Position command. The documentation refers to a “position uncertain” flag which I would expect to be set at startup.

adafruit_support_bill
 
Posts: 81319
Joined: Sat Feb 07, 2009 10:11 am

Re: How can I smooth out stepper motor operation

by nlmara2036 on Fri Apr 16, 2021 4:44 pm

I added the command for "halt and set position"
uart.write( bytes( [0xEC] ) )
Same result.

I also added the command "exit safe start" which is supposed to clear any errors.
uart.write( bytes( [0x83] ) )
Same result.

nlmara2036
 
Posts: 8
Joined: Thu Feb 06, 2020 9:31 pm

Please be positive and constructive with your questions and comments.