Markbishop16
Member
Hello, this is my first post so please be gentle.
I have a circuit using an 08M on an external beam, when the beam is broken it bleeps in the house in the day time, at night bleeps and brings the lights on.
Below is my program, don't laugh, well not too loud.
On the programming simulator the program works correctly, in real life it does not.
I/P 4 is the analogue input for the lights on timer. After much head scratching I found out that if the I/P on 4 is at minimum up to 1/3rd it works fine, when turned up beyond and all the way to max the inputs stop working. It appears that I/P 4 is still acting as a digital input, when 4=0 the board works, when 4=1 both inputs stop working and the units sits there like a lemon, the light timing function still works correctly.
The first program only had two trigger states, buzzer or buzzer and lights.
To get round this problem I have changed my trigger inputs to include I/P 4 in the table in both states 0 or 1. Originally I/P 4 was not in the table as I thought it being analogue would not change anything. If some kind soul could show me the error of my ways I would be most grateful.
Thank you in advance. I have read the manuals over and over but can not find the answer
I have a circuit using an 08M on an external beam, when the beam is broken it bleeps in the house in the day time, at night bleeps and brings the lights on.
Below is my program, don't laugh, well not too loud.
On the programming simulator the program works correctly, in real life it does not.
I/P 4 is the analogue input for the lights on timer. After much head scratching I found out that if the I/P on 4 is at minimum up to 1/3rd it works fine, when turned up beyond and all the way to max the inputs stop working. It appears that I/P 4 is still acting as a digital input, when 4=0 the board works, when 4=1 both inputs stop working and the units sits there like a lemon, the light timing function still works correctly.
The first program only had two trigger states, buzzer or buzzer and lights.
To get round this problem I have changed my trigger inputs to include I/P 4 in the table in both states 0 or 1. Originally I/P 4 was not in the table as I thought it being analogue would not change anything. If some kind soul could show me the error of my ways I would be most grateful.
Code:
let dirs = %00010 ; sets as outputs 0&1 as 0 is op any way
let pins = %10 ; outputs 0 low op 1 high
main: ; input (3) Buzz only. Input (3) & (2) LDR to start lighttime and buzz
readadc 4,b2 ;AD4 is the analogue input to B2 variable for time on
pause 200 ; debounce delay
if pins = %11110 then gosub interrupt ; night time, (3)beam & (2)LDR high THESE ARE THE COMMANDS I USE TO GET ROUND PIN 4
if pins = %01110 then gosub interrupt ; night tine, (3) beam & (2)LDR high
if pins = %11010 then gosub buzzertime ; daytime (3)beam high (2) LDR low
if pins = %01010 then gosub buzzertime ; daytime (3)beam high (2) LDR low
goto main
interrupt: ; Darkness. buzzer(0) and light (1) on
let pins = %01 ; light on and buzzer on
pause 1000 ; on for 1 second
let pins = %00 ; buzzer off
pause 1000 ; wait 1 second off
let pins = %01 ; buzzer on
pause 1000 ; buzzer on for 1 second
let pins = %00 ; buzzer off light stays on
wait 10 ; 10 second time with light on and no buzz, for beam blocked
for b0 = 1 to b2 ; b2 = variable, light on
let b1 = pins & %01100 ; b1 is the variable mask,for interrupt, input 3 & 2 high together
if b1 = %01100 then interrupt ; so if (3) beam & (2) LDR are on then buzz and start time loop again
pause 1000 ; length of delay for loop
next b0 ; loop command keep counting
let pins = %10 ; turns off,
setint %01100,%01100 ; reset interrupt on pin 3 & 2 going high
return ; go to main
buzzertime: ; Daytime. if (3) beam high (2) LDR low then buzz (0)only
let pins = %11 ; buzzer on
pause 1000 ; on for 1 second
let pins = %10 ; buzzer off
pause 1000 ; wait 1 second off
let pins = %11 ; buzzer on
pause 1000 ; buzzer on for 1 second
let pins = %10 ; buzzer off
Pause 5000 ; delay if beam blocked
return ; go to main
;0= OUTPUT for buzzer + in alarm
;1= OUTPUT for lights relay + normal state, low for lights on
;2= INPUT from LDR. Switch 0v with 100k to +
;3= Input from Beam. NC switch 0v with 10k to +
;4= Input from potentiometer. 250k