Board index FlightGear Support Interfacing

Got Arduino connected to windows10

Connecting two computers, using generic protocol, connecting with Matlab?

Got Arduino connected to windows10

Postby bill516 » Wed Jun 26, 2019 4:16 pm

Started this thread as I didnt want to jump on the thread viewtopic.php?f=36&t=35973#p349764 by simone04.

I have managed to get the Arduino to talk to FG via win10 after much trials, testing and various examples on the net. I eventually used the example control test on the wiki but had to change some things.

Every example I have come across for windows has had --generic=serial,in,30,(port),(baud), file.xml. or some slight variation on it. After reading the thread above I started playing around and found that if I put \com9 for port9 \\.\com10 for port 10 I could connect to FG, but only if I had run this terminal program from https://sites.google.com/site/terminalbpp/. I dont know what difference this make to unpluging the arduino after viewing the serial monitor but for me FG would freeze at finalising display. Running the terminal program shoed that the arduino was sending the correct info to FG and after closing the terminal prog FG started normally and I could see the switch for strobe working on the a/c panel.

The throttle didnt work so I had a re-read on simone04 thread and read about the engine protocol. Changed the protocol to read engine/current engine/throttle</node> and lo and behold the throttle responded to the turn of my test pot.

So far I have to use the following procedure to get FG and arduino to work, on my setup it is:

after loading program to arduino and viewing serial monitor disconnect arduino and close ide.
start FG and enter into settings --generic,serial,in,30,\com9,9600,controltest (note there is no fullstop before the backslash for com), If using com port above 9 then use \\.\com(port number)
close FG
run terminal program verify data is being sent, close terminal program.
run FG.

Your --generic,serial,in might be different from mine if you use a different com port speeds and .xml file

I would love it someone would confirm this works on their computer and not just on mine. I would use linux but my FG install in linux is giving me a hard time and I want to keep this specific to windows.

Edited to add Arduino to title
Last edited by bill516 on Thu Jun 27, 2019 12:08 pm, edited 1 time in total.
bill516
 
Posts: 8
Joined: Tue Jun 25, 2019 5:20 pm

Re: Got connected to windows10

Postby Alant » Wed Jun 26, 2019 11:50 pm

Welcome to Flightgear.

Thanks for the input of your experiences.

Alan

P.S. Adding "Arduino" to the subject title might help people to see this ;)
Alant
 
Posts: 1219
Joined: Wed Jun 23, 2010 6:58 am
Location: Portugal
Callsign: Tarnish99
Version: latest Git
OS: Windows 10/11

Re: Got Arduino connected to windows10

Postby bill516 » Thu Jun 27, 2019 12:09 pm

Thanks for the welcome Alant, I've added Arduino to the tilte as per your suggestion.
bill516
 
Posts: 8
Joined: Tue Jun 25, 2019 5:20 pm

Re: Got Arduino connected to windows10

Postby wlbragg » Thu Jun 27, 2019 4:58 pm

I think part of the confusion with the serial ports is (at least in Linux) that "first plugged in, first assigned". Meaning that every time you plug or unplug a serial device it gets assigned the next available identity.. So if one time you plug in the FG device first and the next time you plug in some other serial (usb) device, your serial ID (actually I guess it would be the port ID) can change. That appears to be a major cause for confusion when programming a serial device interface. Being able to list the ID's of all currently connected devices at any given time is very helpful when working with serial devices. It makes it clear what is what and when things change.
Kansas and Ohio/Midwest scenery development.
KEQA, 3AU, KRCP Airport Layout
Intel i7/GeForce RTX 2070/Max-Q
User avatar
wlbragg
 
Posts: 7588
Joined: Sun Aug 26, 2012 12:31 am
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Linux/RTX 2070

Re: Got Arduino connected to windows10

Postby WoodSTokk » Fri Jun 28, 2019 3:39 am

If it is a real serial port, it is mostly '/dev/ttyS0' (or, if your computer have 2 serials build in, it can be '/dev/ttyS1').
If you use a USB-serial converter, you can look into the last kernel messages with:
Code: Select all
sudo dmesg | tail -n 20

This show you the last 20 lines of kernel messages triggered by events.
In my case (i have now pluged in a USB-serial converter), the last lines shows:
Code: Select all

[ 2253.987219] usb 5-2: new full-speed USB device number 5 using ohci-pci
[ 2254.187618] usb 5-2: New USB device found, idVendor=0403, idProduct=6001, bcdDevice= 4.00
[ 2254.187627] usb 5-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 2254.187631] usb 5-2: Product: usb serial converter
[ 2254.187635] usb 5-2: Manufacturer: ftdi
[ 2254.187639] usb 5-2: SerialNumber: ftE1MFQF
[ 2254.298921] usbcore: registered new interface driver usbserial_generic
[ 2254.298951] usbserial: USB Serial support registered for generic
[ 2254.308488] usbcore: registered new interface driver ftdi_sio
[ 2254.308497] usbserial: USB Serial support registered for FTDI USB Serial Device
[ 2254.308576] ftdi_sio 5-2:1.0: FTDI USB Serial Device converter detected
[ 2254.308604] usb 5-2: Detected FT232BM
[ 2254.311668] usb 5-2: FTDI USB Serial Device converter now attached to ttyUSB0

The numbers in brackets are the seconds since last boot of the system.
The last line show the assigned device node 'ttyUSB0'. So this serial port can be used as '/dev/ttyUSB0'.
WoodSTokk
 
Posts: 1077
Joined: Tue Oct 17, 2017 3:30 pm
Location: Milky Way/Sol/Earth/Europe
Callsign: SX-W57
IRC name: WoodSTokk
Version: 2020.4.0
OS: Debian Bullseye

Re: Got Arduino connected to windows10

Postby Volador » Sun Sep 27, 2020 1:51 pm

bill516 wrote in Wed Jun 26, 2019 4:16 pm:Started this thread as I didnt want to jump on the thread viewtopic.php?f=36&t=35973#p349764 by simone04.

I have managed to get the Arduino to talk to FG via win10 after much trials, testing and various examples on the net. I eventually used the example control test on the wiki but had to change some things.
but only if I had run this terminal program from https://sites.google.com/site/terminalbpp/. I dont know what difference this make to unpluging the arduino after viewing the serial monitor but for me FG would freeze at finalising display. Running the terminal program shoed that the arduino was sending the correct info to FG and after closing the terminal prog FG started normally and I could see the switch for strobe working on the a/c panel.

after loading program to arduino and viewing serial monitor disconnect arduino and close ide.
start FG and enter into settings --generic,serial,in,30,\com9,9600,controltest (note there is no fullstop before the backslash for com), If using com port above 9 then use \\.\com(port number)
close FG
run terminal program verify data is being sent, close terminal program.
run FG.

Edited to add Arduino to title


Bill516 Thank you! thank you! thank you!! I have finally managed to connect arduino to FG without FG freezing (windows 7) on finalize position using your method with the terminal app. I can now see ailerons moving according to analogue inputs. This is a break-through as I'm just starting to develop an Arduino project that will interface with FG.
User avatar
Volador
 
Posts: 1140
Joined: Tue Sep 01, 2020 4:58 pm
Callsign: Volador, G-VLDR
Version: 2020.4
OS: Windows 10, 64 bit


Return to Interfacing

Who is online

Users browsing this forum: No registered users and 3 guests