USB PTT foot-switch

  • 5
  • Idea
  • Updated 2 months ago
that something i have in my brain for some time  to build a USB PTT foot-switch

i operate remote and already have USB studio mike and not like to rely on third party application 
only for handle my "CTS"  serial port foot-switch

so i take Arduino nano and fit it  inside on treadlite II switch 








that beta code 

//on next version will add a time-out timer  by polling ZZTX; status and force RX if TX stay on for //longer that 180 second  (JT-65 and meteor-scatter friendly)


#include <Bounce2.h>
#define PTT 2
int PTT_State = 0;

Bounce debouncer = Bounce(); 

void setup() {
  // put your setup code here, to run once:
  Serial.begin(57600);
  pinMode(PTT, INPUT_PULLUP);
  debouncer.attach(PTT);
  debouncer.interval(5); // interval in ms
}

void loop() {
  // put your main code here, to run repeatedly:
  debouncer.update();
  
  if (debouncer.read() != PTT_State){
   if (digitalRead(PTT) == LOW) {
     Serial.println("ZZTX1;");
     PTT_State = 0; 
     delay(100); }
   else  {
     Serial.println("ZZTX0;"); 
     PTT_State = 1; 
     delay(100);
     Serial.println("ZZTX0;"); }  // just in case radio missing it 
  }
}


Next on my todo list was  Native USB  radioSport  RS60CF headset
by put mini external USB sound card inside the headset shell  
so keep analog audio line as short as possible ;-)

73!  Marc   VE2OLM
Photo of Marc Lalonde

Marc Lalonde

  • 370 Posts
  • 91 Reply Likes

Posted 3 years ago

  • 5
Photo of EA4GLI - 8P9EH - Salvador

EA4GLI - 8P9EH - Salvador

  • 1815 Posts
  • 560 Reply Likes
Very cool! Thanks for sharing!
Photo of K1DBO

K1DBO

  • 583 Posts
  • 128 Reply Likes
I did something similar a while back but I used a serial port instead of USB.  You might find this:  https://community.flexradio.com/flexradio/topics/push-to-vox-version-1-0-0-is-now-available interesting. With it you can can toggle either VOX or MOX.
Photo of W7NGA

W7NGA

  • 452 Posts
  • 190 Reply Likes
Nice work Marc! I too have been integrating the Arduino with my 6500. I use the Arduino to debounce my old Vibroplex keyers and massage the dit/dash timing, and use the new USB support to decode frequency and control bandswitching, antenna switching, SteppIR configuration, and utilize i2C bus devices to perform just about anything I desire (e.g. analog voltages for old Icom antenna tuners). Great fun ...

W7NGA  dan
Seaside, Oregon
(Edited)
Photo of Marc-Andre

Marc-Andre

  • 37 Posts
  • 4 Reply Likes
Nice work Marc, this is a good idea.. let me know if you ever come down to Amos so we can meet somewere
Photo of W7NGA

W7NGA

  • 452 Posts
  • 190 Reply Likes
 Serial.println("ZZTX1;");

I can find no reference that states the TX command is supported. 
Does this actually work on a Flex Signature radio?

W7NGA dan
Seaside, Oregon
Photo of Marc Lalonde

Marc Lalonde

  • 370 Posts
  • 91 Reply Likes
HI  that native cat command for SmartSDR  ,at least it work on my 6700 whit last software

page 32 of  SmartSDR-CAT-User-Guide.pdf

but may use kenwood ts-2000 if what to 

73 Marc l. VE2OLM
(Edited)
Photo of W7NGA

W7NGA

  • 452 Posts
  • 190 Reply Likes
hmmm ... I can't find a SmartSDR CAT User-Guide 

I am using the new USB cable interface and this command doesn't appear to be supported.

I think that is the issue ... it supports a very limited subset of CAT commands.
Photo of Ria - N2RJ

Ria - N2RJ, Elmer

  • 2328 Posts
  • 966 Reply Likes
Outstanding. I am going to try it. 
Photo of Marc Lalonde

Marc Lalonde

  • 370 Posts
  • 91 Reply Likes
