dir gpio.0 out
dir gpio.1 out
dir gpio.2 out
dir gpio.3 in 'stop switch
dir gpio.4 out
dir gpio.5 in 'serial rx
dim mxl as word
dim mxr as word
dim pox as word
dim temp as word
#define RecAHigh GPIO.5 off
#define RecALow GPIO.5 on
InitSer 1,r1200,1,8,1,none,invert
loca = 0
mxl=0
mxr=0
pox=0
wait 1 s
zeroloc
wait 1 s
main:
if loca = 0 then
SerReceive 1, Temp
if temp = 88 then loca = 1 'X
end if
if loca = 1 then
SerReceive 1, Temp
end if
if temp > pox then
temp - pox = mxr
right
pox = pox + mxr
mxr = 0
loca = 0
end if
if temp < pox then
pox - temp = mxl
left
pox = pox - mxl
mxl= 0
loca = 0
end if
goto main
sub Left
repeat mxl
set gpio.0 on
wait 2 ms
set gpio.0 off
set gpio.1 on
wait 2 ms
set gpio.1 off
set gpio.2 on
wait 2 ms
set gpio.2 off
set gpio.4 on
wait 2 ms
set gpio.4 off
end repeat
end sub
sub right
repeat mxr
set gpio.4 on
wait 2 ms
set gpio.4 off
set gpio.2 on
wait 2 ms
set gpio.2 off
set gpio.1 on
wait 2 ms
set gpio.1 off
set gpio.0 on
wait 2 ms
set gpio.0 off
end repeat
end sub
sub zeroloc
do until gpio.3 off
set gpio.0 on
wait 2 ms
set gpio.0 off
set gpio.1 on
wait 2 ms
set gpio.1 off
set gpio.2 on
wait 2 ms
set gpio.2 off
set gpio.4 on
wait 2 ms
set gpio.4 off
loop
end sub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It always helps to provide as much information as possible. Most of the time error messages are available that point you in a direction of the problem. The error messages are in the output window of the editor, you may have to scroll up to see them. Given that, does expressions like 'temp - pox = mxr ' seem odd? Kent
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have made changes to where it is now, i get a .asm file but not .hex and I m not sure where to get the errors, as the windows close and there is no error file that i can find.
dir gpio.0 out
dir gpio.1 out
dir gpio.2 out
dir gpio.3 in 'stop switch
dir gpio.4 out
dir gpio.5 in 'serial rx
dim mxlt as word
dim mxrt as word
dim posx as word
dim temp1 as word
#define RecAHigh GPIO.5 off
#define RecALow GPIO.5 on
InitSer 1,r1200,1,8,1,none,invert
spot = 0
mxlt = 0
mxrt = 0
posx = 0
wait 1 s
zerolocfind
wait 1 s
main:
if spot = 0 then
SerReceive 1, temp1
if temp1 = 88 then spot = 1
end if
if spot = 1 then
SerReceive 1, temp1
spot = 2
end if
if spot = 2 then
if temp1 > posx then
mxrt = temp1 - posx
gxrt
end if
if temp1 < posx then
mxlt = posx - temp1
gxlt
end if
end if
goto main
sub gxlt
repeat mxlt
set gpio.0 on
wait 2 ms
set gpio.0 off
set gpio.1 on
wait 2 ms
set gpio.1 off
set gpio.2 on
wait 2 ms
set gpio.2 off
set gpio.4 on
wait 2 ms
set gpio.4 off
end repeat
posx = posx - mxlt
mxlt = 0
spot = 0
end sub
sub gxrt
repeat mxrt
set gpio.4 on
wait 2 ms
set gpio.4 off
set gpio.2 on
wait 2 ms
set gpio.2 off
set gpio.1 on
wait 2 ms
set gpio.1 off
set gpio.0 on
wait 2 ms
set gpio.0 off
end repeat
posx = posx + mxrt
mxrt = 0
spot = 0
end sub
sub zerolocfind
do until gpio.3 off
set gpio.0 on
wait 2 ms
set gpio.0 off
set gpio.1 on
wait 2 ms
set gpio.1 off
set gpio.2 on
wait 2 ms
set gpio.2 off
set gpio.4 on
wait 2 ms
set gpio.4 off
loop
end sub
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This will not make a hex file? I must have some variable wrong or something
#chip 12F683, 8 'mhz
#config INTRC_OSC_NOCLKOUT, MCLRE=off, WDT=off
dir gpio.0 out
dir gpio.1 out
dir gpio.2 out
dir gpio.3 in 'stop switch
dir gpio.4 out
dir gpio.5 in 'serial rx
dim mxl as word
dim mxr as word
dim pox as word
dim temp as word
#define RecAHigh GPIO.5 off
#define RecALow GPIO.5 on
InitSer 1,r1200,1,8,1,none,invert
loca = 0
mxl=0
mxr=0
pox=0
wait 1 s
zeroloc
wait 1 s
main:
if loca = 0 then
SerReceive 1, Temp
if temp = 88 then loca = 1 'X
end if
if loca = 1 then
SerReceive 1, Temp
end if
if temp > pox then
temp - pox = mxr
right
pox = pox + mxr
mxr = 0
loca = 0
end if
if temp < pox then
pox - temp = mxl
left
pox = pox - mxl
mxl= 0
loca = 0
end if
goto main
sub Left
repeat mxl
set gpio.0 on
wait 2 ms
set gpio.0 off
set gpio.1 on
wait 2 ms
set gpio.1 off
set gpio.2 on
wait 2 ms
set gpio.2 off
set gpio.4 on
wait 2 ms
set gpio.4 off
end repeat
end sub
sub right
repeat mxr
set gpio.4 on
wait 2 ms
set gpio.4 off
set gpio.2 on
wait 2 ms
set gpio.2 off
set gpio.1 on
wait 2 ms
set gpio.1 off
set gpio.0 on
wait 2 ms
set gpio.0 off
end repeat
end sub
sub zeroloc
do until gpio.3 off
set gpio.0 on
wait 2 ms
set gpio.0 off
set gpio.1 on
wait 2 ms
set gpio.1 off
set gpio.2 on
wait 2 ms
set gpio.2 off
set gpio.4 on
wait 2 ms
set gpio.4 off
loop
end sub
Right and left are reserved words used by GCBasic. Try renaming your left and right subs to something else and see whether that helps.
nope that didnt do it
It always helps to provide as much information as possible. Most of the time error messages are available that point you in a direction of the problem. The error messages are in the output window of the editor, you may have to scroll up to see them. Given that, does expressions like 'temp - pox = mxr ' seem odd? Kent
I have made changes to where it is now, i get a .asm file but not .hex and I m not sure where to get the errors, as the windows close and there is no error file that i can find.
#chip 12F683, 8 'mhz
#config INTRC_OSC_NOCLKOUT, MCLRE=off, WDT=off
dir gpio.0 out
dir gpio.1 out
dir gpio.2 out
dir gpio.3 in 'stop switch
dir gpio.4 out
dir gpio.5 in 'serial rx
dim mxlt as word
dim mxrt as word
dim posx as word
dim temp1 as word
#define RecAHigh GPIO.5 off
#define RecALow GPIO.5 on
InitSer 1,r1200,1,8,1,none,invert
spot = 0
mxlt = 0
mxrt = 0
posx = 0
wait 1 s
zerolocfind
wait 1 s
main:
if spot = 0 then
SerReceive 1, temp1
if temp1 = 88 then spot = 1
end if
if spot = 1 then
SerReceive 1, temp1
spot = 2
end if
if spot = 2 then
if temp1 > posx then
mxrt = temp1 - posx
gxrt
end if
if temp1 < posx then
mxlt = posx - temp1
gxlt
end if
end if
goto main
sub gxlt
repeat mxlt
set gpio.0 on
wait 2 ms
set gpio.0 off
set gpio.1 on
wait 2 ms
set gpio.1 off
set gpio.2 on
wait 2 ms
set gpio.2 off
set gpio.4 on
wait 2 ms
set gpio.4 off
end repeat
posx = posx - mxlt
mxlt = 0
spot = 0
end sub
sub gxrt
repeat mxrt
set gpio.4 on
wait 2 ms
set gpio.4 off
set gpio.2 on
wait 2 ms
set gpio.2 off
set gpio.1 on
wait 2 ms
set gpio.1 off
set gpio.0 on
wait 2 ms
set gpio.0 off
end repeat
posx = posx + mxrt
mxrt = 0
spot = 0
end sub
sub zerolocfind
do until gpio.3 off
set gpio.0 on
wait 2 ms
set gpio.0 off
set gpio.1 on
wait 2 ms
set gpio.1 off
set gpio.2 on
wait 2 ms
set gpio.2 off
set gpio.4 on
wait 2 ms
set gpio.4 off
loop
end sub