ReeceEngineering
Posts: 9
Joined: Thu Jun 06, 2019 3:50 pm

2 Stepper Motors; Independent control

Mon Sep 16, 2019 4:47 pm

I am building a machine to polish airsoft barrels. This invloves a 3d printed bit on the tip of a long rod being driven through the barrel several thousand times & rotated between each pass. I plan to achieve this by using 1 stepper motor to drive a pulley system and another to rotate the rod.

I will need to drive the larger stepper motor on the belt through about 20 revolutions, then return to 0. Next the smaller stepper motor on the rod rotates any # of degrees that does not divide into 360.
6 steps of 1.8 degrees=10.8
360/10.8=33.33333
Therefore 6 steps on each cycle will work on the smaller motor.

This system uses a spring (of known constant) attached to the rod and a slide potentiometer in order to measure depression. This will be used to calculate the force applied to the rod. If force drops below a cut off point the machine must stop and flash an LED, signaling an adjustment is needed. The slide potentiometer has an analouge signal so it would need conversion to work with a Pi. Shouldnt be hard.

The distance run by the larger stepper operating the belt system will depend on the barrel length. This information is something Id like to be able to enter into the machine via a screen and user interface. And from what I understand running a user interface with graphics would be best achomplished with a Raspberry Pi.

However while researching what controller and parts I should use it has been suggested to me to use an Arduino over a Raspberry pi. Reasoning that the Raspberry Pi will loose some resolution & accuracy when made to independently control 2 motors (true?). I was told to use an Arduino to run the stepper motors and that I could use a Raspberry Pi to run the user interface and communicate with the arudino to tell it what to do with the motors.


Where I seek your advice:

1. Is this true? Do Raspberry Pi's really loose resolution when made to independently control 2 stepper motors?

2. Would a Raspberry Pi or an Arudino be better suited to calculating force applied to the rod in order to detect when to stop operation? Or would they both work just as well? Does the controller running the stepper motors NEED to be the same one calculating force or could they be seperate?

3. How would a Raspberry Pi and Arudino compare in ability to run a user interface through a screen?

4. Are there any Raspberry Pi HATs that are capable of running 1.8ohm stepper motors with 2amps and up to 50volts? This is going to require current limiting and I havent seen any HATs that meet these specs, which I find quite suprising. Though I am new to this hobby so perhaps my google skills are lacking.

pws
Posts: 92
Joined: Mon Apr 11, 2016 4:16 pm

Re: 2 Stepper Motors; Independent control

Tue Sep 17, 2019 12:48 pm

bCNC / GRBL is worth looking at....

User avatar
joan
Posts: 14376
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: 2 Stepper Motors; Independent control

Tue Sep 17, 2019 12:56 pm

It sounds like something easy to do on the Pi. Of course you would need an ADC.

How many steps per second per motor? How accurately do the pulses need to be timed? Must they be synchronised? These are the sort of questions which will let you know if an Arduino is more suitable.

ReeceEngineering
Posts: 9
Joined: Thu Jun 06, 2019 3:50 pm

Re: 2 Stepper Motors; Independent control

Tue Sep 17, 2019 7:56 pm

joan wrote:
Tue Sep 17, 2019 12:56 pm
It sounds like something easy to do on the Pi. Of course you would need an ADC.

How many steps per second per motor? How accurately do the pulses need to be timed? Must they be synchronised? These are the sort of questions which will let you know if an Arduino is more suitable.
Here is a video I made at an earlier stage of this project showing the machine's layout. The question Im asking in this old video was about measuring distance, and I found the solution with the slide potentiometer so disregard that part: https://www.youtube.com/watch?v=WhsNTUPkNVQ

Motor #1: 2amps, 1.8 Ohms https://tinyurl.com/y63cdhwz
Drives the pulley system. I'd like to get the maximum steps per second the motor is capable of. The puleses wont need to be accuractly timed for basic operation, however the total # of steps completed will need to be very accurate. This motor must be synchronised in that it will move roughly 20 rotations and return to 0, then the other motor will rotate 6 steps, then repeat. This is synchronisation however not nearly as complicated as a 3d printer's synchronisation.

Motor #2: 1.5 amp, 2 Ohms https://tinyurl.com/y5vwulex
Rotates the rod. This motor will only rotate between each cycle of motor #1. 24 steps per second will work.

^These descriptions are the motors job and how it will work during simple operation: Only 1 motor will be moving at a given time.



I would also like to be capable of complex operation where 2 motors will be moving at the same time. As motor #1 is moving through 20 revolutions motor # 2 will rotate through 50-200 steps. When motor #1 switches direction to return to 0 motor #2 also rotates the opposite direction and returns to 0. Motor #2 then rotates 6 steps. Repeat.

This could allow the geometry of the work surface to be improved even more due to the inital twist producing a checkerboard pattern. As the 1st few thousand cycles procede this twist from motor #2 will slowly taper down to no twist during the cycle. This could be achived with an equation in the coding (should be fun!). Once motor #2's rotation during the cycle has tapered back to 0 the machine then switches back to simple operation where only 1 motor moves at a time for several thousand more cycles. The idea is to end on a striaght line so all the marks are inline with the direction the BBs travel.

pootle
Posts: 340
Joined: Wed Sep 04, 2013 10:20 am
Location: Staffordshire
Contact: Website

Re: 2 Stepper Motors; Independent control

Wed Sep 18, 2019 7:34 am

