wiki for moving Basic Stamp users to Arduino

Hey y'all,

Some of you already know me, but I bet most don't...super short version, I teach physical computing in the SF Bay Area, and make art.

I recently started (less than a week ago in fact) a project to ease and/or speed up the Basic Stamp and PBASIC users' transition to Arduino. We have a wiki - http://pbasic2arduino.pbwiki.com/ - that is coming along nicely.

The initial plan is to take many of the tutorials in Parallax's "What's A Microcontroller?" book and show them in both PBASIC and Arduino. Many more examples will also be made available over time. There are also (or will be) many other parts to the site like command-for-command comparisons in both directions, hardware information and comparisons, and a syntax difference tutorial.

So this is mainly just an FYI, although we invite participation at any level - send us examples, come make additions and corrections, send us advice, or just send Basic Stamp users to the site when it comes up.

Thanks for your attention! CTP

ps - if you are interested in contributing, the edit password is arduino :)

I wonder if we could just write some software that converts pbasic to Arudino code?

That would be interesting.

D

The easiest way to do that would be to compile it and work it out from the assembly. Pretty damn hard.

I used to program in Clipper (dBase language compiler) and we could use all kinds of directives to ‘translate’ commands in the pseudo-compiler output (I think that is what it was called).

It worked something like this (long time ago that I used it):

#xcommand printf(<value>) => print <code>

I am not sure if the Arduino environment can use something like#xcommand did for Clipper programmers, but maybe something like this can be added to the Arduino language

You know it's funny - just a couple of weeks ago I was thinking outloud to Nathan Seidle about the possibilities of having an Arduino run a PBASIC interpreter (which would have to be reverse engineered) and after he told me what a dumb idea it was I got to thinking - being an educator and all - that the translation should happen in my student's brains. That it's good for them! :)

Of course we'll have a load of examples already translated on the site - it will be a great start for BS2 users who want to try Arduino and learn the language...and let's face it, there are a TON of BS2 users out there.

It should be pretty easy to write a pbasic interpreter for arduino. The mega168 has a lot more program memory that the PIC that implements the interpreter. (OTOH, it should be equally easy to put an entire BS1 into one of the newer PIC chips like the 16F88, and no one has done that either. Perhaps lawyers are involved.)

Similarly, one of my "back burner" projects is to implement a portable "Basic-52" interpreter. If an 8052 could implement a powerful floating point basic in 8k of 8052 assembler and as little as 1.25k of RAM, it should certainly be possible to write a similar interpreter in C that would run on any number of the more-capable micros that are around now with 32k+ of flash and 2k+ of RAM...

(OTOH, where's the arduino library containing near-exact equivalents of the stamp's PBASIC statements/functions? That'd be an obvious first step, right?)

"(OTOH, where's the arduino library containing near-exact equivalents of the stamp's PBASIC statements/functions? That'd be an obvious first step, right?)"

Hey! You're gonna put my wiki out of business with talk like that!!! ;)

As a longtime (13 years) PBASIC programmer and former Parallax employee, I’m kind of looking for the best way to port PBASIC’s DATA statements and READ function to the Arduino. I bought one to support my customers (company is EFX-TEK) and would like to give them as much support as I can for those that purchase the Prop-1 (BS1), Prop-2 (BS2), or Prop-SX (SX28).

That is exactly what I'm doing (moving from Pbasic/picbasic to Arduino). I've made a lot of MIDI controllers and synths using PBasic and PicBasic, and now looking into the Arduino.

This is a very cool thing, providing the "wiki". Thanks for doing this.

Tony

I'm kind of looking for the best way to port PBASIC's DATA statements and READ function to the Arduino.

Wow. That's a pretty tough one, considering the extent to which it looks like "data" is overloaded compared to the DATA statement we all known and love from Dartmouth BASIC. Even the simple string support would be hard to do with C primitives. Which forms of the DATA directive would be most important to support? EEPROM from BS1 would be easier (fewer options), but still difficult to do strings, I think.

And Hmm. You don't care about WRITE? So in theory DATA could go in flash rather than actual EEPROM? That might make things a bit easier... Would a syntax like this be close enough to be useful:

DATASTART(label)
DATA 12, 13, 14, 15
DATAEND
DATASTART(stringlabel)
STRINGDATA("a string that has some characters in it")
DATAEND
DATASTART(anotherlabel)
DATA 65, 66, WORD(0x3738), 39
DATAEND

It wouldn't be exactly like PBASIC's DATA statement, but the idea would be that it wouldn't be TOO hard to edit some PBASIC DATA statements to fit the new syntax...

I did something a little like this for a menu library that I've been working on:

MENU_START(menu_A)
MENU_ACT('X', menu_up)
MENU_ACT('A', menu_boot)
MENU_SUB('B', menu_3deep)
MENU_END(menu_A)

Thanks for the feedback.

In the end, I don't care about WRITE (the values won't change at run time). Most of my programs these days have to do with prop control, a LOT for Halloween, and as I'm an actor in LA and know a bunch of FX guys I help them, too. A lot of props use a simple sequencer template for the BSI that stores records like this:

EEPROM (%00000000, 0)

The first byte is what to put on the output pins, the second is how long (in timing units, usually 100 ms) to hold that state. In effect, it's a digital player piano. I'd like to duplicate this in the Ardunio -- it it's possible within the constraints of the language. What I'm really after is a named constant array that I can index through as the program runs.

A named constant array is pretty easy; the question is how much it should look like the equivalent PBASIC statements. I mean, here's ugly raw C that does it:

struct {int index; unsigned char data[];} playdata =
   {0, {
       0x81, 1,
       0x42, 1,
       0x24, 1,
       0x18, 2
   }
};

#define PLAYER_READ(pd) (pd.data[pd.index++])
#define PLAYER_RESET(pd) pd.index = 0;

void loop()
{
    unsigned char bits, time;

    PLAYER_RESET(playdata);
    bits = PLAYER_READ(playdata);
    time = PLAYER_READ(playdata);
    setport(bits);
    delay(time);
}

getting it to more exactly match the semantics of PBASIC READ (what to do after all the data is read, for instance) is harder, and hiding C ugliness (" What's "struct" do? It's not in the arduino manual!"), using EEPROM or flash to save ram space, and so on, are all ... additional effort.

(I always wanted to write an "LED blinking" language a lot like your "digital player piano." Alas, it tends to quickly suffer from feature bloat...)

[Question for the arduino experts: if I use the gcc primitives for putting data in EEPROM, does the arduino utility load the EEPROM when downloading a sketch?]

Thanks, again, I'll give that a try. I'm only interested in duplicating the function (of EEPROM and READ), the form should be true to Arduino's language. Question: Does that constant structure exist in RAM or in Flash? Putting the data into Flash is what I'm after.

As shown, the structure will get copied from flash to RAM at device reset time. But don't forget that an Arduino has a lot more RAM (1k) than a BS1 has EEPROM (256 bytes, shared with the program itself.) You can PROBABLY fit any script that fits in a BS1 in Arduino RAM without having to worry about the more exotic memory technologies.

This discussion has drifted from the original Wiki announcement; I think we should move any more discussion of DATA/READ/etc functionality, or "script players" to A thread in the Software/Development area