MadMan
Posts: 8
Joined: Mon Apr 23, 2012 11:47 am

Re: PiBasic

Mon Apr 23, 2012 1:25 pm

When I started to play around with 'puters, all there was (for dos) was GWBasic but it was enough to get me hooked.

So, how about a "simple" interpreted language that runs on a Pi?

There are probably many coders out there who have experience with C on the Unix platform and I'm betting that this would be a great challenge for them especially if the overriding rule is "only well formed code allowed".

More importantly, having an app like PiBasic (or call it what you will) would enable the scholars (and those who want to "play") to get their first "Hello World" on the screen.

From there on, the sky would be the limit.

Think about a code editor with a "Save" button and a "Run" button.

Start with simple screen output commands (what to put and where to put it)

Then add font size and color options.

Adding buttons/shapes etc

Next, input from the keyboard and later mouse clicks on buttons/shapes

Then the whole of the mathematical calculations set.

Access to a database engine (MySQL) would be very nice and could be done over the network - maybe Pi is not suitable for hosting MySQL - do not know!

And of course, accessing the GPIO pins and anything else plugged into the USB, WiFi or other ports (think the drivers for the hardware would have to run on the OS though)

In my opinion, give a young enthusiast a way to get a Pi to do something that does not require mountains of work and they will soon start innovating - that "something" will soon grow to be a monster at which time, they can graduate to the higher level languages but they will be "hooked", much like I was when I coded my first version of "Pong" on my ZX81 back in the day.

Any thoughts?

User avatar
croston
Posts: 703
Joined: Sat Nov 26, 2011 12:33 pm
Location: Blackpool
Contact: Website

Re: PiBasic

Mon Apr 23, 2012 1:34 pm

You just described Python which is where the "Pi" in "Raspberry Pi" came from! The educational user guide will explain how to start doing the things you suggest.

toxibunny
Posts: 1382
Joined: Thu Aug 18, 2011 9:21 pm

Re: PiBasic

Mon Apr 23, 2012 6:44 pm

Ditto. Putting shapes on screen is a tiny bit more complicated, in that in modern OSes, you wouldn"t draw shapes to the screen, you"d put a *window* on the screen, and then draw the shapes in the window. Pygame does that with only 2 or 3 extra lines of code...

I can see the appeal of having an 8-bit style "boot to BASIC", like many of us grew up with, but I think it would be a hindrance nowadays... Python is barely more difficult to learn than the BASICs of old, and is *heaps* better once you get the hang of it. Plus, you can run your programs on Mac, windows, Linux PCs, or the Pi, often completely unchanged (I think).

Sorry for the rant.

Question for those with the pi/Linux know-how - would it be possible to get a Pi running like the 8-bits of old, for those of us using composite on an old TV? I.e. it boots straight to something like "RASPBERRY PI MODEL B, ©2011 RASPBERRY PI FOUNDATION, PYTHON V3.1 113MB SYSTEM RAM & 128MB VIDEO RAM FREE, READY >>>" with a flashing cursor, easily switchable between "screens" showing your interpreter, whatever scripts/modules you"re working on, and a graphics window? And a debugger. Know what I mean? Best of both worlds...
note: I may or may not know what I'm talking about...

rherrera72
Posts: 4
Joined: Wed Mar 28, 2012 1:19 am
Contact: Website

Re: PiBasic

Mon Apr 23, 2012 7:09 pm

May I suggest Small Basic, this is a tiny a very usefull language, simple and beautifull, lots of examples, very small footprint.

User avatar
gordon@drogon.net
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: PiBasic

Tue Apr 24, 2012 11:20 am

MadMan said:


When I started to play around with 'puters, all there was (for dos) was GWBasic but it was enough to get me hooked.

So, how about a "simple" interpreted language that runs on a Pi?


Done.

Well - it's a work in progress, but it's at the point where it's fully functional and usable, and although I hadn't originally thought of the RPi when I started the code (see the link below for details), it works remarkably well on the RPi.

See https://projects.drogon.net/return-to-basic/ however there's no code there yet, hopefully after this weekend if I have time.

I've posted screenshots in the past about it, but here is a taster:



not a terribly good image, but also look at:



