Is there any C Compiler (free or paid) for PICAXE ?

hippy

Technical Support
Staff member
No, there is no known C compiler for PICAXE.

The best one could do is automatically translate C to PICAXE Basic and compile that. That would allow only a limited subset of C which many would say could not really be called C and would likely not deliver whatever it was hoped using C would provide for.

Something could probably be done but the limitations and effort involved would probably outweigh any gains it could offer.

If you have some code in C you would like to port to PICAXE Basic, members here will likely be able to help with that if it is not too complicated or too much, will at least be able to offer suggestions for how such porting should best be approached.
 

bpowell

Senior Member
Here is what I did FWIW:

For about $50, you can buy a PICKIT 3 programmer...this is the Flash Programmer necessary to put code onto "raw" PIC chips (not PICAXE). From there, you can download (for Free) Microchip's "MPLAB-X" and the "XC-8" compiler (MPLAB-X is the development environment, and XC-8 is the C-compiler for 8-bit micros). Then, I found a program called, "Tiny PIC Bootloader" or something along those lines...it's a small serial bootloader that you can flash onto a raw PIC with the PICKIT3. Once that's done, you have a PIC chip that has a serial bootloader (similar to PICAXE) which you can load with FTDI cables. Then, you can write your code in C using MPLAB...compile it, and use the bootloader program to push that compiled code to the chip.

You lose all the ease and abstraction from hardware that PICAXE provides, but you can program in C, and start to learn a little more about the bare-metal of the chip.

I will say, the PICAXE support community is unmatched out there...when you go on the Microchip forum and ask a question, you'd better gird yourself for some rude (and unhelpful) answers...but again, it forces you to get into the datasheets, and see what makes these chips (and even the PICAXE) tick!
 

bpowell

Senior Member
Why would anyone convert Basic into "C"?........ speed?
I don't think OP is looking to convert Basic into C, I think OP is asking if there is a C programming environment for PICAXE.

*Edit: Stan, I see you were just answering a question from above. :)
 
Last edited:

srnet

Senior Member
Great Cow Basic compiles pic and avr to hex which is faster than arduino c, https://sourceforge.net/p/gcbasic/blog/2017/04/youtube-chuck-compares-arduino-and-great-cow-basic/
Well maybe, although the author of the video has a poor grasp of basic sums. The examples given that a basic compiler was "3 times, well almost" than an Arduino (C\C++) program. It was actually 2.43 times faster so a little more than two times faster.

However its been said many times on here that how fast a program runs is often not a significant issue, its ease of use and simplified development that predominates.

Great Cow Basic does initially sound attractive, its free, a complier so it should be fast, but easy to use ? Well not in my experience. I decided to try and do a complied version of a simple watchdog program I had for a 08M2 (12F1840). I eventually got it working, but it was a struggle and only after I corrected an error in the Great Cow Basic .dat file that was the definition for the particular PIC. Beginners stuff it was not.
 
Last edited:

pxgator

Senior Member
However its been said many times on here that how fast a proram runs is often not a significant issue, its ease of use and simplified development that predominates.
You hit the nail on the head with that statement Sir..:)
 

alhoop

Member
.....................

I will say, the PICAXE support community is unmatched out there...when you go on the Microchip forum and ask a question, you'd better gird yourself for some rude (and unhelpful) answers...but again, it forces you to get into the datasheets, and see what makes these chips (and even the PICAXE) tick!
Second that on the PICAXE support community. If learning C you can also expect to meet some rude ones on the Arduino forum - I sure did - met some helpful folks there also - most of them from AUS.

Al
 

tmfkam

Senior Member
Well maybe, although the author of the video has a poor grasp of basic sums. The examples given that a basic compiler was "3 times, well almost" than an Arduino (C\C++) program. It was actually 2.43 times faster so a little more than two times faster.

However its been said many times on here that how fast a program runs is often not a significant issue, its ease of use and simplified development that predominates.

Great Cow Basic does initially sound attractive, its free, a complier so it should be fast, but easy to use ? Well not in my experience. I decided to try and do a complied version of a simple watchdog program I had for a 08M2 (12F1840). I eventually got it working, but it was a struggle and only after I corrected an error in the Great Cow Basic .dat file that was the definition for the particular PIC. Beginners stuff it was not.
I find GCB to be very easy to use. Their forum is almost as helpful as this one is too. I've converted a number of programs from PicAxe Basic to GCB, some very simple ones, others rather more complex ones with 2-3000 lines of source code.

Where there are errors, I think there was an error I found in the .DAT files for the 16F1825/9, a post on the forum will get this checked and corrected if needed.

Not forgetting that GCB is produced by volunteers, for no charge and with no restrictions on use, commercial or otherwise.

For certain repetitive operations, the speed increase between PicAxe Basic and GCB (compiled) Basic can be enormous. If you need that speed then GCB is a good choice, if you don't then PicAxe Basic is the way to go. I sometimes develop an idea using a 20M2, build a prototype, code it and make sure it works. I then plug in a 16F1829 and convert the code to GCB. That way I get the idea working quickly using the speed of the PicAxe development before taking advantage of the speed increase of the base PIC.
 

