Need help - Just want to make a simple switch using RF Modules


Closed Thread
Results 1 to 14 of 14

Hybrid View

  1. #1

    Exclamation Need help - Just want to make a simple switch using RF Modules

    Hello everyone.
    I have two RF modules and I want to make a switch where the receiver should keep a pin high if and untill it is getting a valid signal from the transmitter. Receiver is driving a 12v Relay using 9013 via 1K.
    Currenty the relay is producing flickering. My code is attached.

    Can some please try to help?
    Attached Files Attached Files
    ___________________
    WHY things get boring when they work just fine?

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    With the code you have posted, you set high gpio.5 when w1 is 24 and gpio.1 when w1 is 51 then you go to label start and you set gpio to 0, this is why relay flickers

    Code:
    start:                                                          
    gpio=0
    serin GPIO.2,N2400,["pl65"],w1
      if w1=24 then gpio.5=1
      if w1=51 then gpio.1=1 
      'if w1=90 then gpio.4=1
      'if w1=36 then gpio.0=1
      pause 500
     goto start
    Set gpio=0 to the begining of your code, in such a way that is executed at start up only once, than use a condition like :

    Code:
     
    if w1=25 then gpio.5=0
    if w1=52 then gpio.1=0
    to switch off your relays.

    Al
    All progress began with an idea

  3. #3
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    966


    Did you find this post helpful? Yes | No

    Default

    Use this as your receiver code

    Code:
    Define OSC 4
    intcon=0
    cmcon0=7
    TRISIO=%001100
    GPIO=0
    w1 VAR byte
    prevw1 var byte
    Include "modedefs.bas"
    
    @ __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _CP_ON & _BOD_ON & _CPD_ON & _IESO_OFF & _FCMEN_ON & _WUREN_OFF
    
    start:                                                          
    serin GPIO.2,N2400,["pl65"],w1
    if w1 <> prevw1 then                    ' new command not same as prev
      prevw1 = w1                             ' update the value of prev command
      gpio = 0
      if w1=24 then gpio.5=1                ' and change the output
      if w1=51 then gpio.1=1 
      'if w1=90 then gpio.4=1
      'if w1=36 then gpio.0=1
      pause 500                                ' you may not need this line now
    endif
     goto start

  4. #4


    Did you find this post helpful? Yes | No

    Exclamation

    Thanks for the answers guys, few questions:
    I only have two buttons on Tx as an option. I am sorry if I failed to explain that the process has to work with one button only, i.e. if button 1 is pressed relay one should activate and when it is released relay should stop, same with the button 2 and relay 2.

    I added gpio=0 at after start to make sure the relays are off if no valid signal is comming otherwise before that statement relay was just left on.

  5. #5
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    Your transmitter, when you release the push-botton, should Tx ascii(100) or "d" then reciever will reset to zero both relays

    Code:
    start:                                                          
    serin GPIO.2,N2400,["pl65"],w1
    if w1=24 then gpio.5=1
    if w1=51 then gpio.1=1 
    if w1=100 and gpio.1=1 or gpio.5 = 1 then gpio = 0 
    goto start
    Al.
    All progress began with an idea

  6. #6


    Did you find this post helpful? Yes | No

    Question

    Problem is that the Tx only gets power while the button is pressed once button is released, power is also removed from the pic. Is there any way I can achieve my goal using an capacitor or somthing at the output in the hardware as I dont seem to figure out an solution with software (Unless someone comes up with somthing I can try on my exsisting setup). I already tried using an 470uF at the output pin + replacing 1K wih an diode. I am having problem with timings now BUT flickering seems to have been absorbed by the capacitor. If possible any sugesstion about the cap values I can try to have instant responses by the receiver PIC?
    Last edited by financecatalyst; - 24th October 2009 at 17:23.
    ___________________
    WHY things get boring when they work just fine?

  7. #7
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Might be able to do what you want by counting. Keeping track of the last push...

    But you will only have to count to one. The count VAR could start at 0. When the button is pushed...
    IF COUNT VAR = 0 THEN
    TX XYZ
    COUNT VAR = 1
    ELSE
    IF COUNT VAR = 1 THEN
    TX ZYX
    COUNT VAR = 0

    EEPROM may be required...

    Something like that
    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. Simple RF remote control code
    By Bruce in forum Code Examples
    Replies: 13
    Last Post: - 22nd January 2014, 10:45
  2. RF Modules (Zigbee)
    By Chris Barron in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 4th March 2010, 18:28
  3. RF transmission and FSK modules
    By boban in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 8th May 2009, 07:19
  4. RF Transceiver modules help
    By davewanna in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th May 2008, 14:54
  5. Help with CC1100 RF Modules.
    By charudatt in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 27th November 2006, 20:58

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