Using the Z88 to control a Radio Scanner
This article was written by Ian Burkinshaw, I do not know how to contact him so I hope he will not mind his article to be published here. The IC-10 described here is no longer available, but the principal should work with later radios.
For most people the serial (RS232) is just used to connect to a printer. However the Z88 user manual says the Z88 can be used to control other devices. With this in mind and being interested in Short Wave listening I wanted to control a Radio Receiver. The radio I started to work with is the Icom IC-10 hand held scanner.
This radio covers from 500KHz to 1300MHz in all major modes AM, FM, WFM (wide band fm for band 2 broadcast band), CW (continuous wave, carries Morse (code), SSB (single side band) both USB and LSB. This like other Icom radios has a Cl-V protocol, which I will outline below.
I found early on, getting the serial port to work in this application was not as straight forward as you would first think. So you will find below my solution to this problem. However there may be another way of doing this which I have not discovered.
The Hardware
The radio has a 3.5mm mono jack which is used for serial communication, This is a bidirectional port. This port works on a 5V signal., this is different to the signal coming from the Z88 which is +/- 12V (RS232). There is a conversion box made by Icom called CT-17. The CT17 is small (100mm [w] x 60mm [d] x 30mm [h]) box with a power input connector on the rear panel, the voltage range being 9 to 15 volts which can be either a mains adapter or batteries. On the front panel there is a power LED and four 3.5mm jack sockets. This box can be used to control up to four radio's and/or transceivers.
The control of each radio/transceiver is achieved by each device having its own address which is a hex number in the range of 01 to 7F. This box is a bit expensive for what it is. If you are into electronics you can make a similar box yourself All you need is a 5V power regulator (78L05) and a MAX232CPE which is a RS232 to TTL (5V) level converter, integrated circuit. A typical circuit is shown below.
Please note: if you attempt to build this circuit yourself it is at your risk to your radio and computer, do check every thing twice ! All the parts to make the converter are available from Maplin Electronics.
Connect the ring of the 3.5 mm jack to GND. Not shown for clarity.
Testing the cable
It is a good idea to make sure each part of the system is working, in this case this is very easy. Having made the cable, short pin 2 and pin 3 of the 25 way D-Type together. Plug the 9 pin D- Type into the Z88 and turn the Z88 on. Select the Index by pressing the index button, then with the up/down arrow keys select Terminal.
The terminal application will now run if all is OK type in any letters or numbers you like and you will see the letters displayed. If this does not work then check your wiring of the D-Type connectors do not forget to also check for any short circuits. If this works then move on to the next stage.
Switch off the Z88 and disconnect the 9 Pin D-Type from the Z88 and remove the short from the
25 pin D-Type.
Testing the CT-17 box or your home made converter.
Plug the 9 Pin D-Type in the Z88 as before and plug the 25 pin D-Type in the converter. Do not connect the radio at this stage. Provide power to the converter (If you are using the CT-17 the LED on the front should light). Turn on the Z88 and if you have not changed anything the Z88 should return to the terminal application. Again type any number or letter and you should see it displayed just as when you tested the cable. If not check the converters wiring, it may be you reversed the connections pin 2 and pin 3 in the 25 way D-Type.
In the event of this not working try connecting an LED and resistor to the output of the converter (The radio side). To do this connect the anode of an LED to the tip of a 3.5mm jack plug, then the cathode to one end of a 470 ohm resistor and the other end of the resistor the sleeve of the jack plug, plug this into the converter. When you type on the keyboard of the Z88 you should see the LED flash. This means the transmit (Z88 to radio) side of your set up is working.
Once you have the above working you can connect the radio via an 3.5mm jack to jack cable.
The Icom protocol (C1-V)
Notes on Cl-V Control of IC-R10 Receiver and other Icom radios and transceivers.
General
The IC-RI0 can be connected to a computer via the computers RS .232C port using an optional CT-17 Cl-V level converter or the circuit show above. This allows you to control the receiver from the computer and/or transfer data from the receiver to the computer.
R10 Baud Rates are as follows:-
300
1200
4800
9600
19200
The baud is set in the radio under the SET MODE (Function Key SET)
Data Format
The Cl-V system can be operated using the following data formats. Data formats differ according to command numbers. A data area is added for some commands.
Controller (Z88) to IC R10
FE(254) | FE(254) | 52(82) | E0(244) | Cn | Sn | Data Area | FD(253) |
---|---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
Note: The numbers in brackets are the decimal of the hex number preceding.
IC-R10 to Controller (Z88)
FE(254) | FE(254) | E0(244) | 52(82) | Cn | Sn | Data Area | FD(253) |
---|---|---|---|---|---|---|---|
1 | 3 | 2 | 4 | 5 | 6 | 7 |
1=Preamble Code (Fixed)
2=Receivers default address (This is set in the radio under the SET MODE see above)
3=Controllers default address
4=Command number(see table below)
5=Sub command number (see table below)
6=BCD code data for frequency entry
7=End of message code (Fixed)
Command Table
Description | Cn | Sc |
---|---|---|
Transfers frequency data (transceive) | 00 | - |
Transfers mode data (transceive) | 01 | - |
Reads display frequency | 03 | - |
Reads display mode | 04 | - |
Sets frequency data | 05 | - |
Sets LSB mode | 06 | 00 |
Sets USB mode | 06 | 01 |
Sets AM mode | 06 | 02 |
Sets CW mode | 06 | 03 |
Sets FM mode | 06 | 05 |
Sets WFM mode | 06 | 06 |
Reads squelch condition (open or closed) | 21 (15) | 01 |
Reads S-meter level | 21 (15) | 02 |
Page 73 of the instruction manual for the R10 has an error. The command table shows Cn (Command Number) for reading the S-meter and squelch condition as 15, in fact it is 21.
Some examples for controlling the IC-R10
Transmit Frequency 131.725500
FE(254) | FE(254) | 52 | E0 | Cn | Freq | Data | FD |
---|---|---|---|---|---|---|---|
254 | 254 | 82 | 244 | 5 | 0.85 | 114,49 | 1,253 |
Read Receiver Frequency
Send
FE(254) | FE(254) | 52 | E0 | Cn | Freq |
---|---|---|---|---|---|
254 | 254 | 82 | 244 | 3 | 253 |
Return
FE(254) | FE(254) | E0(244) | 52(82) | Cn | Sn | Data Area | FD(253) |
---|---|---|---|---|---|---|---|
254 | 254 | 224 | 82 | 3 | 0,0,0,0 | 16,253= | 7 |
Details of data area, using the above example.
0 | 0 | 0 | 0 | 16 |
---|---|---|---|---|
LSB | | | | | | | MSB |
| | | | | | | | | |
| | | | | | | | 1,0 |
| | | | | | |------------------ | 00, |
| | | | |-------------------- | 00 | |
| | |-------------------- | 0,0 | ||
|-------------------- | 00 |
1,000,000,000=Hz
Read Receiver Mode
Send
FE(254) | FE(254) | 52 | E0 | Cn | Freq |
---|---|---|---|---|---|
254 | 254 | 82 | 244 | 4 | 253 |
Return
FE(254) | FE(254) | E0(244) | 52(82) | Cn | Sn | Data Area | FD(253) |
---|---|---|---|---|---|---|---|
254 | 254 | 224 | 82 | 4 | 3 | 1,253= CW Mode | 7 |
254 | 254 | 224 | 82 | 4 | 1 | 1,253 = USB Mode |
|
Read Squelch Mode
Send
FE(254) | FE(254) | 52 | E0 | Cn | Freq |
---|---|---|---|---|---|
254 | 254 | 82 | 244 | 21 | 1,253 |
Return
FE(254) | FE(254) | 52(82) | E0(244) | Cn | Sn | Data Area | FD(253) |
---|---|---|---|---|---|---|---|
254 | 254 | 82 | 224 | 21 | 1 | 0,253= Closed | 7 |
254 | 254 | 82 | 224 | 21 | 1 | 1,253 = Open |
|
Read S- Meter level
Send
FE(254) | FE(254) | 52 | E0 | Cn | Freq |
---|---|---|---|---|---|
254 | 254 | 82 | 244 | 21 | 2,253 |
Return
FE(254) | FE(254) | E0(224) | 52(82) | Cn | Sn | Data Area | FD(253) |
---|---|---|---|---|---|---|---|
254 | 254 | 224 | 82 | 21 | 2 | n,253= | 7 |
The Z88 serial port
So now we have the radio and Z88 connected together all we do is write the control codes into print statements and off we go. Try it. It does not work, why? Ther3 are several reasons, first the
Z88 sends out various control codes for printers, secondly extra codes get send if the Z88 is set to
Xon, that is software is used to control the flow of data between the Z88 and external device.
So there are two things we have to do before we can control the radio.
First thing to be done is to switch off the Xon mode. Select Panel from the applications menu and on the right hand side of the screen you see a line Xon/Xoff make sure this is to No. Also check that the Transmit and receive baud rates are set to be the sate as your radio (recommend1200 baud) and that Parity is set to None.
Second thing to do when using Basic is to use the COM label in place of the PRT label,
i.e. LET prt=OPENOUT ":COM.0" in place of LET prt=OPENOUT":PRT 0"
The difference between PRT and COM is that PRT goes though the Printer Filter which adds printer control codes so that in Basic each time you open the printer using OPENOUT":PRT,0" the Z88 will output 27(B),64(@),27(B),82(R),0(nul),13(CR),any ext,13(CR). This just confuses the radio so will not work.
However the COM label gives direct access to the serial port without the addition of the printer control codes.
Now you can type in and run the program below.
Example test programs
This first program is just a simple one that cycles the radio though the modes just so you can see your set-up working and as an example of how to control the radio . One last point each time you transmit data to the radio that data comes back to the ZK since in effect the output of the Z88's RS232 port is connected to the input all the time via the converter so echo's all the data. So when requesting say the frequency from the radio you must, in your software ignore the commands sent from the Z88 to the radio.
10 LET fe$=CHR$(254)
20 LET rx$=CHR$(82):REM receiver default address
30 LET tx$=CHR$(224)
40 LET fd$=CHR$(253)
50 LET lsb$=fe+fe$+rx$+tx$+CHR$(6)+CHR$(0)+fd$
60 LET usb$=fe$+fe$+rx$+tx$+CHR$(6)+CHR$(1)+fd$
70 LET am$=fe$+fe$+rx$+tx$+CHR$(6)+CHR$(2)+fd$
80 LET cw$=fe$+fe$+rx$+tx$+CHR(6)+CHR$(3)+fd$
90 LET fm$=fe$+fe$+rx$=tx$+CHR(6)+CHR$(5)+fd$
100 LET wfm$=fe$+fe$+rx$+tx$+CHRS(6)+CHR$(6)+fd$
1010 LET prt=OPENUP ":COM.0"
1020 PRINT "Setting LSB Mode"
1030 PRINT#prt,lsb$
1040 PROC_delay
1050 PRINT "Setting USB Mode"
1060 PR1NT#prt,usb$
1070 PROC_delay
1080 PRINT "Setting AM Mode"
1090 PR1NT#prt,am$
1100 PROC_delay
1110 PRINT "Setting CW Mode"
1120 PRINT#prt,cw$
1130 PROC_delay
1140 PRINT "Setting FM Mode"
1150 PRINT#prt,fm$
1160 PROC_delay
1170 PRINT "Setting WFM Mode"
1180 PR1NT#prt,wfm$
1190 PROC_delay
1200 END
2000 DEF PROC_delay
2010 FOR a=0 TO 1000:NEXT a
2020 ENDPROC
As a second example this program reads the currently displayed frequency of the radio.
10 LET fe$=CHR$(254)
20 LET rx$=CHR$(82)
30 LET tx$=CHR$(224)
40 LET fd$=CHR$(253)
50 LET read_freq$=fe$+fe$+rx$+tx$+CHR$(3)+fd$
1000 LET prt=OPENUP":COM.0"
1010 PRINT "Reading Frequency from R10 radio."
1020 PRINT#prt,read_freq$
1030 INPUT#prt,a$: REM reading echo from above print statement.
1040 PRINT a$
1050 LET x=1
1060 REPEAT
1070 a=BGET#prt
1080 a$=STRS~(a)
1090 IF x=7 THEN LET a$=FNbases(16,2,a$):PROCchecklen:LET fl$=a$
1100 IF x=8 THEN LET f2$=FNbases(16,2,a$)
1110 IF x=9 THEN LET f3$=FNbases(16,2,a$)
1120 IF x=10 THEN LET f4$=FNbases(16,2,a$)
1130 LET x=x+1
1140 UNTIL x>10
1150 LET f11$=FNbases(2,10,LEFT$(f1$,4))
1160 LET f12$=FNbases(2,10,RIGHT$(f1$,4))
1170 LET f21$=FNbases(2,10,LEFT$(f2$,4))
1180 LET f22$=FNbases(2,10,RIGHT$(f2$,4))
1190 LET f31$=FNbases(2,10,LEFT$(f3$,4))
1200 LET f32$=FNbases(2,10,RIGHT$(f3$,4))
1210 LET f41$=FNbases(2,10,LEFT$(f4$,4))
1220 LET f42$=FNbases(2,10,RIGHT$(f4$,4))
1230 LET freq$=f41$+f42$+f31$+f32$+"."+f21$+f22$+f11$+f12$+"MHz"
1240 PRINT freq$
1800 END
1900 DEF PROCchecklen
1910 REPEAT
1920 length=LEN(a$)
1930 IF length=8 THEN 1950
1940 a$="0"+a$
1950 UNTIL length=8
1990 ENDPROC
2000 REM
*
2010 REM * A function to convert numbers between base; for number bases in the
2020 REM * range 2 through 16, (C) Darmey Langton 11(88.
*
2030 REM * Use in your own programs with a call as :
*
2040 REM * result$=FNbases(sourcebase,destinationbase,sourcenumber$)
2050 REM * e.g., Print FNbases(2,16,"1101") will give a r esult "D". *
2060 REM
*****************************************************
2070 :
2080 DEFFNbases(f%,t%,s$) LOCALerr$,bad%,L%,T%
2090 err$="Bad input to FNbases"
2100 IFf%<2ORf%>160Rt%<20Rt%>16VDU7:PRINTerr$':END
2110 FORL%=1TOLENs$:IFEVAL("&"+MID$(s$,L%,1)>=f%bad%=TRUE:L%=LENs$
2120 NEXT:IFbad%PRINTerr$:':END
2130 IFf%=t%:=s$
2140 IFf%=16s$=STR$EVAL("&"+s$):f%=10:T%=VALs$
2150 IFf%<>10FORL%-=1TOLENs$:T%=T%+EVAL("&"+MID$(s$,L%,1))*f%^
(LENs$-L%):NEXTELSET%=VALs$
2160 IFt%=16:=STR$~T%
2170 s$="":REPEATs$=STR$~(T%MODt%)+s$:T%=T%DIVt%:UNTILT%=0:=s$
Even if you do not have a radio such as the one covered above I hope it is of interest to show the different uses the Z88 can be put to. If you do try this, good luck.
(Pretty Amazing or what? Thanks for the Article, Ian — Please keep,) them coming, but to Andy Davis of course from now on!! — Editor.)
Note: This program has NOT been run to check for typos. Please advise any errors found. - Vic Gerhardi