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


Closed Thread
Results 1 to 14 of 14
  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
    948


    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.

  8. #8


    Did you find this post helpful? Yes | No

    Question

    Quote Originally Posted by mackrackit View Post
    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
    Thanks for the answer, but I am sorry I couldnīt get your point how this will help. Could you explain a bit more please.
    ___________________
    WHY things get boring when they work just fine?

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by financecatalyst View Post
    Thanks for the answer, but I am sorry I couldnīt get your point how this will help. Could you explain a bit more please.
    Well I miss read what you are wanting to do... If I am reading it all correctly now just have the receiver activate the relays only if there is a valid RF signal with the correct data coming in. If the data is not correct the relay stays off or goes off....

    Sorry to confuse things... It is time for my nap...

    BTW you is that in post #4?
    Dave
    Always wear safety glasses while programming.

  10. #10


    Did you find this post helpful? Yes | No

    Question

    Quote Originally Posted by mackrackit View Post
    Well I miss read what you are wanting to do... If I am reading it all correctly now just have the receiver activate the relays only if there is a valid RF signal with the correct data coming in. If the data is not correct the relay stays off or goes off....

    Sorry to confuse things... It is time for my nap...
    That is correct. Sorry for the mixup in post #4, its two of us working on the same thing and using the same computer. Hope to find the solution soon to this problem.
    ___________________
    WHY things get boring when they work just fine?

  11. #11


    Did you find this post helpful? Yes | No

    Default

    I did a design a while back where the TX needed to be completely off for max battery life. I used a n-channel FET and I/O pin to enable the pic to strap itself on while the tx button was pressed, once released the code saw the falling edge and transmitted the off data. After that the pic turned itself off.

  12. #12


    Did you find this post helpful? Yes | No

    Question

    Quote Originally Posted by Macgman2000 View Post
    I did a design a while back where the TX needed to be completely off for max battery life. I used a n-channel FET and I/O pin to enable the pic to strap itself on while the tx button was pressed, once released the code saw the falling edge and transmitted the off data. After that the pic turned itself off.
    In the circuit I have, the Transmitter module gets full 12V(via LR23 battery) and Tx gets 5V via 7805. The circuit only completes upon when button is pressed. Any sugesstion for making any change to the hardware part i.e. at the output pin of the Rx. I am having a feeling now that this problem cannot be solved via software!!
    ___________________
    WHY things get boring when they work just fine?

  13. #13


    Did you find this post helpful? Yes | No

    Default

    Ok I am missing something......you posted a couple of posts ago the following....

    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?
    So I came back with my design for a FET transistor supplying power as long as it takes to transmit an off command when you let go of the button. This should solve your issue. Especially since you have two different voltage sources, your N-channel FET would go between your common grounds, to essentially switch ground on or off. Just imagine it as a switch that cuts your circuit off at the ground side.

    If you use a 100uF cap at the + side make sure that there is a resistor in parallel with the cap that will discharge it when the FET cuts off ground.

    Nick
    Last edited by Macgman2000; - 25th October 2009 at 02:41.

  14. #14


    Did you find this post helpful? Yes | No

    Post

    hello Macgman200, can I please please request you to draw me a simple schematic for what you are saying. I am not very expert in this domain. Looks like you are talking a practical solution! Many thanks
    ___________________
    WHY things get boring when they work just fine?

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