EMC2 running on Raspberry Pi?

More
15 Mar 2013 21:34 #31452 by mhaberler
thats not what I read, but I'll meet the author in a week or two and have him explain

unfortunately the method is useful only on the output side; it wont help e.g. with encoders

-m

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

More
15 Mar 2013 21:55 - 15 Mar 2013 22:10 #31453 by PCW
Replied by PCW on topic EMC2 running on Raspberry Pi?
I think the author is using this for R/C servos at 50 Hz (1-2 ms range so 1 uSec timing gives ~10 bits of resolution = fine for R/C servos)

1 uSec is a bit crude for PWM (<6 bit resolution at 20 KHz), but low CPU overhead and output channels only limited bit GPIO bits.

Strangely enough we did the exact thing about 20 some years ago for a ~0 hardware LCD interface using DMA (the LCD contrast was done with a PDM "track" in the DMA'ed LCD data stream)

A stepgen would be a bit tricker as it would have to be able to generate the memory patterns for the DMA faster than the DMA consumed them.

Also you can read encoders this way (DMA in the Port data to a circular RAM buffer and process the say 1024 samples every servo tic)
Last edit: 15 Mar 2013 22:10 by PCW.

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

More
16 Mar 2013 00:45 #31458 by metachris
Hello, author of RPIO here. LinuxCNC looks very interesting; I am currently familiarizing myself with it. Not sure whether RPIO may possibly useful.

RPIO.PWM can theoretically set pulse-widths down to 1 us (eg. a frequency of 500kHz), although such short pulses have a few percent fluctuation which sum up over the course of a second. I have not yet fully tested the performance limits of this approach. The C source is here: github.com/metachris/RPIO/blob/master/source/c_pwm/pwm.c; the PWM docs are there: pythonhosted.org/RPIO/pwm_py.html.

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

More
16 Mar 2013 01:25 #31460 by mozmck
Can you control the *number* of steps using a PWM channel? I have not seen any way to do that and that's what would be needed for a step/dir based system. Also, the pulse width should not need to change, but the frequency would change... frequently :)

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

More
16 Mar 2013 01:31 #31461 by metachris
Do you mean the exact number of pulses within a certain timeframe, with 'number of steps'? If so, the answer depends on the number of pulses -- what are typical ranges of steps/time?

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

More
16 Mar 2013 01:47 #31462 by mozmck
Yes, if you want a stepper motor (or servo using a step/dir drive) to move a specific distance, then you have to send a certain number of steps - or pulses. These are generally all the same width, but the time between steps will change to accelerate and deccelerate the motor. I don't know the typical range offhand, but with the PWM I've worked with (which is not very many and on small microcontrollers) the frequency range was pretty limited.

I guess if you have a large range on the PWM frequency, you would know how many pulses were output in a given time at a given frequency, and you could use timer interrupts to change the frequency at the right places to do acceleration etc.

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

More
16 Mar 2013 01:49 - 16 Mar 2013 01:58 #31463 by PCW
Replied by PCW on topic EMC2 running on Raspberry Pi?
mozmck: A DMA driven stepgen is not quite the same as a DMA driven PWM gen but seems possible (if tricky)

Imagine the current software stepgen that instead of writing a single GPIO port every base thread, writes say 1000 memory locations with pairs of bits in each memory word being step and dir, and does this every 1 ms servo thread.

This memory block is continously written to the GPIO pin at a 1 MHz rate, so it takes 1 ms to copy all memory to the GPIO pins (effectively playing out the pre-recorded rate data in memory) . Now by loading the next segment of 1000 memory locations every 1 ms Servo thread, we can generate any step rate we want (and we know exactly how many steps we have generated)

(I have glossed over the tricker thread/DMA timing/buffering aspects)
Last edit: 16 Mar 2013 01:58 by PCW.

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

More
16 Mar 2013 02:00 #31464 by mozmck
I guess I'm not sure I understand how a DMA driven PWM works. The PWM I've used before you would set the base frequency, and then you just vary the pulse width. Can you leave the pulse width static and vary the frequency easily and over a wide range with a DMA driven PWM?

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

More
16 Mar 2013 02:17 - 16 Mar 2013 02:21 #31467 by metachris

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: 16 Mar 2013 02:21 by metachris.

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

More
16 Mar 2013 02:19 - 16 Mar 2013 02:22 #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: 16 Mar 2013 02:22 by PCW.

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

Time to create page: 0.111 seconds
Powered by Kunena Forum