Help Compiling PIC chip!

I have run into a problem with my latest robot project. I am making a serial servo controller (seen here: rentron.com/PICX5.htm) Here is my problem, I do not have PicBasic Pro! The point of this was to build a servo controller for around $3, but to buy a $250 compiler defeats the purpose!

I have MPLAB ICD 2, so I can program the chip fine in assembly.

Does anyone have access to a C compile that you could compile this to say Hex code or something I can use in MPLAB?

The chip is a PIC12F675.

Any help would be awesome, or a suggestion of a free compiler.

THanks!

here is the code:

[code]include “modedefs.bas”

define osccal_1k 1 'Set osccal for OTP chips

pos var byte 'Servo position
servo1 var gpio.5 'Servo control output-pin
serpin var gpio.4 'Serial control input-pin
ID var byte 'ID number storage variable
ID = 5 'Assign unique ID to servo-pod
adcon1 = 7 'All pins digital I/O, not AD
trisio = %00010000 'gpio.4 = input
pos = 125 'Center servo on power-up

low servo1 'Setup for positive pulse

main:
pulsout servo1,pos
serin serpin,N9600,15,nxt,[ID],pos 'Get input
nxt:
goto main
end[/code]

Slight problem, this doesn’t look like C. Looks more like BASIC!

Either way, I can probably compile C or MBasic for you. Oh wait, you did say PicBasic Pro. I have that as well. Not on this laptop, I think. Let me get back to one of my other machines. Email me if you wish.

Did you know that Microchip offers it’s compiler? You can often get an eval of many compilers? Hitech, Microchip, CCS, etc.

Get to compile with Atom Basic Pro, and MBasic should also be able to compile it.

OK, found a compiler, but it gives errors in the pbppic14.lib file it apparently includes.

Alan KM6VV

Lol sorry, I really should proof read my posts better! It is Basic code!

I’ll shoot you an email, thanks!

As I replied to your email, this BASIC program isn’t compiling. Maybe it’s missing another include file?

Ask them, and we’ll give it another go!

Alan KM6VV

Hello,

You might want to check this code before even trying to run this on a 12F675, different pics have different settings, for example, the basic code you are providing, is for a PIC12C671 (OTP)

After contacting the creators of this code and asking how to modify it to run on a PIC12F675 I got this code as a reply, they said it compiles fine.

Does anyone have the resources to compile this in PBP?

[code]include “modedefs.bas”

DEFINE OSCCAL_1K 1 'Set osccal for OTP chips

pos var byte 'Servo position
servo1 var gpio.5 'Servo control output-pin
serpin var gpio.4 'Serial control input-pin ID var byte 'ID number storage variable
ID = 5 'Assign unique ID to servo-pod
ANSEL = 0 ’ all digital
CMCON = %00000111 ’ set all pins to digital
trisio = %00010000 'gpio.4 = input
pos = 125 'Center servo on power-up

low servo1 'Setup for positive pulse

main:
pulsout servo1,pos
serin serpin,N9600,15,nxt,[ID],pos 'Get input
nxt:
goto main
end
[/code]

Thanks for any help! I just got all my components for my bot and this is the last major hurdle!

I downloaded Proton IDE Lite, it supports this chip, but I cannot get this code to compile still. I removed the include because it was not needed according to the original code (rentron.com/PICX5.htm)

Here is my current code:

[code]’ Using register addressing
OPTIMISER_LEVEL = 6 ’ Set for maximum optimiser level
Device = 12F675

’ Setup for internal MCLR pin, and internal Oscillator

Config CPD_OFF,CP_OFF,BODEN_OFF,MCLRE_OFF,PWRTE_OFF,WDT_OFF ,INTRC_OSC_NOCLKOUT
XTAL = 4

    SERIAL_BAUD = 9600	
	RSOUT_PIN = GPIO.1
	RSOUT_MODE = TRUE
	RSOUT_PACE = 10

pos var Byte 'Servo position
servo1 var GPIO.5 'Servo control output-pin
serpin var GPIO.4 'Serial control input-pin
ID var Byte 'ID number storage variable
ID = 5 'Assign unique ID to servo-pod
ANSEL = 0 ’ all digital
CMCON = %00000111 ’ set all pins to digital
TRISIO = %00010000 'gpio.4 = input
pos = 125 'Center servo on power-up

Low servo1 'Setup for positive pulse

main:
PulsOut servo1,pos
SerIn serpin,15,nxt,[ID],pos 'Get input
nxt:
GoTo main
End

[/code]

and my compilation error
"ERROR [Line 31]; Unrecognised or Illegal characers found’,POS’! (12F675ADC.bas)

Perhaps I am going about this all wrong…

I got it to compile!

I don’t have your email on this machine. Let’s try HEX here.

:1000100084133408800664000D280E28A00A0319F2
:10002000A10F0B28800689283708A0003508A100F9
:100030000130A200A30164003C20031C2F28A20B66
:100040001B28FF30A30703181B28A007031CA107C8
:10005000031C89283230A2000030A3001B2847204F
:100060000830A30048203C20A20C3628A30B3228DD
:100070004820031422080800360884003408841736
:1000800080048413000533193406FF3E080033173B
:10009000330D0639A0005620A100A00A5620331FB8
:1000A00067283313A00002307E20672800308A00C2
:1000B00020088207013475340334153400343C348D
:1000C0000C34D934FF3A841780058928A101E83E11
:1000D000A000A109FC30031C7028A00703186D289C
:1000E000A0076400A10F6D2820187628A01C7A288C
:1000F00000007A2808000310A10CA00CFF3E031892
:100100007B2820088928A009A109A00A0319A10AAF
:10011000080083130313831264000800FF2383166F
:10012000900083120530B80083169F0183120730B8
:10013000990083161030850083127D30B900851236
:100140008316851283123908A000A10105308400AE
:10015000203001200530B6001030B4000630B30066
:100160000F30B700B5011420031CBD283802031D51
:10017000B3281420031CBD28B900A3286300BE289F
:02400E00FC3F75
:00000001FF
[/code]

I’ll email the files to you tomorrow.

Alan KM6VV

Sweet! I got it to load onto the chip an appears to work. I now need to work out the other end and figure out how to send commands to it.

Thanks!

Yeah, it looked like it would work.

There is another example that demonstrates how to send to this little PIC. you have to send a ‘5’ as an ID, the SERIN waits for it. Personally, I’d have put a ‘#’ for it to look for also.

Alan KM6VV