i take it here  www.flexradio.com/downloads/smartsdr-cat-user-guide-pdf/

since it a FTDI chip  i assume it may work directly on radio USB port
but for now i only try on my Desktop PC

for kenwood CAT emulation  it TX;  or RX;

that may tested on CAT  log..  windows  whit the test Button
Photo of W7NGA

W7NGA

  • 452 Posts
  • 190 Reply Likes
Thanks Marc. 
Photo of Marc Lalonde

Marc Lalonde

  • 370 Posts
  • 91 Reply Likes
HI  bit of reading and  "CAT" USB cable plug on radio not handle ZZTX; command  or TX; RX;

but i also not a issue since it have PTT on accessory connector (DB15)
and on mic connector on front of radio

on my case i what to use laptop / Desktop   and my radio was remote in cabinet in the basement
so have USB PTT take sense ;-)  same whit USB headset
Photo of Marc Lalonde

Marc Lalonde

  • 370 Posts
  • 91 Reply Likes
ok got my RadioSport headset from Flex today 

so i turn it into a USB headset  for use on my remote radio  
Think it the first USB RS-60  

so i take a small external USB sound card on ebay  and remove all connector 
then solder head phone wire to it  ,and use 4 pin of mini XLR for USB
noting to complex about 45 min of work    , i lost the use of build PTT but who use it really ?





first test look really good , this week-end Winter-Field day will be the real test  ;-)
(Edited)
Photo of Mark K0JM

Mark K0JM

  • 38 Posts
  • 3 Reply Likes
Just built one of the foot switches this week with a cheap Chinese nano-clone. Works great! Thanks for sharing the code.
Photo of Jason Frazier

Jason Frazier

  • 4 Posts
  • 0 Reply Likes
Building one of these now with a nano-clone off Amazon.  I notice there is a 3v3 pullup resistor to D2 in the first photo, but the value is hidden.  Is it even required, since the internal pullup resistor is already enabled?
Photo of Marc Lalonde

Marc Lalonde

  • 370 Posts
  • 91 Reply Likes
HI  value is not critical   1K  is good   , internal pull-up is very weak  so it like ti rely on external  one 
Photo of Mike, W8BE

Mike, W8BE

  • 196 Posts
  • 41 Reply Likes
Marc,

Did you ever finalize the code.  I see your beta code posted.   Wondering if there is a GA version.

tu
Photo of Marc Lalonde

Marc Lalonde

  • 370 Posts
  • 91 Reply Likes
HI normally code work and have never change   

but cannot test i since i no longer have flex ,sine none of the radio seem to work 
on my un-heated remote site during cold Canadian whiner 
Photo of Mike, W8BE

Mike, W8BE

  • 196 Posts
  • 41 Reply Likes
Thanks Marc...
Photo of Mike, W8BE

Mike, W8BE

  • 196 Posts
  • 41 Reply Likes
I just stuck my toe in the Arduino world for the 1st time... Downloaded the web editor and ran Marc's code.   It threw out an error on bounce2.h .  A quick google search and I learned about library manager.  I downloaded bounce2.h and ran the code again.   Success...Now I need is the nano and some solder time.  I decided to get real Arduino boards instead of knock offs.  It's not the boards I am worried about.  It's more the drivers that I suspect.   Regardless I hope to put my PTT switch together soon.

thanks to Marc for the code...
(Edited)
Photo of Michael Walker

Michael Walker, Employee

  • 1215 Posts
  • 360 Reply Likes
You can also do it without the Arduino.  It is discussed here:

https://community.flexradio.com/flexradio/topics/remote-footswitch-how-to-lan-vpn-solution

Mike 
Photo of Mike, W8BE

Mike, W8BE

  • 196 Posts
  • 41 Reply Likes
Update - It's working.  I used the Nano Every.  It was a tight fit but I have it in the foot switch.. I wish there was CAT command to disable DAX.  I did not see it in the log.  Then I would not have the issue where PTT is on but no audio.   Regardless having a USB PTT is cool...Thanks Marc.   



I would have went with the rs-232 port but I plan on using this with a lap top...
Photo of Tim - W4TME

