How do I syncronize two or more Cog´s
ciphernet
Posts: 24
I have the need for synchronizing more than two Cog´s, I use for PWM.
Is there any "easy" (hopefully) way to do this?
Set a flag or...?
Anybody got a clever solution to this challenge.. ???
Thanks in advance...
Is there any "easy" (hopefully) way to do this?
Set a flag or...?
Anybody got a clever solution to this challenge.. ???
Thanks in advance...
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
It's not all that hard to count the number of grains of sand on the beach. The hardest part is making a start - after that it just takes time.·· Mirror - 15 May 2007
and then use COG-RAM countervariables to switch the logic level of the PWM-PINs
basic principle
increment a central countervariable by every loop
compare value of central countervariable with another variable containing a value for the on/offtime of the PWM-signal
if it matches change logical-level
now it depends on the frequencies that you nedd
for lower frequencies it might be possible in spin
for higher frequencies you will need assembler
is it nescessary to synchonize up every nanosecond ?
write something very CONCRETE about your application
greetings
Stefan
The thing is that I need to control a RGB backlight for a LCD display and if the timing is off on one or more of the RGB LED chains, there will be visual flicker and also the background color can change, because of the different resets, if the three PWM´s are not exactly timed.
I thought about the idea regarding using·the global counter, but that will not keep the three channels synchronized in itself, since all three cog´s can not sync up to a common timing reference, because the propeller does not have a Interrupt like the SX chips that I use for other projects.
I need some sort of "global" reset of PWM ASM code running·in the three Cog´s.
Since the Propeller does not allow all three Cog´s to read a global flag at the same time, I have a bit of a problem.
What if I set a pin as an output and run a Cog that keep track of the global counter and then set the pin high at some pre-determined point (right after maximum PWM time) and then let the three PWM cog´s detect that state-change...?? Would that be a good idea?? Afterall all three PWM cog´s can read the port at the same time...
Am I on the right track?
Jan
I could of course also use one "primary" PWM Cog that could set a port pin high after each cycle and then two·"secondary" PWM Cog´s that are timing-slaved to the "primary" Cog.
The two·"secondary" Cog´s·simply wait for a state-change after each PWM cycle and then I could save one Cog for other purposes.
Does this sound okey??
Seems pretty straight-forward but is it 100% sure that two or more Cog´s can access·the same·port pin at the same time without any problems or glitches?
Jan
I use the PCA9531 for driving the rgb leds.
Here is a photo of my light board.
I use a cog for 8 pwm lines for switching spotlights from 0 - 100 % and i use 2X PCA9531 for my rgb mix.
If you hoock up two of those to the same address they a 100% syncrone.
Anubisbot
The easiest form·of syncronization is·to choose some CNT value·that will occur in the near future but far enough out that you know all cogs will be able to get to the "starting block" in time. Each performs a WAITCNT on that value, and when that value occurs all cogs that are in a WAITCNT start executing thier following instructions in perfect synchronization, and if you·do time-symmetric programming they will remain in synchronization for as long as they run.·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Post Edited (Paul Baker (Parallax)) : 6/8/2007 4:15:26 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
*.*
Ibsen
" It's nice to be important, but
·· more important to be nice... "
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Thanks very much for your reply. That´s what I needed. Great!
what is it where you are working on..
LCD backlights (high-brightness for custom applications) with tunable color temperature control