for a proper screen-shot. This is a turtle graphics example. (spot the deliberate mistake


There are probably many coders out there who have experience with C on the Unix platform and I'm betting that this would be a great challenge for them especially if the overriding rule is "only well formed code allowed".


I have also started to write a manual for it - and yes, while it has GOTO, you don't need it once you've grasped the basics as it were.


More importantly, having an app like PiBasic (or call it what you will) would enable the scholars (and those who want to "play") to get their first "Hello World" on the screen.


It's the "wow factor" - I really think there is nothing better than getting people hooked by getting their name up in lights. Instantly.


From there on, the sky would be the limit.

Think about a code editor with a "Save" button and a "Run" button.

Start with simple screen output commands (what to put and where to put it)

Then add font size and color options.

Adding buttons/shapes etc

Next, input from the keyboard and later mouse clicks on buttons/shapes

Then the whole of the mathematical calculations set.

Access to a database engine (MySQL) would be very nice and could be done over the network - maybe Pi is not suitable for hosting MySQL - do not know!


I was asked recently to put in support for SQLite - so I've made a start by allowing associative arrays (you don't need to use them though!)


And of course, accessing the GPIO pins and anything else plugged into the USB, WiFi or other ports (think the drivers for the hardware would have to run on the OS though)


Harder, possibly not that important for the initial systems though. However I have (again, to satisfy my own needs!) put in support to talk to arduinos over the USB serial port. My aim is to make the same code (in BASIC) work on an arduino or the GPIO.


In my opinion, give a young enthusiast a way to get a Pi to do something that does not require mountains of work and they will soon start innovating - that "something" will soon grow to be a monster at which time, they can graduate to the higher level languages but they will be "hooked", much like I was when I coded my first version of "Pong" on my ZX81 back in the day.

Any thoughts?


Your preaching to the converted here - others will throw scorn at you, but so what For me it's the initial entry level that you have to break through - put people in a siruation which is simple - get them to write a sinple program or two, then those who are really keen can go on to learn editors, IDEs, debuggers and other programming languages. Starting on BASIC (35 years ago) didn't do me any harm at all - but I had good teachers and that's half (or more!) of the battle. If you have keen teachers who're willing to let you learn and "feed" you more and more when you want it then you've won...

Gordon
--
Gordons projects: https://projects.drogon.net/

User avatar
gordon@drogon.net
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: PiBasic

Tue Apr 24, 2012 11:38 am

toxibunny said:


Ditto. Putting shapes on screen is a tiny bit more complicated, in that in modern OSes, you wouldn"t draw shapes to the screen, you"d put a *window* on the screen, and then draw the shapes in the window. Pygame does that with only 2 or 3 extra lines of code...


in RTB:

GR // Initialise low res graphics

PLOT (0,0) // Point at 0,0 - bottom left

LINETO (50,50)

COLOUR = Pink

CIRCLE (50,50,15,1) // Circle at 50,50, radius 15, 1 = solid

Or prefix it with line numbers to make a program...


I can see the appeal of having an 8-bit style "boot to BASIC", like many of us grew up with, but I think it would be a hindrance nowadays... Python is barely more difficult to learn than the BASICs of old, and is *heaps* better once you get the hang of it. Plus, you can run your programs on Mac, windows, Linux PCs, or the Pi, often completely unchanged (I think).


I think it's the entry level thats harder. Although there is an interactive mode for Python you really need to learn an editor too, then switch between the editor and run-time.


Sorry for the rant.

Question for those with the pi/Linux know-how - would it be possible to get a Pi running like the 8-bits of old, for those of us using composite on an old TV? I.e. it boots straight to something like "RASPBERRY PI MODEL B, ©2011 RASPBERRY PI FOUNDATION, PYTHON V3.1 113MB SYSTEM RAM & 128MB VIDEO RAM FREE, READY >>>" with a flashing cursor, easily switchable between "screens" showing your interpreter, whatever scripts/modules you"re working on, and a graphics window? And a debugger. Know what I mean? Best of both worlds...



I have an experimental SD card that boots directly into my BASIC on the RPi. boots in about 15 seconds. Would be much quicker if I threw away most of the startup code, but some of it is handy - like initialising the network, USB, etc. The issue I have right now is that if people having fiddled with the overscan stuff (config.txt) for the composite video output - getting BASIC to pick-up the real screen size is somewhat problematic right now. It ought to be fine in HDMA mode, but I've not gotten that far yet.

