Rc signal help


Closed Thread
Results 1 to 40 of 43

Thread: Rc signal help

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Posts
    91

    Default Rc signal help

    I have read quite a bit on this and most sources point to using PulsIn.

    I found some code on the web for another chip and am trying to modify it for 12F675 but am getting no love.

    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
    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 > 50 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
    It should blink when no signal and be solid when there is but it seems to do whatever it wants no matter what signal I try and send it.

    Is it the config settings?
    Last edited by geckogrotto; - 25th August 2006 at 12:23.

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,610


    Did you find this post helpful? Yes | No

    Default

    Hi,
    Your program jumps to the same location whatever the pulsewidth is:
    Code:
    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     '<----HERE......
       If Pulselen > 50 Then GoTo Blink     '<----and HERE.....
       GoTo ReadPWM
    Change the the second If statement to
    Code:
    If Pulselen > 50 then Goto Solid
    HTH
    /Henrik Olsson.

  3. #3
    Join Date
    Aug 2006
    Posts
    91


    Did you find this post helpful? Yes | No

    Default

    Yea that was an accident when I retyped to simplify the code but its fixed now and still doesn't work.

    I also added this
    CMCON = 7 ' PortA Digital inputs

    I think this chip starts as analog or something still no help.
    Last edited by geckogrotto; - 25th August 2006 at 12:27.

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,610


    Did you find this post helpful? Yes | No

    Default

    Hi,
    The 'F675 has one comparator AND an A/D converter.
    The comparator is turned off with CMCON=7 and the the pins for the A/D is set to digital only with ANSEL=0.

    However....

    You're using GP3 for your input and that pin is not connected to either the comparator or the A/D so none of the above should really matter but I'm not sure. GP3 is however the MCLR pin and it seems you have a typo in your config setting. I THINK it should be MCLR_OFF and not MCLRE_OFF. - try it.

    Also, you're using a byte-size variable to store the pulsewidth, try switching that to a Word instead.

    /Henrik Olsson.

  5. #5
    Join Date
    Aug 2006
    Posts
    91


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by HenrikOlsson
    Hi,
    The 'F675 has one comparator AND an A/D converter.
    The comparator is turned off with CMCON=7 and the the pins for the A/D is set to digital only with ANSEL=0.

    However....

    You're using GP3 for your input and that pin is not connected to either the comparator or the A/D so none of the above should really matter but I'm not sure. GP3 is however the MCLR pin and it seems you have a typo in your config setting. I THINK it should be MCLR_OFF and not MCLRE_OFF. - try it.

    Also, you're using a byte-size variable to store the pulsewidth, try switching that to a Word instead.

    /Henrik Olsson.

    I tried swapping back and forth on ANSEL and CMCON neither seem to make a difference. Also when I change to MCLR_OFF it errors and will not even compile.

    I tried using word as well no luck.

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


    Did you find this post helpful? Yes | No

    Default No problem w/ MPLAB

    Hi, gecko

    No problem compiling with MPASM 7.41 and PbP 2.46a ...

    Error [ 118 ] is to forget when using @ __config

    May be add END ... at the end !!!, but that's not compulsory ( good habit then ... )

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

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