More IF_THEN dumb questions.


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Dec 2003
    Location
    Storrs, Ct.
    Posts
    91


    Did you find this post helpful? Yes | No

    Default more info

    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.
    Attached Files Attached Files

Similar Threads

  1. Olympic Timer
    By Melanie in forum Code Examples
    Replies: 47
    Last Post: - 17th September 2008, 19:46
  2. Two quick (and elementary) questions.
    By scorpion990 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 26th June 2008, 23:03
  3. A few 12F683 questions
    By dhouston in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 24th May 2008, 03:54
  4. Usart Questions
    By shawn in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 8th March 2008, 01:17
  5. Still new to PicBasic - i2c questions
    By cometboy in forum mel PIC BASIC
    Replies: 4
    Last Post: - 13th November 2006, 18:27

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts