Convert From Multiple Stamps to A Single Prop
John Burrow
Posts: 27
This is a really long post, so I apologise in advance.
Before I jump in at the deep end, I thought I'd·ask for experience, comments, etc.
I have 4 BS2Ps, and various other devices, supporting my model railway. I would like to replace the 4 BS2Ps with a Prop.
The reason for this is that I have gone as far as I can with 'single thread' processing. The next step is to 'watch' the trains and at the same time send out commands (Stop, Start, Slow, Fast, Change Turnouts, Change Signals, etc.).·Single threading with·Stamps, sooner or later a message·will get lost, and that could become very expensive.
Heres what I currently have
Stamp 1 - "WebServer" : Monitors·PINK for input commands. Formats commands and sends them to Stamp 3. Only 1 Slot is in use here
Stamp 2 - "Touch Screen" : Monitors touch screen for input commands.·Validates and formats commands and sends·to Stamps 3 and/or 4. (Touch screen runs WinCe, and has a simple serial interface, so that's not really a concern). All 8 slots are full·with·code. Very little DATA
Stamp 3 - "Automation" : Accepts commands from Stamps 1 and 2. Does all the heavy lifting and sends commands to LocoBuffer (train control network) and to Stamp 4. 7 of 8 slots are full. Slots 0 to 4 are mostly code. Slot 5 is 50% code, 50% data. Slot·6 is all·DATA. Slot·7 is·unused
Stamp 4 - "Slave" : Accepts commands from Stamps 2 and 3.·Sends connads to TextToSpeech, MusicPlayer, SpeakerSwitcher and ServoController.· 3 Slots used, mostly code
I intend to use PropBasic, and then maybe switch to PASM.
I understand there 32K bytes of non-executable shared storage (i.e. DATA) in a Prop, right?
Can I get all this code into one Propellor? Is there some sort of approximate conversion factor, like 1 Slot = 1 Cog?
I'll go and read the manual now...
Curiously yours, John Burrow
San Diego
Before I jump in at the deep end, I thought I'd·ask for experience, comments, etc.
I have 4 BS2Ps, and various other devices, supporting my model railway. I would like to replace the 4 BS2Ps with a Prop.
The reason for this is that I have gone as far as I can with 'single thread' processing. The next step is to 'watch' the trains and at the same time send out commands (Stop, Start, Slow, Fast, Change Turnouts, Change Signals, etc.).·Single threading with·Stamps, sooner or later a message·will get lost, and that could become very expensive.
Heres what I currently have
Stamp 1 - "WebServer" : Monitors·PINK for input commands. Formats commands and sends them to Stamp 3. Only 1 Slot is in use here
Stamp 2 - "Touch Screen" : Monitors touch screen for input commands.·Validates and formats commands and sends·to Stamps 3 and/or 4. (Touch screen runs WinCe, and has a simple serial interface, so that's not really a concern). All 8 slots are full·with·code. Very little DATA
Stamp 3 - "Automation" : Accepts commands from Stamps 1 and 2. Does all the heavy lifting and sends commands to LocoBuffer (train control network) and to Stamp 4. 7 of 8 slots are full. Slots 0 to 4 are mostly code. Slot 5 is 50% code, 50% data. Slot·6 is all·DATA. Slot·7 is·unused
Stamp 4 - "Slave" : Accepts commands from Stamps 2 and 3.·Sends connads to TextToSpeech, MusicPlayer, SpeakerSwitcher and ServoController.· 3 Slots used, mostly code
I intend to use PropBasic, and then maybe switch to PASM.
I understand there 32K bytes of non-executable shared storage (i.e. DATA) in a Prop, right?
Can I get all this code into one Propellor? Is there some sort of approximate conversion factor, like 1 Slot = 1 Cog?
I'll go and read the manual now...
Curiously yours, John Burrow
San Diego
Comments
I think you could port your project to the Propeller, but I would use Spin. PropBASIC is very new and multi-cog usage is not as easy now as it ultimately will be. Using Spin will let you take advantage of ready-to-run objects without having to convert them.
It will probably help to know that the 32k RAM on the Prop that is accessible by all the COGs is not "non-executable".
Whist it is true that the COGs cannot execute their native instructions from the HUB RAM directly the Spin language implementation gets around this by being interpreted. An interpreter running on a COG reads and executes byte codes from HUB RAM. These byte codes are quite space efficient.
So it is possible to have pretty much 32K of Spin byte codes running from HUB. Less of course depending on how much data you have there as well.
There can be from 1 to 8 interpreters running Spin code simultaneously. Or some running Spin and some running native PASM, for example device drivers.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
For me, the past is not over yet.
You might be able to use two Propeller Servo Controllers since that hardware platform looks like a good match for what you want to do and, at $40 each, is a cheap way to upgrade your system.
So this would be 38kB of BS2-RAM.
Know to make an raw estimation about RAM-usage in the propellEr - can you code a loop with two if conditions if true set variable to 100
and post this BS2-code and how much BS-RAM that does use.
Then we can port this testcode in SPIN and check how much RAM this will use in the propeller.
For huge data you could use an SD-card or another EEPROM or a bigger EEPROM from where you load the data
PropBasic gets compiled and can only use COG-RAM (2kB per cog)
In SPIN you have 32kB of HUB-RAM which is shared by all cogs in any usage-ratio
best regards
Stefan
Ok ... assuming that I'm right that means you have 16kB EEPROM per BS2 and only little RAM. The Propeller has 32kB of HUB-RAM, which usually stores the whole program AND data. Additionally each COG has it's own storage area of 512 longs ( equivalent to 2kB). Again it holds program AND data. But a COG has free access to HUB-RAM as well.
During startup 32kB are loaded from EEPROM to HUB-RAM. Usually the program starts to initialize all COGs. If a COG runs some SPIN code, the SPIN interpreter is loaded from ROM. If a COG runs some PASM (Propeller assembler code) it's usually loaded from HUB-RAM, thus it's part of the program that has to fit into the 32kB. But it's also possible to load PASM-code from upper part of EEPROM or from SD card.
You have 4 BS2 running, which makes max. 64kB of program/data. Is the program stored in the SLOTs compiled to bytecode and that's interpreted or is it there in plain text? Maybe it's possible to find a rough estimate on whether all your code - translated to SPIN - would fit into a propeller if you compare a BS2 program size with the size of the same program written in SPIN. But I guess that would not take into account that some things simply will look different when you implement for a propeller.
For example all your "send commands" from BS2 1 to 3 or from BS2 2 to 3/4 will look different. For all your serial communication you need the same code running on BS2 1 and BS2 3 ... On the propeller you only need one object running in one COG that can handle 4 serial interfaces.
My feeling says that one propeller should be enough to do what you currently do, because you already exported some tasks to other hardware (PINK, touchscreen, text to speech?, sound?). How many I/O pins do you use in total?
LocoBuffer ... what's that? Train control network? Is it DCC based? I plan to reprogram my DCC-booster using the propeller instead of an AVR.