Shop OBEX P1 Docs P2 Docs Learn Events
Convert From Multiple Stamps to A Single Prop — Parallax Forums

Convert From Multiple Stamps to A Single Prop

John BurrowJohn Burrow Posts: 27
edited 2010-01-07 00:09 in Propeller 1
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

Comments

  • mparkmpark Posts: 1,305
    edited 2010-01-06 21:11
    What's a slot?
  • JonnyMacJonnyMac Posts: 9,208
    edited 2010-01-06 21:16
    John,

    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.
  • heaterheater Posts: 3,370
    edited 2010-01-06 21:24
    Not sure how to size your problem as I have no idea about STAMPS and Slots.
    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.
  • JonnyMacJonnyMac Posts: 9,208
    edited 2010-01-06 23:29
    @Heater: a slot in the BS2p series is just a an EEPROM bank switching mechanism to extend the program space without breaking the 2K code limit built into the interpreter.
  • Mike GreenMike Green Posts: 23,101
    edited 2010-01-06 23:50
    @John - You may still want to use multiple processors, partly because of memory space. If you're using a servo controller, you could use the Propeller-based servo controller and eventually add some other functionality right in the servo controller. As hardware, this can work well since the 16 servo control pins are actually bidirectional and have 5V to 3.3V level bidirectional level translators built-in. You'd have to modify the firmware, but it's all open-source and mostly written in Spin. I think the built-in firmware only uses 3 or 4 cogs and I can't imagine it using a lot of the memory space. It's not that complicated.

    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.
  • StefanL38StefanL38 Posts: 2,292
    edited 2010-01-06 23:54
    If I count right you are using 19 slots each 2kB right?

    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
  • MagIO2MagIO2 Posts: 2,243
    edited 2010-01-07 00:09
    From a short glance the closest I could get to SLOT is the 8 x 2k EEPROM that's mentioned in the specs of the BS2. So a slot is only storage area for programs and data ?

    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.
Sign In or Register to comment.