Pinguino Forum

Full Version: Steppers, micro-stepping and G-code parser
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi all,
I'm finishing the new Stepper library which now allow micro-stepping (up to 32/step) thanks to PWM and interrupt. I did my tests on a Pinguino 32MX250 but the library will be available for both 8- and 32-bit chips.
The next big step is to parse G-code to drive the steppers.
I don't want to run the parser on a Pinguino because I think it is just too slow to do it and drive the steppers at the same time (we talk about CNC with minimum 3 axis = 3 steppers * 400 steps/rev * 32 micro-steps/steps @ 800rpm that must be driven at the same time). Running the parser on a PC would be a far better solution. It would let the Pinguino concentrate on moving the steppers only. We would only have to send compact commands to the Pinguino through USB (so LinuxCNC is not what I need because it only communicates through parallel port). I could try to adapt GRBL to make it run on a PC but there are maybe other existing tools that I could more easily modify ? Thank you for your suggestions.
I'm wondering:
1. what does the code need to do per interrupt?
2. is it doing (worst case) 3 * 400 * 32 * 800 interrupts per minute or if not how many?

On 40MHz PIC32 from flash (does it have WS? I know 80MHz chip does) I guess about 20MIPS of quite crude instructions so can estimate from there. If #2 is worst case then it's 0.5M so only about 40 instructions available per interrupt which sounds too few in reality.

Maybe post the code as-is. Even those who don't have steppers may look and have ideas Smile

I can imagine it will get used when you have it working.

John
(20-12-2013, 12:55 PM)pingotg Wrote: [ -> ]1. what does the code need to do per interrupt?

1. get duty value of each PWM (2 at a time) from a sine lookup table (the current in one winding is kept constant over half of the complete step and current in the other winding is varied as a function of sine to maximize the motor torque)
2. generate PWM outputs

(20-12-2013, 12:55 PM)pingotg Wrote: [ -> ]2. is it doing (worst case) 3 * 400 * 32 * 800 interrupts per minute or if not how many?

I think we can move all steppers in the same interrupt, so it left :
- 234 cycles at PBclock = 40MHz (80MHz PIC32MX)
- 117 cycles at PBclock = 20MHz (40MHz PIC32MX)
- 70 cycles at PBclock = 12MHz (48MHz PIC18F)
which is in any way far too few to calculate 3 axis stepper motor interpolation.
Is there even enough time to do USB as well as steppers?

It's a funny, bursty, thing.

John
(20-12-2013, 06:54 PM)pingotg Wrote: [ -> ]Is there even enough time to do USB as well as steppers?

I will need to buffer the commands in RAM first and then move the steppers.
BTW, I think I've found what I was looking for : http://replicat.org/sanguino3g
I will study the code and try my own simple G-code parser in Python first.
I'm very interrested in this stepper work.

I came to pinguino to try to have an alternative to arduino and Marlin to control steppers.
I'm not sure thow where to find info about thoses libs, are they ready ?

I think writing a full doc is teadious but maybe record a video, showing the principles, like how to have 1/32 1/16 stepping would be very informative. 

Atm this stepper work is want I want to work on, but I don't know where to start nor where to find theory that I could transpose.
Hi,
The stepper library works for both 8- and 32-bit Pinguino boards and there are examples how to use it.
(14-10-2014, 09:30 PM)regis Wrote: [ -> ]Hi,
The stepper library works for both 8- and 32-bit Pinguino boards and there are examples how to use it.

regis,
 i have tried the stepper examples with my 4550 and the motor just vibrates. i hooked the same stepper up to and arduino it works fine.

thank you 
fred
Ok, I see. The Timer 3 prescaler has been configured with bad values (actually PIC32 values).
I will fix it ASAP.
(19-10-2014, 04:34 PM)regis Wrote: [ -> ]Ok, I see. The Timer 3 prescaler has been configured with bad values (actually PIC32 values).
I will fix it ASAP.

Thank you Regis
Pages: 1 2