PDA

View Full Version : need help in displaying data send by PC s/w controlling radio scanner.



vu2iia
- 2nd September 2007, 17:24
Hi all,

I want to view data on 2X16 LCD coming from PC serial port, which controlls the Icom radio scanner R-10.

A PC programme called 'Unitrunker' decodes trunking data coming from FIRST radio and sends data to SECOND reciever (R-10) via serial port to follow the different channels ie it gives instruction to radio to tune to different frequencies to follow hopping frequencies.

Data is send in specific format. Please see the attatchment for the data format.This Data is exchanged between radio and PC. I want to see this data on LCD which is send to the second radio. I am especially interested in extracting information which in BCD format which actually gives radio information about the frequency.

I also want PIC to acknowledge back to PC in a specific format given in attatchment.

Can anybody help me in getting started. I intend to use pic16f828 or pic16f72.

Any help would be very much appreciated.

thanks in advance.

vu2iia

www.vu2iia.blogspot.com

HenrikOlsson
- 2nd September 2007, 19:17
Hi,
Here's something that may get you started. Obviously you need to set the correct baudrate and change the size of the array to match the maximum number of bytes that may be transfered (now set to 16).


'Set baudrate for USART
DEFINE HSER_BAUD 2400

'Set up an array of 16bytes to use as storage for the data.
myString VAR BYTE[16]


'Wait for $52 and $E0 and then store the next 16 characters in the array
'myString. Terminate if $FD (End of message) is recieved before we have
'16 characters in myString. $52 and $E0 are default TX and RX adresses,
'change if needed.

HSERIN [WAIT($52,$E0), STR myString\16\$FD]


You now have the data stored in the myString array. The first byte is the CN byte so if that byte is $00 then the datafield (from byte 3 and forward, to the last byte or the byte containing $FD) contains the frequency.

Hope it helps.

/Henrik Olsson.

vu2iia
- 3rd September 2007, 10:01
Hi Henrik,

I will follow ur advice and give it a try. If I have any problem I'll get back to you. I hope I am not taking ur precious time.

thanks for ur prompt reply.

regards
vu2iia

vu2iia
- 3rd September 2007, 14:34
Hi Henrik,

Sorry to bother u again, but I am still new to PBP. I cant figure out how to view data stored in array on LCD in the format given in attatchment.

Please help me, if this work I can use the BCD data to change the frequecies of Third radio I have got. Entire idea is to recycle old radios in to something usefull.

below is my code . Pls bear with my stupid code.

Can u pls explain why have u declared array (mystring var byte (16) of 16.

Right now display shows some constant number " 253" when I choose R-10 radio in the PC software. If I choose another radio it doesnt show anything ecept LCD OK, which I have put in the code to check display.


'************************************************* *****************
@ device pic16F628A, intrc_osc_noclkout
trisb = %00000001
trisA = %11110011
include "modedefs.bas"
' Define LCD registers and bits
Define LCD_DREG PORTB
Define LCD_DBIT 4
Define LCD_RSREG PORTA
Define LCD_RSBIT 0
Define LCD_EREG PORTA
Define LCD_EBIT 1

DEFINE LCD_LINES 4 'Define using a 2 line LCD
DEFINE LCD_COMMANDUS 2000 'Define delay time between sending LCD commands
DEFINE LCD_DATAUS 50 'Define delay time between data sent.
'define osc 4
'* hser setup
DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
DEFINE HSER_TXSTA 20h ' Enable transmit, BRGH = 0
DEFINE HSER_SPBRG 25 ' FOR 20MHZ 129 = 2400, 32=9600,25 @ 4 for 2400
DEFINE HSER_CLROERR 1 ' Clear overflow automatically
DEFINE HSER_BAUD 2400
cnt var byte
CMCON = 7 ' PORTA is digital
Pause 100 ' Wait for LCD to startup
r10data VAR BYTE[16]
lcdout $FE,1
LCDOUT "LCD OK"
PAUSE 200
clear

loop:

' CANT FIGURE OUT HOW TO EXTRACT NECESSARY BCD INFO FROM ARRAY

HSERIN WAIT($52,$E0), STR r10data\16\$FD]
'for cnt = 1 to 16
lcdout $FE,1
LCDOUT $fe,$80,dec r10data
'LCDOUT $fe,$c0+cnt," ",dec r10data [cnt]
'next cnt

PAUSE 10

GOTO LOOP

End
'************************************************* **************


hoping for some relpy from u, please help.

regards
vu2iia

HenrikOlsson
- 3rd September 2007, 16:28
Hi,
This is probably not the best project for a beginner and I don't have any way to test what I write but lets see if we can figure it out. If any one else sees this please feel free to jump in!



Can u pls explain why have u declared array (mystring var byte (16) of 16

Since I didn't know how many bytes the computer sends in the data-area and the spec-sheet you uploaded doesn't say I just took a number. You may need to adjust that to match.

1) Are you sure about the 2400baud? What about parity? 1 or 2 stopbits? The spec-sheet doesn't say....

2) You are running the PIC on its internal oscillator - this is usually not a good idea when using serial comms. I sugest you switch to a X-tal, atleast untill you have it working. Then you can try running on the internal oscillator.

3) Arrays are zero-indexed so if you have an array of 16bytes they are numbered 0-15.



x VAR Byte
cnt VAR Byte
r10Data VAR Byte[16]

'************** Array and LCD-test *******************
'This will fill the buffer with 65,66,67,68 etc which is ASCII for A,B,C,D etc
for cnt=0 to 15
r10Data[cnt] = cnt + 65
NEXT cnt

'Then run thru the array and display on the LCD - should read: ABCDEFGHIJKLMNOP
LCDOUT $FE,1 'Clear display
for cnt= 0 to 15
LCDOUT r10Data[cnt]
NEXT cnt

Pause 1000
'************************************************* ****
loop:

HSERIN [WAIT($52,$E0), STR r10data\16\$FD]
LCDOUT $FE,1,"Data recieved" 'Show messege
PAUSE 1000 'Wait....

FOR cnt = 0 to 15
LCDOUT DEC r10data[cnt], " "
NEXT cnt

PAUSE 1000
GOTO LOOP


/Henrik Olsson

vu2iia
- 6th September 2007, 05:59
Hi Henrik

Thank u my friend, I can see frequency send by PC program to radio on LCD via serial port. I have extracted necessary info from relevent array and I have got my project going. Last month I also made a simple repeater controller for 2m and repeater is working very well.

Once again thanks to you and to this wonderful forum.

LONG LIVE PBP.

regards
mahesh
vu2iia