- Posts: 5
- Thank you received: 0
EMC2 running on Raspberry Pi?
13 years 7 months ago #31458
by metachris
Replied by metachris on topic EMC2 running on Raspberry Pi?
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 .
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.
13 years 7 months ago #31460
by mozmck
Replied by mozmck on topic EMC2 running on Raspberry Pi?
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.
13 years 7 months ago #31461
by metachris
Replied by metachris on topic EMC2 running on Raspberry Pi?
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.
13 years 7 months ago #31462
by mozmck
Replied by mozmck on topic EMC2 running on Raspberry Pi?
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.
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.
13 years 7 months ago - 13 years 7 months ago #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)
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: 13 years 7 months ago by PCW.
Please Log in or Create an account to join the conversation.
13 years 7 months ago #31464
by mozmck
Replied by mozmck on topic EMC2 running on Raspberry Pi?
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.
Time to create page: 0.187 seconds