THE ICOM CI-V COMPUTER INTERFACE E. R. (Randy) Cole, KN6W 3100 Ocean Park Blvd. Santa Monica, CA 90405 Copyright (c) 1986,1987 Edwin R. Cole (This document may be freely copied and distributed provided the above copyright notice is included on all copies. It may not be sold by anyone except the author) Have you bought a new radio lately? If you have, you probably noticed that it came with an increasingly common feature -- a computer interface. Actually, radios with computer interfaces have been around since 1976, when the ICOM IC-211 and 245 appeared on the scene with a computer interface that allowed remote control of the radio's frequency. The IC-701, introduced in 1978, used the same interface. Since then ICOM has produced the IC-720/251/255/260/451 series and the IC-R71/751/271/471/1271 series, each with a different type of computer interface. Both Yaesu and Kenwood now have their own interfaces for their families of radios. The various interfaces are described in [1] - [5]. ICOM recently introduced a new type of computer interface, called the CI-V Communication Interface System. The CI-V interface first appeared on the IC-735, and is now also found on the IC-275, IC-375, IC-475, IC-575, IC-761 and IC-R7000. The functions performed by the radios via this new interface are generally the same as those possible via the interface for the R71/751/271/471/1271 series [4], plus a few enhancements. A recent Ham Radio article [6] provides a very simple (one resistor) interface and an elaborate Basic program for controlling the IC-735 with a Commodore 64. That same interface can be used to control any of the ICOM CI-V radios using a C64. However, there are significant differences between radios, especially in the case of the R7000. The author has tested the IC-735, IC-275, IC-475, and IC-R7000. This article describes how to control any of the current ICOM CI-V radios. A short Basic program for the IBM PC is included to demonstrate use of the interface. THIS ONE IS DIFFERENT Ho hum, you say, yet another interface. Big deal; what we really need is some standardization. That's certainly true, but the latest ICOM interface is altogether different from all the rest. Picture this: You can have up to 15 radios and up to 254 computers, all connected in parallel to the same two-wire bus. Any computer can control any radio. In fact, radios can control each other. You can even have more than one of the same type of radio on the bus. Commands are guaranteed to get through, even if different computers decide to send commands to different radios at exactly the same time. How is it done? The new ICOM interface is a CSMA/CD bus. The letters stand for Carrier Sense Multiple Access with Collision Detection, and the technique has been used for computer networks (like the Ethernet(tm)) for years. Multiple access refers to the fact that there can be many devices (computers and radios, in this case) on a single bus. Carrier sense means that a device listens to see if the bus is busy before it sends a message, just like you listen to make sure a frequency is clear before you transmit. If the bus is clear, the device then sends its message. Collision detection means that the device listens to the bus while it is sending its message and compares what it hears with what it put on the bus. If the two are the same, all is OK. If they are different, it is because another device tried to send a message at the same time. If there was a conflict, or collision, the device deliberately sends a jamming message to ensure that the other device, which is also listening, senses the collision. Next each device waits for a short time, listens, and then tries to send the message again. The waiting times are randomized to minimize the chance of repeated collisions. If a radio receives a valid command, it sends a positive reply message to the computer that sent the command, telling it that the command was received and executed. If a radio receives an illegal command, it sends a negative reply message to inform the sender that the radio could not successfully execute the command. Not all commands cause the radio to generate positive or negative replies. Some commands simply request information from the radio, and the radio replies with the requested information rather than a positive reply. Two special commands are provided that do not generate replies. Not too many amateurs have more than one computer. However, most hams do have more than one radio, and ICOM's new interface bus is a simple way to control several different radios with a single computer, using only one interface connection to the computer. Other manufacturers' interfaces either require a separate connection to the computer for each radio, or don't permit control of more than one radio of the same type on a single bus. PHYSICAL INTERFACE Unlike the previous ICOM interface [4], the new ICOM CI-V system requires no additional hardware inside the radios themselves. The new system uses the standard RS-232C format, with both the RS-232C Transmit Data (TXD) and Receive Data (RXD) connected to the single ICOM interface bus signal line to allow both transmitting and receiving on the two-wire ICOM bus. The interface runs at TTL (+5V and 0V) levels, so most computers will need a simple voltage level converter to convert from the TTL levels of the ICOM interface bus to the +12V and -12V levels used by standard RS-232C serial ports. ICOM doesn't currently make such a device, but does include the schematic for a level converter in some of the manuals. Yaesu makes a level converter (the FIF-232C) and so does Kenwood (the IF-232C). A simple level converter that requires only a single +5V power supply can be built using a single MAX-232 chip (from Maxim Integrated Products, 510 N. Pastoria Ave., Sunnyvale, CA 94086). The bus address and baud rate of the radios are selected by internal jumpers. The 735 has three bits of address, the R7000 has four bits, and the 275 and 475 have seven. Bus address 0 has a special meaning and should not be assigned to a radio. The 735, R7000, 275 and 475 come with their addresses set to 4, 8, 16 (hex 10) and 20 (hex 14), respectively. All the radios seem to come with their baud rate set to 1200 baud. Baud rate for all can be set at either 300, 1200, or 9600 baud. Data is sent using 8 data bits, no parity, and one stop bit. COMMAND FORMAT Commands (and replies) on the ICOM interface bus are sent in the form of packets. Yes, packets are everywhere these days. These packets aren't the same as the well-known AX-25 or TCP/IP packets used by ham packeteers, but there are some similarities. Each packet is a series of 8-bit bytes. A diagram of a packet looks like: FE FE destaddr srcaddr cmdcode [data1 data2 .... dataN] FD, where FE FE is the preamble, destaddr is the bus address of the destination device, srcaddr is the bus address of the source device, cmdcode is the command code, data1 .... dataN are the data bytes, and FD is the end byte. The first two bytes (both hex FE) are a PREAMBLE, which signals the start of a packet. The third byte is the DESTINATION ADDRESS, which tells which device the packet is intended for, and the fourth byte is the SOURCE ADDRESS, which tells which device the packet is being sent from. Next comes the COMMAND CODE, followed by zero or more DATA bytes. Finally, an END byte (hex FD) indicates the end of a packet. Packets vary in length from six to seventeen bytes. An address can be any 8-bit value except FD (FD is unusable because FD is used for the end byte of a packet). Computers can be assigned any unique address except 0 and FD. Address 0 is a special "broadcast" address for Transceive Mode. ---------------------------------------------------------------- TABLE 1: COMMAND SUMMARY COMMAND FUNCTION DATA BYTES BYTES BYTE SENT RETURNED 0 Set Frequency frequency none (TX Mode) 1 Set Mode (TX Mode) mode none 2 Read Frequency none IC 275/475, IC735: Range lower [2D] upper R7000: upper [2D] lower 3 Read Frequency none frequency 4 Read Mode none mode 5 Set Frequency frequendy FA/FB 6 Set Mode mode FA/FB 7 Set VFO none/VFO FA/FB 8 Set Memory memory FA/FB 9 Write VFO to Mem. none FA/FB A Write Mem.to VFO none FA/FB B Clear Current Mem. none FA/FB C Read Current Offset none offset D Set Current Offset offset FA/FB E Start/Stop Scanning start/stop FA/FB Note: Commands 0 through A are documented in information available from ICOM. Commands B through E are not currently documented, but have been found to work on the IC275 and IC 475. ---------------------------------------------------------------- COMMANDS Table 1 is a summary of the available commands. Not all commands are meaninglful to all radios. For example, the R7000 has 99 memories but no VFO, and generates a negative reply to Commands 7 and A. DATA BYTES Frequency: Frequency data is packed two digits per byte, beginning with a (10Hz, 1Hz) byte. The 275, 475 and 735 ignore the 1 Hz digit, and the R7000 ignores the 1 Hz and 10 Hz digits, but they must be sent nonetheless. Only as many bytes as necessary need be sent. For example, if the highest digit to be changed is the KHz digit, only two bytes of frequency data are needed. IC-735: 4 bytes 9 (e.g., 14.12345 is sent as 50 34 12 14) IC-275/475, IC-R7000: 5 bytes (e.g., 148.76543 is sent as 30 54 76 48 01). Mode: Modes can be designated by either one or two bytes. The R7000 can operate on either sideband, but selection is made by a switch on the back panel. Since there is no command that definitively sets an R7000 to USB or LSB, ICOM has used a different code for SSB on the R7000. IC735: R7000: IC275/475 00 - LSB 02 - AM 00 - LSB 01 - USB 05 - FM Wide 01 - USB 02 - AM 05 02 - FM Narrow 03 - CW 03 - CW 05 00 - SSB 03 02 - CW Narrow 04 - RTTY 05 - FM 05 - FM VFO: VFO data is a single byte, either 0 for VFO A or 1 for VFO B. Memory: Memory data is a single byte containing the memory number. Start/Stop Scanning: A single byte. A one starts scanning, a zero stops scanning. REPLY MESSAGES Reply messages consist of a packet with a preamble, destination and source addresses, a reply code, and an end byte. The reply code is either hexadecimal FA, a negative reply, or hexadecimal FB (cute, huh?) for a positive reply. Transcieve Mode commands do not cause the radio to generate a reply. A negative reply is returned by the radio to the computer whenever a command is undecipherable or there is an error in the data inside the packet, such as out-of-bounds frequency data, missing bytes, an attempt to select a non-existant memory, an undefined command, etc. A positive reply is returned by the radio to the computer after a legal command is received and executed. Inquiry commands which cause the radio to send data back to the computer do not return a positive reply, since the returned data itself serves as a positive reply. JAMMING SEQUENCE When a radio is sending a message and detects a collision, it will immediately stop sending. In order to prevent the (somewhat unlikely) case in which the collision merely corrupts the content of a message without destroying its format, ICOM has implemented a jamming sequence, which is: FC FC FC FC FC. After detecting a collision, the radio immediately sends the jamming sequence and then waits for a short randomized period of time before it listens to the bus and tries to resend the message that was involved in the collision. The radio will repeat the process for up to five times, but will then give up trying. TRANSCEIVE MODE (TX MODE) This interface provides a new feature, called Transceive Mode (TX Mode). TX Mode allows two compatible radios to be connected so that whenever the frequency or mode is changed on one radio the other radio's frequency or mode will follow. No computer is needed. The bus connector on the back of one radio is simply connected to the bus connector on the back of the other. Transceive Mode also allows a computer to monitor the current state of a radio without the need to issue any commands. This capability is useful for logging purposes. TX Mode is enabled and disabled by a switch on the same internal switch block that controls the radio's address and baud rate. If a radio's TX Mode is enabled, then whenever the radio changes frequency or mode, the radio itself will send a command that will cause the other radio to change frequency or mode correspondingly. All radios examined thus far have come from the factory with TX Mode enabled. If a radio's TX Mode is enabled, it will send a Command 0 (Set Frequency) packet whenever it changes frequency and a Command 1 (Set Mode) packet whenever it changes mode. The destination address in these packets is always 0, and the source address is the radio's own address. Any radio with TX Mode enabled will respond to Commands 0 and 1 if the destination address is 0 or the radio's actual address. A radio in TX Mode will not generate frequency and mode command packets while it is scanning, but will generate both when it is stopped from scanning. When a radio receives a Command 0 packet, it DOES NOT reply with a positive or negative reply packet. While primarily designed to implement TX Mode, Command 0 can be used by a computer in place of Command 5 if no reply is desired. THE STRANGE CASE OF THE R7000 The behavior of the R7000 is a bit different than that of the 275 and 735, largely because it lacks the concept of VFO A and VFO B as implemented in the other radios. The following describes the known peculiarities of the R7000. An R7000 is capable of receiving signals at frequencies up to 1999.9999 MHz (except for 1000 to 1025 MHz). Above 1 GHz, ICOM only publishes and guarantees specifications within the 1240 to 1300 MHz band. Frequencies above 1 GHz are selected by a "1 GHz" switch on the radio's front panel, which inserts a 1 GHz converter in the radio's signal path. The converter cannot be selected or deselected via the computer interface, nor can the state of the "1 GHz" switch be sensed through the interface. If the "1 GHz" front panel switch is depressed, all frequencies will be raised by 1 GHz. The R7000 always replies to Commands 7 (Set VFO) and A (Write Memory to VFO) with a negative reply message. In the R7000, Command 8 (Set Memory) causes the contents of the selected memory to be transferred to the dial, causing the R7000 to jump to the frequency and mode stored in the specified memory. This is equivalent to selecting a memory and writing it into the current VFO on the 275, 475 or 735. Command 9 (Write VFO to Memory) causes the R7000 to write the current frequency and mode as shown on the display into the selected memory. When it is in TX Mode, the R7000 sends only a mode packet when its mode is changed via the front panel, while the 275, 475 and 735 send both frequency and mode packets when their mode is changed, even though the frequency may not have changed. SAMPLE BASIC PROGRAM The sample Basic program runs under IBM BASIC or BASICA on the IBM PC, and allows the user to set the frequency and mode of an R7000 from the computer. It has not been tested on any other computer or any other version of Basic, but translating it to your computer's version of Basic should not be too difficult. The program reads back and prints back both the command that was sent and the radio's reply. However, the program doesn't compare the command it sent out with what it heard on the bus, which would be necessary if there were more than two devices on the bus. IMPROVEMENTS OVER PREVIOUS COMMAND SETS The new command set has some improvements over the command set for the R71/751/271/471/1271 series. You can now: o Stop the radio from scanning (by issuing a Set Frequency command) and take control of the radio, If a radio receives a Set Frequency command while scanning, it will stop scanning and change to the specified frequency. If it receives any other command (legal or illegal) it will hold the command until scanning is stopped manually and will then process the command. o Select which VFO to use, if the radio has more than one (this feature was possible on ICOM's second type of interface but missing from the third), and o Monitor the radio's frequency and mode without issuing commands to the radio (using TX Mode). o Clear memories. o Set and read the radio's duplex offset. o Start and stop scanning (on the 275 and 475). However, the command set still lacks a number of features, as pointed out in [4], such as setting or reading the RIT. With the previous ICOM interface, NG6Q was able to go a bit beyond the normal command set and achieve a few additional functions by accessing "memories" 33 to 255 (the radios have only 32 memories). The processors in the 275, 475, 735 and R7000 enforce memory and frequency limits more rigorously, and the author has thus far been unable to "fudge" the memory and frequency boundaries. SUMMARY The new ICOM CI-V interface makes it easy to control one radio with one computer, and at the same time makes it possible to control more than one radio with more than one computer. The additional hardware needed to connect the radio to the interface bus is simple and easy to build. Command set functionality is improved over the previous interface. Amateur radio operators, one of the most ingenious groups around, should be able to think of many unique and interesting applications using the new interface. REFERENCES [1] G. Williman, "A Three-Chip Microcomputer for Your Station," QST, Aug. 82, p. 19 (describes the IC-701/211/245 interface). [2] C. Terwilliger, "Computer Control of the IC-255A," QST, May 81, p. 30 (describes the IC-720/251/255/260/451 interface). [3] L. Studebaker, "Simple, Low-Cost Computer Control for the ICOM IC- 720," QST, July 84, p. 34. [4] R. Bisbey, "Computer Control of ICOM R-71, 271, 471 and 751 Radios," Ham Radio, April 86, p. 47. [5] K. Strom, "A CAT Control System," QST, Oct. 85, p. 38 (describes the Yaesu CAT interface system). [6] C. Bahr, "Simple ICOM IC-735 to C-64 Interface," Ham Radio, March 87, p. 39. APPENDIX (OR SIDEBAR) 1 - SAMPLE BASIC PROGRAM 10 ' This sample program is written in IBM PC Basic, and sets the 20 ' mode and frequency of an ICOM R7000. The mode must be AM, FMW, 30 ' FMN, FM, or SSB, and the frequency must be between 25 and 40 ' 999.9999 MHz. 50 OPEN "COM2:1200,N,8,1" AS #1 ' Author's setup uses COM2: 60 INPUT "FREQUENCY,MODE";F,M$ ' Get frequency, mode 100 ' This section looks for mode = "AM", "FMW", "FMN", "FM", or "SSB", 110 ' complains if it doesn't find it, and otherwise assembles the 120 ' data string for the mode command. 130 IF (M$="AM") THEN MO$=CHR$(&H02): GOTO 200 140 IF (M$="FMW") THEN MO$=CHR$(&H05): GOTO 200 150 IF (M$="FMN") OR (M$="FM") THEN MO$=CHR$(&H05)+CHR$(&H02): GOTO 200 160 IF (M$="SSB") THEN MO$=CHR$(&H05)+CHR$(&H00): GOTO 200 170 PRINT "Unknown mode "; M$; " Please try again": GO TO 60 200 ' This section checks the frequency to make sure it is in bounds, 210 ' objects if it isn't, and otherwise assembles the proper data 220 ' string for the frequency command 230 IF (F>=25) AND (F<1000) GOTO 250 ' Bounds check 240 PRINT "Out-of-bounds frequency"; F; "Please try again": GO TO 60 250 F$=STR$(F) ' Make a string out of it 260 F$=MID$(F$,2,LEN(F$)-1) ' Eliminate leading space 270 IF (F<100) THEN F$="0"+F$ ' Add leading zero if needed 280 FOR I=1 TO 5: F$=F$+"0": NEXT I ' Add trailing zeros 290 FR$=CHR$(0) ' Format for ICOM 300 FR$=FR$+CHR$(16*VAL(MID$(F$,7,1))+VAL(MID$(F$,8,1))) 310 FR$=FR$+CHR$(16*VAL(MID$(F$,5,1))+VAL(MID$(F$,6,1))) 320 FR$=FR$+CHR$(16*VAL(MID$(F$,2,1))+VAL(MID$(F$,3,1))) 330 FR$=FR$+CHR$(VAL(MID$(F$,1,1))) 400 ' Here is the main part of the program 410 DA=8 ' Destination address (R7000) 420 SA=&HF1 ' Source address (IBM PC) 500 ' Send the Set Mode command and look at the command and reply 510 CM=6 ' Set Mode command code 520 DA$=MO$ ' Mode data 530 GOSUB 1000 ' Send the command 540 GOSUB 2000 ' Print out command heard 550 GOSUB 2000 ' Print out reply heard 600 ' Send the Set Frequency command and look at the command and reply 610 CM=5 ' Set Frequency command code 620 DA$=FR$ ' Frequency data 630 GOSUB 1000 ' Send the command 640 GOSUB 2000 ' Print out command heard 650 GOSUB 2000 ' Print out reply heard 700 CLOSE #1 710 END 1000 ' Command sending subroutine 1010 PRINT #1,CHR$(&HFE);CHR$(&HFE); ' Preamble 1020 PRINT #1,CHR$(DA); ' Destination address 1030 PRINT #1,CHR$(SA); ' Source address 1040 PRINT #1,CHR$(CM); ' Command code 1050 PRINT #1,DA$; ' Data 1060 PRINT #1,CHR$(&HFD); ' End byte 1070 RETURN 2000 ' Monitor command or reply and print it out 2010 A$=INPUT$(1,#1) ' Get next character 2020 V=ASC(A$) ' Convert to number 2030 H$=HEX$(V) ' Convert to hex string 2040 PRINT H$; ' Print it out 2050 PRINT " "; 2060 IF V=&HFD THEN GOTO 2080 ' Look for end byte 2070 GOTO 2010 ' Loop back for next char 2080 PRINT 2090 RETURN -------