PDA

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



Bean
03-23-2009, 06:35 PM
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.



[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.

[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

Cluso99
03-23-2009, 09:32 PM
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 (http://forums.parallax.com/showthread.php?p=786418), SixBladeProp (http://forums.parallax.com/showthread.php?p=780033), website (Multiple propeller pcbs) (http://bluemagic.biz/cluso.htm)
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator) (http://forums.parallax.com/showthread.php?p=790917)
· Prop Tools under Development or Completed (Index) (http://forums.parallax.com/showthread.php?p=753439)
· Emulators: Micros eg Altair, and Terminals eg VT100 (Index (http://forums.parallax.com/showthread.php?p=778427))
· Search the Propeller forums (via Google) (http://search.parallax.com/search?site=parallax&client=parallax&output=xml_no_dtd&proxystylesheet=parallax&proxycustom=<HOME/>&ie=&oe=&lr=)
My cruising website is: ·www.bluemagic.biz (http://www.bluemagic.biz)·· MultiBladeProp is: www.bluemagic.biz/cluso.htm (http://www.bluemagic.biz/cluso.htm)

Oldbitcollector (Jeff)
03-23-2009, 09:51 PM
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. :)
But that's another topic. :)

OBC

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

Visit the: The Propeller Pages (http://www.warrantyvoid.us/tiki-index.php?page=Propeller) @ Warranty Void.

Phil Pilgrim (PhiPi)
03-23-2009, 10:32 PM
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 Green
03-23-2009, 10:44 PM
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).

grasshopper
03-23-2009, 11:58 PM
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 -> www.rawcircuits.com (Http://www.rawcircuits.com)

Bean
03-24-2009, 12:13 AM
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...

·

Humanoido
03-24-2009, 12:17 AM
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

RiJoRi
03-24-2009, 12:21 AM
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

Humanoido
03-24-2009, 01:43 AM
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

Unsoundcode
03-24-2009, 01:58 AM
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.

statemachine
03-24-2009, 02:46 AM
·Believe you've got something there old Bean.

FearTurtles
03-24-2009, 04:08 AM
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.

SRLM
03-24-2009, 12:37 PM
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 Consulting
03-24-2009, 01:02 PM
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

Cluso99
03-24-2009, 01:20 PM
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 http://forums.parallax.com/images/smilies/smile.gif

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

· Home of the MultiBladeProps: TriBladeProp (http://forums.parallax.com/showthread.php?p=786418), SixBladeProp (http://forums.parallax.com/showthread.php?p=780033), website (Multiple propeller pcbs) (http://bluemagic.biz/cluso.htm)
· Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator) (http://forums.parallax.com/showthread.php?p=790917)
· Prop Tools under Development or Completed (Index) (http://forums.parallax.com/showthread.php?p=753439)
· Emulators: Micros eg Altair, and Terminals eg VT100 (Index (http://forums.parallax.com/showthread.php?p=778427))
· Search the Propeller forums (via Google) (http://search.parallax.com/search?site=parallax&client=parallax&output=xml_no_dtd&proxystylesheet=parallax&proxycustom=<HOME/>&ie=&oe=&lr=)
My cruising website is: ·www.bluemagic.biz (http://www.bluemagic.biz)·· MultiBladeProp is: www.bluemagic.biz/cluso.htm (http://www.bluemagic.biz/cluso.htm)

Bean
03-24-2009, 09:08 PM
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...

·

Bean
03-25-2009, 01:50 AM
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...

·

dMajo
03-25-2009, 02:09 AM
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 Allen
03-25-2009, 02:31 AM
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 (http://www.emesystems.com)

hippy
03-25-2009, 07:01 AM
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 Green
03-25-2009, 07:23 AM
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. Quirk
03-26-2009, 08:04 AM
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.


·

Bean
03-26-2009, 10:21 PM
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...

·

Bean
03-27-2009, 06:41 PM
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...

·

MikeS
03-29-2009, 05:40 AM
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

Bean
03-29-2009, 09:03 AM
Mike,
No, not yet.

Bean.

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

·

max72
04-01-2009, 04:29 PM
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

Bean
04-04-2009, 01:12 AM
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 McClick
04-04-2009, 02:43 AM
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 (http://www.gadgetgangster.com) - Sign up as a Designer and get a free 4-pack of Project Boards!

Erik "SPIN" J.
08-10-2009, 08:24 AM
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?

Prettybird
08-10-2009, 08:55 AM
I am a newbee struggling with learning the basic stamp. Just got my first prop and haven't really started yet. Does sound interesting though. Confusing but interesting.

Mike Green
08-10-2009, 10:02 AM
Erik,
If you follow the very long thread on the design of the Prop 2, you'll find that the current analog input functionality has been built into the I/O circuitry for each pin so that it will work much better than that of the Prop 1. It will still require the attention of one or more cogs, using the built-in cog counters like the Prop 1, but the analog processing will be much better. The current Prop 1 can already do 16 analog inputs or outputs, each using one cog counter. The problem is that, in the Prop 1, they tend to have some internal noise because of how the signals are routed on the chip and how the input sensing is done.

For output, you'll still be doing filtered PWM and for input, you'll still be doing sigma-delta conversions, but the signals will be cleaner and be capable of higher resolution and sampling speed.

Whit
08-10-2009, 08:58 PM
Prettybird said...
I am a newbee struggling with learning the basic stamp. Just got my first prop and haven't really started yet. Does sound interesting though. Confusing but interesting.
Prettybird,

You might want to check out this thread on 12Blocks (formerly Spinner). It is Graphical User Interface (GUI) for beginners to the Propeller that is·being developed by Hanno·(developer of View Port).·He has a beta version out now which some forum members are playing with. It is impressive.

See this thread - http://forums.parallax.com/showthread.php?p=819680

Sorry to be off topic.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Whit+


"We keep moving forward, opening new doors, and doing new things, because we're curious and curiosity keeps leading us down new paths." - Walt Disney

Microcontrolled
08-11-2009, 09:02 AM
I think that this emulator, if it could use the current Basic Stamp IDE, would be a great accomplishment that would move others to the Propeller and it's possibilitys, and if it could fit in one cog then you could have a whole ARRAY of virtual stamps running!!! Considering that the SX which makes up most of the Basic stamps has been EOL'ed, this would make a great alternative when they run out! Nice Work!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Just call me micro.


If it's not Parallax then don't even bother.
·
I have changed my avatar so that I will no longer be confused with others who use genaric avatars.

Mini-Din/PS2 connectors are for sale! 5 for $1! PM me if you wish to make an order.
Cheap·shipping unless specified!··········150 left!!··