At the beginning of your program, give a name to all the files you will be using in your program.
Here are some names: You can give a file any name you like. But give it a name you can easily recognise - and try to use it in only one sub-routine. Especially if it is a file that holds a value during the calling of a number of sub-routines.
HTML:
;***************************************************
; variables - names and files
;***************************************************
temp1 equ 20h ;
temp2 equ 21h ;
temp3 equ 22h ;
temp4 equ 23h ;
_beepA equ 24h ;for beep tone
_beepB equ 25h ;for beep tone
_flash equ 26h ;for flashing the LED
_potA equ 27h ;holds value 1-10 for x10minutes
_potB equ 28h ;holds value 1-10 for minutes
_loops equ 29h ;
temp equ 2Ah ;
del_x equ 2Bh ;
del_y equ 2Ch ;
xmin_1 equ 2Dh ;
xmin_2 equ 2Eh ;
xmin_3 equ 2Fh ;
temp_10 equ 30h
retlw means: return to where the sub-routine was called and if the sub-routine creates a value from 1 to 0ffh, it can be placed in "w" register and the value can be used in the Main routine.
It just saves creating another file is a value is created in the called sub-routine. In most cased the micro returns with 00h in w.
goto $+1 increases the pointer but takes 2 cycles, whereas "nop" requires only 1 cycle.
The Main part of your program calls x60mins and this sub-routine loads .60 (decimal sixty) into a file. This sub-routine then calls x1min and it takes 1 minute for the sub-routine to execute. During this time a LED is turned on approx every second for a very short period of time to let you now the delay is executing.
The 1 minute delay returns to x60min sub-routine and the counter is decremented from 60 to 59.
Eventually 60 minutes is up and the program counter returns to Main.
The delay has nothing to do with working a servo.
In Main, you send a brief pulse to the servo (with the correct value of HIGH and LOW) and the servo moves to this position.
You then go to the Delay sub-routine for 1 hour and the servo remains in the same position.
The program then returns to Main and you send another pulse to the servo to change its position.
THE SERVO
A servo module consists of a motor and gearbox, with a PC board containing the electronics to drive the motor in clockwise and anticlockwise direction. The electronics also detects the width of the incoming pulse to drive the motor to mid-position and also other positions.
The motor is connected to the positive rail of the supply via a bridge of transistors within the servo and the red and black wires from the module are taken to the positive and negative of a battery to provide the current to drive the motor.
The third lead (white) is the control line and this is taken to the micro.
This line needs a pulse and the maximum repetition-rate accepted by the servo is every 18mS - it will accept a longer timing between pulses. This is the timing between pulses, the actual pulse-width is very short, between 0.9mS and 2.2mS.
If the pulse is less than 1mS duration (wide) the servo will travel fully in the anticlockwise direction.
If the pulse is 2mS, the servo will travel in the clockwise direction.
If the pulse is 1.5mS, the servo will travel to the mid position.
If the pulse is between these values, the servo will travel to a pre-determined position.
If the time between pulses is longer than 18mS, the speed of rotation will be decreased.