Need advice on Microcontroller to Computer communication

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

Hello! I'm working on a simple project to simulate a cockpit using an ATMega88. I started by using an analog joystick connected to the microcontroller in which the microcontroller will read the ADC input of it. However I'm stuck about the next phase of the project which are the following:

 

1. To pass the information to the computer , from my limited experience with eletronics and microcontrollers usage, I need to make a serial connection from the usb port to the microcontroller. I opted to chose an FTDI  232BM not because I understood what I was picking but more like it was a common choice using an FTDI. I need some advice with it, bear in mind I'm novice in terms of these applications.

 

2. How will my computer be able to understand , in the device manager, that the serial communication means that a joystick is ready to be used in flight simulators? 

 

3. Will i need to use USART for the joystick or does the computer understands the input of the adc? I'm asking about it because in the next phase of the project I will apply switches which once pressed will correspond to a key in the keyboard for example start the engine, activate flaps by using USART.

 

Thank you for reading, I'm sorry if this is not the right place to ask.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Greetings and welcome to AVR Freaks! You have an "interesting" project.

 

The device manager will recognize the FT232 as a COM port if you are on Windows. 

 

You will use the micro's USART to send data via the FT232 to the host computer.

 

There are several hurdles here:

 

1. How to encode the data? You generally do not want to send raw data, even if it is only 8 bits. But, more than 8 bits, you are forced to do something else. One way is to convert the hex representation of your data into ASCII. For example, if the value is 0x9C, you would send the character '9' and the character 'C' or 'c'. There are a number of other ways.

 

2. What are you going to do with the data on the host? Do you have something you are writing or are you using a flight simulator program? If you are using an existing flight sim, then you will be forced to use the number format it expects. Further, it might not even accept input  from a COM device. So, you really need to deal with this, before going much further.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

Last Edited: Sat. Oct 19, 2019 - 09:33 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

... that the serial communication means that a joystick is ready to be used in flight simulators?

 

Welcome to the Forum.

 

I think that means that you are trying to build your own cockpit control system for use with commercial software flight simulators.

 

I think your current approach will prove difficult to implement.

 

USB has a number of defined devices, such as HID, (Human Interface Device), which includes mice, keyboards, and joysticks.

 

So, to easily interface a joystick into the PC's operating system, from which the flight sim software can easily connect, the joystick needs to enumerate as a HID / Joystick device.

 

The FTDI chip is a great way to interface a micro with a PC, but it enumerates as a serial communications port, not as a HID.

 

Although a programmer who understands the innerworkings of the Windows, (or Linux, or Max, etc), operating system might be able to write a Terminate and Stay Resident type of program to enumerate a phantom HID Joystick, read the serial port, convert / scale the data as needed, stuff the HID buffer and trigger its data available flag, etc., that would be a lot of rather complex, and difficult to debug, code.

 

It would make more sense to study up on USB HID interfaces, and then use a micro with a built-in USB interface and a proven software library for enumerating and functioning as a HID device.

 

Get a classic HID keyboard up and running first, even if only for three push buttons that are read by the PC OS as "A, B, and C", for example.

 

Then learn how to make a HID device enumerate as a Joystick, and finally how to read your ADC inputs and feed them through the signal chain to exit out or the PC OS as joystick signals.

 

There are already a few USB HID Joystick projects on the web, so that would be a good place to begin your background research.

 

JC

 

Edit:  Know that many Flt Sim programs allow one to "map" any desired keyboard key to any desired function, (L engine start, Flaps to 10', Landing gear up/down, etc.).

That would allow one to interface their cockpit panel controls as "keyboard" keys, for many functions.

That, by itself, however, would not likely handle yoke and pedal controls.

 

JC

 

Last Edited: Sun. Oct 20, 2019 - 12:16 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Agree with Doc, flightsim is mainly interested in USB HID so providing CDC-ACM (UART) is not going to help much. Get an AT90USB series micro (also megaU2 or megaU4) and put LUFA on it to make it appear as HID. Then deliver "joystick movement" based on its ADC readings.

 

PS this highlights, once again, the need for upfront research and design before rushing to implementation and just "hope this will do the job".

Last Edited: Sun. Oct 20, 2019 - 09:26 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

joaopaulo wrote:
I opted to chose an FTDI  232BM not because I understood what I was picking but more like it was a common choice using an FTDI.
FTDI (Scotland) has USB HID device controllers; it's at distributors.

Prolific (Taiwan) is a new arrival to USB HID; these may already be sourced in China.

USB HID device controllers are fairly common in portfolios along with USB CDC ACM.

An alternative to these is a MCU with a USB device controller.

 

FT260

NEW! USB HID Archives | Prolific USA | IC Design & Manufacturing

https://www.youtube.com/results?search_query=PL23B3 (UART to USB HID)

Teensyduino: Using USB Keyboard with Teensy on the Arduino IDE

Teensyduino: Using Flight Sim Controls on Teensy with Arduino

GitHub - pololu/p-star-examples: A collection of example code and libraries for the P-Star 25K50 Micro, a programmable microcontroller board based on the PIC18F25K50. (4 directories, 'usb-...', USB CDC ACM)

 

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

I was interested by this so did a bit of googling and found

 

https://www.hackster.io/Sam86/fl...

 

The key thing here appears to be "simconnect SDK" so is this what you were planning to use?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

To pass the information to the computer

What are you writing software with on the computer side (C, C++, Python, BASIC, etc)?   That certainly is an important consideration.

 

 I'm working on a simple project to simulate a cockpit using an ATMega88

What do you mean by that?  Is the mega88 doing some part of the simulation? Or is it only interfacing the joystick?  If so, then why not just get a joystick that plugs into the PC?  

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

Last Edited: Sun. Oct 20, 2019 - 03:19 PM