EMC2 running on Raspberry Pi?

More
13 years 7 months ago - 13 years 7 months ago #31467 by metachris

mozmck wrote: Can you leave the pulse width static and vary the frequency easily and over a wide range with a DMA driven PWM?


Yes you can, with various techniques, although within limits. One limit is if you need too many DMA control blocks (if the increment granularity is very small (1us) and the frequency low (eg. 10Hz, because you need so long to jump back to the initial control block in the linked list). I will be testing the limits a bit over the weekend.

@PCW: The DMA driven stepgen idea sounds interesting.
Last edit: 13 years 7 months ago by metachris.

Please Log in or Create an account to join the conversation.

More
13 years 7 months ago - 13 years 7 months ago #31468 by PCW
Replied by PCW on topic EMC2 running on Raspberry Pi?
No PWM involved, all the DMA does is copy from an array in memory to the GPIO port (1 word per usec for example) By arranging things properly I can DMA data from memory continously

So say I want a 5 usec pulse on the output, I have this data in the memory:
...
0000000
0000001
0000001
0000001
0000001
0000001
0000000
0000000
...

By varying the spacing of pulses in the memory record I can generate any step rate I want
Last edit: 13 years 7 months ago by PCW.

Please Log in or Create an account to join the conversation.

More
13 years 7 months ago #31469 by metachris
I see that working, if a few percent fluctuation on the pulse-widths do not matter (eg. it's impossible to achieve 500kHz because the fluctuations add up; exact number yet unknown). I think updating pwm.c in RPIO with this functionality might be quite trivial.

Please Log in or Create an account to join the conversation.

More
13 years 7 months ago #31470 by mozmck
PCW: Ok, I see. I was wondering how/if a PWM channel could be made to do that, but if you can control GPIO directly with DMA that's another matter. Sounds like an interesting idea.

Please Log in or Create an account to join the conversation.

More
13 years 7 months ago - 13 years 7 months ago #31477 by metachris

PCW wrote: No PWM involved, all the DMA does is copy from an array in memory to the GPIO port (1 word per usec for example) By arranging things properly I can DMA data from memory continously

So say I want a 5 usec pulse on the output, I have this data in the memory:
...
0000000
0000001
0000001
0000001
0000001
0000001
0000000
0000000
...

By varying the spacing of pulses in the memory record I can generate any step rate I want


We still use the PWM/PCM hardware for the DMA timings (set to 10MHz in here: github.com/metachris/RPIO/blob/master/source/c_pwm/pwm.c#L599 ), and the DMA writes our memory to the GPIOs. Apps using this would need to write the memory pretty well timed, in order to avoid duplicate step instructions. We could possibly program the DMA part so it does not repeat steps once they were executed (lets hope we do not need this). How exactly can we time the writes in LinuxCNC?

If this runs at 1MHz, that requires the app to write 1M of control instructions every second, and we'd have a million possible step instructions per second. What is typically needed by steppers with LinuxCNC or achieved by hardware drivers?
Last edit: 13 years 7 months ago by metachris.

Please Log in or Create an account to join the conversation.

  • mhaberler
  • New Member
  • New Member
More
13 years 7 months ago #31478 by mhaberler
Replied by mhaberler on topic EMC2 running on Raspberry Pi?
Hi Chris,

the standard 'servo cycle' - the rate by which target positions are updated - is 1 kHz, but some people run this at higher rates up to maybe 10 kHz max; that would also be the rate by which stepper speed gets adjusted

PCW probably can fill in better as what maximum realistic step rates are but lets assume worst-case with fine microstepping:

I wouldnt assume step rates would exceed 100kHz

so as a ballpark figure per servo cycle you'd have maximum 100 steps per servo cycle

maybe a viable method is to use a dual-buffer scheme and switch the DMA between sample buffers at servo rate to avoid sync problems

- Michael

Please Log in or Create an account to join the conversation.

Time to create page: 0.090 seconds
Powered by Kunena Forum