Gordon
--
Gordons projects: https://projects.drogon.net/

MadMan
Posts: 8
Joined: Mon Apr 23, 2012 11:47 am

Re: PiBasic

Tue Apr 24, 2012 11:52 am

Gordon has gotten it!

Maybe I did not put my initial statement too well - did not mean an 8 bit system.

Also, does not have to be a "bootable" - rather an app that runs on the Linux system that is already installed and can be run at will.

If it runs on top of Linux, it can link in to all the "nice" stuff that is already there and those amongst us that are able to code additional drivers (for want of a better word) can do so.

The whole idea is to make it easy for the total newbie to (as it was put in his post) "get his name up in lights".

(Starting to sound like a crack dealer but the principle is the same)

Thanks for all the comments guys - maybe this will become something really useful if we can all work together.

All the best

rrmcbeth
Posts: 19
Joined: Tue Mar 27, 2012 8:07 pm

Re: PiBasic

Tue Apr 24, 2012 12:44 pm

Actually I started writing assembly code before there were nice assembler programs. Remember the S-100 bus, the 8080 and the RCA 1802 CPU?

However, that being said, how about a series of Python's that progress in complexity from something like the very simple 'basic like' commands progressing up to more complex programming with OOP and beyond.   Actually, don't you think it's all in the way the Instruction Manual is written?

If you really want kids to understand the 'why' and well as the 'how' of   programming teach them Assembler.   At DeVry U. (USA)  the first programming class (for the serious student) is PIC assembler.

User avatar
gordon@drogon.net
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: PiBasic

Tue Apr 24, 2012 1:05 pm

rrmcbeth said:


If you really want kids to understand the 'why' and well as the 'how' of   programming teach them Assembler.   At DeVry U. (USA)  the first programming class (for the serious student) is PIC assembler.



I think it's difficult to strike a good balance - certianly for complete newbies - and we're probably taking pre-teen kids here. Based on my own experiences and that of watching and teaching other things (e.g. scuba diving), I feel you need to relatively quickly find out who's really interested and who's not - and for those who aren't don't make it so boring that they give-up and start to become disruptive. The people who're really into it will soon pickup new stuff anyway - I started BASIC on a few different systems, then learned 6502 assembler, then FORTRAN, Pascal, COBOL, C, more different assemblers (8080, Prime, PDP11) and ... who knows what else has leaked out of my mind.

Not sure PIC is the best though - I think the architecture is somewhat old and non-intuitive.. I'd probably pick something a bit nicer - e.g. sweet-16

I also suspect some kids will expect a *lot* - because they've been brought up with iDroidDevices and so on, but someone, somewhere has to write the code that puts every pixel of every icon on that screen, so ...

Gordon
--
Gordons projects: https://projects.drogon.net/

MadMan
Posts: 8
Joined: Mon Apr 23, 2012 11:47 am

Re: PiBasic

Wed Apr 25, 2012 9:03 am

Some very interesting comments - thanks to all concerned.

When I suggested this project I was not suggesting that an immediate "all things to all people" result was required.

Neither was I suggesting that we re-invent the wheel.

Rather, a project that even a newbie could use and that could grow to eventually become a very usefull utility.

As a starting point, it should run on the Pi. (and hopefully be included on the distro later)

So, lets take baby steps.

There should be 2 "windows", the development window which is essentially a code editor, and a "run" window which is where the code under development puts any screen output when it is run.

Now as to commands, first is "cls" [clear screen] which of course clears the screen.

Next is "echo" which puts something on the screen. Parameters: text [, x][, y][,color]

Simply puts the text on the screen optionally at position x, y using a color - there we have "Hello World" !

That was the very first "program" I wrote and it hooked me.

The next step would be to capture keyboard input.

And so it gets built.

In C you have to manually include various libraries at the start of the code which was a pain because I could never figure out which ones I needed and what their dependencies were - a total turn off !

So a suggestion would be that IF the first line of executable code is reached and there have been NO LIBRARY INCLUDE COMMANDS, all libraries stored in the libraries folder are automatically included.

This would have 2 distinct advantages:


