Rc signal help


Closed Thread
Results 1 to 40 of 43

Thread: Rc signal help

Hybrid View

  1. #1
    Join Date
    Mar 2006
    Location
    China
    Posts
    266


    Did you find this post helpful? Yes | No

    Default Have you tried timers?

    Hi,

    I am not a big fan of PULSIN. It is sometimes hard to know what is happening so I prefer setting up timers to measure things myself. There are several posts in this forum how to use timers and it is really not that hard. If you pick a 16 bit timer and set the prescaler to 1:1 you can measure up to 65 ms without overflowing at 4 Mhz and 2.55 ms with a 8-bit timer and getting a nice resolution. The RC signal shouldn't be hard to catch this way.

    If you have tried everything else, Timers might be worth a try.



    /me
    Last edited by Jumper; - 26th August 2006 at 18:35.

  2. #2
    Join Date
    Aug 2006
    Posts
    91


    Did you find this post helpful? Yes | No

    Default

    Ok im feeling really dumb but may have it worked out. Doing some tests
    Last edited by geckogrotto; - 26th August 2006 at 19:13.

  3. #3
    Join Date
    Aug 2006
    Posts
    91


    Did you find this post helpful? Yes | No

    Default

    Ok man I found the problem it was infinite resistance between the keyboard and chair

    Its working now. Working on cleaning up the code and will post new code when i'm done... It wasn't my code that was the problem it was me lol

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


    Did you find this post helpful? Yes | No

    Wink goal revisiting ...

    Hi, Gremlin - lotto ( ! )

    The blinking rate could help ( US, European ... ??? ) ... thanks.

    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 " !!!
    *****************************************

  5. #5
    Join Date
    Aug 2006
    Posts
    91


    Did you find this post helpful? Yes | No

    Default

    Ok so here it is Im stupid was the main problem. Somehow I figured that the signal would just come pouring out of that little white wire without any ground to the signal cable... Once I got over that blonde moment everything fell into place. The code below could be done a lot better and some saftys put in for wild RC signals but I wanted to get out some working code.
    Basically by moving the stick back and forth it will figure out whats the max high and low and then accept anything thats about 1/3 of that in that direction. Now that its clear as mud here is the code
    Code:
    '12F675
    @ __CONFIG _INTRC_OSC_CLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF
    OPTION_REG.5 = 0                                                       ' clock source internal
    
    Pulselen   var Byte                                                 ' Pulselen can be 0 - 255, 100 = 1 ms, 200 = 2 ms
    Init       var Byte                                                 ' Init used to flash LED
    HighCode   Var Byte
    LowCode    Var Byte
    clear
    highcode = 0 ' setup vars to be changed
    lowcode = 200 ' setup vars to be changed
    Input GPIO.3                                                           ' set pin 5 to RX signal
    
    ReadPWM:
       PulsIn GPIO.3, 1,Pulselen                 ' pin 4 - read high pulse length, times out after .65535 seconds 
    If pulselen > highcode then Highcode = Pulselen ' make sure highcode is at full throw This will avoid having to go though a setup
    If pulselen < LowCode and Pulselen > 50 then Lowcode = Pulselen ' make sure lowcode is at full throw This will avoid having to go though a setup
    if (Pulselen + 20) >= highcode then
       For Init = 1 To 6                                                 
          High GPIO.1                                                      
          pause 60                                                      
          Low GPIO.1                                                     
          pause 60                                                      
       Next
    pause 1000		    
     endif
    If (Pulselen - 20) <= LowCode Then 
          High GPIO.1                                                      
          pause 3000                                                      
          Low GPIO.1
          pause 200
    endif
    
       GoTo ReadPWM

  6. #6
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    Yup - works here too - using a JR X3810 transmitter and cheap and chearful GWS RX

    We got there in the end

  7. #7
    malc-c's Avatar
    malc-c Guest


    Did you find this post helpful? Yes | No

    Default

    I've changed your code a bit to make a simple RC Switch that turns on GPIO.1 in real time (ie activate the switch on the TX and the LED lights or goes out)

    I've also removed some parts that are not needed (input GPIO.3 for example as PULSIN automatically makes the pin an input)

    Code:
    '12F675
    @ __CONFIG _INTRC_OSC_CLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF
    OPTION_REG.5 = 0                                                       
    
    Pulselen   var Byte                                                   
    HighCode   Var Byte
    LowCode    Var Byte
    clear
    highcode = 0 ' setup vars to be changed
    lowcode = 200 ' setup vars to be changed
                                                              
    
    ReadPWM:
    PulsIn GPIO.3, 1,Pulselen                 
    If pulselen > highcode then Highcode = Pulselen 
    If pulselen < LowCode and Pulselen > 50 then Lowcode = Pulselen 
    if (Pulselen + 20) >= highcode then High GPIO.1                                                      
    If (Pulselen - 20) <= LowCode Then low GPIO.1                                                   	    
    GoTo ReadPWM
    Good result for the end of the day.

Similar Threads

  1. Replies: 24
    Last Post: - 1st December 2009, 08:01
  2. Decoding an incoming infrared signal: need advice
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 9th May 2008, 16:28
  3. PIC16F684 + LCD to use the 256bytes of EEPROM - HELP
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 7th March 2008, 14:19
  4. Help with sound command in 2 programs
    By hyperboarder in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th July 2007, 20:36
  5. Rc PCM signal Read (Help)
    By jetpr in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 8th March 2005, 03:37

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