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

    Just a few comments from my basic understanding of RC

    Code:
    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 3 to RX signal - changed as GPIO3 is not ideal
    
    ReadPWM:
       PulsIn GPIO.4, 1,Pulselen    ' pin 3 - 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
    If you read the comments for pulselen it states that 100 = 1ms and 200 = 2ms, but your if / then statement states that if its less than 50 go blink. If you are monitoring a "normal" PPM signal from a receiver, the pulse length will be around 1ms for low stick and 2ms for full stick, with 1.5ms at centre. So even at low stick the signal will be 1ms or a pulse length of 100, it will never be lower than 50, and this the code will never jump to flash.

    I too had to change the config line to MCLRE_OFF for it to program without error

    EDIT:
    Oh and one other thing that may be causing the problem is that the RX will be sending the PPM pulse every 20ms, so you will need to get the timing right so that the pin is checked for a pulse at the right time. According to code it times out after .65535 seconds, maybe you need to make this time out after 20ms so it loops back round. Most of my experiments with other languages used the pre-scaler to get the timer to roll over at the desired timing if a pulse wasn't present. Maybe some of the more experienced guys can jump in here as I don't know if PBP features this option ?
    Last edited by malc-c; - 26th August 2006 at 00:53.

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Thank Melanie

    '12F675
    @ DEVICE pic12F675, INTRC_OSC_NOCLKOUT
    ' System Clock Options
    @ DEVICE pic12F675, MCLR_OFF
    ' Master Clear Options (Internal)
    @ DEVICE pic12F675, WDT_OFF
    ' Watchdog Timer
    @ DEVICE pic12F675, CPD_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.3 ' set pin 5 to RX signal

    ReadPWM:
    PulsIn GPIO.3, 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

  3. #3
    Join Date
    Aug 2006
    Posts
    91


    Did you find this post helpful? Yes | No

    Default

    ugg that doesn't compile either
    A bunch of illegal opcode warnings and errors
    207 and 122.

  4. #4
    Join Date
    Aug 2006
    Posts
    91


    Did you find this post helpful? Yes | No

    Default

    This is what the author of the original code said to me.

    That clock is much faster (meaning the 12F657) . The 12c508 has a 4Mhz clock. The return from Pulsin for the 12c508 is: 100 = 1.0 ms, 150 = 1.5 ms, 200 = 2.0 ms. You need to adjust the numbers to whatever your PIC returns in Pulsin. I have not looked at the data sheet. It will be there somewhere, or in the help data for your compiler.

    Maybe this is the problem?

  5. #5
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Really?

    It compiled without error on my PBP ver 2.47, I don't mean to be rude, Did you remember to select the appropriate device in the compiler (IDE) up at the top? I am confused are we talking about a 12F675, a 12f657, or a 12c508?
    It shows 199 words compiled for 12F675, it will not compile for a 12c508 or 12f508 as is. As for if it will work or not, that's beyond the scope of my examination, and likely ability, but it does compile as is.
    Last edited by Archangel; - 26th August 2006 at 07:00.

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


    Did you find this post helpful? Yes | No

    Default

    The reason it fails to compile is due to the config lines beginning with the @ sign. Change it to the format

    @ __CONFIG _INTRC_OSC_CLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF

    and it compiles OK. This is due to using either PBP or MPSAM as the compiler.

  7. #7
    Join Date
    Aug 2006
    Posts
    91


    Did you find this post helpful? Yes | No

    Default

    What Malc said.
    whenever I use
    @ DEVICE pic12F675, INTRC_OSC_NOCLKOUT
    ' System Clock Options
    @ DEVICE pic12F675, MCLR_OFF
    ' Master Clear Options (Internal)
    @ DEVICE pic12F675, WDT_OFF
    ' Watchdog Timer
    @ DEVICE pic12F675, CPD_OFF

    it errors all over the place.

    @ __CONFIG _INTRC_OSC_CLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF
    Works fine but HenrikOlsson said "I THINK it should be MCLR_OFF and not MCLRE_OFF. - try it."

    I'm not even sure thats were the problem is or why having the @ device lines like that fails.
    I have PBP 2.46 and MPLAB 7.41 MPSAM 5.04

    I still have no idea if thats the actual problem im having where the RC signal is basically ignored.

    Is anyone able to get this chip to actually work with RC signal with any settings?

  8. #8
    Join Date
    Aug 2006
    Posts
    91


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S.
    It compiled without error on my PBP ver 2.47, I don't mean to be rude, Did you remember to select the appropriate device in the compiler (IDE) up at the top? I am confused are we talking about a 12F675, a 12f657, or a 12c508?
    It shows 199 words compiled for 12F675, it will not compile for a 12c508 or 12f508 as is. As for if it will work or not, that's beyond the scope of my examination, and likely ability, but it does compile as is.

    Oh and yes I chose and am using 12F675

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