Re: Control a Radio PLL with a PIC
Quote:
Originally Posted by
cncmachineguy
I have a concern for you, in this bit of code
Code:
LOOP
PEEK CHSEL CHSELVAR
If CHSEL > CHSELVAR Then UP
Else
PEEK CHSEL CHSELVAR
IF CHSEL < CHSELVAR Then DOWN
Else
GOTO Start
I think your intention is to set chselvar equal to the contents of address chsel. then in the next line you test to see if they are different. So if I am following this correctly, you will have to move the channel selector at the exact moment between the peek and the IF. May work better to set a var like chselvarold then on the next loop see if chselvar = chselvarold. if = then goto start, if not decode what to do.
What about if I don't recheck with Peek and do this instead;
CHLP:
PEEK CHSEL, CHSELVAR 'Look at the 4 input pins from the channel selector
If CHSEL > CHSELVAR Then UP 'if it's larger then run subroutine UP
IF CHSEL < CHSELVAR Then DOWN 'if it's smaller then run subroutine DOWN
GOTO Start 'if neither are true then goto start
What do you think?
Re: Control a Radio PLL with a PIC
That worked great! Thanks
Re: Control a Radio PLL with a PIC
Quote:
Originally Posted by
scalerobotics
It looks like you should have a comma:
PEEK CHSEL, CHSELVAR
Adding the comma worked great! Thanks
Re: Control a Radio PLL with a PIC
Got that working! Thanks for the tip,
Now on to the display. 3 digit 7 segment display, common cathode.
I want to take the port C pin states and look those up in a table.
Then Send the table contents at that address to the 3 digit display.
I've been reading post and looking at some lookup codes but to be honest, I don't know where to start.
I think I know what I want in the table but getting it to the display is where I'm getting confused.
Any suggestions?
Re: Control a Radio PLL with a PIC
Rayl113, I assume the display is going to be multiplexed as all you are using is port c? Is it going to have latches for the digit data or is it going to be some kind of serial display?
Re: Control a Radio PLL with a PIC
Quote:
Originally Posted by
Dave
Rayl113, I assume the display is going to be multiplexed as all you are using is port c? Is it going to have latches for the digit data or is it going to be some kind of serial display?
The display is laid out like this;
RB0=A
RB1=B
RB2=C
RB3=D
RB4=E
RC0=F
RC1=G
RC2=dp
RC3=Digit-1
RC4=Digit-2
RC5=Digit-3
RC6=Digit-4(future)
RC7=Digit-5(future)
I'm using NPN transistors to switch the digit commons to ground.
It would probably be a good idea to latch in the display data but I'm not sure how to proceed.
It's mostly learn by trial and error at this point.
1 Attachment(s)
Re: Control a Radio PLL with a PIC
Rayl113, I have attached an old program that you can use parts of or simply as a template to understand the workings of a multiplexed display using a pic. I hope this helps. I found an old hallway clock from a school and backward engineered the circuit. I just had to as the clock has 5 inch 7 segment digits. It used a pic processor so, I redesigned the software to accomodate the already designed circuit. Works Great....
Re: Control a Radio PLL with a PIC
Thanks. I think I got that part figured out;
Display:
'Segment A = PORTB.0
'Segment B = PORTB.1
'Segment C = PORTB.2
'Segment D = PORTB.3
'Segment E = PORTB.4
'Segment F = PORTC.0
'Segment G = PORTC.1
'Segment dp = PORTC.2
'Digit1 = PORTC.3
'Digit2 = PORTC.4
'Digit3 = PORTC.5
Where I'm stuck is building the tables and selecting the information to send to each digit. I have a spreadsheet with the values already calculated.
I want to sample PORTD and use that as the address of the info I want to send to the digits.
e.g., If PORTB = $3F, I want to use Address $3F as a pointer within the table and pull the info from that location and send it to the digits. Let's say "C19".
I need "C" in digit 1, "1" in digit 2, and "9" in digit 3.
This is where I'm stuck. The manual is really lacking when it comes to creating Lookup tables. I've looked at some of the example files, but gotten more confused.
So any help on this would be appreciated.
Re: Control a Radio PLL with a PIC
Rayl113, It is possible, as you can have a table that is upto 255 entries in size maximum. An easy way is to have 3 tables, one for each digit and then use the "3f" entry as the index. The output of each table would be the digit value to display. The other way is to use a table that outputs "word" values. That way you only have one table for the lookup, indexed by a byte value from "00" to "ff" and outputs the word. That way the word can have a value equal to between "0000" and "ffff" . The entries into the table for the output could be the 3 digit hex representation of the display such as "C19".
Re: Control a Radio PLL with a PIC
Quote:
Originally Posted by
Dave
Rayl113, It is possible, as you can have a table that is upto 255 entries in size maximum. An easy way is to have 3 tables, one for each digit and then use the "3f" entry as the index. The output of each table would be the digit value to display. The other way is to use a table that outputs "word" values. That way you only have one table for the lookup, indexed by a byte value from "00" to "ff" and outputs the word. That way the word can have a value equal to between "0000" and "ffff" . The entries into the table for the output could be the 3 digit hex representation of the display such as "C19".
I got it working by using 3 tables. Thanks. I never could get the word version to work. It only gave me 16 bits and I needed 24. Haven't tried the long word version yet. That's next.
Now I need to set the FOSC bits in the CONFIG1H register to 0010. I'm sure it's a CON command. But don't know which one. Any help appreciated.
Re: Control a Radio PLL with a PIC
Rayl113, I'm glad you got it working, I just got back from a vacation with the wife and kids. We did some serious shooting and the wife likes gun's now... Yipeeeee
Re: Control a Radio PLL with a PIC
Trying to get my code to run on a PIC18LF2680. When I step thru the code I notice it skips over all of the "VAR" statements.
However, when I continue, it acts like it is performing the required instruction. But when I try to run stand-alone, it doesn't work. I can see with an O'Scope that the clock is working but no I/O activity.
Here's the config code;
#CONFIG
__CONFIG _CONFIG1H, _OSC_HS_1H
__CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
;Set osc, Low-Voltage Programming disabled,
;Extended Instructionset disabled,
#ENDCONFIG
Define OSC 4 ' 17
' 18
TRISA = $00 'set port a to all outputs ' 19
TRISB = $00 'set port b to all outputs ' 20
TRISC = $FF 'set port c to all inputs ' 21
LATB = $00 'clear port b latches ' 22
PLLDATA Var Byte ' stores value for PLLDATA ' 28
LASTCH Var Byte ' stores value for LASTCH ' 29
PLLDATAOUT var byte 'stores ouput for portB ' 30
CHSEL Var Byte 'channel selector storage ' 31
Display Var BYTE 'Display storage ' 32
Char1 VAR BYTE 'Digit 1 transistor switch ' 33
Char2 VAR BYTE 'Digit 2 transistor switch ' 34
Char3 VAR BYTE 'Digit 3 transistor switch ' 35
LASTCHSEL Var Byte 'stores the previous position of the ch selector ' 36
SEGSW Var BYTE ' 37
LOGOCNT Var BYTE ' 38
Digit3 Var PORTA.0 ' 41
Digit2 Var PORTA.1 ' 42
Digit1 Var PORTA.2 ' 43
BNDDNSW Var PORTA.3 ' 50
BNDUPSW Var PORTA.4 ' 51
LTCHENBL Var PORTA.5 'Latch Enable ' 46
'LTCHENBL = 0
CHSEL = PORTC & $0f 'set the inputs for the channel selector register ' 57
READ 5, LASTCH 'Read the last channel data from the EEProm 58
IF LASTCH = $FF THEN LASTCH = $70 'power up ch = CH 16 (Call channel) ' 59
IF LASTCH = $00 THEN LASTCH = $72 'power up ch = Ch 18 (Coast Guard) ' 60
PLLDATAOUT = PLLDATA 'put PLLDATA on the output pins ' 121
PORTB = PLLDATAOUT
LTCHENBL = 1
LTCHENBL = 0
PORTB = Display
LOGOCNT = $a0 'set the countdown timer for logo display ' 65
Start:
Is there something else I need to do in the configuration statement?
Thanks
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?
Quote:
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Ω.
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....