Wednesday, 18 October 2017

RS232/TTL conversion for digital interface

What a puzzling world, that of RS232.

RS232 is used for communication with Data Terminal Equipment. It used to be commonly found on the back of Windows PCs in the form of a male DB9 connector. Carrying the following signals

pin    sig
1      DCD
2      RXD input from rest of world ) ICOM CI-V CAT control
3      TXD output to rest of world  )
4      DTR
5      GND PC side ground
6      DSR
7      RTS used for switching to transmit (PTT)
8      CTS
9      RI
The signals on RS232 are anything up to +/-13V, not TTL 0/5V.

Screen Shot 2017 10 17 at 14 24 49

And the logic is inverted. positive logic '1' RS232 HIGH = negative logic '1' TTL LOW voltage. So,for example, a data byte B10101010 on RS232 and TTL look like those above.

To convert RS232 to TTL logic signals means converting the voltage levels and the logic. This is commonly done with an FT232 or MAX232 chip and an opto-converter, like the 1N35 or the better PC900V.

Screen Shot 2017 10 17 at 14 56 33 PC900V

Data Interface

To interface todays PCs with USB input/outputs a further step is needed. To convert USB to RS232. Here is a typical complete circuit using a FT232R IC to generate an islated CI-V interface:

Screen Shot 2017 10 14 at 23 31 01 Cables

Another practical way is to use a low cost, ready made cable which has on one end a slightly larger USB plug, containing the "232" chip, and on the other 6 wires carrying TTL level RS232 signals.

Saturday, 14 October 2017

BARS Tech Group - Digital mode interface for the ICOM 718

This is the latest status from the BARS Constructors group.

Digital

Our aim is to interface our ICOM 718 to a PC so that we can transmit the digital FSK (audio) on USB SSB from the ICOM, and receive audio for decoding digital FSK on the PC. Using for example the new WSJT-X software which supports many new digital modes.

FT-8

One digital mode that was introduced only in July 2017 is called FT-8. This has taken the amateur fraternity by storm, and hundreds of QSO are pouring across the ether using this mode. Attached is a short presentation I gave last week about FT-8. Have listen on 7074kHz to hear the signals.

BASIC DIGITAL COMMS

We are making progress in the development and design of a digital interface for our ICOM 718.  I have read the manual twice, and tried to understand the connections, modes and numerous front panels buttons. One thing we did discover is that our ICOM needed a RESET before it was in the mode to output/input audio and provide more than 10W output!

Digital Mode Interfaces do three things:

Audio IN/OUT
PTT ON/OFF
CAT Data IN/OUT

1. Pass audio in and out between the ICOM and the Soundcard of the PC (if it has one, if not an external Soundcard is used) via isolating transformers and volume controls to avoid ground loops and set the levels for TX & RX.

We have tested this by connecting an audio output tone from my MacBook via a Soundcard - the STARTECH one we all purchased when we built the SRD receiver two years ago, to the ICOM. It needed 200mV p-p to output 10W RF on 40m (into a dummy load of course). We also tested the audio output which provided up to 500mV peak, by connecting to an external small Amp+LS. We also tested the use of the ICOM SEND connection (PTT) and this switched us to TX with no problems.

2. We need a cable on a 23 pin DIN plug to connect to the ICOM ACC port on the back of the Transceiver. This ACC plug provides some signals we need:

+8V
GND
AFO - audio output, 200-500mV
MOD - audio input, 100-200mV
SEND - PTT, low = TX

John tackled this, bought a 13 pin DIN and built a cable. I have to apologise to him as I told him we need only four wires, I forgot the +8V supply wire, sorry John… we need to add this.

In order to connect these signals to our interface we will need a multi-pin plug on the other end I have ordered a 5pin DIN plug and socket for this. Connections to be defined...

3. We need to connect to a USB port on the PC and derive from this virtual COM Port the RS232 signals (as you would get from a DB9 connector in the PC if it had one, but most PCs today do not support a DB9 RS232 connection). So a USB<->RS232 convertor has to be used, this is best implemented using a FT232 chip (a driver must be installed on Windows, the MacOS has one already). A cable can be purchased for a few pounds as a USB plug incorporating the chip and providing the six signals we need:

+5V
GND
TXD - used for CAT data
RXD - used for CAT data
RTS - used for PTT/SEND
CST

I have a cable in purchase.

4. Develop an isolated interface between the RS232 RTS signal (active HIGH) and the PTT/SEND connection (active LOW) on the back of the ICOM. This is very simple, the RTS (TTL level) signal HIGH is used to drive the diode in an opto-coupler, the output opto-transistor is connected GND-PTT/SEND to pull PTT LOW and activate TX mode.

BOXING IT UP

After we have done this initial development, which is quite simple, it will be time to wire up a PCB and put the stuff in a box. This will give us basic digital comms.

CAT or CI-V

Then we can tackle the CAT system. CAT is called CI-V by ICOM (Computer Interface V-five). It is a single wire serial bus used for two way communication between the PC and the ICOM. The bus line is normally pulled HIGH by a resistor in the ICOM, and is pulled low by either our interface or the ICOM itself. When the interface pulls it LOW it is transmitting data to the ICOM, and when ICOM pulls it LOW it is sending data to the PC.

The USB to RS232 convertor (above) has two signals TXD & RXD to send data in/out of the PC from/to any digital software we are using for controlling the ICOM. Over the link a lot of the operating modes of the ICOM can be controlled, the most common of which is to switch bands and change frequency. Data is sent at a baud rate which can be programmed in the ICOM (I think/hope) as I read it the default is 19200baud which has to be set up in the PC software.

SOFTWARE - volunteers please

We need a group of us to investigate, download and learn about the many software packages that are on the web so we know how they interface for Audio, PTT and CAT. And so we know what they can do (RTTY, PSK31, digital modes like WSPR, FT-8, JT-65, SSTV…).

So that’s where we are right now, progress. See you in a couple of weeks for more for the nest step - checking out our audio isolation transformers, both the ones I found on eBay or the one’s that Franks has kindly given us, to see which is best. We need to check also the audio signal levels coming out of the PC sound card (both Mac and PC I suggest).

Sunday, 1 October 2017

IMPORTANT for MacOS users

Whatever you do, do NOT install the FTDI drivers from FTDIChip on your MacOS Sierra. They block the use of the Apple Driver, which works just fine, and you will not be able to acces your Arduino board!

Sunday, 10 September 2017

LATEST Sketches and libraries

Download here.

The fight to read an ASCII string into Arduino

If you have a terminal program sending characters of a string input at 9600 baud to the USB port of an Arduino, then they arrive in just over 1ms per character. In 1ms the Arduino can do a lot of things.

So a program like this won't work,

//  GET  MESSAGE
// Try to get a message in from the terminal
void getMsg(char *m) }
  int p;
  
  p = 0;
  while (Serial.available() > 0) {
   m[p++] = Serial.read();
  }
}

Why? Because after the first character arrives and Serial.Available() says it has done so, the next line Serial.read() happens very fast, a long time before the next character at 9600 baud arrives. So the next pass of the while loop fails, as there is no character in the RAM buffer.

What to do? Well wait for the next character before trying to read it, of course. Like this

// GET MESSAGE
// get line m (EOL '\n')
bool getMsg(char *m) {
  int p;

  if (Serial.available() > 0) {                 // data available ?
    p = 0;
    while ((m[p] = Serial.read()) != '\n') {    // end of line?
      p++;
      while (!Serial.available());              // wait for next char
    }
    m[p] = '\0';                                // terminate string
    return true;                                // data received
  }
  return false;                                 // no data
}

Here you can see that after the first iteration of the while loop and the Serial.read() we wait for the next character to arrive.

The next problem is to know when all the string's characters have been read, and this is done by marking the end of the input with a special character - in this case the program expects a LF or '\n'. You must make sure your terminal is set up to end the line it sends with this character.

Screen Shot 2017 09 10 at 17 13 15

Saturday, 2 September 2017

Got a new toy - USB Scope

Elektor magazine just offered me a deal I could not refuse. A SmartScope from LabNation. This is a 100ms/s sampling scope with software for PC & MacOS. Here the display of a 7.1MHz output from my VFO.

IMG 1453

Screen Shot 2017 09 02 at 14 57 14