The new user will not have their first coding attempt fail because of a "invalid command" error.
When new functionality is released (for example, a call to fetch something from a url) all that needs to be done is the new library has to be placed in the library folder, restart PiBasic and its available for use.

How this will work on a "nuts and bolts" level and which language would be used is something that I am not qualified to say - most people suggest Python - I have never used it myself.

Needless to say, it must be able to do the "Hello World" thing right out of the box so as not to intimidate and scare away anyone new.

Lastly, I realize that this forum is not ideally suited to host the discussions etc that will be needed to get a project like this up and going. So if there are enough people who are willing to be a part of it from the development point of view, I can set up a forum on one of my dormant domains that can be used.

Anyone interested?

User avatar
gordon@drogon.net
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: PiBasic

Wed Apr 25, 2012 10:41 am

MadMan said:


Some very interesting comments - thanks to all concerned.

When I suggested this project I was not suggesting that an immediate "all things to all people" result was required.

Neither was I suggesting that we re-invent the wheel.

Rather, a project that even a newbie could use and that could grow to eventually become a very usefull utility.

As a starting point, it should run on the Pi. (and hopefully be included on the distro later)


If you write it for Linux in-general, then it will run on the Pi. I developed my BASIC on an x86 Linux system and making it run on the Pi was just a matter of copying the sources over and typing 'make'.


So, lets take baby steps.

There should be 2 "windows", the development window which is essentially a code editor, and a "run" window which is where the code under development puts any screen output when it is run.

Now as to commands, first is "cls" [clear screen] which of course clears the screen.

Next is "echo" which puts something on the screen. Parameters: text [, x][, y][,color]


Traditionally BASIC uses PRINT (and doesn't have screen XY controls), however..


Simply puts the text on the screen optionally at position x, y using a color - there we have "Hello World" !


You've just added a level of complication to something that should be simple:

> PRINT "Hello World"

Hello World

If you want it in colour:

>TCOLOUR = Yellow

>PRINT "Hello in Yellow"

Hello in Yellow




That was the very first "program" I wrote and it hooked me.

The next step would be to capture keyboard input.


BASIC traditionally has INPUT, but newer ones have GET (single key), INKEY (test for keypressed) and some have others.


And so it gets built.

In C you have to manually include various libraries at the start of the code which was a pain because I could never figure out which ones I needed and what their dependencies were - a total turn off !


Write more C


So a suggestion would be that IF the first line of executable code is reached and there have been NO LIBRARY INCLUDE COMMANDS, all libraries stored in the libraries folder are automatically included.



This would have 2 distinct advantages:


The new user will not have their first coding attempt fail because of a "invalid command" error.
When new functionality is released (for example, a call to fetch something from a url) all that needs to be done is the new library has to be placed in the library folder, restart PiBasic and its available for use.

I don't think BASIC is big enough to warrant the effort. Just apt-get update for a new version... But if you really want to go down that route, it can be done without restarting a program..


How this will work on a "nuts and bolts" level and which language would be used is something that I am not qualified to say - most people suggest Python - I have never used it myself.


Your starting to describe something more like Python or PHP...


Needless to say, it must be able to do the "Hello World" thing right out of the box so as not to intimidate and scare away anyone new.


Its what BASIC is good at!


Lastly, I realize that this forum is not ideally suited to host the discussions etc that will be needed to get a project like this up and going. So if there are enough people who are willing to be a part of it from the development point of view, I can set up a forum on one of my dormant domains that can be used.

Anyone interested?


Not me, sorry. I have enough on my plate as it is and I'm happy with my BASIC. You originally wanted BASIC - I have a BASIC that runs under Linux (including the RPi), and there are many others - now you want to write your own... All I can suggest is good luck!

When I get some time (time!) I'll be putting up all the sources too, so feel free to hack it if you like.

Gordon

--
Gordons projects: https://projects.drogon.net/

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23981
Joined: Sat Jul 30, 2011 7:41 pm

Re: PiBasic

Wed Apr 25, 2012 11:41 am

rrmcbeth said:


Actually I started writing assembly code before there were nice assembler programs. Remember the S-100 bus, the 8080 and the RCA 1802 CPU?

However, that being said, how about a series of Python's that progress in complexity from something like the very simple 'basic like' commands progressing up to more complex programming with OOP and beyond.   Actually, don't you think it's all in the way the Instruction Manual is written?

If you really want kids to understand the 'why' and well as the 'how' of   programming teach them Assembler.   At DeVry U. (USA)  the first programming class (for the serious student) is PIC assembler.


I've said it before, but I totally disagree with this assembler thing being necessary to learning to program. To program (and debug) really well, a decent understanding of how computers work is required, but not much  assembler is needed, and certainly not in the early stages - that will just put people right off, esp. since assembler on modern CPU's is pretty damn incomprehensible compared with the 6502's and 8051's I grew up with.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

User avatar
morphy_richards
Posts: 1603
Joined: Mon Mar 05, 2012 3:26 pm
Location: Epping Forest
Contact: Website

Re: PiBasic

Wed Apr 25, 2012 12:01 pm

Perhaps cover briefly memory adresses and the commands

add

sub

mov

To illustrate the foundations of how and where pretty much every other conceivable function on a computer comes from..?

But you wouldnt need to go into huge detail, just enough to give students an overview of the basic mechanics of the stuff.?

rasbeer
Posts: 242
Joined: Wed Mar 07, 2012 8:35 am

Re: PiBasic

Wed Apr 25, 2012 12:41 pm

GordonH said:


I think it's the entry level thats harder. Although there is an interactive mode for Python you really need to learn an editor too, then switch between the editor and run-time.


I think this is right, and GordonH's basic is a great idea. But if the syntax was Python-like it would make the transition to 'full-Python' smoother. Perhaps implementing the 'type in your code and run' idea as an embedded interpreter (if that's the right phrase?) in a Python program that runs on startup would one the way to go.

