Tim, the way I am looking to do this is to use the counters in assembly. The base frequency of the counter would be my carrier frequency (approx 8khz) and I would constantly change the duty cycle via a loop in assembly which is determined by both the running motor frequency and the desired duty cycle for each iteration.
Okay, have spent the last few days 'plunging' into assembly ... then discovered, you can't really learn assembly unless you first learn the structore of the CPU.
I think I have it! When you load an assembly routine (via SPIN), you actually load COG-RAM. 512 longs minus the 16 longs for the special registers. (making progress)
Now, on the timers ... Have played with the examples in the 'lab' chp 7. But I'm not quite sure how to generate the carrier (8khz in your case)? Freqa gets added to phsa each clock tick (in duty mode) and then the 'carry' bit actually output to your pin.
So, would you use the 'duty' mode, or the NCO mode with some fancy assembly?
Tim, the counters are IMO the most poorly documented component on the prop chip. That is a relative "poorly" as I find the manual very good but it took me some time to grasp how each function performed.
While the manual give good detailed information more examples are needed and the few I saw for the duty cycle, while they worked as I expected, the waveforms shown would have kept me from using them.
Anyway, off my soap box, the counters are great in design and certainly can do a ton of heavy lifting allowing your program to go off and do whatever it needs to do.
You will be pleased that you took the time to learn assembly. Right now, for the most part, I only use SPIN to launch assembly and handle basic serial communications. I have not spent a bunch of time with the TV stuff but others sure have.
NOTE: I am currently using only 3 counters to create an ADC for 154 individual analog inputs (scanned at high speed) for a unique method to calibrate 3 positions and speed of movement on 154 keys for a pipe organ to MIDI conversion. All in pasm.
I needed to detect OFF, 1st touch (approx 1/3 travel) and 2nd touch (approx 3/4 travel) and the rate at which they changed so as to give me the ability to play a piano via the organ console and have it be velocity sensitive via MIDI.
To be able to let the counters capture each key position while I was processing the previous key made for great and true multitasking.
Tim, the counters are IMO the most poorly documented component on the prop chip. That is a relative "poorly" as I find the manual very good but it took me some time to grasp how each function performed.
While the manual give good detailed information more examples are needed and the few I saw for the duty cycle, while they worked as I expected, the waveforms shown would have kept me from using them.
Anyway, off my soap box, the counters are great in design and certainly can do a ton of heavy lifting allowing your program to go off and do whatever it needs to do.
You will be pleased that you took the time to learn assembly. Right now, for the most part, I only use SPIN to launch assembly and handle basic serial communications. I have not spent a bunch of time with the TV stuff but others sure have.
True, so far I've discovered quite a few things I was unware of ... learning the structure of the cpu has really helped! I've just added a buzzer to my 7-seg-led driver, using the timers. What a big help!
Thanks for encouraging me to take the 'plunge' ... alot of studying ahead. Just finished reading the 'FullDuplexSerial' assembly section and figured out the 'jumret' instruction. That had my head spinning for a little while.
Tim my intention was to use DUTY Differential mode.
Set the base frequency you want to use sweep the value in FRQA to generate the changing pattern of duty cycle required.
That's most confusing? Here's a cut from the education lab page 130
How DUTY Mode Works
Each time FRQ gets added to PHS, the counter modules phase adder
(that adds FRQ to PHS with every clock tick) either sets or clears a carry flag.
I wired it up and ran a test program, and it generates pulses ... but they are brief! This is due to the 'carry' bit of the timer. Since it's either set, or cleared on every clock tick! I can't quite wrap my mind around your intended use of this timer mode?
Tim, trust your judgement! It has been some time since I tried this and using Gear, I would have sworn the pattern was exactly like we would want.
IIRC, via spin I slowly changed the value for duty and sure enough the pulse duty changed. Again I am positive that I used the DUTY differential mode but don't bet your life on that.
As I was testing for this specific pattern I would think my results would be correct and the only thing I can think of is if I inadvertently set up the wrong mode. Doubt it but I have been know to make the occasional mistake.
Comments
Okay, have spent the last few days 'plunging' into assembly ... then discovered, you can't really learn assembly unless you first learn the structore of the CPU.
I think I have it! When you load an assembly routine (via SPIN), you actually load COG-RAM. 512 longs minus the 16 longs for the special registers. (making progress)
Now, on the timers ... Have played with the examples in the 'lab' chp 7. But I'm not quite sure how to generate the carrier (8khz in your case)? Freqa gets added to phsa each clock tick (in duty mode) and then the 'carry' bit actually output to your pin.
So, would you use the 'duty' mode, or the NCO mode with some fancy assembly?
... Tim
Set the base frequency you want to use sweep the value in FRQA to generate the changing pattern of duty cycle required.
That made the most sense to me but like most programming there are many ways to do things.
While the manual give good detailed information more examples are needed and the few I saw for the duty cycle, while they worked as I expected, the waveforms shown would have kept me from using them.
Anyway, off my soap box, the counters are great in design and certainly can do a ton of heavy lifting allowing your program to go off and do whatever it needs to do.
You will be pleased that you took the time to learn assembly. Right now, for the most part, I only use SPIN to launch assembly and handle basic serial communications. I have not spent a bunch of time with the TV stuff but others sure have.
NOTE: I am currently using only 3 counters to create an ADC for 154 individual analog inputs (scanned at high speed) for a unique method to calibrate 3 positions and speed of movement on 154 keys for a pipe organ to MIDI conversion. All in pasm.
I needed to detect OFF, 1st touch (approx 1/3 travel) and 2nd touch (approx 3/4 travel) and the rate at which they changed so as to give me the ability to play a piano via the organ console and have it be velocity sensitive via MIDI.
To be able to let the counters capture each key position while I was processing the previous key made for great and true multitasking.
True, so far I've discovered quite a few things I was unware of ... learning the structure of the cpu has really helped! I've just added a buzzer to my 7-seg-led driver, using the timers. What a big help!
Thanks for encouraging me to take the 'plunge' ... alot of studying ahead. Just finished reading the 'FullDuplexSerial' assembly section and figured out the 'jumret' instruction. That had my head spinning for a little while.
... Tim
I cannot tell you the number of times I placed the return label in a routine and left off the 2nd
"ret"
MySubAssemplyRoutine
MySubAssemplyRoutine_ret
Does not work when you forget the 2nd ret.
MySubAssemplyRoutine_ret ret
That's most confusing? Here's a cut from the education lab page 130
How DUTY Mode Works
Each time FRQ gets added to PHS, the counter modules phase adder
(that adds FRQ to PHS with every clock tick) either sets or clears a carry flag.
I wired it up and ran a test program, and it generates pulses ... but they are brief! This is due to the 'carry' bit of the timer. Since it's either set, or cleared on every clock tick! I can't quite wrap my mind around your intended use of this timer mode?
... Tim
IIRC, via spin I slowly changed the value for duty and sure enough the pulse duty changed. Again I am positive that I used the DUTY differential mode but don't bet your life on that.
As I was testing for this specific pattern I would think my results would be correct and the only thing I can think of is if I inadvertently set up the wrong mode. Doubt it but I have been know to make the occasional mistake.