Why do PICAXE need interpreters?

Hi guys!
I've read many times that the Picaxe is no more than a PIC with an on-board interpreter that makes BASIC language work on a PIC. But why do they need an intrepreter? Wouldn't it be easier to get BASIC language and compile it to machine code and then put it on the PIC (as far as i know this would make the chip interpreter-free and thus faster)?
 

BeanieBots

Moderator
You can do that if you wish.
First you will need to need to purchase a compiler.
Then you will need to purchase a programmer.
Write your program.
Compile it.
Download to your programmer.
Program your PIC.
Fit your PIC into your board.

OR, you could program your PICAXE in situ for FREE with no more than a download cable and two resistors to worry about.
Your choice.
 

Dippy

Moderator
Absolutely. This has been covered a dozen times before.

AND I can assure you that writing, using any compiled language (even BASIC), is far more complicated than PICAXE BASIC.
PICAXE BASIC does a lot for you that you don't know about.

AND you will also need a good working knowledge of PICs and be able to read/absorb/understand multi-hundred page PIC Data Sheets.

AND there are differences between PICs which you will have to understand.

AND you won't get the rapid, (usually) friendly and detailed help on any other Forum. Questions deemed as 'numpty' by PIC Forum users usually get a pretty 'abrupt' answer - usually starting with 'You should really read the Data Sheet'.

Do you know how to set config fuses? Do you know how to set up the PIC's ADC and get a reading? Do you know your TRIS from your ANSEL?

Yes, you could write code that runs 100x faster but it'll take the novice 100x longer to write it.

As BB says "Your choice".

Good luck , but if you struggle with PICAXE BASIC then you will go cross-eyes with compilers :)
 
No no, i didn't mean to say that i wanted to switch to using compiled language.

I just wanted to ask you: why have the guys that made the PICAXE have put in an on-board interpreter, instead of having a program, that understands picaxe basic, convert it machine language?
 

Mycroft2152

Senior Member
No no, i didn't mean to say that i wanted to switch to using compiled language.

I just wanted to ask you: why have the guys that made the PICAXE have put in an on-board interpreter, instead of having a program, that understands picaxe basic, convert it machine language?
Captain Tuna,

Back when, it was part of the original business plan, to pay for the interpreter one chip at a time than to buy the interpreter separately.

Today there are a number of micros that offer free interpreters.
 

Dippy

Moderator
"I just wanted to ask you: why have the guys that made the PICAXE have put in an on-board interpreter, instead of having a program, that understands picaxe basic, convert it machine language?"

If you just 'convert it to machine language' you still have to get it onto the PIC.
For that you need either a Hardware programmer or the PIC to be peloaded with a booloader.
Your 'average' bootloader requires a MAX232 or transistor inverter circuit.
... maybe a compiler and special bootloader for easier programming, I really don't know.
I shoudn't worry about it, it's a sunny day ... :)
 
Sure you need a programmer, but wouldn't the chip be faster? And you wouldn't need to know how to write in assembly or other complex stuff.
 

Tim036

Member
Hi guys!
I've read many times that the Picaxe is no more than a PIC with an on-board interpreter that makes BASIC language work on a PIC. But why do they need an intrepreter? Wouldn't it be easier to get BASIC language and compile it to machine code and then put it on the PIC (as far as i know this would make the chip interpreter-free and thus faster)?
I have used both.

The really BIG difference is 'Maintainability' and 'Simplicity'.

Meeting assembler a couple of years after its been written can be a nightmare !

Ease of use means you can be up and running from a cold start very very quickly when

a) you first write the programme

b) Maintain it a year or two down the line.

Basic compilers fall into two types - cheap and horrendous or good and expensive (very).

This system has an excellent and well supported Basic and ideal for Maintainability. As very good value for money !

And this Forum !

Time for me is a big consideration and if this system halves the time spent getting a working solution then its Mega winner !

:D

Tim
 
Last edited:

Lez T

Member
Older Newbies