User avatar
gordon@drogon.net
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: PiBasic

Wed Apr 25, 2012 1:17 pm

rasbeer said:


GordonH said:


I think it's the entry level thats harder. Although there is an interactive mode for Python you really need to learn an editor too, then switch between the editor and run-time.


I think this is right, and GordonH's basic is a great idea. But if the syntax was Python-like it would make the transition to 'full-Python' smoother.


That assumes that Python is the ultimate goal...

... So what I think we should aim for is to get people interested in programming, not teach programming in one particular language - else we're in danger of vanishing down the Pascal/Modula2 route of 25 years ago... But once people are interested in programming then we can show them different systems and languages without imposing our own preferences on them - e.g. I have absolutely no desire to write a Python program (or anything involving OO) - ever. It's of no use to me whatsoever, but I won't stop anyone else learning it, but I'd hope that alternatives will be presented.

I was taught COBOL at uny - however I struggled with it - until I actually bothered to read the book, when I realised what I was being taught wasn't COBOL, but one particular persons interpretation of COBOL and I resented him forever after that. (& haven't written a COBOL program since)

Gordon

(Actually, I have written one Python program - an implementation of the Ackermann function to test recursion and benchmark my BASIC. Python is marginally faster, but I put that down to it being a much better compiler than my BASIC tokeniser is)
--
Gordons projects: https://projects.drogon.net/

rasbeer
Posts: 242
Joined: Wed Mar 07, 2012 8:35 am

Re: PiBasic

Wed Apr 25, 2012 1:22 pm

GordonH said:


That assumes that Python is the ultimate goal…


Or that a lot of other educational stuff for the RasPi will be Python-based, which is looking quite likely…

An old-school-style Pythonic environment would just push down the age kids can start getting access to it. Which might let them do more interesting stuff earlier.

Introducing multiple languages certainly makes sense at some point, but done too early it might be confusing/discouraging. And starting with Basic, with line numbering etc, before going to Python might be doing just that.

(All this said, I'm not an educationalist, & it's worth seeing what kids of different ages can handle...)

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23981
Joined: Sat Jul 30, 2011 7:41 pm

Re: PiBasic

Wed Apr 25, 2012 1:39 pm

I'd seriously recommend that people arguing about which language/how to make things easy, look at Scratch. Works on the Raspi well enough to be quite usable, and gets away from a particular programming language to something entirely graphical, but that still contain all the programming structures needed.  In some cases, I personally think it makes things too easy, but that's perhaps just me.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I think it’s wrong that only one company makes the game Monopoly.” – Steven Wright

MadMan
Posts: 8
Joined: Mon Apr 23, 2012 11:47 am

Re: PiBasic

Wed Apr 25, 2012 3:01 pm

Hold on guys - Did not mean to start a war.

Gordon: Your BASIC project - did not realize how far down the road you were - this may well be the core of what is needed. Your blog does not go into much detail and I was under the impression that it was a "barely off the notepad" project - sorry about that !

One question: Is it at the point where it can load and run a set of commands from an external file yet?

Python: I see that there is a windows version - I'll have to have a go at that! (Yes, I have to use windows because I need to see what my site development looks like in Internet Explorer [aka crappybrowser] and then dumb it down so that it looks ok)

From that you will realize that my primary programming language is PHP and no, I do not think I will be "converting" to C any time soon - too close to retirement ;>}

Whatever the "newbie" starter app eventually winds up being, I dare say that it (or maybe they) will have to have all sorts of extras written to enable them to use everything that the Pi has available as far as on board hardware is concerned, never mind anything you may want to plug into a USB port or connect to the GPIO pin set.

But maybe this thread will inspire someone to co crazy and write a development/educational utility that is easy to use.

I also admit that for anything that will run on a Pi is concerned, I WILL be a newbie.

Cannot wait until I get my own Pi ! ! ! - Got a robot project that has been waiting for some brains (tried using PIC's - all I got was some very expensive blue smoke - a whole bunch of times)

And also a CNC mill which I built using slide hardware from some architects drawing boards and steppers from industrial strength printers.

Both projects have been packed away in the workshop far too long. Time to dust at least one of them off.

User avatar
jbeale
Posts: 3500
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: PiBasic

Wed Apr 25, 2012 3:11 pm


Got a robot project that has been waiting for some brains (tried using PIC's – all I got was some very expensive blue smoke – a whole bunch of times)


I suppose it's worth noting that if your connections actually burned up your PICs (which are generally 5V tolerant) you are even more likely to burn up the Raspberry Pi (not 5V tolerant) in the same situation. Unless you use a separate USB interface module with protected inputs, for example.

MadMan
Posts: 8
Joined: Mon Apr 23, 2012 11:47 am

Re: PiBasic

Wed Apr 25, 2012 3:16 pm

JamesH said:


I'd seriously recommend that people arguing about which language/how to make things easy, look at Scratch. Works on the Raspi well enough to be quite usable, and gets away from a particular programming language to something entirely graphical, but that still contain all the programming structures needed.  In some cases, I personally think it makes things too easy, but that's perhaps just me.



Looks like it has quite a WOW factor and would certainly be appealing to younger people.

And when they decide to take the next step and start getting into hardcore programming that can do things in the physical world as opposed to on a screen, that is where a slip may occur which drives these young minds away.

That is what we need to address here. Get something to let them have a pleasant crossover experience.

User avatar
gordon@drogon.net
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: PiBasic

Wed Apr 25, 2012 3:23 pm

MadMan said:


Hold on guys - Did not mean to start a war.


No issues!


Gordon: Your BASIC project - did not realize how far down the road you were - this may well be the core of what is needed. Your blog does not go into much detail and I was under the impression that it was a "barely off the notepad" project - sorry about that !

One question: Is it at the point where it can load and run a set of commands from an external file yet?


Yes. You can even run a BASIC program using the "shebang" mechanism - I've actually started to use it to write some trivial little scripts in - the things I'd use PHP for at the command line - more as a proof of concept than anything else. (I've even used it as a back-end CGI script to a web server - again, proof of concept)

Right now it's a fully functional BASIC with long variable names, named procedures & functions with local variables which can be called recusively. IT support multi dimension arrays with both numeric and string indexing (ie. associative arrays) serial port handling is in there too. It does not need line numbers but currently you need to use an external editor. It does give a program line numbers when loaded though - but they start from 1 and go up by 1 which means that if your BASIC program fails you get to know the right line number.. Obviously with no line numbers you can't use GOTO or GOSUB! So there are new looping constructs - actually there is just one looping construct CYCLE...REPEAT and you can modify this with while/until at the top of bottom, or with the FOR construct... It even supports a switch type of construct too. Have a look at http://unicorn.drogon.net/rtb/spiral.rtb for an example.

But your right about the blog - I'm transitioning from an old location to the new one - and there are only 24 hours in the day )-:


Python: I see that there is a windows version - I'll have to have a go at that! (Yes, I have to use windows because I need to see what my site development looks like in Internet Explorer [aka crappybrowser] and then dumb it down so that it looks ok)


If you can run Linux, then there is a binary here: http://unicorn.drogon.net/rtb/ along with a very preliminary manual thing. I'll update that tonight when I get home though, it's a little out of date.


From that you will realize that my primary programming language is PHP and no, I do not think I will be "converting" to C any time soon - too close to retirement ;>}


I treat PHP as lazy/sloppy C... So I use PHP a lot and not just for web/cgi type of stuff, but for command-line stuff... All my business billing code is in written in PHP... However going from PHP to C is relatively straightforward - especially if you don't do much OO stuff in PHP. At least you know where to put {}'s and semicolons...


Whatever the "newbie" starter app eventually winds up being, I dare say that it (or maybe they) will have to have all sorts of extras written to enable them to use everything that the Pi has available as far as on board hardware is concerned, never mind anything you may want to plug into a USB port or connect to the GPIO pin set.


Well.. I added a bit more to the serial port support and came up with DRC - A very simple remote control protocol which emulates the Ardunio "wiring" librarys - so with the DRC program in an arduino, I can control pins, etc. from a BASIC program on the RPi.


But maybe this thread will inspire someone to co crazy and write a development/educational utility that is easy to use.

I also admit that for anything that will run on a Pi is concerned, I WILL be a newbie.

Cannot wait until I get my own Pi ! ! ! - Got a robot project that has been waiting for some brains (tried using PIC's - all I got was some very expensive blue smoke - a whole bunch of times)


Start with Linux - Look at the Debian website - they have Live CDs so you can start to get to grip with Linux on any existing PC.


And also a CNC mill which I built using slide hardware from some architects drawing boards and steppers from industrial strength printers.

Both projects have been packed away in the workshop far too long. Time to dust at least one of them off.


Do it! My family background is mechanical engineering so I know all that stuff too.

Gordon
--
Gordons projects: https://projects.drogon.net/

MadMan
Posts: 8
Joined: Mon Apr 23, 2012 11:47 am

Re: PiBasic

Wed Apr 25, 2012 3:31 pm

jbeale said:


I suppose it's worth noting that if your connections actually burned up your PICs (which are generally 5V tolerant) you are even more likely to burn up the Raspberry Pi (not 5V tolerant) in the same situation. Unless you use a separate USB interface module with protected inputs, for example.



;>}

Tried making a board - soldered all the components on, hooked it up, SMOKE

Tried buying a board - soldered all the components on, hooked it up, SMOKE

Loop 3 times then give up - too expensive!

I can turn just about anything on my lathe, mill just about anything (except helical gears) on my mill but put a soldering iron in my hand and there is going to be trouble!

MadMan
Posts: 8
Joined: Mon Apr 23, 2012 11:47 am

Re: PiBasic

Wed Apr 25, 2012 4:12 pm

Hi Gordon

Don't know what "shebang" is - sorry.

If it already supports associative arrays, getting it to retrieve data from MySQL should not be too hard (he says with a smile!)

I have not done basic since about 1996 but the code you linked to made sense first glance. Guess that once you learn something, you never actually "unlearn" it.

Know what you mean as far as your blog is concerned - mine fell over and I have not had the courage to go in and fix it - will probably mean that I rewrite the code - major mission but...

I do have Ubuntu on a virtual machine but windows does not like it at all - when I run the Ubuntu VM, the whole machine freezes when I go from the Ubuntu VM to the XP "host" - very annoying - strange though because I have my email in an XP VM, Skype in a second and my web radio in a third and I can run all of them without any problem.

As to OO, I use classes extensively in PHP - saves me a lot of time when I can simply upload a file and use it "out of the box" and do not have to debug anything because it has been working reliably for 2 years or more.

I do not know anything about "arduino" except that some people absolutely love it. As I said, I got involved (and burned) with PIC and then gave up.

But it is good news that your basic can access the GPIO pins - if it can detect a state change on a pin, then it can detect whether a limit switch has been triggered which can then send the program off in another direction. EXACTLY what I need in my robot for detecting bumping into obstacles.

Love that you have got a "SWITCH" in there - hate nested if's always become very messy and hard to modify/debug - Good one!

Think I'm going to scratch the bot out of the workshop over the week end (if the missus has not thrown it away on one of her "lets get rid of some junk" sprees)

Will probably need new NiCads - even if my grandsons have not "borrowed" them for their RC cars ;>}

Mmmm.. Wonder when my Pi is going to arrive!

User avatar
gordon@drogon.net
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: PiBasic

Wed Apr 25, 2012 4:21 pm

MadMan said:


Hi Gordon

Don't know what "shebang" is - sorry.


It's a way of making a text/script "program" executable in the unix world. You put

#!/usr/bin/rtb

(or whatever) at the top of the file. The #! is nicknamed shebang..


If it already supports associative arrays, getting it to retrieve data from MySQL should not be too hard (he says with a smile!)


Well - It's to support sqLite, but yes the principle is there.


I have not done basic since about 1996 but the code you linked to made sense first glance. Guess that once you learn something, you never actually "unlearn" it.


I think the same goes for most procedural programming languages - while I don't code in Python, I can read it without too much issues, same for others of that ilk.


Know what you mean as far as your blog is concerned - mine fell over and I have not had the courage to go in and fix it - will probably mean that I rewrite the code - major mission but...

I do have Ubuntu on a virtual machine but windows does not like it at all - when I run the Ubuntu VM, the whole machine freezes when I go from the Ubuntu VM to the XP "host" - very annoying - strange though because I have my email in an XP VM, Skype in a second and my web radio in a third and I can run all of them without any problem.

As to OO, I use classes extensively in PHP - saves me a lot of time when I can simply upload a file and use it "out of the box" and do not have to debug anything because it has been working reliably for 2 years or more.

I do not know anything about "arduino" except that some people absolutely love it. As I said, I got involved (and burned) with PIC and then gave up.


There's a lot of stuff out there that's almost plug and play for the Arduino - including motor drivers and so on.


But it is good news that your basic can access the GPIO pins - if it can detect a state change on a pin, then it can detect whether a limit switch has been triggered which can then send the program off in another direction. EXACTLY what I need in my robot for detecting bumping into obstacles.


Just remember that Linux is not the same as an embedded real-time operating system - it's a multi-user, multi-tasking operating system, and as such it could be doing something else at that vital instant in time - so while you can concoct hardware to latch the state of the switch, if the CPU is busy doing something else, it might be too late before your program sees it. Probably not an issue for a slow floor crawling robot, but a big issue for something a bit more demanding - like stopping the toolpost on a lathe crashing into the chuck for example...


Love that you have got a "SWITCH" in there - hate nested if's always become very messy and hard to modify/debug - Good one!

Think I'm going to scratch the bot out of the workshop over the week end (if the missus has not thrown it away on one of her "lets get rid of some junk" sprees)

Will probably need new NiCads - even if my grandsons have not "borrowed" them for their RC cars ;>}

