How do I compile PIC basic?

Tyro

Member
I am manufacturing a device that currently uses an 08M in a small niche market. Can anyone recommend a product that can convert PIC basic to a form suitable to compile and then programme a raw Microchip device?

I have looked at Microchips PRO basic and compared to Rev Eds version will require a lot of time to get up to speed.

The Rev Ed complier does not handle all the commands I need, eg PWMout and debug.
 

Andrew Cowan

Senior Member
If you need commands like that, the only option is to learn C/assember (or something like PRO basic). Or pay someone to do it for you!

PICAXE's basic to assembler wizerd doesn't work with the more complex commands. Is there anything wrong with using PICAXEs in the end project? The cost per PICAXE is only slightly higher than for a PIC - a small amount of money compared to the time to learn a new language.

Andrew
 

ciseco

Senior Member
There are quite a few compile-able PIC BASICs, off the top of my head, there's sourceboot basic, swordfish basic, proton basic/amicus, they all uk based and have free-ish versions, then theres, great cow basic and mikroelectronica basic, they'll be a lot more I'm sure.

We even have some simple examples of some of them for the xino, here's a splash of code, you'll see differences but nowhere near how scary C is

Miles

PICAXE 28?1 & 28?2

config:
symbol HSBAUD=B9600_4 'set the baud rate for the high speed serial port
'
init:
hsersetup HSBAUD, %01 'put the serial port into the right mode
high 6 'turn the socket on
pause 50 'wait a tiny amount of time for X device to power up
'
main:
hserout 0,("Hello") 'send the message
pause 1000 'wait a second
goto main 'keep repeating the message
'

PROTON/AMICUS for Proton you will need to ?set-up? the PIC, AMICUS does it for you, the same basic code is common to both.

Config:
Clear 'Clears all memory after a soft reset, not vital
Hserial_Baud = 9600 'Set baud rate, XRF and XBee default at 9600bps
'
Init:
High RB6 'turn the socket on
DelayMS (50) 'wait a tiny amount of time for X device to power up
'
Main:
HRSOut "Hello" 'send the message
DelayMS 1000 'wait a second
Goto Main 'keep repeating the message
'

Swordfish BASIC

Device = 18f25k20 'tell the compiler we are using the 25K20
Clock = 16 'set the PIC to 16Mhz
Include "usart.bas" 'tell the compiler to include the serial library

USART.SetBaudrate (br9600) 'set baud rate, XRF and XBee default at 9600bps

High(PORTB.6) 'turn the socket on

DelayMS (50) 'wait a tiny amount of time for X device to power up
'
Main:

USART.Write("Hello") 'send the message
DelayMS (1000) 'wait a second
GoTo main 'keep repeating the message
________
halfbaked
 
Last edited:

techElder

Well-known member
The 08M is a PICAXE not a PIC.

I am manufacturing a device that currently uses an 08M in a small niche market. Can anyone recommend a product that can convert PIC basic to a form suitable to compile and then programme a raw Microchip device?

I have looked at Microchips PRO basic and compared to Rev Eds version will require a lot of time to get up to speed.

The Rev Ed complier does not handle all the commands I need, eg PWMout and debug.
 

ciseco

Senior Member
just a note, not all compilers support all PIC families, eg swordfish is 18f family only, amicus is free but supports only 18f25k20, proton almost anything, but you pay ?99 and sourceboost $49, both have limited free versions which will unleash more code space than you get in an 08m though. I think they will either support the PIC that is the 08m or something remarkably similar.

All "generic" compilers tend to need that you understand what the pic is actually upto (datasheets become your friends) The picaxe environment is a warm and fuzzy place where lots of the bizarre terms are hidden from you, expect more effort for more reward. Some of them support proper variables, floating point maths and plenty of libraries.

If you are playing with picaxes in the order of 10's of devices, you'll not save a penny for the effort, I'd suggest you stick with them.

Miles
________
Imperial
 
Last edited:

Tyro

Member
Thank you for your replies. Unfortunately you have confirmed the requirments for me to learn C!

How much would it cost to have someone write the code for me? The PICAXE basic is 253 bytes and uses all the pins (some twice) and requires sleep, PWMout, debug, readADC10 and various pauses.

I am expecting to use 200 to 1000 units per batch. So the lower price of a raw Microchip device is significant.
 

westaust55

Moderator
Other than price, is there any reason you are looing to go from a PICAXE 08M to a raw 12F683.

Microchip direct price for 100+ is US1-94 each and slightly less if you buy 1000 at a time plus postage.
Then you have to purchase a programmer = $'s or £'s, C or BASIC compilers = $'s or £'s, time and cost for someone to write the program to be compiled etc.

The Rev Ed TechSupplies pricing for the 08M is UK£1.50 pushased individually. This drops to UK£1.30 each in packs of 5 and UK£0.85 in packs of 50.
I presume that Rev Ed could do a better price still if you purchase 1000+ in a single order.
Sure there is still a postage cost from Rev Ed but seemingly you already have the PICAXE program working so development imte/cost from this point on is then nill to get the current program to market.
 

