Can propeller accurately generate nanosecond duration pulses?
CuriousOne
Posts: 931
I need to output pulses with high frequency, 2-4mhz. I've tried to do it on 12F1840 @ 32mhz. Operations is - high pin, low pin, loop. The high pin takes one tick, low pin takes 1 tick also, but loop takes 6 ticks, so output pulses have large "gaps" between them. If I'll try to do same on propeller, will I face same problem?
Comments
You mentioned "pulses." Does that mean something other than 50% duty cycle?
-Phil
"nano second pulses" it says in the title.
"2-4mhz" it says in the question.
Very different things.
2MHz is a 500ns period. 4MHz is a 250ns period.
Making a wild guess at a 50% duty cycle requirement that's 250/125ns to 125/62.5ns up and down time.
That is one or two orders of magnitude away from 1ns.
So, what is it you need? A 1ns pulse at 4Mhz or perhaps a 1ns pulse just once or something less demanding?
if you want a 50% duty cycle then the loop section of code will cause a gap. You could compensate by adding a "nop" not an operation.
On an 80MHz Prop the above code should generate a 5MHz pulse.
As Phil mentioned, using counter you should be able to generate faster pulses.
You need to give numbers on Pulse granularity, and Frequency Granularity, and what jitter can be tolerated, and how often - also does 50% duty cycle matter
The NCO (adder) mode in Prop, can generate 2.50000MHz and 5.00000MHz that are jitter free & stand alone.
As #2 says, for other values there is some jitter.
The Prop can only ever place edges every 12.5ns, but the Adder cannot do a simple "divide by" non binary values so it gets close, but every now and then adds an extra 12.5ns so the average is ok.
This appears as a phase step ( or an edge delay if you prefer)
The 'now and then' varies with adder value relative to 2^32.
Even Whole integers can get infrequent jitter some seconds apart.
eg /14 is actually going to be
2^32/(round(2^32/14)) = /14.0000000130385161
ie mostly (14*12.5ns), and quite rarely (15*12.5ns)
Conversely, /14.5 will alternate 14*12.5ns, &15*12.5ns almost exactly 50:50
The PLL mentioned in #2 will filter better above some PLL filter frequency, so that /14.5 example will give
181.25ns +/- some small jitter ( sub ns?)
This code should toggle the pin every 8 ticks giving 10 MHz.
Sandy
I didn't think of "xor". Excellent.
However, the XOR loop is smaller in code, and easier to scale, and can add 4 cycle NOPs for 3.3333 and 2.5MHz as the next SW steps.
2 APIN 5 MHZ
To change that to 100MHZ (pin has already been specified)
100 MHZ
or 100 HZ or 5 KHZ etc
The counter is set to NCO mode but you can type PLL and change it to that mode and play with that too using <n> PLLDIV to set the divider.
I'm building multi-phase power converter, and while length of pulse for 2mhz is 500ns, there are several phases, and "distance" (so called "dead time") between them (when one pin goes low and next pin is going high" should be adjustable and kept with good precision, in 1-10ns range. Can prop do that?
1 to 10ns is a big range, which do you want? For 1ns resolution you need 1GHz vs a much more achievable 100MHz for 10ns resolution. So say 10ns then and the Prop can be run at 100MHz within reason so it can be adjustable in the 10ns range. However if you are building a multi-phase power converter you almost want this stuff made in hardware or have a CPU with this special timer, or FPGA even, rather than rely upon software and glitches, even just starting up.
-Phil
Your choices are either a digital delay line, or a chip with high resolution PWM hardware that includes deadband control, or a maybe CPLD.
I think TI have low cost DSPs with 1ns and sub 1ns PWM edge control.
That scheme copes a little better with dynamic loads, which can affect how long recovery takes.
If 10nS steps are fine, you can do that in code with counters with some restrictions. Using counters in NCO mode it's easy to make a pulse of N clock cycles with a single write to the counter. You can also use a counter to have a pin change state N clock cycles after writing to the counter. Combining these two inside a loop, you can make sophisticated PWM waveforms.
In one of my devices with the Propeller, I use the counters to generate two PWM waveforms at 48KHz with the two PWM pulses centered on each other. The code then synchronously sampled two ADC's connected to current shunts in the center of each PWM pulse so that the output current ripple would alias to DC with a near zero offset.
Still, I've yet to make PWM code that controls the dead-time between two FETs. I like to avoid letting software bugs fry hardware if I can.
Marty
-Phil
If you need 1 ns resolution phased PWM w/dead-time, the dsPIC GS models can do that (in hardware), and are available in a DIP, as well as being more friendly to program than the TI chips.