Showing posts with label arduino. Show all posts
Showing posts with label arduino. Show all posts

Wednesday, January 14, 2015

FlexControl for Linux+ #hamr

Lately I've been on the air with a FLEX-6700 from FlexRadio Systems.  It's a great rig, but that's a story for another day.

Today's subject is the beautiful FlexControl, which is a "USB Knob" ($99.99).  It is designed as an adjunct input device for the Flex software defined radios, for users who need something more traditional than mouse-based pointing and clicking for tuning and managing a radio.

The product is provided for SmartSDR for Windows, the principal interface program for the Flex 6000 series.  It has a great feel, and it has 3 nice buttons and status lights. SmartSDR provides a Windows driver to work with the FlexControl.

So that's fine, but I'm mainly a Linux guy.  For unfortunate but understandable reasons, Flex only provides Windows control software.  What does the FlexControl look like when plugged into a Linux system?  I could not find any documentation.

With help from Wireshark and VirtualBox, we can do some reverse engineering.

The FlexControl is recognized by Linux (Ubuntu 14.04, but probably most other versions, too).  It appears as /dev/ttyACM0 on my machine. "ACM" signifies that this is a CDC_ACM device.  That category is loosely based on ancient Hayes modem interfaces, but don't worry about that!  Really, it just emulates an old-fashioned serial I/O connection at 115 Kbps.

You can set up minicom or any other Linux program to talk to this device.  The only remaining question is the protocol.  It turns out to be simple.  No surprise, this is a simple device.  The scoop:

Sending from FlexControl to host:
All commands terminate with ';' (no returns or line feeds)
U; - knob CW (single tick) -- U02; U03; U04; etc - multiticks
D; - knob CCW (single tick) -- D02; D03; D04; etc - multiticks
S; - short press, main knob
L; - long press, main knob
C; - fast double click, main knob


The fast knob codes reflect multiple encoder ticks between USB polling times, so the knob should be able to keep track of fast spinning.  (Alas, SmartSDR will not always keep up so well.)

XnS; - normal press, key n=1,2,3
XnL; - long press
XnC; - fast double click

e.g. 
   U; (frequency up one tick)
   X2S; (normal press, button 2)

Sending from host to FlexControl:


Ixyz;  where x,y,z = 1 or 0 for LED 0, 1, 2 on or off
e.g.
   I001; set right hand LED on
   I000; set all LEDs off

   I111; set all LEDs on

Note that SmartSDR for Windows only uses a fraction of the FlexControl's button capability.

See a simple Python program to illustrate how to communicate at http://aa6e.net/wiki/FlexControl

[Added 4/24/2023: That link has gone dead.  A copy of the old file can be found at http://web.archive.org/web/20150226074911/http://aa6e.net/wiki/FlexControl. Note that the code is written in version 2 Python.  It will need updating for version 3.]

The FlexControl should be very useful for all kinds of DIY software projects.  Connect it to your Raspberry Pi, your Arduino, your Linux PC for any kind of control project! (There are cheaper USB based controllers available -- for games, etc., but few have the right "ham" esthetics IMO.)

Maybe FlexRadio or one of the designers (K6TD or K6TU) would have divulged the same data if they were asked nicely, but it was more fun to work it out on my bench.

Monday, July 16, 2012

Interesting Little Boards

Shortly, I'll have three little computer boards to understand, play with, and possibly (just possibly) build into some useful projects.

The Arduino Uno is "slow" (16 MHz) ATmega328, has limited RAM and OS support, but is very flexible for interfacing and control applications. Easy C-style programming for simple applications. $27 at Digikey.
The Raspberry Pi is fast (700 MHz ARM) with 256 MB RAM, Fedora Linux, etc., and it's amazingly cheap ($35 US at Allied Electronics, if you can get one!).

As a full-blown Linux system, the Raspberry (and BeagleBoard, below) will require somewhat more software sophistication to get in the game.
The BeagleBoard XM is fastest (800-1000 MHZ ARM) with 512 MB RAM and full set of peripheral connections, running Ubuntu Linux, Android, and others. $149 at DigiKey.

This board has the makings of a DIY netbook computer or tablet, even including a camera interface.

You get extra points if you can program the built-in TMS320 DSP processor.  Usually for audio and video codecs, the DSP development environment is complicated. (To be charitable)

I've mostly been working the the BeagleBoard XM, and I use a lot of its I/O capabilities.  (This is the only board of the three that seems to directly support audio input.)  It provides all the fun and frustration of working in a full Linux environment (including video display, mouse and keyboard if you want), but there are few extra headaches dealing with the embedded aspect.  (E.g., configuring GPIO pins and boot files.)

The rule seems to be: use the simplest board that will support your project without elaborate daughter cards, etc.  In a one-off project it's really easy to use many hours and dollars to shoehorn a project onto a board that doesn't quite fit.  On the other hand, if all you need is blinking lights of one sort or another (even a complex Morse keyer) the Arduino's easy programming system can really save time.

These are all open source boards, making it possible to do your whole project in an open style (software and hardware), a big plus for Amateur Radio DIY work.  There is a huge amount of online information and help forums for all these boards.