There are also 'older' people like me who has a slight working knowledge of basic ( from z80 days ) who stayed away fron PICs because of the nightmare of programming. I understand what you are saying but this system has allowed me to create a circuit, write the code and build what I want in 4 weeks, I had never even held a PIC before I joined this forum ( I did know what they were ) but always built what I needed from 12v using relays, timers and the occasional transistor. I wouldn't have dreamed of touching a PIC let alone understand interrupts etc. I have to raise my hat to the picaxe developers and especially this forum, which is so down to earth that I didn't feel like like a complete numpty ( note the word complete ) and was comfortable asking questions and received excellent guidance, rather than just answers which would have taught me nothing. Please consider this as a whole package not just the how its done, it has been very well thought out.
ps the moderators are good as well ( better say that, otherwise I'll be in the sh*te )
 
...thanks for the answers
but i'm afraid i haven't made myself clear. I don't want to say that i don't like picaxe, i love it as much as you do! I only want to understand the reasons behind this choice, but i like the picaxe as it is now!
:)
 

Jeremy Leach

Senior Member
There is also the point that interpreted code is actually pretty compact in terms of bytes. Yes there IS the overhead of the interpreter code, but I believe from previous threads that compiled code could well require more code space on the pic for more complex programs than interpreted.

It's all a bit complex though with lots of factors to take into account.
 

SilentScreamer

Senior Member
Another point, if lets say you make it so that you can program a PICAXE onto a blank PIC using a programmer and free software, where exactly do rev-ed make money? At the end of the day they are a commercial company with the aim to make a profit.
 

Tim036

Member
...thanks for the answers
but i'm afraid i haven't made myself clear. I don't want to say that i don't like picaxe, i love it as much as you do! I only want to understand the reasons behind this choice, but i like the picaxe as it is now!
:)
Lets say there are 5 reasons :-

Time

Time

Time

Time

and

Time.
 

Wrenow

Senior Member
...thanks for the answers
but i'm afraid i haven't made myself clear. I don't want to say that i don't like picaxe, i love it as much as you do! I only want to understand the reasons behind this choice, but i like the picaxe as it is now!
:)
It seems to me that it has been answered repeatedly. But let me try another tack.

The raw pics do not have a bootloader, so you cannot program them with something as simple as the Picaxe download cable without first burning a bootloader onto it - you have to have a programmer (and these cost $$) to put code into them.

The Picaxe has this capability burned in. And, while they did this, thay also made it easier for the coding you are doing to run across the chip line with minimal coding changes.

Cheers,

Wreno
 
Last edited:

womai

Senior Member
I'm afraid two unrelated things get mixed up here:

- bootloader

- on-chip interpreter

For all larger Picaxes (which can self-write their program memory) it would be perfectly possible to have just the bootloader, but have it download compiled assembler code instead of tokenized Basic code that need to be interpreted. Nothing says you couldn't keep the simple Picaxe Basic syntax for the source code, and have the compiler auto-generate the code for all high-level functions (just include the appropriate libararies behind the scene).

