Pic Basic pro code Compiling help!
Hello, I have a code built in Pic Basic Pro, but I want to add on a reset to this code so the circuit resets every 30 seconds. I think I have the code correct, however I don't have a compiler or the money to purchase at the moment. The free compilers only allow 2k and this file is around 4k. Would anyone be interested in compiling this to a hex file for me? I would appreciate it.
Here is the original code-
@ Device PIC12F675,PROTECT_OFF,INTRC_OSC_NOCLKOUT,MCLR_OFF
DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 50
CMCON=7
GPIO=000000
TRISIO=0110
ANSEL=111110
ADCON0=001100
t VAR WORD
c VAR WORD
cl VAR WORD
m VAR BYTE
hh VAR BYTE
ch VAR BYTE
u VAR BYTE
d VAR BYTE
u=0
d=0
hh=2
ch=1
cl=0
pause 250
ADCIN 3, t
ADCIN 2, c
if(t>c) then
cl=t-c
m=1
endif
if(t<c) then
cl=c-t
m=0
endif
loop:
ADCIN 3, t
ADCIN 2, c
if m=1 then
t=t-cl
else
t=t+cl
endif
if u>10 then
GPIO.0=0
GPIO.5=1
endif
if d>10 then
GPIO.5=0
GPIO.0=1
endif
if t>(c+ch) then
u=u+1
d=0
goto loop
else
if t<(c-hh) then
d=d+1
u=0
goto loop
endif
endif
u=0
d=0
GPIO.0=0
GPIO.5=0
nap 2
GoTo loop
And here is the code that I need to Compile to a Hex file with the 30 second timer reset function that I think is correct. any help is appreciated!
@ Device PIC12F675,PROTECT_OFF,INTRC_OSC_NOCLKOUT,MCLR_OFF
DEFINE ADC_BITS 10
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 50
CMCON=7
GPIO=000000
TRISIO=0110
ANSEL=111110
ADCON0=001100
t VAR WORD
c VAR WORD
cl VAR WORD
m VAR BYTE
hh VAR BYTE
ch VAR BYTE
u VAR BYTE
d VAR BYTE
l VAR WORD
u=0
d=0
hh=2
ch=1
cl=0
l=0
pause 250
restart:
ADCIN 3, t
ADCIN 2, c
if(t>c) then
cl=t-c
m=1
endif
if(t<c) then
cl=c-t
m=0
endif
loop:
ADCIN 3, t
ADCIN 2, c
if m=1 then
t=t-cl
else
t=t+cl
endif
if u>10 then
GPIO.0=0
GPIO.5=1
endif
if d>10 then
GPIO.5=0
GPIO.0=1
endif
if t>(c+ch) then
u=u+1
d=0
goto loop
else
if t<(c-hh) then
d=d+1
u=0
goto loop
endif
endif
u=0
d=0
GPIO.0=0
GPIO.5=0
nap 2
if l=600000
GPIO.0=1
GPIO.5=1
GoTo restart
endif
l=l+1
GoTo loop
Re: Pic Basic pro code Compiling help!
Hi and welcome to the forum!
The PIC12F675 only has 1k so it'll be impossible to fit a 4k program. However, it's not the size of the source file (ie the "text file" containing the program) that matters, it's the size of the compiled .hex file that you actually program into the PIC. I can't think that piece of code would result in more than 1k, not to mention 2k which you say is the limit of the free version (which version is that?).
Finally, IF l=600000 won't work because l is declared as a WORD (ie 16bits) so it can only hold values between 0 and 65535 and there's a missing THEN on the same line.
/Henrik.
Re: Pic Basic pro code Compiling help!
Hello and Thank you, I looked again after you told me that info and It appears as though I have exceeded the maximum number of code lines allowed using the PicBasic Demonstration Compiler so that is the revised issue. -thx
Re: Pic Basic pro code Compiling help!
You can download PBP3.06 from MELABS site, install it and use it in trial mode for 15 days.
/Henrik.