Sorry for the delay, here's what I'm doing. I'm using a 16f876 with 4Mhz and of course PBP. Webpage interface thru Siteplayer.
What I'm trying to do is this..
I have 8 pilot relays to control from 4 to 8 lighting contactors via a time schedule.
Some of the contactors are mechanically held and require a pulse on, pulse off. For these I'll assign two seperate pilot relays, one for on pulse and one for off pulse.
Other contactors are electrically held and only require one relay to be energized when the contactor is to be on and cleared when the contactor is to be off.
I have declared R1ctrl thru R8ctrl variables to let me know what type control the relay will be used for, if clear the relay will be pulsed, if set the relay will hold on. These variables are set and cleared thru a webpage user interface that already works well.
The relays will also follow a time schedule, daytime and nighttime.
Each relay has a schedule bit R1sched thru R8sched to let me know if the relay is on the day schedule or the night schedule, day is clear and night is set.These variables are also set and cleared thru a webpage user interface that already works well.
I've also declared 4 additional bit variables, dayontime and dayofftime and nightontime and nightofftime.If dayontime is set anything on the day schedule should turn on and if dayofftime is set anything on the day schedule should be turned off.
Same goes for the nightontime/nightofftime relays.
These bits are set and cleared thru a RTClock subroutine, again set up thru a webpage that already works well.
code:
',
if rtchr = onhour and rtcmin = onmin then 'setup dayontime
dayontime = 1
else
dayontime = 0
endif
if rtchr = offhour and rtcmin = offmin then 'setup dayofftime
dayofftime = 1
else
dayofftime = 0
endif
if rtchr = nonhour and rtcmin = nonmin then 'setup nightontime
nightontime = 1
else
nightontime = 0
endif
if rtchr = nonhour and rtcmin = nonmin then 'setup nightofftime
nightofftime = 1
else
nightofftime = 0
endif
' ,
I also declared status variables for each contactor which need to be set when the contactor is told to be on, and cleared when the contactor is told to be off. R1status, R2status...R3status... These variables will be sent to the webpage for user notification that the lights are told to be on or off. (Possible realtime feedback in the next version.
Another bit variable, "override" I have declared, if set will not allow any clock control and if cleared allows clock control.
The entire system must be available for manual control at any time. This manual user interface comes via a webpage that I've already tested with a simple on/off routine.
I'm thinking I can come up with a subroutine for each relay to sort thru the necessary variables and give the desired output to the relay. My limited experience with PBP puts me in a box with A load of if-then's.
What I'm thinking is maybe someone with more knowledge of PBP can devise a different approach and get me out of my box. Something more compact maybe. I'm not looking for someone to write the code for me just Ideas on what direction I should try. I like the concept of the "CASE SELECT" but I don't see how it can be applied to this app.
I've included a knocked down version of the variables with only the ones that apply.
Thanks for any help.
Bookmarks