programming question / system clock
agfa
Posts: 295
Is there a way to time events, such as toggle an output at a given interval, while doing other "processes", instead of using the waitcnt command which, if i understand, pauses program flow?
More specifically I am trying to create output pulses (1 to 2 ms on then 20 ms off) to drive a continuous rotation servo (the servo on the boe bot) while toggling an LED to indicate a wheel encoder input.
I've attached my programming efforts. I'm not sure if I've nested the repeats correctly.· I'm sure the way i used the system clock wouldn't work but was hoping someone could suggest another way.
spin
782B
Comments
There already is an "object" that handles servos (up to 32 of them). Take a look at Servo32 in the Propeller Object Exchange. It will take care of the timing and pulse generation for you. There's another object called Servo-4 which is written entirely in Spin and has some additional features.
There are other tools for independent functionality. In particular, each cog has two identical counters that can generate output pulses, do timing, do analog to digital and digital to analog conversions, all pretty much independently from other code running in the cog. Download the application note (AN001) on the counters from the Propeller download page.
I knew·that it could be done with another cog, and I plan on trying that. I was trying to get familiar with spin and I was trying to get creative and get as much out of a single cog as I could.
Thanks again
I am not good at spin so there may be syntax errors, but hope this helps.
Cluso99-after a closer look, looks like basically the same thing i'm trying to do.
Attached is a sampe program which outputs the the serial using the FullDuplexSerial. It output shows what happens with wraparound.