I am really struggling trying to convert a program I had written for a different chip to the ZX-24.
I really have no idea how to best get these loops to work correctly with the ZX-24
I have tried a couple of different ways, and I either end up in an endless look or it just doesn't work. So I guess what I am asking is what is the best way to implement these loops so they will function with the ZX-24
Code: Select all
start:
;-------------------------------------------------------------------------------------------------------------------------------
;--------------------------------------------Check solenoid time out-------------------------------------------------
;-------------------------------------------------------------------------------------------------------------------------------
if Sol_Count = $FFFF then
goto Main ;Wait for solenoid timer to run out before activating system
else
pause 50
if sol_count = 250 then
high buzzer
endif
goto Checks
endif
;-------------------------------------------------------------------------------------------------------------------------------
;----------------------------------Start of main program------------------------------------------------------------------------
;-------------------------------------------------------------------------------------------------------------------------------
Main:
pause 40 ;~40 ms time delay
;-------------------------------------------------------------------------------------------------------------------------------
;---------------------------------This section checks sensor activity--------------------------------------------------
;-------------------------------------------------------------------------------------------------------------------------------
If (Door_Switch = 0) and (Motion_Trig = 0) Then goto system_hit ;system was hit turn on hit light
If (Door_Switch = 0) Then Goto Door_opened ;Turn on IR leds and recorder
If (motion_Trig = 0) Then goto motion_sensed ;Turn on everything except hit light
;-------------------------------------------------------------------------------------------------------------------------------
;---------------------------these routines decrements counters at ~25 ms loop cycle time----------------------------------------
;-------------------------------------------------------------------------------------------------------------------------------
Checks:
;Wait_time: ffff indicates disabled, 0000 indicates timer completed, other value is current count
if Wait_time=$ffff then Check_sol ;check if disabled
if Wait_time = 0 then ;check if timed out
let Wait_time = $ffff ;disable Wait_time
Low IR_LEDS
High DVR_Control
Low Cameras
endif
Let Wait_time = Wait_time - 1 ;decrement real time count
;-------------------------------------------------------------------------------------------------------------------------------
;check to see if 20 seconds has elapsed
;-------------------------------------------------------------------------------------------------------------------------------
check_sol:
if sol_count = $ffff then check_IR_Leds ;check if disabled
if sol_count = 0 then ;check if timed out
let sol_count = $ffff ;disable sol_count
goto system_Startup ;This gets the system up and running
endif
Let sol_count = sol_count -1 ;decrement solenoid time count
;-------------------------------------------------------------------------------------------------------------------------------
;check to see if 1 minute has elapsed IR leds are turned on and DVR is recording
;-------------------------------------------------------------------------------------------------------------------------------
check_IR_Leds:
if IR_Leds_Delay = $ffff then check_hit_light ;check if disabled
if IR_Leds_Delay = 0 then ;check if timed out
let IR_Leds_Delay = $ffff ;disable Wait_time
low IR_LEDS
High DVR_Control
low Cameras
endif
Let IR_Leds_Delay = IR_Leds_Delay -1 ;decrement real time count
;-------------------------------------------------------------------------------------------------------------------------------
;Delay before the hit light comes on 25 minutes
;-------------------------------------------------------------------------------------------------------------------------------
check_hit_light:
if Hit_light_delay = $ffff then next_check:
if (Hit_light_delay = 0) and (Hit_flag = 1) then
High Hit_light
let Hit_light_delay = $ffff
endif
Let Hit_light_delay = Hit_light_delay -1
next_check:
goto start
Any help on the best way to do this would be appericated.
Thanks
Patrick