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 Cool

    That's awsome, be back in a day or so.. Lots to work on now.

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


    Did you find this post helpful? Yes | No

    Lightbulb an easier way?

    After confusing myself a little I came up with this,

    Code:
    checkrelays:
            select case myinput
                case 1,3,16,66          'manual and auto pulse on day and night
                   high relay1 : pause pulsetime : low relay1
                case 5,7,20,70          'manual and auto hold on day and night
                   high relay1 
                case 8,10,40,138       'manual and auto pulse off day and night
                   high relay2 : pause pulsetime : low relay2   
                case 12,14,44,142      'manual and auto hold off day and night
                   low relay1
               end select
               return
    This seems to cover all my possible cases, however this is for one relay, I have 8 to test.


    After filling MYINPUT the first time the only bits that need to be changed for the next relay are:
    myinput.1, myinput.2, myinput.3, and then the relays to act on, IE relay2, relay3, etc....

    Is there a better way to do this or just write a seperate case select for each relay?

    Thanks for any input!
    Last edited by ronjodu; - 22nd February 2005 at 00:41. Reason: Back to the drawing board.

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Are those other have the same condition ?!?

    If so, some array can be usefull..
    Code:
         For Loop = 0 to 3
         SelectCase Loop
              Case 0
                   TempTestVar = MyInput
              Case 1
                   TempTestVar = Myinput1
              Case 2
                   TempTestVar = Myinput2
              Case 3
                   TempTestVar = Myinput3
         end select
    
         Select case TempTestVar
              ' cases stuff BUT 
              ' Relay1[Loop] = 1 or 0
              ' Relay2[Loop] = 1 or 0
         end select
         Next
    Once it's done do a loop for refresh each relay section... that's it
    Last edited by mister_e; - 22nd February 2005 at 19:38.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

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


    Did you find this post helpful? Yes | No

    Thumbs up some success!

    I've coded the "myinput" and Select Case by hand for all 8 relays and ran it on my relay board and other than one typo relay # it worked perfectly. I was able to select time schedules, on and off, and relay control and watch it all happen realtime, in manual and auto mode.. Really cool!!!
    However, that portion of the program, all coded out individually, took 1.2K...
    which I'm sure can be done with less.

    I'm trying to follow your recent post about using an array. I'll surely have questions.

    Thanks a bunch for the help so far, my next post I'll probably start a new thread about Arrays. Going to check the archives first.

    Again thanks alot!!

Similar Threads

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