Rc signal help


Closed Thread
Results 1 to 40 of 43

Thread: Rc signal help

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    I've used the 12F675 as an RC switch and it works fine. The only thing is it was programmed in Assembler, and JAL (which I lost the notes on due to a PC crash).

    I'm sure its just a matter of getting the timing correct, so the PIC is able to detect and measure the pusle width of every pulse. As I mentioned above, the RX will be sending a pulse every 20ms, which is generally 1 - 2 ms in duration.

  2. #2
    Join Date
    Aug 2006
    Posts
    91


    Did you find this post helpful? Yes | No

    Default

    Wouldn't holding the stick cause the signal to repeat and therefore catch it at some point?

    I have tried and assumed that it would eventually see the signal but never seems to see anything.

    I may have to go picaxe as I can't seem to dissect a data sheet.

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


    Did you find this post helpful? Yes | No

    Default

    Well I just compiled the following and I get flashing LEDs (I haven't got the time this morning to hook up a receiver and test the reading of the PPM signal)

    Code:
    '12F675
    @ __CONFIG _INTRC_OSC_CLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF
    
    
    DEFINE OSC 4
    OPTION_REG.5 = 0 ' clock source internal
    CMCON = 7
    ANSEL=0
    
    Pulselen var word ' Pulselen can be 0 - 255, 100 = 1 ms, 200 = 2 ms
    Init var word ' Init used to flash LED
    Clear ' set all variables = 0
    
    Input GPIO.4 ' set pin 5 to RX signal
    
    ReadPWM:
    PulsIn GPIO.4, 1,Pulselen ' pin 4 - read high pulse length, times out after .65535 seconds
    pause 15
    If Pulselen < 50 Then GoTo Blink ' no signal -> blink led
    If Pulselen > 75 Then GoTo solid ' signal -> Solid led
    GoTo ReadPWM
    
    Blink:
    For Init = 1 To 3 ' blink led 3 times
    High GPIO.1
    pause 200
    Low GPIO.1
    pause 200
    Next
    pause 1000
    GoTo ReadPWM
    
    Solid:
    High GPIO.1
    pause 3000
    Low GPIO.1
    pause 200
    GoTo ReadPWM
    END
    The only change I made was to use GPIO.4 and not GPIO.3

    EDIT:
    OK so I couldn't go out without testing the code to see if it reads the PPM signal.. sorry to say it doesn't detect it
    Last edited by malc-c; - 26th August 2006 at 08:37.

  4. #4
    Join Date
    Aug 2006
    Posts
    91


    Did you find this post helpful? Yes | No

    Default

    Malc bud when you get back could you try it for me?

    I get the blinking light as well that means it is seeing no signal. I can't seem to get it to go solid tho, well actually it does when it feels like it sometimes but not when im pressing the stick.

    This has been the problem the whole time just blinks how it wants and seemingly ignores any signal no matter what changes I make to the config or anything.

  5. #5
    Join Date
    Aug 2006
    Posts
    91


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by malc-c
    EDIT:
    OK so I couldn't go out without testing the code to see if it reads the PPM signal.. sorry to say it doesn't detect it

    Ahh posted edit right as I posted hehe. Yea thats the same thing I get

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


    Did you find this post helpful? Yes | No

    Default

    Hi, Gecko

    Some little gags here and there ... but try it !!!


    '12F675
    @ __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF ' clock source internal
    OPTION_REG.5 = 0

    DEFINE PULSIN_MAX 2500
    DEFINE OSCCAL_1K 1

    CMCON = 7 'Tout digital pour 12F675
    ADCON0 = 0 'ADC off "
    ANSEL = 0
    VRCON = 0



    Pulselen var Byte ' Pulselen can be 0 - 255, 100 = 1 ms, 200 = 2 ms
    Init var Byte ' Init used to flash LED
    Compte var Byte

    In var GPIO.3
    Led var GPIO.1

    Clear ' set all variables = 0

    TRISIO = %001000

    High Led

    ReadPWM:

    PulsIn In, 1,Pulselen ' pin 4 - read high pulse length, times out after .65535 seconds

    If Pulselen < 80 OR Pulselen > 220 Then

    Pause 15

    Compte = Compte + 1

    IF Compte // 16 THEN

    Pulsout Led, 10000

    ENDIF

    Else

    HIGH Led

    ENDIF

    GoTo ReadPWM

    END

    I'll do better next time ...

    Alain

    PS: ... breadboard verified .... Yess !!!
    Last edited by Acetronics2; - 26th August 2006 at 10:25.
    ************************************************** ***********************
    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 " !!!
    *****************************************

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


    Did you find this post helpful? Yes | No

    Default

    Looking at the manual it states

    If the pulse edge never happens
    or the width of the pulse is too great to measure, Var is set to zero.
    Maybe the the pulsein statement is reaching the 65535 counts before the end of the pulse width and thus is setting the value of pulselen to 0 which will always cause the code to jump to the flash led section.

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


    Did you find this post helpful? Yes | No

    Default

    Alain,

    Now we're getting somewhere... when the TX is powered the LED is constant, when the TX is off (ie no signal beeing transmitted) the LED falshes...

    However when the TX is on and the channel that is connected has its state changed (ie gear switch on CH5) nothing happens. Now could this be down to the fact that its detecting a sync pulse and not the actual channel PPM pulse ?

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


    Did you find this post helpful? Yes | No

    Default

    Well there are no sync pulses coming out of the rx, just a nice train of 1ms pulses at 20ms intervals
    Attached Images Attached Images  

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


    Did you find this post helpful? Yes | No

    Default

    Hi, Malc - the - bass - beat - filter - forum ...

    I do not understant your question so well ...

    When the transmitter is on ( and good link to Rx !!! ) the received channels durations are ALWAYS in the 800 - 2200 µS range ...

    WHATEVER you do with your sticks and switches ...

    THE ONLY exception is the LM1872 IC coder where pulses can " disappear" from the frame. But I didn't see such circuit in any of our R/C dedicated radios for, at least 30 years ...

    I Think you're mixing memory switch and missing ( or wrong ) pulse detector ...

    Nothing has to happend on a stick position change, here ...

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

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


    Did you find this post helpful? Yes | No

    Default

    Don't talk to me about base beat filters !!

    Let me explain the test rig. I,m using a simple GWS 8ch RX. Ch5 is a straight switched channel on the TX. Ch5 on the RX is connected to the input pin on the PIC. With power applied to the RX and the TX turned on with the switch in one position you get a nice train of 1ms pulses appearing on the PIC input. - There is no mixining involved.

    I think whats happening here is we are getting confused over Dan's requirements are. He doesn't want to simply detect the presence of a signal, he needs to detect the change of state of that pulse from 1ms width to 2ms. So maybe the IF/THEN statement should read if pulselen <150 flash LED else LEDS is solid ??

    Does pulsein measure the time between positive going pulses, or is it triggered by the positive going pulse, then measures the time in 10us chuncks until it goes negative ? The reason I ask is that if it measures from one positive going pulse to the next then the value will be 20ms (or 2000 counts) and will thus always invoke a "no signal" responce ??

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