"slaving" two Props together
davejames
Posts: 4,047
In the discussions of Prop2, I read multiple comments wishing for more cogs.
Not knowing much about the Propeller in general, I ask the question: Can two (or more) Propellers be "slaved" together and run synchronously?
Might solve the perceived lack-of-cogs if this can be done.
Not knowing much about the Propeller in general, I ask the question: Can two (or more) Propellers be "slaved" together and run synchronously?
Might solve the perceived lack-of-cogs if this can be done.
Comments
The "bottom line" is that you can synchronize two Props, but it requires use of an external clock source and it's not as simple as you'd like.
using propforth, one may connect two props using power, ground, 2 i/o lines, clock, reset, and the EEPROM input (seven wires).
The Master prop boots from its EEPROM to propforth. The master then resets the "slave" and elumates clock for the slave, then emulates EEPROM for the slave. Each slave can have sub-slaves with no limit discovered. Each additional slave has a hardware costs of seven wires and three resistors (four wires if you are lazy and use the resistors as point to point connections).
The communications channel runs at full clock speed and continuously sends 96-bit packets. Users plops bytes into the I/O queue and they are sent over the serial channel, so it appears as the ordinary forth prompt.
The communications channel consumes one cog on the master and one cog on the slave. Also two I/O lines, send and receive; also the master uses one I/O line to send clock to the slave.
The user accesses the slave cogs with the same interface as in the master, with one-time set-up for the channel. To the users, it appears that seven more cogs and twenty eight pins have been added. There is no noticeable difference in the interactive user interface. Of course, the user must take care that application that need to happen FAST do not have to cross the inter-prop channel, but we have never encountered a problem with this yet. If we are lucky, we might create an application that is limited in this way before the prop2 comes out, but this is unlikely.
http://code.google.com/p/propforth/wiki/PropForth4SetupAndTest
search "High Speed Synchronous Serial channel"
If you don't like using forth (most consider forth to be cheating because its too easy ), the code for the high speed serial can be optimized to assembler and use in for example spin programs. But I don't know of anyone who has done this yet.
The instructions are a bit lacking since few people have tried them, PM me or open a thread for help. I will update the instructions as better descriptions come available.
My goal ultimately is to sync a single communication cog on several props in a ring, so that each prop has a snapshot (and bridge) to the others by updating a shared profile and mirroring it onto the others. I am however new to dealing with clock speed at this level, so I am uncertain what level of synchronicity this will require. For that matter, Im not all that clear on the difference in functionality of an internal vs external clock source, or a shared clock source vs discrete ones for each chip/cog/etc.
I avoid disagreing with people smarter than me, but think I must disgree here. Its actually MUCH easier using an appropriate configuration: When master prop send clock to the slave, both props are IDENTICALLY synchronized by nature of the hardware setup, for free. There may be other factors that I don't know about (my experience is limited) but we have not seen a dropped bit in the sync serial except during testing when we pulled the wire.
1) Master sends its current Counter value to a slave
2) Slave Sends the difference of it's counter value back to the Master (call it Counter Delta)
3) Master sends its current Counter value plus the Counter Delta back to a Slave.
4) At this point the slave Counter should match what the Master just sent in #3. If not, incremental adjustments are made to the Counter Delta until the values are locked.
5) Once locked, either the Master or the Slave (not both) reference the Counter Delta when counter sync operations are necessary.
Note: #1 to #4 could be a reiterative loop, since #1 and #3 could be the same code (Assuming that Delta counter on the Master starts out as Zero)
You could then have code running on either Prop that sends a future system-wide time to a cog on either Prop that the two cogs can, after adjusting for the local CNT, use in a WAITCNT. The two cogs will emerge from their WAITCNTs at the same time regardless of which Prop they're running in. Because the Props are running off the same external clock, they're in lockstep, completely deterministic.
Maybe those that know the Propeller intimately could devise, proove, and document a method that would make this effort easier (subjective) for other members?
Regards and thanks again for the technical insight,
DJ
You may or may not know that I've currently been working on getting two independent props ( on the same clock ) to work together synchronised.
Now, the problems that you come across is way before you even get to run your first instruction. because the fact of the matter is...
The program gets read off the i2C EEPROM using the internal RC clock, which is unfortunately, not very accurate, so what happens is...
Not only do both your props not execute the first instruction at different times, but they also have a different HUB-OP round robin placement, as Round Robin slot 0 on prop 1 could be Round Robin slot x on Prop 2
I've got some more free time next week over the weekend, so hope to get the sync working on every reset for my DuoGFX project.
All this is basically done.
A master - slave framework, in spin, done with very minimal components, shows how to set up a multipropeller network operating on the same clock frequency source,
The link shows 55 propeller DIP chips wired to eachother. 1 chip acts as a master with an eeprom, the other chips are programmed through the rx/tx lines PARALLEL.
The amount of time to program 100 props like this is the same as programming a single prop. Very fast.
The program and circuit attached show how to set up a communication network between all 55 props using only the TX and RX lines, (this requires order, or bad things happen on two lines with 55 props,)
Order is achieved by running a random number generator on each prop. It happens that each prop does indeed randomly generate a number the size of your variable.
http://forums.parallax.com/showthread.php?127983-55-Parallax-Propeller-s-Parallells-Processing-of-Permanent-Perturbations.
Where I said "(2 * calculated_difference & 0x7)" should read:
((calculated_difference >> 1) & 0x7).
The algorithm I outlined above is what I already use, assuming that both Props are running off the same crystal, it works great.
And as I said there is a possible error of 1 clock cycle.
Please we know you can fallow a simple algorithm (the great work you show on the forums proves this).
I just ran your scenario through the above code (that is only run on COG 0 of the secondary Prop [all other cogs are assigned relative to this], and is intended to find the cog synced with COG 0 on the main Prop), and your scenario gave COG 0 on Prop 0 equals COG 0 on Prop 1 (which is the situation that brings you of by 1 clock cycle [because Hub Windows are 2 Cycles long]), and since the other cogs are given relative to the value calculated by this routine, you end up with "COG + 1" of Prop 1 (which is COG 1, as this code is only run on COG 0 of Prop 1), being assigned as synced to COG 1 of Prop 0.
Also I corrected the two typos, above.