Pages: [1] 2   Go Down
Author Topic: BASIC-like Interpreter for Arduino  (Read 5107 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 3
Posts: 118
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I started a BASIC-like interpreter for Arduino located here: https://github.com/Pualware/serialBasic.

The BASIC program is stored in EEPROM, and commands are accepted over the serial port.

Comments are appreciated.

Ultimately I want to create an OS that has a master atmega interacting with slaves over the I2C bus.

I will be making updates hopefully daily for awhile and if anyone would like to contribute an I2C device to the command set please let me know.

I try to use PSTR strings everywhere so that RAM is not used too much.
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 545
Posts: 27352
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Have you seen bitlash?
You could be duplicating that.
http://bitlash.net/
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

0
Offline Offline
Full Member
***
Karma: 3
Posts: 118
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you for that link, I was not aware of bitlash, and this gives me an opportunity to clarify the intent of where I would like to go and highlight the difference between this and bitlash.

  First of all bitlash is much farther along as an interpreter than mine will ever be.  But I don't want to make a c compliant interpreter.

  Rather than allowing people to store their c functions in eeprom rather than Flash (why?), I would like to create an intermediate language that bridges the gap between component complexity and language complexity.  I'd like to make a dumber language with a smarter component interface.

  I'd like to be able to build projects in this language that have a Master I2C component and n slave I2C components.  Some kind of standard interface to the components would be created with hopefully wiring diagrams and maybe stackable shields.  The intent would be to make something that could be appropriate for junior-high level students by hiding as much of the unnecessary complexity as possible.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 631
Posts: 50115
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The BASIC program is stored in EEPROM
A UNO has 1K of EEPROM. That severely limits the size of the program that can be created/uploaded/stored.
Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 545
Posts: 27352
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

"The intent would be to make something that could be appropriate for junior-high level students by hiding as much of the unnecessary complexity as possible. "

Some questions:

You've got 2 wires, power, ground. Isn't that pretty non-complex already with I2C?

How are you going to get kids into hardware engineering if everything is turned into one software only effort?
« Last Edit: October 11, 2012, 02:28:02 pm by CrossRoads » Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

0
Offline Offline
Full Member
***
Karma: 3
Posts: 118
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

1000 bytes of EEPROM will not severely limit the size of the program because the complexity is pushed to Flash.  The commands themselves will be 1 byte each followed by n bytes of parameter.  

There are a 100 reasons why students don't make electronics.  I think they can all be boiled to 4 main categories:
   1) I don't know what to build
   2) Its too complex
   3) It doesn't work
   4) Somebody else might "steal" my idea


Get rid of those 3 and electronics will be more "fun", and that's really what kids care about.  So in response:
   1=> This is our partly our responsibility to get the word out and show people what can be done.
   2=> The language will be simple
   3=> This will have to be watched carefully.
   4=> Who cares.  Shift to open source model.  Make something cooler with more people watching quality above.

What do you think?
« Last Edit: October 14, 2012, 09:15:42 pm by Paulware » Logged

Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 545
Posts: 27352
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I am not sure what I think.

I see kids programming for FIRST Robotics competition in non-simplified language, and programming in drag/drop Lego programming.

I see kids who just want to slap something together quick and make a motor jump around, quickly losing interest because its not texting or graphics on a computer to poke & click.

I see the kids here in the forum putting in the effort to learn somewhat simplified C. The Arduino IDE C seems like fancier BASIC to me, but I've been exposed to a lot over the years.

I think interpretive programming could fit in there somewhere.

Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

0
Offline Offline
Full Member
***
Karma: 3
Posts: 118
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A friend wanted to set a relay when temperature of a pipe was around room temperature.
I added thermistor and relay (just digital output) to components, and uploaded to github https://github.com/Pualware/serialBasic
The EEPROM Basic-like "program" that runs on Arduino is just:

thermistor
ifA<80
relay3on
endif

The Arduino will be powered on a 24 hour automatic timer and run for 1 hour so a real time clock and loop is not necessary

