Click here to Skip to main content
13,863,067 members
Click here to Skip to main content
Add your own
alternative version


6 bookmarked
Posted 22 Mar 2016
Licenced CPOL

FT857D Manager Ham Radio Controller

, 22 Mar 2016
Rate this:
Please Sign up or sign in to vote.
Change the frequency , the mode and sent morse code on radio


The code connects to a Ham Radio via CAT cable and it changes the frequency and mode on the Radio. It also sends the CW (morse code) via a cable connected to the Radio CW keyer stick from a USB-to-SERIAL port and with two resistors and an NPN transistor. So it uses the Radio's own sound device and a sound card is not used for sending morse code.


The idea was to make a Radio controller controlled by the computer and learn how to use CAT commands. So the first part of the project was to create a program that could change the frequency on screen and later connect to the radio so the CAT command could be used to change the frequency and the mode (LSB,USB,CW) on the radio by pushing a button on in the Windows application. So I started to write the software and ordered the CAT cable and a USB-to-USB cable. When the cable came I finished the 1.0 version of the program. After that, I was challenged to make the CW (morse code) sending part. I ordered new cables and get make some test and code the CW part of the application.

Using the Code

The code is built in three parts. One Windows project and two class libraries. The first class library is called ft857d and it controls the CAT connections to the radio. The second class library is called ft857dcw and it controls the cw sending to the radio.

This part of the code in the CAT controller change the frequency on the radio. It gets a string from eight textboxes (the frequency ex. "01,40,00,00" for the 14MHz). It first removes the "," then converts to a 16 byte (40 - 0x40). Then it sends the byte array to the COM port and changes the frequency on the radio.

public void WriteTx(string tx)

           string a = tx.Substring(0, 2);
           string b = tx.Substring(3, 2);
           string c = tx.Substring(6, 2);
           string d = tx.Substring(9, 2);

           byte[] talbyte = { Convert.ToByte(a, 16), Convert.ToByte(b, 16), Convert.ToByte(c, 16), Convert.ToByte(d, 16), 0x01};

           try {

                   comPort.Write(talbyte, 0, talbyte.Length);

           catch  {  }


This code in the CW controller takes the text from the textboxes and translate it to morse code. For example: "abc de" ".-¤-...¤-.-. -..¤." The ¤ is set between the letters and space is just a space.

 public void createCW(string text, int wpm)
            text = text.ToLower();
            int dit = 1200 / wpm;
            string cwText = "";
            char[] ctext = text.ToCharArray();
            for(int i=0; i<ctext.Length; i++)
                cwText += CW(ctext[i]);
                cwText += "¤";

            sentCW(cwText, dit);

private string CW(char letter)
            string cwtext = "";
            switch (letter)
                case 'a':
                    cwtext = ".-";
                case 'b':
                    cwtext = "-...";

This part of the code in the CW controller sends the code to the radio. It opens the COM port and when the DRT is true, it sends a tone and close when the DRT is false. Thread.sleeping is a how long the tone has to be sent or wait before it is sent the next letter. The "dit" is the "." and "dah" is the "-".

private void sentCW(string cwtext, int dit)
               int dah = 3 * dit;
               int space = 5 * dit;
               char[] cw = cwtext.ToCharArray();
               for (int a = 0; a < cw.Length; a++)
                   switch (cw[a])
                       case '.':
                           comPort.DtrEnable = true; ;
                           comPort.DtrEnable = false;
                       case '-':
                           comPort.DtrEnable = true; ;
                           comPort.DtrEnable = false;
                       case '¤':


                       case ' ':


           catch { MessageBox.Show("You have to connect a CW Com Port."); }

The program is in C#.

Points of Interest

When I was beginning to code the Windows Application I think that I was not able to get it to work. It looked too difficult and I was worried a lot about how it was gonna work when I ordered the cables. I ordered cables two times. First the CAT cable and the USB-to-USB. After that worked, I ordered the USB-SERIAL and SERIAL-to-SERIAL and the two 10kOhm resistors and the NPN BD 135 transistor because I also have to solder some the component. I am not good at electronics so I thought I might not be able to finish the project. But I was very surprised over how easy it was and I was also able to learn about thread sleeping.

I ran into a problem when I changed the frequency on the radio. It would only change the Tx frequency and not the Rx frequency, but I was told I needed to just add thread sleeping into the code.

This code is in Form1.cs and is activated when the Update button in the Radio or in the memory Tab.

private void Update_Write(string con)

           FT857D_CatControl.Instance.PortName = comboPortsCAT.Text;
           FT857D_CWControl.Instance.PortName = comboPortsCW.Text;
           FT857D_CatControl.Instance.DisplayWindow = rtbDisplay;
           FT857D_CWControl.Instance.DisplayWindow = rtbDisplay;
           SerialPort comPort = FT857D_CatControl.Instance.OpenPort();
           SerialPort comPort1 = FT857D_CWControl.Instance.OpenPort();
           if (con == "ptt")
                 if (comPort.CtsHolding)
                   string msgMode = comboMode.Text;

                   string msgTx = lblFreTx_0.Text + lblFreTx_1.Text + "," + lblFreTx_2.Text + lblFreTx_3.Text + "," + lblFreTx_4.Text + lblFreTx_5.Text + "," + lblFreTx_6.Text + lblFreTx_7.Text;

                   string msgRx = lblFreRx_0.Text + lblFreRx_1.Text + "," + lblFreRx_2.Text + lblFreRx_3.Text + "," + lblFreRx_4.Text + lblFreRx_5.Text + "," + lblFreRx_6.Text + lblFreRx_7.Text;

               catch (Exception ex) { MessageBox.Show(ex.ToString()); }

                        else { MessageBox.Show("You kneed to Connect your Radio"); }



Images on the listview. In the Form1.cs

private void FillHelpTop()
           listViewHelpTop.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
           ListViewItem item1 = new ListViewItem("Connect CAT", 0);
           ListViewItem item2 = new ListViewItem("Connect CW", 0);
           ListViewItem item3 = new ListViewItem("Select frequency", 1);
           ListViewItem item4 = new ListViewItem("Edit Memory Stations", 2);
           ListViewItem item5 = new ListViewItem("Wheater", 1);
           ListViewItem item6 = new ListViewItem("Sent CW", 3);
           listViewHelpTop.Items.AddRange(new ListViewItem[] { item1, item2, item3,item4,item5,item6 });

Change frequency by mouseclick

private void lbl_MouseClick(object sender, MouseEventArgs e, string box)
           int btTal = 0;
           switch (e.Button)

               case MouseButtons.Left:

                   btTal = -1;

               case MouseButtons.Right:

                   btTal = 1;
           int tal = 0;
               case "Tx0": tal = int.Parse(lblFreTx_0.Text) + btTal;
                   if (tal < 0) { tal = 4; } else if (tal >  4) { tal = 0; }
                   lblFreTx_0.Text = tal.ToString();
                   lblMemTx_0.Text = tal.ToString();
               case "Tx1":
                   tal = int.Parse(lblFreTx_1.Text) + btTal;
                   if (tal < 0) { tal = 9; } else if (tal >  9) { tal = 0; }
                   lblFreTx_1.Text = tal.ToString();
                   lblMemTx_1.Text = tal.ToString();


  • Version 1.0 (never released only to test) XML database for radio memory and changing frequecy on the radio.
  • Version 2.0 (this version) XML database for CW memory and morse code text could be sent via the radio.


Thanks to Michael OZ8AGB for guiding me though the project and it was his idea that I should make the project.

Thanks to Bjarne OZ7BKJ for the help with the xml gateway.

Thanks to Niels OZ5NM that showed my the diagram how to solder the resistors and transistors.

Thanks to my litle brother Brian that guided me how to create the CW translator.

The Connect code to the Com Port was something I found on the WEB.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Member 12338789
Denmark Denmark
My name is Tommy Clemmensen

My call is OZ1THC that is a danish Amatour Callsign.

I am 48 years old.
And is a before pensionist.

You may also be interested in...


Comments and Discussions

QuestionGreat Article! Minor Edits ... Pin
bling22-Mar-16 11:50
memberbling22-Mar-16 11:50 
AnswerRe: Great Article! Minor Edits ... Pin
Member 1233878922-Mar-16 12:21
memberMember 1233878922-Mar-16 12:21 
AnswerRe: Great Article! Minor Edits ... Pin
Member 1233878922-Mar-16 13:31
memberMember 1233878922-Mar-16 13:31 
GeneralRe: Great Article! Minor Edits ... Pin
bling22-Mar-16 14:06
memberbling22-Mar-16 14:06 
GeneralRe: Great Article! Minor Edits ... Pin
Member 1233878922-Mar-16 14:26
memberMember 1233878922-Mar-16 14:26 
GeneralRe: Great Article! Minor Edits ... Pin
Member 1233878922-Mar-16 14:55
memberMember 1233878922-Mar-16 14:55 
GeneralRe: Great Article! Minor Edits ... Pin
Member 1233878923-Mar-16 1:08
memberMember 1233878923-Mar-16 1:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web04 | 2.8.190214.1 | Last Updated 22 Mar 2016
Article Copyright 2016 by Member 12338789
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid