Shop OBEX P1 Docs P2 Docs Learn Events
A Propeller based "Basic Stamp" emulator. Any interest in this ? [CODE UPDATED — Parallax Forums

A Propeller based "Basic Stamp" emulator. Any interest in this ? [CODE UPDATED

BeanBean Posts: 8,129
edited 2009-08-11 02:02 in Propeller 1
I've been toying around with making a Propeller based basic stamp emulator.

My initial test show that the speed would be about 1,000 instructions per second, compared to a "real" BS2 which runs at about 4,000 instructions per second. This is because the emulator is written in spin. I don't think there would be enough code space to do it in assembly without use LMM. But that would be a MUCH bigger project.

The saving grace is that you can have multiple BS2 programs running in parallel.

Also, it could have a built-in debug terminal with NTSC output and a PS/2 keyboard input. These would communicate with serial to the running BS2 programs. Also it would use the existing Basic Stamp Editor to get the PBasic code into it.

Anyway, I'm just getting started with this, and was wondering if there is any interest in it. Anyone a BS2 user and a Propeller user ?

I've only just begun, but hopefulling in a week or two I'll post some working code.



[noparse][[/noparse]EDIT] I have posted the code so far. It's not much right now, but you can see the basic framework. Any comments or questions are welcomed.

[noparse][[/noparse]EDIT·Apr 3, 2009] Posted updated code that allows the "Basic stamp IDE" to download the program into the propeller.

Bean.
·

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There is a fine line between arrogance and confidence. Make sure you don't cross it...



Post Edited (Bean (Hitt Consulting)) : 4/3/2009 6:15:26 PM GMT
«1

Comments

  • Cluso99Cluso99 Posts: 18,069
    edited 2009-03-23 14:32
    I cannot comment as I haven't used the BS. However, you might try posting on the BS Forum.

    Did you see the webinar (Chips section) - its 128MB and over an hour. Anyway, one of the guys asking questions said his students were playing with the propeller because it was easier. Another asked if Parallax were going to produce a xxxx version like one of the BS boards. To me, it seemed like a lot of young students are starting to progress to the propeller. Therefore, I think it would be a good transition for the students who already know the BS.

    Just my thoughts.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps: TriBladeProp, SixBladeProp, website (Multiple propeller pcbs)
    · Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
    · Prop Tools under Development or Completed (Index)
    · Emulators: Micros eg Altair, and Terminals eg VT100 (Index)
    · Search the Propeller forums (via Google)
    My cruising website is: ·www.bluemagic.biz·· MultiBladeProp is: www.bluemagic.biz/cluso.htm
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2009-03-23 14:51
    I'm another who is just starting to look at BASIC STAMP,
    (I just couldn't swallow the price when I started with the Propeller.)
    but it does look like a perfect way to build a bridge for BS users into the Propeller.

    I'm a little worried that we drag too many BS users over and Parallax may have to
    find another way to stay in business. (Like release of PropellerII)
    Based on price, there's a lot more profit in the STAMP than in the Propeller. I'm sure of it. [noparse]:)[/noparse]
    But that's another topic. [noparse]:)[/noparse]

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    New to the Propeller?

    Visit the: The Propeller Pages @ Warranty Void.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2009-03-23 15:32
    I'm afraid that a Stamp emulator that required taking such a large performance hit would be counterproductive. If the idea is to attract BASIC Stamp users to the Prop, getting lower performance than they're used to with the Stamp itself would not only be a disincentive but could sour them on the Prop as a whole.

    This is just a personal opinion, but I believe the best use of one's time developing for the Propeller (with the maximum commercial advantage both to oneself and to Parallax) are forward-looking projects that take advantage of its unique capabilities, rather than backwards-compatible emulators.

    -Phil

    Post Edited (Phil Pilgrim (PhiPi)) : 3/23/2009 3:43:04 PM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2009-03-23 15:44
    Bean,
    If you include a debugger that allows you to display the variable space and I/O registers, it might be an excellent tool for people to debug programs and to learn about the Stamps despite the speed hit. As is often the case with large complex programs, you may find that a small part of it can be translated into assembly with a major impact on speed. For emulators, usually this is the fetch / decode loop and some of the simpler operations (like basic arithmetic).
  • grasshoppergrasshopper Posts: 438
    edited 2009-03-23 16:58
    I agree with Phil.
    I have used a BS2 and frankly Ill never return - sure it was great, but once I sat down, took the time, asked several question - basically a true effort to learn Spin. I was blow away at its simplicity.

    I think that it would be a waste of time Bean. Just my opinion though. Teach SPIN~~

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Visit my site -> [url=Http://www.rawcircuits.com]www.rawcircuits.com[/url]
  • BeanBean Posts: 8,129
    edited 2009-03-23 17:13
    Thanks for the insight guys.

    I guess I agree about the performance issue. The BS2 tokenize program is really complex. It is geared towards saving every bit of program space. And running programs SLOWER than a BS2 could leave a bad taste in the mouth.

    I think to get to at least the performace of the BS2 I'd have to do as Mike has suggested. Use assembly for the fetch/decode loop. Maybe even convert the tokens to a simpler representation (taking more memory, but simpler to decode).

    The main reason for this is that there is SO much documentation for the basic stamps. If users could use these programs on the propeller it would open up a new world to them. Without having to convert everything to spin (which is sometimes not a big deal...and sometimes it is difficult).

    I am just in the beginnings of working on this project. So I'm open to just about any suggestions. Keep them coming...

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    There is a fine line between arrogance and confidence. Make sure you don't cross it...

    ·
  • HumanoidoHumanoido Posts: 5,770
    edited 2009-03-23 17:17
    Bean,

    It sounds like a fantastic project for all those who develop projects
    on the Basic Stamp platform, myself included. I don't really care
    about what's under the hood in this project or how you accomplish
    it, as I would be happy to use the final product. In every respect,
    the final product would be a leap of technology.

    Some advanced guru's may disagree, as they have rightfully put in
    their time and evolved far beyond the level of my humble laboratory
    loft. But I truly believe those people at hobbyist and introductory
    education levels can vastly benefit from your efforts.

    The aspect of outputting to NTSC, having the option for multiple BS2
    programs running in parallel, and the ability to do a 1,000 IPS,
    is absolutely incredible. It would be a literal boon, Bean, to develop
    apps on your simulator! I encourage you to continue and look forward
    to the release of your impending project!

    humanoido
  • RiJoRiRiJoRi Posts: 157
    edited 2009-03-23 17:21
    Just thinkin' aloud, here...
    a) Perhaps a pair of #spin ... #endspin commands could be helpful, like #asm ... #endasm in C. This could let the user start converting to SPIN for speed, or to BSx for learning.
    b) If there isn't one already, perhaps a BSx -> SPIN tutorial could be written. I'm still at the programming-with-manual-in-hand stage for both languages, or I might volunteer.
    c) Could "What is a Microcontroller?" be re-written for the Propeller?

    --Rich
  • HumanoidoHumanoido Posts: 5,770
    edited 2009-03-23 18:43
    Thinking out loud here too... how about programming the propeller with the basic stamp 2 emulator-like code, so it will run PBASIC, yet gain much of the speed and features, such as BS2 parallel processing, from the propeller side? Then you don't need to rewrite "What's a Micro." You can have a single propeller chip that functions like multiple BS2s. Instead of switching program banks, one can switch BS2 banks.

    humanoido
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2009-03-23 18:58
    When most come across Parallax usually the first thing they see is the Stamp·they see·robots and other hardware geared for use with a Stamp . Reading the forum content the Stamp column tends to have less "technical" content than the Prop . The capabilities of the Prop and its instruction set by far exceed the Stamp but this also makes the Stamp look like a better option for someone just starting out , and in some circumstances it is the better option.

    So I can see why so many initially use the Stamp processor . I keep flip flopping between the two gradually getting more confident with the Propeller·, I would like to see some kind of bridge ,·perhaps not for myself but for others . But hey to use the emulator you have to buy a Prop right!!

    The speed is not the issue introducing more to the Propeller is the key , I liked the idea of the #spin directive and the emulator is not an unreasonable idea.

    Jeff T.
  • statemachinestatemachine Posts: 24
    edited 2009-03-23 19:46
    ·Believe you've got something there old Bean.
  • FearTurtlesFearTurtles Posts: 89
    edited 2009-03-23 21:08
    I really don't think there is a need. I'm basically new to all of this even tho I have had BS for over a year. Pbasic is great for a first programming language. The information available for aiding the learning part is outstanding. Now I'm dabbling into the Propeller system and I really don't find understanding it that difficult. So I think in trying to create a go-between would prolong the learning of the new language.
  • SRLMSRLM Posts: 5,045
    edited 2009-03-24 05:37
    I think a better solution would be a book or guide to transition users from BS2 to Propeller, with perhaps descriptions or projects of some of the more common situations (servos, LCD, debugging, Ping, etc.). IMHO, it's better to be able to learn a new language with a bit of effort (and it becomes easier every time) then to rely on your old knowledge to try and do something new. However, if you get something nice going, you could probably market it embedded into the spin stamp platform and create the first BS3! That would be cool, and allow BS2 users to easily transition. I guess the question is, what is the focus? If it's to help BS2ers get used to the Propeller, then it's as I said before. If it's to provide a more powerful BS2, then go for it.
  • WBA ConsultingWBA Consulting Posts: 2,935
    edited 2009-03-24 06:02
    Even with the slowness, I think I would be interested....for a short time. I would love to take advantage of several BS2s in a single package to get past my limitations with the BS2. However, once I started to use it, I would probably force myself to take the time to learn SPIN and move up the food chain.

    ps. I am imagining the product could be called BS2-prop-emu, thus your product logo could be an Emu with a prop beanie.....

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andrew Williams
    WBA Consulting
    IT / Web / PCB / Audio
  • Cluso99Cluso99 Posts: 18,069
    edited 2009-03-24 06:20
    A lot of opposing opinions. I think the emulation would be good. Once working (slower is not a problem), we could implement a direct interpreter in pasm. After all, that is what the BS is doing. So... IMHO small steps leading to a better solution. So go for it smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps: TriBladeProp, SixBladeProp, website (Multiple propeller pcbs)
    · Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
    · Prop Tools under Development or Completed (Index)
    · Emulators: Micros eg Altair, and Terminals eg VT100 (Index)
    · Search the Propeller forums (via Google)
    My cruising website is: ·www.bluemagic.biz·· MultiBladeProp is: www.bluemagic.biz/cluso.htm
  • BeanBean Posts: 8,129
    edited 2009-03-24 14:08
    I am working on assembly code to do the token fetch and to stack literals (literals happen alot).
    This should get me up to at least the speed of a "real" BS2.

    Only downside, is that now I need 2 cogs to run the program. One running the spin and one running the assembly. So maybe only be able to have 2 or 3 parallel programs running. I figure I'll need one cog to handle the downloading of programs and such. Plus one for the debugger.

    I'll be ready to post some code after I get the assembly working. It's hard for me to swtich between the SX and Propeller because the assembly is SO different. So I'm just getting my head around Propeller assembly again.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    There is a fine line between arrogance and confidence. Make sure you don't cross it...

    ·
  • BeanBean Posts: 8,129
    edited 2009-03-24 18:50
    Okay,
    I got the assembly working. With this simple BS2 program.

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    Start:
    HIGH 15
    LOW 15
    GOTO Start

    I got a frequency of 1825 Hz. There are three instruction in the loop so that works out to 5475 instructions per second. I will have to find my BS2 as see what frequency it gives.

    If anyone has a BS2 and a frequency counter handy, could you see what the real BS2 gives ?

    I'm making progress... Stay tuned...

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    There is a fine line between arrogance and confidence. Make sure you don't cross it...

    ·
  • dMajodMajo Posts: 855
    edited 2009-03-24 19:09
    Bean,

    what about focusing on the PC:
    - you can have a PC side program that has a virtual serial port. With the basic stamp editor you can connect to this serial port. The PC program will translate the BS2 code to spin/pasm/lmm an upload the propeller (eg. with propellent, brad's compliler or homespun compiler).
    - once the BS2 code has been converted and transferred to propeller, you can have a cog connected to that program acting as debugger and all other cogs free (to run converted BS2 code - 6/7 stamps running parallel at prop native speed). In this situation the PC app will collect the data from prop and emulate BS2 debugger passing to StampEditor-DebugTerminal the data through the virtual serial port
    - all this can happen transparently for the BS2 user, just a small app/task more on the PC running in background
  • Tracy AllenTracy Allen Posts: 6,664
    edited 2009-03-24 19:31
    Bean

    Data per request..
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    Start:
    HIGH 15
    LOW 15
    GOTO Start
    



    BS2: 1778 Hz
    BS2pe: 1841 Hz
    BS2p: 4608 Hz
    BS2px: 6655 Hz

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • hippyhippy Posts: 1,981
    edited 2009-03-25 00:01
    A better benchmark test is perhaps ...

    Start:
    Toggle PIN
    Goto Start

    Or whatever that is in real BS2 parlance ( I've never used one ).
  • Mike GreenMike Green Posts: 23,101
    edited 2009-03-25 00:23
    Bean, that's great! Don't worry about needing more than one cog. If you're interested about adding "value" by running Stamp code on a Prop, consider the ability to debug and to use a keyboard and display for control information. You could also provide serial input buffering whose absence is often a major limitation of the Stamps. Being able to move operations like COUNT to one of the cog counters would be very helpful, but both would fall outside of Stamp emulation. One thing you might consider would be to add "pseudo-peripherals" patterned after 3rd party co-processors to do PWM, buffered serial input, pulse counting, servo control. These would be Spin or assembly programs that would run in a cog and watch a specified I/O pin for commands and respond via that I/O pin. You could add these at a later time.

    You might also think about the Spin Stamp with its compatible size and pinout to the Stamps. It's not a "drop in" replacement because of the different logic levels (3.3V vs. 5V), but that would be one way to provide your emulator.
  • Capt. QuirkCapt. Quirk Posts: 872
    edited 2009-03-26 01:04
    I certainly see a benifit, I know the topics come up before in a thread, Chip was involved in.

    I thought Parallax already started something like this for the Spin Stamp? If so maybe they could share their work on what they have completed.


    ·
  • BeanBean Posts: 8,129
    edited 2009-03-26 15:21
    I'm slowly working through all the tokens. The tokenized BS2 program is very complex. I have no idea how Chip got all this into a PIC back in the day.

    It's not really useful until I get it to the point where you can upload programs from the Basic Stamp editor. And I have quite a ways before I get to that point. Also I have to make sure Parallax doesn't have a problem with me posting code that basically "exposes" the BS2 IP.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    There is a fine line between arrogance and confidence. Make sure you don't cross it...

    ·
  • BeanBean Posts: 8,129
    edited 2009-03-27 11:41
    I have posted the code so far in the first post of this thread.

    I will continue to update and put the "latest and greatest" version in the first post.

    Comment and questions are welcomed.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    There is a fine line between arrogance and confidence. Make sure you don't cross it...

    ·
  • MikeSMikeS Posts: 131
    edited 2009-03-28 22:40
    Bean,
    I am very much interested in your BS2 emulator. In your first post
    Bean said...
    Also it would use the existing Basic Stamp Editor to get the PBasic code into it.

    Will the spin program you posted do that now?

    Thanks,
    MikeS

    Post Edited (MikeS) : 3/28/2009 10:47:24 PM GMT
  • BeanBean Posts: 8,129
    edited 2009-03-29 02:03
    Mike,
    No, not yet.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    There is a fine line between arrogance and confidence. Make sure you don't cross it...

    ·
  • max72max72 Posts: 1,155
    edited 2009-04-01 09:29
    I'm a little late, but I think a Basic Stamp emulator would be extremely nice.

    I moved to propeller because of the power and the possibilities offered, but when starting for scratch, or when testing a feature or a peripheral I still find Basic Stamp easier.
    The idea of having multiple stamps in a single propeller is even more intriguing..

    Massimo
  • BeanBean Posts: 8,129
    edited 2009-04-03 18:12
    I have posted updated code that allows the "Basic Stamp IDE" to download PBASIC code into the propeller.
    The propeller emulates a stock BS2. When the propeller is started it waits to recieve a program from the "Basic Stamp IDE", then it runs that program.
    To download a new PBASIC program, you need to reset the propeller.

    NOTE: Only a limited number of the PBASIC commands are implemented so far. This is a work in progress...

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    There is a fine line between arrogance and confidence. Make sure you don't cross it...

    ·
  • Nick McClickNick McClick Posts: 1,003
    edited 2009-04-03 19:43
    Nothing helpful to say other than to show my support; It would be a huge help for me! A fair number of folks have been asking to post Stamp related projects, but stamps are too expensive for me to stock (It would drive up the cost of projects). I've been pointing them to the PICaxe, but I'm sure they'd prefer to not rewrite code.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Gadget Gangster - Share your Electronic Projects - Sign up as a Designer and get a free 4-pack of Project Boards!
  • edited 2009-08-10 01:24
    I feel that this is an excellent idea. I have a suggestion for the Propeller 2 - Once it has a whopping 64 I/O, there should be 8-16 analog I/O. This would allow people like me not losing their minds over trying to figure out filtered PWM and duty-modulation for analog output, and would allow more complex measurements.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Stop it - you're making my head SPIN!

    Whaddya say we take this lil' chip for a SPIN?
Sign In or Register to comment.