Control a Radio PLL with a PIC


Closed Thread
Results 1 to 40 of 54

Hybrid View

  1. #1
    Join Date
    Jun 2011
    Posts
    37


    Did you find this post helpful? Yes | No

    Default Re: Control a Radio PLL with a PIC

    Quote Originally Posted by Archangel View Post
    That's funny. I just ordered 2 pic18f4431 s on Thursday for this specific purpose. I found even using asm interrupts the 16f690 too slow to track the encoder without losing steps, (either that or it was switch bounce). So I figure to use a PIC with QEI Hardware inputs and a 40mhz clock. Failing that I will try using flip flops to buffer the inputs. In any event there is plenty to learn.
    Now off to Costco for a box of Corn Nuts, and 3 pounds of coffee . . .
    Edit:

    Or you can use a lookup table and display channels or frequency.
    Do you have an old Knight Kit radio as well?
    Display channels or frequency? This sounds great. How would I do that?
    My displays are only 3 digits.

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


    Did you find this post helpful? Yes | No

    Exclamation Re: Control a Radio PLL with a PIC

    Quote Originally Posted by RayL113 View Post
    Do you have an old Knight Kit radio as well?
    Display channels or frequency? This sounds great. How would I do that?
    My displays are only 3 digits.
    Nope no Knight kit, I was thinking of a retrofit for old 23 ch CB radios make them useful, other freqs, 10M . . . set a couple of vars
    Code:
     temp var byte
    Code:
     i var byte
    Code:
     lookup i[010,020,030 . . .500],temp
    this aliases your count to the numbers in the lookup table . . . You could set a freq switch with static displays like 142, 143, 144 . . . and follow with the displays driven by the lookup table displaying the fine freqs. Or change up to a word var and you have up to 65535 values you could step through, or use 2 encoders (old Henry 2m used 2 switches ganged) sorry about the code formats, crazy forum software glitch killed formatting for me, so I had to do it this way.
    Last edited by Archangel; - 11th June 2011 at 08:53.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    Jun 2011
    Posts
    37


    Did you find this post helpful? Yes | No

    Default Re: Control a Radio PLL with a PIC

    Var, I take to mean variable. Remember I'm new to Pics and PBP. So a word var? Is this an extended table?

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


    Did you find this post helpful? Yes | No

    Default Re: Control a Radio PLL with a PIC

    From the manual
    4.3. Variables

    Variables are where temporary data is stored in a PICBASIC PRO™ program. They are created using the VAR keyword. Variables may be bits, bytes or words. Space for each variable is automatically allocated in the microcontroller=s RAM by PBP. The format for creating a variable is as follows:
    There are basically four sizes a VAR can be while using PicBasicPro 2.6x
    BIT = number of BITs - 1
    BYTE = number of BITs - 8
    WORD = number of BITs -16
    LONG = number of BITs - 32
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default Re: Control a Radio PLL with a PIC

    Yes, var= variable
    bit is one of the placeholders in the larger variable, example
    say you want a variable to hold a value as a flag for an event, you could make a bit variable, called . . . FLAGBIT this way FLAGBIT VAR BIT
    or you might need several flag bits and do it this way
    FLAGBIT VAR BYTE which gives you an 8 bit byte full of FLAGBITS as follows
    FLAGBIT.0 lowest bit in the byte
    FLAGBIT.1 second bit in the byte
    FLAGBIT.2 third " " " "
    FLAGBIT.3 . . .
    FLAGBIT.4 . . . all the way to FLAGBIT.7 , FLAGBIT.7 being the highest order bit in the byte variable
    which is to say you can address every bit of your variable individually.
    Byte = %00000000 will hold 0 to 255 in decimal
    word = %00000000 00000000 will hold 0 to 65535 in decimal
    LONG = %00000000 00000000 00000000 00000000 which is 4294967295 but I think (I am not sure of this) only allows 1/2 that much on each side of zero -2147483647 0 2147483647

    Notice the way I have written the binary expression %00000000 this is the appropriate syntax for P Basic Pro, other compilers may use different "punctuation" and you will see "BIG ENDIAN" and LITTLE ENDIAN" usage and all that means is which end of the group of zeros is the least significant bit, the Left or the Right.

    You will see different ways of displaying hex as well, in PBP we use $00 whereas in C you might see something like 0h00
    Last edited by Archangel; - 12th June 2011 at 01:15.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: Control a Radio PLL with a PIC

    in PBP we use $00 whereas in C you might see something like 0h00
    high likely 0x00
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default Re: Control a Radio PLL with a PIC

    This may not be it, but the only thing I notice is: you have OSC_HS selected, but you are using an oscillator at 4 mhz. If you are using an oscillator instead of a resonator, this should be set to XT for 4 mhz. If you are using a resonator, did you see the note with the data sheet?

    Note: When using resonators with frequencies
    above 3.5 MHz, the use of HS mode,
    rather than XT mode, is recommended.
    HS mode may be used at any VDD for
    which the controller is rated. If HS is
    selected, it is possible that the gain of the
    oscillator will overdrive the resonator.
    Therefore, a series resistor should be
    placed between the OSC2 pin and the
    resonator. As a good starting point, the
    recommended value of RS is 330Ω.
    http://www.scalerobotics.com

  8. #8
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: Control a Radio PLL with a PIC

    Rayl113, Also make sure the "PBADEN" bit's are set for Digital on reset. Other wise the port Bb.0 thru B.3 are set as analog after reset....
    Dave Purola,
    N8NTA
    EN82fn

  9. #9
    Join Date
    Jun 2011
    Posts
    37


    Did you find this post helpful? Yes | No

    Default Re: Control a Radio PLL with a PIC

    Quote Originally Posted by Archangel View Post
    Yes, var= variable
    bit is one of the placeholders in the larger variable, example
    say you want a variable to hold a value as a flag for an event, you could make a bit variable, called . . . FLAGBIT this way FLAGBIT VAR BIT
    or you might need several flag bits and do it this way
    FLAGBIT VAR BYTE which gives you an 8 bit byte full of FLAGBITS as follows
    FLAGBIT.0 lowest bit in the byte
    FLAGBIT.1 second bit in the byte
    FLAGBIT.2 third " " " "
    FLAGBIT.3 . . .
    FLAGBIT.4 . . . all the way to FLAGBIT.7 , FLAGBIT.7 being the highest order bit in the byte variable
    which is to say you can address every bit of your variable individually.
    Byte = %00000000 will hold 0 to 255 in decimal
    word = %00000000 00000000 will hold 0 to 65535 in decimal
    LONG = %00000000 00000000 00000000 00000000 which is 4294967295 but I think (I am not sure of this) only allows 1/2 that much on each side of zero -2147483647 0 2147483647

    Notice the way I have written the binary expression %00000000 this is the appropriate syntax for P Basic Pro, other compilers may use different "punctuation" and you will see "BIG ENDIAN" and LITTLE ENDIAN" usage and all that means is which end of the group of zeros is the least significant bit, the Left or the Right.

    You will see different ways of displaying hex as well, in PBP we use $00 whereas in C you might see something like 0h00
    Thanks that helps alot. Yes I had noticed the % in front of what looked like binary expressions but hadn't noticed the $ in front of hex expressions. Can you still use the "b and h" in PCB? In case I forget and use the asm expression?

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


    Did you find this post helpful? Yes | No

    Default Re: Control a Radio PLL with a PIC

    Can you still use the "b and h" in PCB?
    Nope.
    From the manual.
    4.8. Numeric Constants
    PBP allows numeric constants to be defined in the three bases: decimal, binary and hexadecimal. Binary values are defined using the prefix '%' and hexadecimal values using the prefix '$'. Decimal values are the default and require no prefix.

    100 ' Decimal value 100
    %100 ' Binary value for decimal 4
    $100 ' Hexadecimal value for decimal 256
    Dave
    Always wear safety glasses while programming.

  11. #11
    Join Date
    Jun 2011
    Posts
    37


    Did you find this post helpful? Yes | No

    Default Re: Control a Radio PLL with a PIC

    What if I want to use a cb channel switch instead of an encoder? The first four pins have a logical progression of 0000 to 1111. Couldn't I use this like a Gray code encoder? Count increase would equal up and count decrease would equal down. What do you think?

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