Controlling Relays


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default When do you turn off the leds that you turn on initially?

    My thinking is that while keeping the switch on for the momentary relay to stay on the data being branch would be the same so the relay would stay on. When I release the switch then the data being branched changes so the relay would turn off. Is this correct?

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    Yes,


    on each loop, you must check which keys are released and de-energize the corresponding 1-5 relays. ( the last ones do not need it ...)

    the PIC outputs must be considered as Bistable ones ... and you must write every change you want !!!

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3


    Did you find this post helpful? Yes | No

    Default what value is Keydata if no key pushed ??? good question !

    The value of Keydata is 0 if no key is pressed: here is how I've set that,
    if keyin = nokey then keydata = %00000000

    Thank you for your help.

  4. #4


    Did you find this post helpful? Yes | No

    Default This is what I am using to send to the relay board

    define osc 4
    INCLUDE "MODEDEFS.BAS"
    CMCON = 7
    serpin var porta.3
    nokey con %11111111
    preamble con %01010101
    synch con 254
    keyin var portb
    keydata var byte
    trisb = %11111111
    trisa = %00010111
    key1 VAR PORTB.0
    key2 VAR PORTB.1
    key3 VAR PORTB.2
    key4 VAR PORTB.3
    key5 VAR PORTB.4
    key6 VAR PORTB.5
    key7 VAR PORTB.6
    na VAR PORTB.7




    findkey:
    clear
    pause 50
    if key1 = 0 then sw1
    if key2 = 0 then sw2
    if key3 = 0 then sw3
    if key4 = 0 then sw4
    if key5 = 0 then sw5
    if key6 = 0 then sw6
    if key7 = 0 then sw7
    if key8 = 0 then sw8

    goto findkey

    sw1:
    keydata = 1
    goto transmit
    sw2:
    keydata = 2
    goto transmit
    sw3:
    keydata = 3
    goto transmit
    sw4:
    keydata = 4
    goto transmit
    sw5:
    keydata = 5
    goto dout
    sw6:
    keydata = 6
    goto transmit
    sw7:
    keydata = 7
    goto transmit
    sw8:
    keydata = 8
    goto transmit




    transmit:

    serout serpin,N2400,[preamble,synch,keydata]
    pause 50
    if keyin = nokey then keydata = %00000000
    goto findkey


    end

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    All define's must be capitalized (not that it makes any difference in this case)

  6. #6
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Default

    1. There is no Key8.
    2. You can send the content of the whole PORTB when a change occurs; may be it would be more convenient but it is up to your choice.

    For example:

    Code:
    FindKey:
         CLEAR
         KeyData = PORTB                    
         PAUSE 50
         IF PORTB = KeyData THEN FindKey   'Transmit only if there is at least a (one) change on PORTB. 
    
         SEROUT SerPin,N2400,[PreAmble,Synch,PORTB]
         PAUSE 50
             
         GOTO FindKey
    This code will transmit the content of the PORTB every time there is a change on PORTB.
    Thus, for instance, if PORTB.0 is 0, it will transmit, and then if it is still 0, it will NOT transmit.
    If PORTB.0 is still 0 and then another change occurs at say PORTB.1 then it will transmit.

    This way, you can handle the process at receiver side.
    Last edited by sayzer; - 29th January 2008 at 11:59.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

Similar Threads

  1. Replies: 10
    Last Post: - 17th February 2012, 07:19
  2. SMS control for Relays
    By charudatt in forum Code Examples
    Replies: 15
    Last Post: - 2nd May 2009, 00:08
  3. PIC relays control
    By flipper_md in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 1st October 2008, 16:03
  4. High End Pre with PIC 16F876A
    By abidr in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 8th May 2008, 08:13
  5. Controlling a DC solenoid
    By The Master in forum Off Topic
    Replies: 2
    Last Post: - 23rd December 2007, 01:26

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