syntax error

Gramps

Senior Member
Good morning,
My old workhorse code has suddenly started to show a syntax error at line 45.
What in the world is a "rtxd"?
Perhaps a copy and paste error?
code:

'Shadow-Bot feedback control code with limits the best one!!!
#picaxe 28x2
#no_data
#no_table
symbol DEADZONE = 4 ; Switch motor off (Make as small as practical)
symbol SLOWZONE = 12 ; Slow motor down (NB: May depend on motor speed ! )
symbol MotorSpeed = w4 ; (To replace the "300" in the present PWMOUT code)
symbol LOOPGAIN = 33 ; i.e. MAXPWMVALUE / SLOWZONE (= 399 / 12)
symbol PWMPERIOD = 199 ; Equivalent Max Duty Cycle is 799
symbol xb0 = b0 ' reserved for bit variables
symbol bReverseForward=bit1 ' 0=reverse,1 =forward
symbol bMotorState=bit0 ' 0=off,1=on
symbol REVERSE_=0
symbol FORWARD_=1
Symbol desired_pot_value = b1
Symbol feedback_pot_value = b3
Symbol diff=b4
Symbol desired_pot = 13 'B.5
Symbol feedback_pot = 11'B.4
Symbol MOTOR = B.0' Energize PWM
Symbol Direction = B.7
Symbol MAXPWMVALUE = 399
Symbol bSlowState=bit2
Symbol old_feedback_value= b5
Symbol old_desired_value= b6
Symbol ENDSTOP_A = 35 ; desired_pot MINimum value
Symbol ENDSTOP_C = 210 ; desired_pot MAXimum value
;Lower shoulder min=35 max=210
;Upper shoulder min=?? max=???

Main:
Readadc Desired_pot, desired_pot_value
Desired_pot_value = Desired_pot_value MIN ENDSTOP_A MAX ENDSTOP_C
'sertxd (#desired_pot_value," ",#b1,13,10)
Readadc feedback_pot, feedback_pot_value
' sertxd (#feedback_pot_value," ",#b3,13,10)
'sesertxd("Desired/Feedback: ",#desired_pot_value," ",#feedback_pot_value,13,10)
;endif
if desired_pot_value > feedback_pot_value then
diff=desired_pot_value - feedback_pot_value
else
diff=feedback_pot_value - desired_pot_value
endif
rtxd("Desired/Feedback: ",#desired_pot_value," ",#feedback_pot_value,13,10)
If old_feedback_value<>feedback_pot_value or old_desired_value<> desired_pot_value then
old_feedback_value=feedback_pot_value
old_desired_value=desired_pot_value


if diff > DEADZONE then
MotorSpeed = diff * LOOPGAIN max MAXPWMVALUE ; Limits speed outside of SLOWZONE
if desired_pot_value > feedback_pot_value then
high Direction ; Set forward direction
else
low Direction ; Set reverse direction
endif
pwmout MOTOR , PWMPERIOD , MotorSpeed ; Slows motor within SLOWZONE
else
pwmout MOTOR , OFF ; STOP
bMotorState=0 ; Not sure what these do (now)
bSlowState = 0 ;
endif

goto main
 

cpedw

Senior Member
Surely it's meant to be "sertxd"? But fixing that raises "If without endif" error on the next line. Putting endif where that big space is can fix that; is that where it belongs?
 

Gramps

Senior Member
Surely it's meant to be "sertxd"? But fixing that raises "If without endif" error on the next line. Putting endif where that big space is can fix that; is that where it belongs?
yes! That fixed it! thanks!
If I remember correctly this was Hippy's wonderful code.
 

papaof2

Senior Member
Someone pasted a large chunk of code between the "se" and the "rtxd" of a "sertxd command.

The insertion point was in the middle of a command instead at the beginning of a line. These are the offending lines:
'sesertxd("Desired/Feedback: ",#desired_pot_value," ",#feedback_pot_value,13,10)
;endif
if desired_pot_value > feedback_pot_value then
diff=desired_pot_value - feedback_pot_value
else
diff=feedback_pot_value - desired_pot_value
endif
rtxd("Desired/Feedback: ",#desired_pot_value," ",#feedback_pot_value,13,10)
 

erco

Senior Member
Gramps, you are the coolest. I'm guessing you're a senior citizen (as am I) and you are extremely active programming and always asking and learning. You are an inspiration and a role model to us all!
 

Gramps

Senior Member
I'm guessing you're a senior citizen
Thanks, erco, you and many others on this forum have sure been a real encouragement!
I suppose 74 years qualifies me to be one of those old geezers called seniors.🙂
When I spoke to my son, oldbitcollector,(years ago!) about where to start writing code, he recommended the Picaxe micro.
You gentleman just go to prove that you can teach an old dog new tricks!
Gramps
 
Top