Tim - W4TME, Customer Experience Manager

  • 9309 Posts
  • 3611 Reply Likes
 I wish there was CAT command to disable DAX. 

ZZDX0;
Photo of Mike, W8BE

Mike, W8BE

  • 196 Posts
  • 41 Reply Likes
Ask and you shall receive.   I did not see it in the manual .  Thanks Tim..  Going to mod the code and give her a whirl...
Photo of Mike, W8BE

Mike, W8BE

  • 196 Posts
  • 41 Reply Likes
Tim,

Impressive...  I just coded it up and works as advertised.   Here is the revised code.  

#include <Bounce2.h>
#define PTT 2
int PTT_State = 0;
Bounce debouncer = Bounce();
void setup() {
  // put your setup code here, to run once:
  Serial.begin(57600);
  pinMode(PTT, INPUT_PULLUP);
  debouncer.attach(PTT);
  debouncer.interval(5); // interval in ms
}
void loop() {
  // put your main code here, to run repeatedly:
  debouncer.update();
 
  if (debouncer.read() != PTT_State){
   if (digitalRead(PTT) == LOW) {
     Serial.println("ZZDX0;");
     Serial.println("ZZTX1;");
     PTT_State = 0;
     delay(100); }
   else  {
     Serial.println("ZZTX0;");
     PTT_State = 1;
     delay(100);
     Serial.println("ZZTX0;"); }  // just in case radio missing it
  }
}

I am wondering if it makes sense to do the DAX disable in the setup.  There is a slight lag due to the extra command.  Not really a big deal.  Just wondering.



Photo of Mike, W8BE

Mike, W8BE

  • 196 Posts
  • 41 Reply Likes
So I made a test and using this line of code it seems to work faster/smoother.  

Replace 

Serial.println("ZZTX1");

with    

 Serial.println("ZZDX0;ZZTX1");

Tim you da Man...
     




Photo of Tim - W4TME

Tim - W4TME, Customer Experience Manager

  • 9309 Posts
  • 3611 Reply Likes
You're very welcome.  I am glad I was able to help out.
Photo of Mike, W8BE

Mike, W8BE

  • 196 Posts
  • 41 Reply Likes
Update / question ....

I have been testing the foot switches I have made.   I have noticed that some times  SmartCAT is not able to interpret the CAT commands.    I will see ??? in the log.   I have played around with the driver properties and disabled the FIFO buffers.   It seemed to help but not always.   The usb port is configured as 57600 bps, 8 data bits, no parity and 1 stop bits.  


When this issue occurs I am always able to see the CAT command using the Arduino serial port monitor and Putty so I am pretty sure it's not a garbled command.   


I am just looking to understand if I can make the interface more stable.

thx
Photo of Mike, W8BE

Mike, W8BE

  • 196 Posts
  • 41 Reply Likes
I think I found the issue.  When you configure your CAT port in SmartCAT there is no where to set the baud rate or control params.  This did not seem right to me so I went looking for a config file and found it in: 

C:\Users\MyName\AppData\Roaming\FlexRadiosystems  

I found the settings for the USB port

&lt;PortSettings&gt;
    &lt;Protocol&gt;CAT&lt;/Protocol&gt;
    &lt;PortCommType&gt;Serial&lt;/PortCommType&gt;
    &lt;SerialPortType&gt;Existing&lt;/SerialPortType&gt;
    &lt;TCPPortNumber&gt;0&lt;/TCPPortNumber&gt;
    &lt;UDPPortNumber&gt;0&lt;/UDPPortNumber&gt;
    &lt;LifetimeSeconds&gt;0&lt;/LifetimeSeconds&gt;
    &lt;Name&gt;USB PTT Foot Switch&lt;/Name&gt;
    &lt;SliceIndex&gt;A&lt;/SliceIndex&gt;
    &lt;ExistingSerialPortName&gt;COM10&lt;/ExistingSerialPortName&gt;
    &lt;SerialPortBaudRate&gt;57600&lt;/SerialPortBaudRate&gt;
    &lt;SerialPortDataBits&gt;8&lt;/SerialPortDataBits&gt;
    &lt;SerialPortParity&gt;None&lt;/SerialPortParity&gt;
    &lt;SerialPortStopBitsStr&gt;1&lt;/SerialPortStopBitsStr&gt;
    &lt;SerialPortStopBits&gt;One&lt;/SerialPortStopBits&gt;
    &lt;SerialPortFlowControlStr&gt;None&lt;/SerialPortFlowControlStr&gt;
    &lt;SerialPortFlowControl&gt;None&lt;/SerialPortFlowControl&gt;
    &lt;SerialUseRTS&gt;true&lt;/SerialUseRTS&gt;
    &lt;SerialUseDTR&gt;true&lt;/SerialUseDTR&gt;
    &lt;SerialPinActiveLow&gt;true&lt;/SerialPinActiveLow&gt;
    &lt;AutoSwitchTXSlice&gt;true&lt;/AutoSwitchTXSlice&gt;
    &lt;AutoRemoveSplitSlice&gt;true&lt;/AutoRemoveSplitSlice&gt;
  &lt;/PortSettings&gt;

