I am looking at using an industrial controller I built with a FEZ Mini as the brain to drive stepper motor actuators. I tried using a simple on/off action of a digital output to as the pulse input to the stepper driver that I am using, but controlling the pulse speed was difficult, as I need a speed less than a Thread.Sleep(1) interval, but more than no sleeping. I could use the PWM for a more accurate output, but I do not see how to control the number of steps output, and I also want to do some acceleration if possible. Does anyone know of a better way to accomplish a pulse train output? Is this possible with this controller? I have used a CUBLOC controller in the past that has a PULSEOUT command that allowed you to output stepper pulses with acceleration and deceleration. Is something like this available, or are there plans to make it so?
Thanks in advance,
For an accurate pulse train look at using OutputCompare. You can control the number and width of the pulses.
I got the OutputCompare to work to a point. One problem I am running into is the limited size of the buffer. I need something like 25000 pulses to do what I need, and the buffer does not accept more than 1000 or so. I can repeat the command, but that leads to jumpy movement. Any ideas?
Not enough memory on the smaller boards for 25000 pulses.
I do not know stepper motors, but I am surprised that a pulse train would be 25000 pulses long.
Rather than sleeping in managed code, with a Sleep() call, you could keep keep reading the system clock and waiting for the required time of a pulse to pass. A system clock tick is less than a millisecond.
There is a problem with shaping pulses in managed code. Every once in a while, garbage collection can automatically happen, and this would introduce a few milliseconds delay.
The only reliable way of implementing a variable pulse train is with RLP. RLP can be near real-time.
I have never worked with RLP… I was hoping for a simpler solution. Perhaps I will look at a third party driver or different processor.
This is one of those things NETMF is simply not good at.
Have a look at this painful post on realtime timing… http://www.tinyclr.com/forum/2/1835/#/1/
You can get about a 10 kHz pulse stream in a tight loop - but not much more - and the garbage collector will probably mess with your pattern.
You can use SPI and carefully construct a bit stream. It will “clock out” at a constant rate - but crafting the right bit sequence is a pain and you are limited to the two SPI ports.
RLP is an option - but not easy. Wouter is the man on the forum that seem to know what he’s doing when it comes to outputting constant rate streams. See http://www.tinyclr.com/forum/2/3924/
My vote would go to suggest to GHI to introduce a new method in library:
PulseStream(Cpu.Pin pin, byte bitpattern, int rateHz) or something.
[quote]My vote would go to suggest to GHI to introduce a new method in library:
PulseStream(Cpu.Pin pin, byte bitpattern, int rateHz) or something.[/quote]
How is this different than OutputCompate we already have?
I would like to see something like this command in the CUBLOC module:
StepAccel (channel, port, freqBase, freqTop, FreqAccel, qty)
channel : StepPulse channel (StepAccel supports only 0)
port : Output port
freqBase : The starting stepper frequency (Up to FreqTop)
freqTop : The frequency after acceleration is finished (Up to 3.3KHz)
freqAccel : The acceleration in steps per second
qty : # of pulses to output (up to 2147483647)
This command outputs a set number of pulses at a set frequency (up to
3.3kHz) with acceleration. The StepAccel command supports only 1
channel, so 0 must be used for the channel parameter.
You can use any of the available I/O ports on the CUBLOC. When the
StepAccel command is executed, the specified port’s I/O mode is
automatically set to output. Even after the command has finished
generating pulses, the port’s I/O mode remains output.
The output frequency can be set from 1hz to 3.3KHz.
This command will run in the background independently, so system
resources can be used for other tasks.
Any plans in the works to do anything like this?
If this can be proven in RLP then I think I can convince GHI of adding it built-in. It has to be generic so anyone can benefit from it, not made for one specific use.
You can also look at L6470H by ST Micro. It contains a motion engine that ramps up/down etc. You specify Max speed, ramp up speed, ramp down speed, number of steps and direction. Then it tells you when it’s done…
Outputcompare is very close. All it needs is a count parameter instead of repeat. What the stepper guys are after is something that will output a fixed number of pulses at a constant rate.
The shape of the pulse isn’t very important so something like PulseOut(int period, int count) should do the trick. Acceleration is not too difficult to add.
If there are multiple axes it becomes a differt story.
I think RLP is best for this. A nice one to give it a try with.