Hello to the Community.
I am using PBP Compiler version 2.46
I started by programming BasicStamp 2SX and then adapting the programs to fit into PiCs.
I switched to Picaxe (also programmable in Basic) and am now trying to adapt my Picaxe program to fit into a Pic12F629.
However, the compiler gives me errors that I don't understand
For example, it mentions undefined symbol names that do not exist in the program: GO_DONE, ADRESH, ...
What are these "extra tokens", ...?
Can you help me?
In appendix, print screen of the compiler errors and... the code.
Thanks.
CODE:
-------------
'----------------------------------------------------------------------------------
' SERVO_TR PIC01.bas - "ON/OFF" Servo - Servo "Tout ou Rien"
' Adaptation for PBP compiler v2.4x (DO..LOOP..Until not supported !)
'
' V1.0 - 09/05/2022 - RGL
'
' Moves a servo to two preset positions, depending on the state of a logic input
' Servo signals adjustable from 0.75 ms to 2.25 ms
'----------------------------------------------------------------------------------
'
' TWO POSITION SETTING PROCEDURE
' -----------------------------------
' - In Normal Mode (Input Mode=1), the LED is on.
' - Set the logic input (S_Pos) to 0V or 5V to select either servo position.
'
' - In Configuration Mode (Input Mode=0), the LED is blinking.
' - The state of the S_Pos input will determine which position you are setting !
' - Turn the potentiometer in either direction: The servo follows the movement.
' - When the desired position is reached the LED goes out after a few seconds.
' - Then, return the configuration input to normal mode (High)
' The LED lights up again and the new position is stored in Eeprom.
' The system returns to Normal Mode with the new programmed position.
' - Do the same for the other position by changing the state of the S_Pos input.
'----------------------------------------------------------------------------------
'PotADC gives values from 0 to 255
'ServoPos delivers pulse values from 75 to 225 (0,75msec to 2,25msec)
' Pic Specifications
'--------------------
@ Device Pic12F629, intrc_osc, wdt_off, pwrt_on, mclr_off, protect_off 'DIP8
DEFINE OSC 4 ' 4Mhz Resolution=10µsec => 1 msec=100
CMCON = 7 ' Comparator off
'ADCON0 = 7
'ANSEL = 0 ' Set I/O to digital
' __ __
' Vcc o| U |o Gnd
' NC GP5 x| |> GP0 Led
' Config. GP4 >| |> GP1 Servo
' Position GP3 >| |< GP2 Pot
' -----
'*** In/Out pins ..................................................
' GND pin8 - Gnd
Output 0 : Symbol LED = GPIO.0 'Led pin7 - Out0
Output 1 : Symbol S_Out = GPIO.1 'Servo pin6 - Out1
Input 2 : Symbol Potar = GPIO.2 'Pot pin5 - In2
Input 3 : Symbol S_Pos = GPIO.3 'S_Pos pin4 - In3
input 4 : Symbol Mode = GPIO.4 'Mode pin3 - In4
' pin2 -
' pin1 - Vcc
'*** Variables .................................................. ..
Position1 VAR BYTE 'W0 Position1 servo
Position2 VAR BYTE 'W0 Position2 Servo
PotADC VAR BYTE 'W1 Pot ADC Value
NewADC VAR BYTE 'W1 New ADC Conversion
_PotADC VAR BYTE 'W2 =PotADC/10
_NewADC VAR Byte 'W2 =NewADC/10
Pulse VAR BYTE 'W3 Pulse value to servo
State VAR BIT 'W3 Normal/Configuration
Flashing VAR word 'W4 Counter for Led Flashing Frequency
Waiting VAR WORD 'b10-11 Counter for Validation Delay
Space VAR WORD 'b12-13 Pause time between each servo pulse
'depending on the length of the pulse,
'to obtain a standard total Space of 20 msec.
'*** Constants .................................................. ..
FrBlink CON 2 'Flashing Frequency of the Led
TValid CON 150 'Waiting Time for Validation
'================================================= =================================
INIT:
Read 0,Position1 'Read Positions in Eeprom
Read 1,Position2
IF Position1<75 OR Position1>225 OR Position2<75 OR Position2>225 Then
Position1= 180 'if values outside the limits of a servo
Position2= 120 'Preset Values = 1.2msec, 1.8msec
EndIF
LET Flashing=0
LET Waiting=0
'---------------------------------------------------------------------------
MAIN: 'Main Loop
IF Mode = 1 Then 'NORMAL Mode
High Led
IF S_Pos = 0 Then 'Read the Desired Position
Pulse = Position1
Else
Pulse = Position2
EndIF
GoSub UpdateServo 'Update the servo
Else 'CALIBRATION Mode !
State = S_Pos
DO_CALIB:
'DO Until Waiting = TValid 'Configuration Loop
IF Waiting <> TValid Then
GoTo Calib
Else
GoTo Out_Calib
EndIF
CALIB:
'State = S_Pos
ADCIN Potar,PotADC
Pulse=PotADC*59/100+75 'Converting ADC to Pulse
GoSub UpdateServo 'Update the servo
_PotADC=PotADC/10 'Stabilisation of the inaccuracy
_NewADC=NewADC/10 'of the Pot ADC reading
IF _PotADC=_NewADC Then 'If Pot Position Unchanged
Waiting = Waiting +1 'Increase Waiting Time (Until=TValid)
Else
NewADC=PotADC 'Reset of the Waiting Time
Waiting=0
EndIF
Flashing = Flashing +1
IF Flashing=FrBlink Then
Toggle Led 'Blinking Led
Flashing=0 'Reset cpt Led
EndIF
'LOOP 'Configuration Loop
GoTo DO_CALIB
Out_CALIB:
GoSub Validation 'The position of the Pot is Stabilised
EndIF
GoTo Main 'Main Loop
End
'================================================= ================================
' --- SUBROUTINES ---
'================================================= ================================
UPDATESERVO:
PulsOut S_OUT, Pulse 'ServoPos = pulse values from 75 to 225 (0,75msec to 2,25msec)
Space = 2000 - Pulse '= 20msec - pulse duration
PauseUs Space '
Return
'+++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++++++
VALIDATION: 'Storage of the New Position in Eeprom
Low Led 'Waiting to Deselect Configuration Switch Mode !
Do_Until:
'DO
'LOOP Until Mode = 1 'Mode=1 -->NORMAL Mode
IF Mode <> 1 Then
GoTo Do_Until 'Loop Until Mode = 1 !
Else
GoTo Out_Do_Until 'Mode = 1 = Mode NORMAL
EndIF
Out_Do_Until:
High Led 'OK, Ready to return to Normal Mode
IF State=0 Then 'New position Writing in Eeprom
Position1=Pulse
Write 0,Position1
Else
Position2=Pulse
Write 1,Position2
EndIF
Flashing=0 : Waiting=0 'Reset Counters
Return 'to Normal Mode
'"== END OF PROGRAM ================================================== ==============
Compiler ERRORS:
Bookmarks