For driving stepper motors, a raspbery pi is every bit as capable as an arduino, either by offloading the low level driving to external chips, or by using dma control of the I/O pins providing very highly accurate timings.

The standard Hat's available are not in general suitable for smart driving of stepper motors as the are typically just H-bridges really designed for driving DC motors, but is is pretty easy to assemble a couple of proper stepper controllers onto a prototyping hat such as one of these adafruit hats. 2 driver boards can easily be assembled onto such a hat - here's one I did a couple of years ago.

Once you go beyond driving a simple bridge to drive the motor, there are several layers of capability, The lower end is chips like the A4988 - and there are versions of these which will operate up to 50V. However to run at absolute maximum speed (which requires the stepping rate to be ramped up and down), requires quite significant software, as the step pulses are generated by the raspberry pi, and to get precise timing this in turn needs dma controlled driving of the gpio pins using software like pigpio.

At the upper end are chips from the likes of TMC. These effectively run the motor autonomously, and (once the various settings are configued), just require commands such as 'GOTO step X', and the chip takes care of timing, ramping, current limiting and if set up properly can detect if the motor stalls etc.

I did some testing of these described here.

There is no problem at all running to motors simultaneously.

ReeceEngineering
Posts: 9
Joined: Thu Jun 06, 2019 3:50 pm

Re: 2 Stepper Motors; Independent control

Wed Sep 18, 2019 10:23 pm

pootle wrote:
Wed Sep 18, 2019 7:34 am
At the upper end are chips from the likes of TMC. These effectively run the motor autonomously, and (once the various settings are configued), just require commands such as 'GOTO step X', and the chip takes care of timing, ramping, current limiting and if set up properly can detect if the motor stalls etc.

I did some testing of these described here.

There is no problem at all running to motors simultaneously.
Pootle thanks for the information! I looked on Trinamic's site and saw dozens of drivers that would meet the power specs of the motor in question, all of these boards have many features I dont know about making it difficult to choose. From what I see the TMC5160 seems to be a good choice for me and a larger brother of the 5130 chip you tested on your blog.

Would all of the TMC drivers be able to run motors autonomously after settings configuration & function with commands as simple as go to "stepX"?

pootle
Posts: 340
Joined: Wed Sep 04, 2013 10:20 am
Location: Staffordshire
Contact: Website

Re: 2 Stepper Motors; Independent control

Thu Sep 19, 2019 6:41 am

ReeceEngineering wrote:
Wed Sep 18, 2019 10:23 pm
Would all of the TMC drivers be able to run motors autonomously after settings configuration & function with commands as simple as go to "stepX"?
All of the ones in that family - 5130, 5160 etc, I would expect to run pretty simply:

Code: Select all

Check at position zero
clear crash flag
repeat 111 times:
    set goto position max
   sleep(.1)
   read ramp stat register
   while not position reached and not crash: #flag in ramp stat register
   	sleep(.1)
   	read ramp stat register
   if not crash:
       set goto position min
        sleep(.1)
       read ramp stat register
       while not position reached:
           sleep(.1)
           read ramp stat register
       set twist motor position +x
       etc.
If you want to twist slowly at the same time as runniing up and down the bore then set a low VMAX on the twist motor and set it in velocity mode at the same time as set position max / min.

A separate thread to check the slide pot input and set the crash flag

IanS
Posts: 234
Joined: Wed Jun 20, 2012 2:51 pm
Location: Southampton, England

Re: 2 Stepper Motors; Independent control

Mon Sep 23, 2019 8:26 am

I would suggest having end-stop switches on the back-and-forth motion. Then, move to and fro until the switches trigger instead of going a fixed distance. This way you can cope with skipped steps and it does not matter if the power gets interrupts part way along leaving the device to restart in an unknown position.

ReeceEngineering
Posts: 9
Joined: Thu Jun 06, 2019 3:50 pm

Re: 2 Stepper Motors; Independent control

Mon Oct 14, 2019 12:52 am

IanS wrote:
Mon Sep 23, 2019 8:26 am
I would suggest having end-stop switches on the back-and-forth motion. Then, move to and fro until the switches trigger instead of going a fixed distance. This way you can cope with skipped steps and it does not matter if the power gets interrupts part way along leaving the device to restart in an unknown position.
End stop switches are in the plans for future development. I could probably do that with optical sensors.

How should I size up the decision between a TMC1560 and something like the Synthetos board which can execute G-code: https://www.adafruit.com/product/1749

It seems like that might make programming easier and reduce chances for inaccuracies in movement due to the processor no longer needing send timely commands to coordinate movement between two TMCs. Is this correct or would it really not matter? Theres quite a difference in price between the 2 and I have almost no experience writing code.

ReeceEngineering
Posts: 9
Joined: Thu Jun 06, 2019 3:50 pm

Re: 2 Stepper Motors; Independent control

Tue Nov 19, 2019 12:24 am

IanS wrote:
Mon Sep 23, 2019 8:26 am
I would suggest having end-stop switches on the back-and-forth motion. Then, move to and fro until the switches trigger instead of going a fixed distance. This way you can cope with skipped steps and it does not matter if the power gets interrupts part way along leaving the device to restart in an unknown position.
How would you recomend setting up the end stop switches? Im not sure how we can keep count of the number of passes if the motor had its circurt to the board opened. Im sure someone has probably found a work around for this before

Return to “Automation, sensing and robotics”