Dippy

Moderator
"Unfortunately you have confirmed the requirments for me to learn C!"
- Eh? Way out. How did you come to that conclusion ?????
Have you read/understood what CISECO posted? I'm not here to advertise other people's products btw.

If you want 1000 devices programmed per batch that's the awkward no-man's land. i.e. a pain to do yourself by hand, perhaps too small to go automated.

Having said that if you need to send code to a third party to programme for you they will probably want HEX.
DIY you'll need a programmer + ZIF unless you are doing in-circuit.

But, by all means learn C. It ain't that difficult. If a numpty like me can do it in a week then a genius could do it in a morning.
While you're at it, learn PASCAL too :)
Just make sure your keyboard semi-colon and curly brackets buttons are heavy-duty.


Maybe Rev-Ed could do a 1000off with PICAXE code at a reasonable rate?
That would be the quickest and easiest solution for now - why not ask?
Don't be scared - they won't send hippy round to your house wearing a bandana (banana?) and hose you down with an Uzi. ;)
 
Last edited:

ciseco

Senior Member
At (what I seem to remember is) a maximum of 80 lines of code (08m) your project cant be particularly complex, converting it might be from minutes to maybe be an hour or two.

As dippy asks, did you not look at the three bits of sample code I posted, all in different flavours of BASIC for the PIC, there's no "C", unless the word compiler is where the confusion lies.

If your question is "can I buy something to produce a HEX file I can blow onto a blank pic from my PICAXE editor code", the answer is a simple no. If it's "are there any PIC BASIC style applications that CAN produce a standalone HEX file", then YES, see previous post.

If you take a quick look at the microchip site, in quantity, the lowest cost 12F series PIC quoted with 10bit PWM is $0.55, in pounds shillings and pence that's maybe 35p.

If you want the easy route and get someone else to do it, there's ?100 to ?500 in your potential savings to get it done, I'm sure if your code is clear a commercial organisation would convert it for you, if you pick the right one, they could even build finished PCB's or products and even ship them for you, depends how much you want to do yourself.

With some systems you dont even need a hardware programmer, to my knowledge there is only one product that you can use the trusty old PICAXE cable as a programmer with other types of compiler/blank PICS, it's called XINO, I'm rather familiar with them ;). It requires what is called a bootloader, this is what essentially you buy and some pre compiled routines when you buy a PICAXE. There's a bootloader for every type of PIC out there. Some of these compilers are no more complicated than the PICAXE environment, it's just the syntax of commands is subtly different across many platforms. Eg I can never remember what ever application I'm using if it's

PAUSE xx or DELAY xx or DELAYMS xx or WAITMS xx

Miles
________
Ferrari Inter picture
 
Last edited:

hippy

Ex-Staff (retired)
There was similar discussion along the same lines previously; wanting to take a PICAXE product and turn it into a PICmicro product to save costs. As there the issue is much more than raw chip costs; compilers, hardware programmers, setting everything up, getting it all to play ball, understanding it, learning new programming languages, the effort of converting code, testing that it works, debugging when it doesn't, the time to convert code, any costs of time to market delays, plus time which could be spent on other products, developments and other business.

If you choose an alternative you could go from fully outsourced to doing it all in house. It's hard to give any specific advice, which is most cost effective or best, as that would depend on the particular business case and costings for each scenario and only you can decide which is best for you. Do take into account though that it's not just 'N x component cost savings' you'll see as profit, but that offset against other costs involved.
 

Tyro

Member
Thank you Hippy for writing such a well thought out description of my dilemma. It has given me pause for thought.

Ciseco, after reading your comments I had a look at the prices from Rev-Ed and it appears that they will only supply 50+ quantities to educational establishments. I phoned them and went straight to voicemail.

I live in the US, (btw, why does that fact not appear in my profile?) so I did not think they would phone me back. I have just sent an e-mail to them asking for clarification of their policy for selling direct to me.

My US supplier has a price of $2.40 for one hundred pieces. For surface mount devices, it is $3.50 from a different suppler.

My application requires that I use surface mount parts because one side of the PCB is a sensor and I cannot use through hole parts. This means that when I use an 8-pin DIL part I also have to use an SMT DIL socket ($0.49).

Initially I am going to stay with a DIL 08M and continue investigating alternatives. This thread has achieved what I wanted it to in clarifying the various options I have.
 

Minifig666

Senior Member
My US supplier has a price of $2.40 for one hundred pieces. For surface mount devices, it is $3.50 from a different suppler.
Blimey, who is this kind supplier?

I'm amazed that you can't persuade someone to write the code for you. Mabie a PIC forum?
What is this mistery product anyway?
 

Tyro

Member
Eclectic, I fixed my profile after my last post, duh!

Minifig666, The supplier for the $2.40 part is Sparkfun in the US. The mystery product is a water leak sensor using the change in capacitance that occurs when the area under the sensing PCB changes from dry to wet.
 
Top