stan74

Senior Member
You said it all tmfkam. Picaxe is fine for most things but lots of repeated calculations like calculating a plot position on a line for graphics or large arrays the speed difference is crucial.
picaxe forum is more populated than gcb but it's the same songs.
The difference is the gcb.h include files which are like arduino include files. These are absent in picaxe and it's all roll your own. I'm thinking of stuff on ebay you can connect to a uctlr.
I messed with a gcb ssd1306 and posted this as a gcb tester and the next lib will have this feature, Feedback is taken into consideration. https://www.youtube.com/watch?v=3RhTwAqYqY4
PS A uno and usb and gcb is plug and play and the terminal works...a pic needs a board and a usb ttl converter and a tinybootloader...hassle.
Gcb and a uno board for me is top but a 18f25k22 at 64MHz is a faster option. mega328p is nice chip.
 
Last edited:

Goeytex

Senior Member
...However its been said many times on here that how fast a program runs is often not a significant issue, its ease of use and simplified development that predominates.
Yes, it is said quite a bit and is generally true ,especially for beginner level educational and hobby projects.

However it has also been said many times and is equally true, that how fast a program runs often IS a significant issue. It all depends upon the application requirements. Use what works for your application. If a Picaxe is fast enough, use it. If not then find something else that does. GCB, Arduino, MPLAB C, whatever floats your boat.

I agree that GCB may not be the best choice for rank beginners with zero knowledge of microcontrollers, or for those not willing to look at a datasheet or set up some registers from time to time. I would say it is between Beginner and Intermediate Level with the potential for doing some highly advanced and high speed applications.
 

stan74

Senior Member
Goeytex "I agree that GCB may not be the best choice for rank beginners with zero knowledge of microcontrollers, or for those not willing to look at a datasheet or set up some registers from time to time. I would say it is between Beginner and Intermediate Level with the potential for doing some highly advanced and high speed applications."
I must reply that if you look at forum posts there's much low level stuff that shouldn't be basic like no dim (array). This results in @bptr peek/poke stuff that basic is supposed to dumb down but picaxe make an issue. OK most people don't use arrays?
I don't see picaxe changing/improving. Gcb is changing/improving daily...a team of little people like me. It's open source.
 

stan74

Senior Member
I find GCB to be very easy to use. Their forum is almost as helpful as this one is too. I've converted a number of programs from PicAxe Basic to GCB, some very simple ones, others rather more complex ones with 2-3000 lines of source code.

Where there are errors, I think there was an error I found in the .DAT files for the 16F1825/9, a post on the forum will get this checked and corrected if needed.

Not forgetting that GCB is produced by volunteers, for no charge and with no restrictions on use, commercial or otherwise.

For certain repetitive operations, the speed increase between PicAxe Basic and GCB (compiled) Basic can be enormous. If you need that speed then GCB is a good choice, if you don't then PicAxe Basic is the way to go. I sometimes develop an idea using a 20M2, build a prototype, code it and make sure it works. I then plug in a 16F1829 and convert the code to GCB. That way I get the idea working quickly using the speed of the PicAxe development before taking advantage of the speed increase of the base PIC.
To me that makes no sense. The syntax differences and changing say the picaxe servo command to a timer1 uno or pic interrupt is not trivial so not like re writing the hitch hikers guide to the galaxy in 34 languages. Why not just test it in gcb...with a £3 uno off ebay...not a pic and make a dev board and in circuit programmer . uno usb is so nice from gcb. you un rem a batch file and say which com port
I should add my intent is to get arduino users that find c hard but basic easy to try gcb as the thread was c compiler for picaxe (basic?)
 
Last edited:

tmfkam

Senior Member
At the risk of veering further away from the original question regarding a C compiler for PicAxe I just wanted to address some of the comments made in the responses above.

While PicAxe basic doesn't have the .h include files directly, they are there to a degree, just hidden. Calls to PWMOUT and such are replaced with code for the PWM functions, which hides the complexities of initialising the PWM hardware on chip. This is similar to an include file and has the same end result. As do the SPI, and I2C commands. PicAxe Basic taking (hiding?) away all the hard work again.

I don't find it too difficult to convert a PicAxe program to GCB. A copy-paste-convert process doesn't work too well, the syntactical differences lead to too many obvious and a few hard to spot errors, but a printout of the PicAxe program and re-type of the GCB program doesn't take much longer and is more reliable. Why bother? The PicAxe simulator is too good...

I've never needed any of the servo commands so haven't tried moving these from PicAxe to GCB.
 

lbenson

Senior Member
While PicAxe basic doesn't have the .h include files directly, they are there to a degree, just hidden
...
The PicAxe simulator is too good...
+1

Picaxe ease-of-use is invaluable--if what you are wishing to do is within the scope of what the picaxe firmware allows.

Hiding complexity is a good thing, as long as you don't need features beyond what is provided. If you do, then "horses for courses", to quote the long-absent Dippy.
 
Top