To date, I have used time delays to to pace my QRSS and OPERA Beacons, both running on same Propeller Micro Processor (using only one COG). The timing was typically just a 6 minute delay after the last transmitted data.
Peter and some other Grabber owners can Stack grabs to provide even more sensitive reports. A similar technique is used by Astronomers to photograph very faint stars. The typical QRSS Grabber is programmed to capture a frame each 10 minutes. To play the game, QRSS Beacons need to sync to a 10 minute interval, it does not matter where in time, but repeat in sync with itself.
So, this requirement provided me an opportunity to learn more Propeller Spin Programming. I tried several approaches to provide a Real Time Clock or Sync Timer Function, but nothing I programmed was working very well. With more reading, learning, and experimenting, I decided to try to build a "Epoch" counter in a second COG.
It was so easy I could not believe it. To start a new COG, the following line is all that is needed within the first (default) COG:
cognew(procedureName, @someStackSpace)
The "cognew" statement specifies the new COG's default starting procedure, in the same way as the default GOG (0) always starts with the first listed procedure in the Spin file.
The new COG has access to all of the routines, variable, and constants listed in Spin file. In my case, I need a "delay(1000)" routine to update the Epoch counter within the new COG.
PUB UpdateEpoch ' Runs In its own COG
repeat
delay(1000)
Epoch++
Here is the First COG Code for "Main" that starts and uses the Epoch for Sync:
VAR
Long RFFreq
Long Epoch, EpochStack[16]
PUB Main | Sync
doInitialize
cognew(UpdateEpoch, @EpochStack)
Sync := 60 * 10 '10 minutes
Epoch := 0
repeat
RFFreq := Qrss_Tx_30m
doQrssBeacon
noTone
delay(10000)
RFFreq := Opera_Tx_30m
doOperaBeacon
noTone
delay(10000)
' Delay for Sync
repeat while Epoch // Sync
delay(100)
Note: The "//" operator is modulus function.
The new and much improved (published) delay routine is:
PUB delay(ms) | t
t := cnt - 1088 ' 1088 is Published Time for Overhead at 80mHz
repeat ms
waitcnt(t += MS_001)
Now, my Beacons should now show up on the Grabbers in 10 minute Sync.
I am enjoying Programming the Propeller !
--
No comments:
Post a Comment