Freq.Synth for a specific amount of ms or us
Jkane
Posts: 113
Hello,
I'm new to this, but I'm trying to use Freq.Synth to run for a specific amount of time. I have a logic analyzer attached to validate the length and frequency, the frequency is usually perfect, but I can't seem to get the duration correct, I've tried it many different ways, but nothing gives me expected or predictable results. I know this is simple code but it shows what I have tried.
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
Pin1 = 0
Frequency1 = 30_000_000
Freq.Synth("A",Pin1, Frequency1)
waitcnt(clkfreq/1000+cnt) 'wait for 1 millisecond
Freq.Synth("A",Pin1, 0)
Freq.Synth("A",Pin1, Frequency1)
waitcnt(clkfreq/10000+cnt) 'wait for 1 microsecond
Freq.Synth("A",Pin1, 0)
I have also tried
ms := cnt + (1 *(clkfreq/1_000)) ' 1 millisecond
repeat until (cnt >= ms)
Freq.Synth("A",Pin1, Frequency1) 'Synth({Counter"A" or Counter"B"},Pin, Freq)
I do get times, but they make little sense.
I also noticed that cnt shows a negative number, which seems strange
Cnt counter is: 1588437453
ms delta is: 1588716333
Clkfreq counter is: 80000000
===========================================
Cnt counter is: -693574839
ms delta is: -693298423
Clkfreq counter is: 80000000
anyway, Freq.Synth does exactly what i want, but I just need an accurate way to set duration.
Thanks
Jeff
===========================================
I'm new to this, but I'm trying to use Freq.Synth to run for a specific amount of time. I have a logic analyzer attached to validate the length and frequency, the frequency is usually perfect, but I can't seem to get the duration correct, I've tried it many different ways, but nothing gives me expected or predictable results. I know this is simple code but it shows what I have tried.
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
Pin1 = 0
Frequency1 = 30_000_000
Freq.Synth("A",Pin1, Frequency1)
waitcnt(clkfreq/1000+cnt) 'wait for 1 millisecond
Freq.Synth("A",Pin1, 0)
Freq.Synth("A",Pin1, Frequency1)
waitcnt(clkfreq/10000+cnt) 'wait for 1 microsecond
Freq.Synth("A",Pin1, 0)
I have also tried
ms := cnt + (1 *(clkfreq/1_000)) ' 1 millisecond
repeat until (cnt >= ms)
Freq.Synth("A",Pin1, Frequency1) 'Synth({Counter"A" or Counter"B"},Pin, Freq)
I do get times, but they make little sense.
I also noticed that cnt shows a negative number, which seems strange
Cnt counter is: 1588437453
ms delta is: 1588716333
Clkfreq counter is: 80000000
===========================================
Cnt counter is: -693574839
ms delta is: -693298423
Clkfreq counter is: 80000000
anyway, Freq.Synth does exactly what i want, but I just need an accurate way to set duration.
Thanks
Jeff
===========================================
Comments
This blob of code should output your frequency for ~10ms, then turn it off for ~90ms
BTW, this is a method I have in my standard programming template that does what you want (kill the output with frequncy input of 0). It doesn't work for all ranges of the counter, though.
regards
Jeff
Perhaps a better explaination, I'm interfacing to a printer head, the IO lines are
1 - 40Mhz clock (Oscillator MAX045, always on)
2 - 30Mhz clock (Oscillator MAX045T with enable/disable pin)
3 - data line 1 30Mhz (variable bits from a bit-buffer about 640 bits long)
4 - data line 2 30Mhz same as above item 3
5 - data line 3 30Mhz same as above item 3
6 - data line 4 30Mhz same as above item 3
7 - dataline 5,6,7,8 inverser of dataline 1-4
8 - termination data signal 1 1us
9 - termination data signal 2 1 us signal 8 and 9 are on different pins
and two serial lines tx and rx (cmd data to head - from bit buffer)
so the things that change are 3-7 and 1,2,8 and 9 can be hardcoded as long as i can turn them off and on when required.
The propeller will be responsible for running the head, the BS2 will run all the diagnostic switches and sensors (flowmeters, current, pressure and LCD displays, so I'll connect the BS2 and the Propeller together
and then the prop demo or rasberry pi will be the HCI (Human Computer Interface) - keyboard, mice, display) (which I think will be connected to both the prop and the BS2
anyway, currently I am just working on the Prop to head, the code you gave me works, I was just curious what that code would look like in prop assembler.
regards
Jeff
PUB GenStart(pin, Fx, Nx) | fa, pb
It uses two counters to accomplish that, and it is accurate even up to the maximum frequency and short duration. The counter output could be made differential so that you get both the true and inverted outputs.
I don't understand how this print head works, to need such high frequencies on multiple lines.