I changed the baud rate to 57600 and now it seems stable.  I will do some more random tests to ensure that the change actually fixed it.  

I assume that the SmartCAT must have some dynamic way of setting the baud rate because it did work most of the time.  Only on occasion did I get the erroneous CAT command in the log:

2020-01-07 16:59:34.985 COM10 [rcvd]: ?
2020-01-07 16:59:34.987 COM10 [rcvd]: f?f?f?~
2020-01-07 16:59:35.988 COM10 [rcvd]: ?f
2020-01-07 16:59:35.989 COM10 [rcvd]: ?`?f?~?
2020-01-07 16:59:35.989 COM10 [rcvd]: f?f?f?

I will say I am having fun with this...

Regards

Photo of Mike, W8BE

Mike, W8BE

  • 196 Posts
  • 41 Reply Likes
So I tried it again and the errors came back.   I have 2 options in my head now:

Throttle the usb port down to 9600 or add a delay after the daxoff cat command.  

I tried both and they seem to work.  I set the day to 15ms before sending the pttOn cat command.  

Btw I am testing this on 2 different 6400's so I don't think the issue is related to radio hardware.  

I will report back in a couple of days with more testing results.

Regards
Photo of Michael Walker

Michael Walker, Employee

  • 1215 Posts
  • 360 Reply Likes
Mike

If this isn't working, you can actually do the same thing by creating a SmartSDR CAT/PTT port that uses on RTS.  You pair that with a local Com port on your PC and then use a foot switch to toggle RTS high and low.  It  is documented in the communtiy.

Don't get me wrong, I love the ingenuity of using the Nano to send a CAT command.  

The baud rate should not matter as long as it matches, but I have found that keeping the baud rate in the 4800-9600 area is a bit more reliable and less impacted by any noise since you need less bandwidth. 

The errors in the log do look like framing errors.  Might it be RF related?

Mike
Photo of Mike, W8BE

Mike, W8BE

  • 196 Posts
  • 41 Reply Likes
Mike,

Thanks for getting back to me.   It's not rf as I have the pwr setting at 0 for testing.  I am testing it now on my lap top and have added the 20ms delay after the daxOff cat command and so far that seems to have worked.  If I cant duplicate it on my laptop then I have to think something is up with my usb driver on  my desktop. 

I am not there yet however.   Does Flex have any recommendation on  the use of FIFO buffers?  I currently have mine enabled but have the buffer setting at the minimum.  I am not sure if I buffers are needed as I am sending 14 chars * 256 for 3,584 bytes.  Also is there any issue with me editing the CAT config fie?  

The main reason I want to use USB is because DB-9 ports on lap tops are non existent today.   I will keep playing with it to try to get it more stable.  

I am still having fun with it.   
Photo of Michael Walker

Michael Walker, Employee

  • 1215 Posts
  • 360 Reply Likes
Hi Mike

I can't really say as I doubt we really exploited it.  I think they try to stay with the default unless there is a reason to change it.  Same is true with editing the CAT config file and I would not recommend doing it as it may complicate other debugging should we have to do that.

Mike
(Edited)