(note from moderator - what showed up in e-mail notification is:
Code:
thermistor
ifA<80
relay3on
endif
ifA>90
relay3off
endif
wait10
jump1
)
« Last Edit: October 14, 2012, 09:55:25 pm by CrossRoads » Logged

Global Moderator
Online Online
Brattain Member
*****
Karma: 495
Posts: 19038
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
if A<80
relay3on
endif

I'm not a big fan of trying to simplify things "to make it easier" because ultimately you have to learn more complex things.

For example, the above could be written in C as:

Code:
if (A < 80)
  relay3on ();

Is that so much harder to understand? I think not.

The trouble with simplified languages is that, although you may do simple programs marginally faster, once you have moved past that and want to do interrupts, timers, I2C, SPI etc. you then need to learn other stuff, and interface with your interpreted language.

Then the simplification works against you.
Logged


0
Offline Offline
Full Member
***
Karma: 3
Posts: 118
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I remember when my dad showed me a FORTRAN program for the first time. I was 15or16 and couldn't make any sense out of it.  I typed it in on the computer terminal and I think it displayed some error message.  It was just gibberish to me. Hopefully a simple language like this might keep a student from turning away especially if there was something blinking or moving on the other side.
Logged

Global Moderator
Online Online
Brattain Member
*****
Karma: 495
Posts: 19038
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, well the Blink example isn't particularly hard to follow:

Code:
void setup() {               
  // initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards:
  pinMode(13, OUTPUT);     
}

void loop() {
  digitalWrite(13, HIGH);   // set the LED on
  delay(1000);              // wait for a second
  digitalWrite(13, LOW);    // set the LED off
  delay(1000);              // wait for a second
}
Logged


Global Moderator
Boston area, metrowest
Offline Offline
Brattain Member
*****
Karma: 545
Posts: 27352
Author of "Arduino for Teens". Available for Design & Build services. Now with Unlimited Eagle board sizes!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

We had to do FORTRAN programming freshman year in college on punch cards, mostly for the experience of it.
Would get back what seemed like totally unintelligible error messages back.
Don't recall if girlfriend (now wife) had to do the same a couple years later, of if they had moved on by then. If they did, I would have helped her with it.
Didn't see it again until FORTRAN-77 running on military program computers when I started work in 1985.  

I agree with Nick tho - if you make it too simple it becomes to hard to do complicated stuff.   We have Lego Mindstorm computers for the kids, I always found the drag & drop programming difficult to understand vs just typing out what I wanted it to do.
Think that's part of the reason I never liked Apple/Mac's either - too used to having control under DOS and being able to do what I wanted. That and they bombed out with the little bomb icon and no chance to recover.
Logged

Designing & building electrical circuits for over 25 years. Check out the ATMega1284P based Bobuino and other '328P & '1284P creations & offerings at  www.crossroadsfencing.com/BobuinoRev17.
Arduino for Teens available at Amazon.com.

0
Offline Offline
Full Member
***
Karma: 3
Posts: 118
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Created a video to demo some features
« Last Edit: November 03, 2012, 06:00:49 pm by Paulware » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No offence intended, but I think the two moderators are being a little hypocritical here.
Was not the whole Arduino platform for which this forum is based on, built to SIMPLIFY the coding of AVR's?

Should the "simplification" stop here at what Arduino is now, and not go any further?

A professional AVR programmer would say the same about Arduino, as what the moderators are saying about "Paulware".
Logged

0
Offline Offline
God Member
*****
Karma: 39
Posts: 988
Get Bitlash: http://bitlash.net
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think there is value in these smaller languages (it's why I wrote Bitlash), and I think they should be encouraged by the community.

While we're playing code golf, here's blink written in bitlash… small, forces a little thinking about the algorithm, and doesn't explicitly introduce delay() as a bad habit to break later:

Code:
function t13 {d13=!d13;}
function setup {pinmode(13,1); run t13,500;}

Let there be a thousand small languages.

-br
http://bitlash.net
Logged

Pages: [1] 2   Go Up
Jump to: