Welcome to the new FlexRadio Community! Please review the new Community Rules and other important new Community information on the Message Board.
If you are having a problem, please refer to the product documentation or check the Help Center for known solutions.
Need technical support from FlexRadio? It's as simple as Creating a HelpDesk ticket.

Need help on Flex control with an Arduino or Teensy.

KEV31779
KEV31779 Member ✭✭
I am starting up a project where I would like to build some external controls to and from the Flex. Where do I start and where can I find are the most current library's and documentation? I assume the best way to connect would be over ethernet/wifi. Or is using serial the better way with the micro hardware?

I have all types of micro hardware lying around and want to put them to use.

I would like to have access to things like the items below to start.

Read and set modes.
SWR reading.
Mic gain.
AGC level.
Set power levels.
Read S-meter.
Read Freq. per Slice.
Set Freq and step control with the ability to increment or decrement to new freqs.

Answers

  • KD0RC
    KD0RC Member, Super Elmer Moderator

    Hi Kev, I did build just such a project. You can follow along on the Flex Community, TeensyMaestro thread:

    The project itself is on GitHub where you will find a User Manual, Bill Of Materials, schematic and other supporting material:

    Additional pictures and project history can be found on my QRZ page.

    The source code and Flex API library are available on GitHub so that you can make it the way you want. I set things up so that you only need to include the controls that you are interested in without re-compiling. I also provide the .hex file and loader so that you can load the firmware without even opening any of the source or having the Arduino IDE.

    A critical component (at least for me...) was the Arduino library of Flex API commands that Enzo, IW7DMH built. I upgraded it very slightly to work with V 3 of SmartSDR and to add a few features of my own. If you elect to roll your own, I recommend starting with this library and the program called FlexSignatureTeensy.ino. This forms the basis for all the functionality that I used in my project. FlexSignature.ino is also included in case you want to build an Arduino version.

    I based my design on the Teensy 4.1 board from PJRC. Other Teensy boards have more than enough power, but the 4.1 has built-in ethernet and over 40 GPIO pins (I used them all...).

  • KEV31779
    KEV31779 Member ✭✭
    Thank you for your links. I was looking through your program on Github seems pretty involved. In your examples you have several files. Which one was your final project? Do you have any examples of simple calls to the Flex to get started. Something as simple as reading an S-meter and freq in the controller. Your design is nice. I think I need to try to break it apart in small pieces so I can build my understanding of the communication and programming structure. Is there any small examples?
  • KD0RC
    KD0RC Member, Super Elmer Moderator

    Hi Kev, The final project is in the release section of GitHub:


    The FlexSignatureTeensy.ino program looks complicated but makes using the API much easier. Here is a quick test program I did that uses the IW7DMH library (FlexRigTeensy.h) but not FlexSignature.ino.

    Here is a link to the Flex API Wiki. It has a few errors and omissions but is largely good. This shows you the format of the API commands and gives you a good idea of what is available. The Flex API is very complete; it is what Flex used to create SmartSDR. If SmartSDR can do something, then your program can too.

    Home · flexradio/smartsdr-api-docs Wiki (github.com)

    Using the FlexRigTeensy.h library makes everything much, much easier. It looks daunting at first, but once you see the magic in what Enzo did, it becomes your friend very quickly. Same goes for the FlexSignatureTeensy program (I guess you would call it a wrapper...). Once you see how the events work, it makes things an order of magnitude easier than just the library. If you start with FlexSignatureTeensy and a few Serial.print statements to look at freq, volume, AGC-T and that kind of thing, you will start to understand how it all fits together.

    One complication that you need to deal with is the concept of binding a non GUI-Client (like the TeensyMaestro) to a GUI-Client (like SmartSDR). Certain things just won't work right without this. Once you get past understanding the command structure and the text-based communications (e.g. read or change freq on a slice), then you can tackle binding to the GUI-Client.

    You mentioned Teensy in the thread title; do you by any chance have a Teensy 4.1 with the ethernet cable and jack? If so, you can load the .hex file, then use putty or something to look at the serial output from the Teensy. You will be able to see the debugging commands that I have in there. If you compile it, you can use the serial monitor in the Arduino IDE. You will have to have the Teensyduino add-in, which I am guessing that you already do.

    The approach that Phil, VK4KW is taking is to build the TeensyMaestro as-is, then change the items that he wants to change. So far, he has a working unit, and his next step is to move things around on the display and add some functionality that suits his operation. I am currently cleaning up the code to make this easier. Should be released this weekend or sometime next week.

  • KEV31779
    KEV31779 Member ✭✭
    Len,
    Yes I have a Teensy 4.1. I just ordered an RJ45 ethernet breakout for it for a couple bucks. I really appreciate all the information. I guess once I get started I will probably have several questions. My goal is to have the teensy connect to the flex and get some band information and readings. I also want to incorporate my tuner and electronic coax switch into the mix so I can eventually control everything remotely with minimal cost. Should be a fun project.

    Thanks Kevin
  • KD0RC
    KD0RC Member, Super Elmer Moderator

    Hi Kevin, here is a quick program that I put together for the Tampa Amateur Radio Club. It has some of the features that you mention and may be a good starting point. Hopefully this will give you some insight as to how this all works.

    /*
     FlexAntDisconnector
      Len Koppl, KDØRC
      08/29/220
      Teensy 4.1 (with built-in Ethernet)
    
     Built for Lu Romero, W4LT to be used with his club station.
     This connects to a Flex and checks for the presence of a logged-in GUI-client.  
    
     A NPN switch can be jumpered to  pin 33 and used to drive an antenna 
     disconnect relay.
    */
    

    Since I wrote the top of program comments, I added code to change bandpass filters based on band. I made them configurable active high or active low (see Config.ini file, below). I also stole the capability to put spots on the SmartSDR screen from the TeensyMaestro project.

    This does not use the FlexSignatureTeensy.ino program, but I did import some key routines from there (they start with G06_ through G12_) to make this easier to implement.

    Here is the config.ini file. Rename it Config.ini. I had to give it a txt extension to get it to post here.

    Hopefully this will help.

  • KEV31779
    KEV31779 Member ✭✭
    Hi Len,
    Thank you so much for all the information and pointing me in the right direction. I will start checking out all the information you have provided this weekend. I think this will keep me busy for a bit.

    Kevin

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.