And pressing the "Program" button in the Programming Editor already executes a conversion (ASCII source code to tokenized code) in the current setup - how is this conceptionally different from compiling? (it really isn't).

As far as code space is concerned, good compilers don't include any functions that aren't actually used, while the Picaxe always has its FULL interpreter, hogging space even when you only use 20% of the available functions.

At the same time Rev-Ed could have some sort of key or encryption to make sure the code their hypothetical compiler produces can only be downloaded to Picaxes that have their bootloader installed. That leaves their business model intact (Compiler is free but you need to buy the chips from them).

Here is my theory where this "on-chip interpreter" concept comes from initially (and Rev-Ed can correct me if my guess is wrong): First, this is how the Basic Stamp works (albeit with an external EEPROM for program storage), and initially the Picaxes were simply intended as less-costly Stamp replacements for the educational market. Second, the smaller PICs (on which the 08 series is based, and I think this also goes the the 18A and 28A) cannot self-write their program memory, so you can't have a bootloader that downloads a new assembler program. Instead they need to use the internal data EEPROM for program storage, while the program memory holds the Basic interpreter (which never changes).

Wolfgang
 
Last edited:

BeanieBots

Moderator
Wolfgang's explanation of 'program' and 'data' memory is also my understanding.
Although the interpreter is 'complete' even if parts are not used, it resides in different memory and so does not impact on available space for user programs.
Also, by using a 'tokenised' language, more 'program' can be squeezed into the limited 'user' area of the data memory.
 

vttom

Senior Member
Perhaps we can appeal to Rev-Ed to come up with an alternative business model....

For instance, I love the simplicity and ease with which I can use the PICAXE in its current form. But sometimes I do feel the need for speed.

What if Rev-Ed offered a PICAXE BASIC->PIC Machine Code compiler for a licensing fee (1-time or annual)? There are many of us who would be willing to purchase the compiler in order to use it with off-the-shelf PIC micros.

Think PICAXE BASIC w/ in-built interpeter as an "amature" or "prototype" offering, and the PICAXE BASIC -> PIC Machine Code compiler as a "professional" or "production" offering.
 

SilentScreamer

Senior Member
The problem is that makes piracy easy, no matter what you do to software it is always hackable as a result of the nature of computers. I do not know of any mainstream software that remains unhacked many of which have far higher antipiracy budgets than Rev-Ed (Adobe and Microsoft for example). A PIC's built in protection can't be hacked easily (though it could probably be done if someone with the knowledge and time really tried).

Also there are a lot of existing compilers, PICAXE has a fairly exclusive niche in the market with only a small number of competitors.
 

Andrew Cowan

Senior Member
What if Rev-Ed offered a PICAXE BASIC->PIC Machine Code compiler for a licensing fee (1-time or annual)? There are many of us who would be willing to purchase the compiler in order to use it with off-the-shelf PIC micros.
Go Tools/Convert Basic to Assembler

This lets you download basic into a raw PIC, at full PIC speed. You must use the BAS800 serial programmer.

A
 

BeanieBots

Moderator
Good point SS.
There are MANY commands available in PICAXE basic which are not supported by the BAS800/compiler. Check carefully before you consider getting one.
 

SilentScreamer

Senior Member
Can the BAS800 be used to program PIC's with hex files from other compilers ? I keep considering getting one, when I have the time :p
 

Andrew Cowan

Senior Member
Yes.

An interesting point, is that I have a serial PIC programmer from another Economatics. However, it is the same PCB, and PE recognises it as a BAS800.

A
 
The absence of serout is a major drawback! But the idea of using the option that converts to assembler is cool. Maybe we could come up with a bit-banged version of the serout (lows, highs and pauses)?
 

Andrew Cowan

Senior Member
If you want to do high speed work; programming editor and PICAXE isn't the way to go. But for everything else, it is amazingly good. However, serout is available.

A
 
Last edited:

womai

Senior Member
Offering a compiler to program raw PICs would break Rev-Ed's business model, and it's correct to say they'd be playing in an area with lots of competition if they did it. Also you'll need extra hardware (a programmer to do it). That's why if asked I'd suggest the approach with keeping some form of bootloader (with encryption) but downloading compiled code, at least for the larger Picaxes. Fast speed but same business model.

Otherwise I see a lot of advantages with Rev-Ed's business model for beginners / students. Just compare the minimum cost to get started:

1 pc. Picaxe $2 - $12 depending on type
Download hardware ~$5 (serial cable and resistors), super-easy to build

With a compiler you need:

Compiler ~$100 (although many code-size limited free demos versions available)
1 pc PIC $1 - $5 depending on type
Programmer $10 - $100 depending if you want to spend more money on a ready-made piece, or a lot of time (+ frustration for a beginner) to build your own.

On top of that, the Picaxes IS easier to get started with than any compiler or programmer I came across so far. Especially since the programs stay virtually unchanged when moving from one Picaxe to another (e.g. 08M to 28X1), which is not the case with raw Pics - anybody tried to access the ADC on two different Pics just to find out that the setup registers are named differently and work very differently...

Wolfgang
 

demonicpicaxeguy

Senior Member
Offering a compiler to program raw PICs would break Rev-Ed's business model, and it's correct to say they'd be playing in an area with lots of competition if they did it. Also you'll need extra hardware (a programmer to do it). That's why if asked I'd suggest the approach with keeping some form of bootloader (with encryption) but downloading compiled code, at least for the larger Picaxes. Fast speed but same business model.

Otherwise I see a lot of advantages with Rev-Ed's business model for beginners / students. Just compare the minimum cost to get started:

1 pc. Picaxe $2 - $12 depending on type
Download hardware ~$5 (serial cable and resistors), super-easy to build

With a compiler you need:

Compiler ~$100 (although many code-size limited free demos versions available)
1 pc PIC $1 - $5 depending on type
Programmer $10 - $100 depending if you want to spend more money on a ready-made piece, or a lot of time (+ frustration for a beginner) to build your own.

On top of that, the Picaxes IS easier to get started with than any compiler or programmer I came across so far. Especially since the programs stay virtually unchanged when moving from one Picaxe to another (e.g. 08M to 28X1), which is not the case with raw Pics - anybody tried to access the ADC on two different Pics just to find out that the setup registers are named differently and work very differently...

Wolfgang

i'd recommend the pickit3 as a programmer - at $69.99USD
or if you're little lower on funds the pickit2 - at $34.99USD
and they will both program the entire pic range

i'd like to know why people insist on these diy serial programmers? which are usaully quite slow and in some cases error prone and usaully only support a handfull of pics and in alot of cases end up costing more than the pickit2...

as for a compiler - here''s a debate that can go on forever,

but honestly you don't need one if your willing to give the pic assembly language a chance it's very very easy to learn and only gets easier as you go up the pic range, a good starting ground is the 18f range

one thing that baffles me is the whole C language cult following, the amount if times i've seen somone say "i'd never attempt to write anything for the pic18f range and above in assembly, it's just to darn compilcated"
yet the same people will whip out code and a "help me my code's not working" request in another thread and usaully th problem turns out to be somthing simple like a missing symbol or a spelling mistake or a misplaced bracket....... usaully a simple mistake or error you'd spot within 1/2 a second if you were using assembly or basic,..... most of these people would be completely stumped by the below on a pic16fXXX

clrf trisb
movlw 0xff
movwf portb

contrary to popular belief it's actaully quite easy to take one asm program from one pic and have it successfully execute on another, even across different ranges, in some cases it makes the code smaller and quicker,

on a pic18fXXX it could be converted to


clrf trisb
setf portb

but would still work the otherway
 

womai

Senior Member
Regarding that C-cult (which I am part of :) I do know some assembler, but never got to like it (except for VERY limited code portions where I need absolute control).

Try to learn assembler programming on a PIC and then move to a 8051 or AVR or some other platform - and start from scratch... (especially when moving from a RISC architecture to a CISC architecture or vice versa).

With C it's the same language, same syntax, etc. C allows me to program a microcontroller much the same way I do on the PC.

Most decent compilers also come with good libraries; e.g. doing an ADC acquisition is

unsigned my_val;
my_val = adc_read (0);

(plus one line to set the appropriate pin as analog). Try to do this in assembler and you're looking at a page of cryptic code.

Try do keep your program modular (and thus much easier to maintain) in assembler - a nightmare. Same is easy in C, since there are functions, local variables, etc.

IMHO assembler was a decent fit for small devices, but with the increase in computing power and memory even on 8-bit microcontrollers that's losing its appeal. From my own experience any good C compiler produces code that is pretty close in speed and compactness to the same program in assembler (and faster and smaller if you're not a good assembler programmer).

