USB Joystick Input

openTx has introduced a range of new features, ideas and bling. It is fast becoming the firmware of choice for many users. openTx will run on ALL current hardware platforms, including the gruvin9x and sky9x boards. Work has already started to support the new FrSky X9D radio!
Post Reply
samworthington
Posts: 6
Joined: Mon Dec 22, 2014 5:13 pm
Country: -
Contact:

USB Joystick Input

Post by samworthington »

There are a few posts about using a USB joystick input instead of the transmitter sticks but all I can find as a solution is using an Arduino to output PPM to use as a trainer port input

http://www.rcgroups.com/forums/showthread.php?t=1515226
http://diydrones.com/forum/topics/spekt ... 4#comments
viewtopic.php?f=45&t=5747

Considering the apparently high level of interest in this and USB port on transmitters like the 9XR, it seems strange there isn't a firmware solution. Is anyone working on this?

Cheers,

Sam

User avatar
MikeB
9x Developer
Posts: 17993
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: USB Joystick Input

Post by MikeB »

It's not so much a firmware problem as a hardware problem. The USB ports are wired as "peripheral" ports not OTG (On The Go) ports. This means the ports don't provide a 5V power supply for use by another peripheral device.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!
SkyNorth
Posts: 958
Joined: Tue Dec 27, 2011 11:40 am
Country: -
Location: Mansfield , Ontario

Re: USB Joystick Input

Post by SkyNorth »

What about if a "powered hub" was used to supply power?

- Also I was thinking since the USB port is on a separate Pcb , it could be hacked in to supplying power maybe...

-Brent
samworthington
Posts: 6
Joined: Mon Dec 22, 2014 5:13 pm
Country: -
Contact:

Re: USB Joystick Input

Post by samworthington »

The powered USB hub certainly sounds like a good option to start with. If that looks promising it shouldn't be too much trouble to either mod the board with the USB port, or make a new one with power that fits in the original board's place.

What do you think Mike, do Brent's suggestions sound feasible?

Sam
User avatar
MikeB
9x Developer
Posts: 17993
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: USB Joystick Input

Post by MikeB »

It might be possible, but clearly would need the OTG code to be implemented, which will take some time to sort out.

Mike.
erskyTx/er9x developer
The difficult we do immediately,
The impossible takes a little longer!

User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: USB Joystick Input

Post by jhsa »

On the 9XR-PRO, Maybe a 5V regulator from the battery, together with an IO pin to turn USB power ON/OFF, or am I misunderstanding something?

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
samworthington
Posts: 6
Joined: Mon Dec 22, 2014 5:13 pm
Country: -
Contact:

Re: USB Joystick Input

Post by samworthington »

João,

I think that is the sort of mod Brent was talking about. I don't think you need to turn the USB power off. If it's not used I don't expect it would cause a problem. Then again, I'm a mechanical engineer so could be missing something with all the electronical wizardary.

Sam
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: USB Joystick Input

Post by jhsa »

When you connect the radio to a PC the PC also sends 5V on the USB connector. I don't know if having another source in the radio would cause problems, hence I mentioned the turning it off..

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
samworthington
Posts: 6
Joined: Mon Dec 22, 2014 5:13 pm
Country: -
Contact:

Re: USB Joystick Input

Post by samworthington »

João,

I see what you are saying. I'd be guessing if I tried to say whether the second power source would cause a problem or not.

Sam
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: USB Joystick Input

Post by jhsa »

If it is a problem, I think it would be possible to switch the power to the USB port with the new expander circuit Mike has been experimenting with ;)

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
SkyNorth
Posts: 958
Joined: Tue Dec 27, 2011 11:40 am
Country: -
Location: Mansfield , Ontario

Re: USB Joystick Input

Post by SkyNorth »

The SD / USB pcb could be re-designed to add the power switch. you would need to solder one wire to the 5V regulator output.
The 9XR Pros 5V switching regulator is good for 1.5Amps....so there is lots of accessory power available.

The USB connection to a Computer is detected by sensing 5V on the USB power pin. So you cant just put 5V on the connector pin.
It needs to be in "input" mode first (Type B) , to see what type of connection it has, then if sees a type B connected to it. , then the Radio can
turn into a Type A (OTG) and supply power.
They make small current limited (500ma) switches for this job.... it also uses a LOW enable signal , so we can double purpose the Erase pin
to provide the enable signal for a OTG connection .. I might be missing something here .. Mike is the true expert on this .

The big question , is there a demand for this?
I have old USB - Sidewinder Pro joystick - I think it would be cool if I could plug into the Radios' USB port and provide control input....
Yes you could use the trainer PPM input for this , but would need the USB to PPM converter.
In theory you could use your simulators flight yoke and pedals to fly with... :geek:

Regards,
Brent
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: USB Joystick Input

Post by jhsa »

Brent, I think the erase pin is already being used for the Bluetooth.. Don't know if that would be a problem..

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
SkyNorth
Posts: 958
Joined: Tue Dec 27, 2011 11:40 am
Country: -
Location: Mansfield , Ontario

Re: USB Joystick Input

Post by SkyNorth »

Yes, I know. nut the only other signal that maybe could be used is the SD card detect switch....
It all comes down to if the ARMs USB hardware port can handle the USB host side of the connection.

-Brent
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: USB Joystick Input

Post by jhsa »

I'm sure that if someone will do a mod like this would also be interested in increasing the number of IO pins with a simple i2c expander. Mike has been working on something like this.. It would probably avoid some delicate soldering to the skyboard/pro's mainboard??

Joâo
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW
fpvjunkie
Posts: 4
Joined: Fri Jan 30, 2015 1:18 am
Country: -