Mmmm.. Wonder when my Pi is going to arrive!


Soon, soon!!! Hang in there... There'll be a glut of them soon and everyone will have one..

Gordon
--
Gordons projects: https://projects.drogon.net/

MadMan
Posts: 8
Joined: Mon Apr 23, 2012 11:47 am

Re: PiBasic

Thu Apr 26, 2012 7:36 am

OK everyone - laugh at me BUT

Installed Python

Maybe I have been doing PHP too long but it is not quite as intuitive as I would have liked - maybe the light will come on with some use.

For my robot controller the actual "thinking" code should not be too hard to do.

Then of course getting it to "talk" to the GPIO pins as required would be easy judging from what others have said. All I need to do there is BUY some h-bridges and connect them up to the motors and connect the micro switches using opto isolators.

I have had a look through the help document supplied with the install but the only "cls" (clear screen) equivalent I found was in the turtle module.

Also, there does not seem to be a way to position a string at a defined place on the screen.

I normally like to have a screen where I can monitor what is going on where - for example, the robot controller would have displays for which motors are on, what direction, when the last trigger on each sensor was detected, the actual run clock and such.

Don't they exist outside the turtle module or am I just not looking for the correct command - if so, what should I be looking for?

GordonH's basic is really starting to look very good if these sorts of commands are not "native" - he must have developed them ;>}

Anyway, have a good day everyone.

Return to “Staffroom, classroom and projects”