Others may (and will) disagree, but I certainly know what I dislike about assembler and why. Wouldn't touch it with a long stick for anything longer than a few lines of code. (Ok, the flame war is on :)

Wolfgang
 

Tim036

Member
Regarding that C-cult (which I am part of :) I do know some assembler, but never got to like it (except for VERY limited code portions where I need absolute control).

Try to learn assembler programming on a PIC and then move to a 8051 or AVR or some other platform - and start from scratch... (especially when moving from a RISC architecture to a CISC architecture or vice versa).

With C it's the same language, same syntax, etc. C allows me to program a microcontroller much the same way I do on the PC.

Most decent compilers also come with good libraries; e.g. doing an ADC acquisition is

unsigned my_val;
my_val = adc_read (0);

(plus one line to set the appropriate pin as analog). Try to do this in assembler and you're looking at a page of cryptic code.

Try do keep your program modular (and thus much easier to maintain) in assembler - a nightmare. Same is easy in C, since there are functions, local variables, etc.

IMHO assembler was a decent fit for small devices, but with the increase in computing power and memory even on 8-bit microcontrollers that's losing its appeal. From my own experience any good C compiler produces code that is pretty close in speed and compactness to the same program in assembler (and faster and smaller if you're not a good assembler programmer).

Others may (and will) disagree, but I certainly know what I dislike about assembler and why. Wouldn't touch it with a long stick for anything longer than a few lines of code. (Ok, the flame war is on :)