Re: USB Joystick Input

Post by fpvjunkie »

Another way to do this would be to plug a USB hub into a Rasp Pi and then plug the USB devices (joysticks, etc) into the hub. If the Pi is running Linux (what else ?) then a lot of the devices are going to have drivers in the kernel. One could then write a little program to take the inputs from the USB devices and turn them into PPM via a USB PPM generator.

One of the problems with connecting USB devices directly to the Taranis is that its going to need drivers for every different device, unless they are generic.
samworthington
Posts: 6
Joined: Mon Dec 22, 2014 5:13 pm
Country: -
Contact:

Re: USB Joystick Input

Post by samworthington »

The generic drivers would certainly be a start. I think most joysticks do work as generic devices, it's just that the device-specific drivers allow the extra features. The generic drivers would allow a joystick with pitch, roll, throttle and yaw to work.

That said, I like the Raspberry Pi idea but it does add another failure point into the loop. I found the following forum post discussing getting PPM out but it's quite an old post doesn't seem to have been concluded.

http://www.raspberrypi.org/forums/viewt ... 1&p=184406

I also found the following page that might be of some use:

https://brskari.wordpress.com/2014/06/0 ... -vehicles/
pickardjoe
Posts: 2
Joined: Fri Feb 26, 2016 5:35 pm
Country: -

Re: USB Joystick Input

Post by pickardjoe »

Sorry for the necro, but I think this is quite relevant if people are still looking for a solution.

I just wrote an addition to the firmware to do this. All you need is my modified firmware, a USB cord, and the computer-program I wrote. It's still quite hackish, but works great. I actually have 2 desktop programs I use. One is a python script that accepts commands of the form: "so <channel> <value>" as an input and writes data to the serial port telling the radio what to do. The other is a c-program that prints out joystick events in the form the python script accepts.

This method is not limited to the 4 channels of trainer input. You can use up to 16 channels. 32 (using a JR module) would be possible with a quick firmware change. The program works at up to 3600 channel-changes per second, which should be well above the amount needed for operation. (That's the equivalent of moving all 4 channels to different positions every 900th of a second.)

I used it with a drift car last night, and was driving with a USB steering wheel and pedals in FPV.

If anybody is still interested in this, please let me know.
User avatar
Kilrah
Posts: 11109
Joined: Sat Feb 18, 2012 6:56 pm
Country: Switzerland

Re: USB Joystick Input

Post by Kilrah »

It could be interesting indeed and could be included in OpenTX! Is it "cleanly" integrated e.g. with an option to enable it instead of the standard behavior?
pickardjoe
Posts: 2
Joined: Fri Feb 26, 2016 5:35 pm
Country: -

Re: USB Joystick Input

Post by pickardjoe »

Right now it only works with the Taranis X9D plus. It is enabled by running make with USB=CONTROL. I have the protocol setup as follows:
1. Wait to receive a byte equalling 181. This is effectively a command-code to make other types of radio-computer synchronisation easier in the future.
2. Next byte is channel.
3. Next two bytes are the new position of that channel. This is an unsigned number from 0 to 2048. 0 corresponds to -100, 1024 corresponds to 0, 2048 corresponds to 100.

The USB input is just another input source, like Sticks / Pots/ Trainer. All the mixing can be done on the radio.

@Kilrah: I assume that you are a developer for OpenTX? Are there any procedures / conventions I need to follow for committing?
User avatar
Kilrah
Posts: 11109
Joined: Sat Feb 18, 2012 6:56 pm
Country: Switzerland

Re: USB Joystick Input

Post by Kilrah »

OK, so it's not really what the thread was about, but can still be useful... what actual USB protocol are you using? HID, virtual COM port?

Nothing very specific to submit a pull request, just follow the style you'll find in existing code, avoid breaking things (on any platform), and ideally make sure to implement all "sides" of the feature you're adding (e.g. if changes are needed in companion, or eeprom conversions are needed do that too).

Once you submit a pull request you'll get some discussion/help about what has to be done if anything.

Due to the extra sources I guess it will be based on and target 2.2 ("next" branch).
cmb
Posts: 1
Joined: Sun Aug 07, 2016 9:45 am
Country: -

Re: USB Joystick Input

Post by cmb »

pickardjoe wrote:If anybody is still interested in this, please let me know.
Definitely interested. I've starred your repo on GitHub and will try it out soon!
samworthington
Posts: 6
Joined: Mon Dec 22, 2014 5:13 pm
Country: -
Contact:

Re: USB Joystick Input

Post by samworthington »

I'm definitely interested too, only I don't have a Taranis. I'll have to get saving up then I can give it a try.

Sam
evilC
Posts: 1
Joined: Mon Nov 26, 2018 11:54 am
Country: -

Re: USB Joystick Input

Post by evilC »

Hi guys, sorry to necro this thread yet again, but is pickardjoe's project (Or one like it) still alive?
I managed to find his GitHub page, but am not sure which project I would need. It looks like this one, but it seems very out of date.
Ideally I would like something that uses pure USB to the Tx, but I do have an Arduino, so could use a solution based on that too.
Am willing to pitch in on coding, I do C# remapping apps as a hobby, so am pretty well versed on the PC input side of things, but am totally new to RC and Tx stuff.
I have an open-source remapping app called UCR, and would be interested in building in support for RC to that.
I would just need to add an "Output Provider" to UCR that supported sending to RC models, and you could then leverage any of the input devices supported by UCR (Joysticks, keyboard, mouse, head trackers, eye trackers, MIDI controllers etc) to control RC models.

Post Reply

Return to “openTx”