Wolfgang
I go along with Wolfgang there !

We used only to write in assembler (Mid 1980s) but when 'C' compiler came along which 'optimised' the code, it produced faster code than our very good and experienced Assembler programmers did !

Mega Gulp round the Coffee mugs as we didn't believe the results. But they were true and so we switched to 'C'.

I understand why 'C' is good but I was not a programmer and quite happy not to write and code in that language. Pascal made more sense to me.

However dire, if you do enough of it any low level or the arcane syntax of 'C' or similar can get to be second nature. The major hazzard was bugs in the compilers - there are usually a few on new releases ! *LOL*

:):):)

Tim
 

Dippy

Moderator
Lordy, here we go again!

People have prefererences how they code.
To write a dirty great prog from scratch in ASM would be a nightmare unless A) You are fluent, B) You need absolute efficiency assuming you are fluent and C) The customer is rich and patient.
So, most people cut'n'paste routines and blocks.

So along comes someone and writes a compiler and saves you time.

Wolfie is abs nail-on-head. Libraries.
Some compilers have open libraries so you can modify them to suit. Or, for greater efficiency, whip out the routine and plonk it your own code.
Some compilers allow insertion of ASM for crucial sections.

Anyway , you Neptunes (C Gods) carry on ;)
 

boriz

Senior Member
ASM is the perfect programming language. It connects the mind with the hardware in a way that no other language can. I honestly spent many joyful hours as a teenager tweaking 6502 ASM, squeezing the best from the CPU logic. It was fun. Even if the program never got finished :) It is also THE BEST way to get the most speed from any processor.

But horses for courses. BASIC and other high level languages are a useful short-cut. You can do in BASIC in five minutes what it would take an hour to do in ASM.

If you are an engineer type, who likes to tinker, with no limits on time, and you enjoy the act of programming for it’s own sake, then you will find ASM very rewarding.

If, however, you just want to get the job done, then high level is the way to go, even if you can program in ASM.
 

leftyretro

New Member
Old subject that gets brought up every so often. There are no perfect answers for everyone, the best one can hope for is to have more choices.

While I still have my Picaxes avalible, (I really like using the 08M for simple applications) I have mostly moved on to the Arduino open source system which is comprised of a open sourced IDE. It uses a open sourced bootloader to program the several AVR processor chips, up to 128k program space now, but gives you the option to burn a compiled program using a ISP hardware programmer if you want. The open source AVR- GCC C/C++ compiler is a mature compiler with all the standard libraries available plus there are a ton of Arduino user contributive library routines available. The Arduino hardware is also open sourced and there are many 3rd part vendors selling systems and one can start with as little as $20-30 for a fully functional board. You can buy an AVR processor chip with an Arduino bootloader installed for as little as $6.50. Also this system is avalible to run on either Windows, Linux or Apple systems.

So if you can stand using a free fully optimized C/C++ language there is a low cost powerful system available called the Arduino. So there are choices available now, I still like and use the Picaxe system some but I like having the ability to use the Arduino for applications requiring more speed and programming space also. The key to both these useful systems is the low entry costs to get started and great user forums for getting help.

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl

Lefty
 
Last edited:

212

Senior Member
Phooey on that Arduino...not only is it inappropriate to advertise for them on this PICAXE forum, they are not near as good as far as I'm concerned. Where I hang out most of the time, I started a "programming" section on the forums. Arduino has been discussed there too, and for the things we do with Picaxe, the Arduino would be a sad sack. There are a couple dozen of us old dogs learning programming, and there is nothing that compares to a Picaxe for our use :)

So I speak for all the old dogs over there when I say THANKS!
 

Dippy

Moderator
I prefer the Crayodinio.
It is fast, cheap, programmed in a simple language called Georgembler - and it sounds like a Brazillian footballer.
 

manie

Senior Member
To put it simply. A year and a half ago I knew ZILCH/ZERO/NADA with respect to micro-controllers etc. Then a need developed and I had to get something going. I googled here, I googgled there, I googled...., you get the picture. I spent DAYS on the Microchip site trying to make sense of HUNDREDS of Pics and compilers and programmers and.... you get the picture. I then happened (by sheer chance/luck) onto the Picaxe web site. WHAT BLISS ! It was written for idiots like me, in PLAIN ENGLISH ! I could download the manuals even BEFORE buying a single CHIP ! It was clear what you needed to get going, it was not covered in "sounds important" mnemonics and garbage. It said plainly "If you want to do this(or that), this is what you must get...". I bought 4 (YES FOUR !) 28x1 project boards, because you don't need much more to get a project really WELL on its way. Sure ! There were LOTS of questions immediately. But you know what ? I had TWO projects up and running, reading battery voltages, reading Hall Effect for current, reading switches (high/low) BEFORE I EVEN JOINED THIS FORUM !

That is why Rev-Ed have Picaxes with interpreters............ good enough ?
 

kevrus

New Member
I,m with Manie on this one...having tried assembler and struggled with simple niterider lights.
Bieng someone who has NO programming knowledge of any sort, the picaxe system has allowed me to actually complete some useful (to me) projects...and long may it continue to do so
 

Mycroft2152

Senior Member
I'm with Retrolefty on this one.

Calling yourself a "programmer" after using a PICAXE is the about same as someone calling themselves a "chef" after thawing a couple of frozen dinners.

If you are serious or have more than "KISS" level projects, you will spend the time and effort to learn a real programming language. Just go out looking for a job and tell them "i'm a programmer of PICAXEs" and they will politely show you the door.

Don't get me wrong, there is a place for junk food and PICAXES, but you can't live off them.

Let's keep it in perspective. the PICAXE is a handy little device but not the be-all, do-all, greatest thing since sliced bread.
 

212

Senior Member
Perspective, yes, the Picaxe lets people that are NOT programmers, and may never be, do some simple programs...fast and easy...and low power too. In my world (the world of old dummies) it IS greatest thing since sliced bread... I do prefer homemade bread though :)
 

demonicpicaxeguy

Senior Member
I'm with Retrolefty on this one.

Calling yourself a "programmer" after using a PICAXE is the about same as someone calling themselves a "chef" after thawing a couple of frozen dinners.

If you are serious or have more than "KISS" level projects, you will spend the time and effort to learn a real programming language. Just go out looking for a job and tell them "i'm a programmer of PICAXEs" and they will politely show you the door.

Don't get me wrong, there is a place for junk food and PICAXES, but you can't live off them.

Let's keep it in perspective. the PICAXE is a handy little device but not the be-all, do-all, greatest thing since sliced bread.
these days unfortunatly getting a job as a programmer, isn't easy if you don't like the much favoured C , one interview i'll never forget was with a small company that does access control solutions for things like forklifts,cars,buildings ..... etc i didn't get a job, but the interview did turn into giving the interviewer ( a hardline C lover himself ) a crash course in pic ASM,
a sigh of relief can be seen in a trend where proof of experience eg, what ever projects you've done in your own time, is getting more valuable than X amount of years of study and a diploma in X, and i think there are employers out there who are starting to see the proverbial light that C isn't the only language out there and that it's not nessarily suited to every possible application , there are some who are starting to look outside the "rectangle"
 
Top