Arduino quick start guide

Support for Arduino in combination with Air Manager and Air Player

Moderators: Ralph, russ

Message
Author
User avatar
Ralph
Posts: 6625
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Arduino quick start guide

#1 Post by Ralph »

First configure your Arduino



Create a hardware instrument


flyatr
Posts: 300
Joined: Tue Dec 01, 2015 8:53 am

Re: Arduino quick start guide

#2 Post by flyatr »

Great tutorial. It's really easy to get started with Arduino.

Here's my FSX example code for an "Autopilot OFF" LED:

Code: Select all

-- Arduino example "Autopliot off"
-- LED will be on for three seconds after autopilot disconnect.
---------------------------------------------------------------

memory_ap = false					-- helper variable
led_autopilot=hw_led_add("ARDUINO_MEGA2560_A_D13",0)	-- Arduino hardware

function autopilotLight(apMaster)
	if not apMaster and memory_ap then	-- autopilot from on to off
		hw_led_set(led_autopilot,0.5)	-- turn on light
		memory_ap = false				-- clear memory
		apoff_timer = timer_start(3000,nil,timer_callback)	-- start timer
	elseif apMaster then				-- when turning autopilot back on
		hw_led_set(led_autopilot,0)		-- turn off light
		memory_ap = true				-- memorize
		timer_stop(apoff_timer)
	end
end

function timer_callback()
    hw_led_set(led_autopilot,0)		-- turn off light after 3 seconds
end

fsx_variable_subscribe("AUTOPILOT MASTER","bool",autopilotLight)
WP_20180325_18_05_18_Pro.jpg
WP_20180325_18_05_18_Pro.jpg (53.46 KiB) Viewed 10624 times
I like that we can control the brightness via software! Now to some encoders...

User avatar
MarkH
Posts: 78
Joined: Sat Dec 05, 2015 8:58 am

Re: Arduino quick start guide

#3 Post by MarkH »

A couple of suggestions for the Arduino installation instructions.

First, you need to ensure Windows installs a driver for the Arduino. This is evidently a serial port emulation and it seems to install a virtual COM3 port. For me it appears in Device Manager as 'USB-SERIAL CH340 (COM3)'. This makes sense of the Arduino installer, which asks for a COM port. (The 'getting started' video also tells you to 'verify the COM port', which made no sense until I realised this). I had to force Windows to install a driver for the Arduino by choosing the 'search Windows Update' option when it failed. I note in passing that Windows also detected the Arduino (a Nano) as a 'coprocessor' and couldn't find a device driver for it. This doesn't seem to cause any extra problems. (This is on Windows 7 64 Home Premium, BTW.)

Then for me, the Arduino installer failed with an unhandled exception and a load of complicated error messages. However, I tried it on my main simulator PC (I have AM on a separate PC), which is running Windows 7 Pro 64 and it all worked fine (including the device driver). I noticed that the sim PC had Microsoft .NET Framework 4.7.2 installed, so I went and installed that on the AM PC. Then the Arduino installer then worked and everything checks out in AM.

Maybe that will help some others who are struggling.
MarkH

Image

flyatr
Posts: 300
Joined: Tue Dec 01, 2015 8:53 am

Re: Arduino quick start guide

#4 Post by flyatr »

There is also no warning if Air Manager is running and you execute the Arduino installer. The COM port is busy then and it will not work.

SimPassion
Posts: 3668
Joined: Thu Jul 27, 2017 12:22 am

Re: Arduino quick start guide

#5 Post by SimPassion »

flyatr wrote: Mon Aug 20, 2018 10:09 am There is also no warning if Air Manager is running and you execute the Arduino installer. The COM port is busy then and it will not work.
I've experienced this many times,
we get at least this kind of messages in the Arduino IDE console like bottom field :

Code: Select all

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "E:\Users\simu\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino9/etc/avrdude.conf"

         Using Port                    : COM7
         Using Programmer              : wiring
         Overriding Baud Rate          : 115200
avrdude: ser_open(): can't open device "\\.\COM7": Access is denied.


avrdude: ser_drain(): read error: The handle is invalid.


avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: The handle is invalid.


avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: The handle is invalid.


avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: The handle is invalid.


avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: The handle is invalid.


avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: The handle is invalid.


avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: ser_send(): write error: sorry no info avail
avrdude: stk500_send(): failed to send command to serial port
avrdude: ser_recv(): read error: The handle is invalid.


avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer

avrdude done.  Thank you.

the selected serial port 
 does not exist or your board is not connected

and also as already mentioned by Mark, the installation could be complex
the Corjan intervention had been a precious help to achieve on this

Regards
Gilles

erj145sim
Posts: 24
Joined: Mon Feb 10, 2020 1:03 pm

Re: Arduino quick start guide

#6 Post by erj145sim »

Hello everyone,

new to a lot of things here, including Raspberry Pi and Arduino, and so I am struggling trying to figure out what I'm doing wrong.
I have a Raspberry Pi 3b+ that is running AirPlayer. Connectivity to AirManager on my Mac running High Sierra works flawlessly.
I also have an Arduino Mega 2560 that I flashed using the SI installer on one of my Windows machines. When I connect it directly to the Mac, it is recognized without a problem.
My challenge is that when I connect the Arduino to the Raspberry Pi, THEN the Arduino is not being recognized (not showing up in the devices tab) in Air Manager. I can see in Terminal that AirPlayer is recognizing the Arduino:

10-02-2020 22:30:29 INFO HardwareArduino: Mapped channel A to port /dev/ttyACM0

I have searched the forum and the web but haven't been able to find out what might be wrong. Anyone has any clues? Any guidance or advice would be appreciated.
Thanks in advance!

Marco

User avatar
Sling
Posts: 4860
Joined: Mon Sep 11, 2017 2:37 pm
Contact:

Re: Arduino quick start guide

#7 Post by Sling »

The Arduino will not show in the Devices tab when not connected to the machine running AM so what you have is perfectly normal. Have you tried to connect any hardware yet. From the sounds of it, it should work fine.

A point worth noting is the Lua script running the hardware functions must be on the same machine that the hardware is connected to. So in your case upload the instrument that has the hardware functions in it to the Rpi and connect your hardware either directly to the Rpi or via an Arduino that is connected to the Rpi.

I hope that helps. Let us know how you go.

Tony

erj145sim
Posts: 24
Joined: Mon Feb 10, 2020 1:03 pm

Re: Arduino quick start guide

#8 Post by erj145sim »

Thanks Tony! I have not yet connected any hardware, as I was stuck trying to "see" the arduino first...
I will try it soon and let you know my progress.

Marco

vernonw123
Posts: 15
Joined: Mon Apr 23, 2018 11:28 am

Re: Arduino quick start guide

#9 Post by vernonw123 »

Hi Guys,

I am having trouble getting my Arduino Mega 2560 and Nano recognised in Air Manager, the odd thing is when running version 3.6 it worked as they appeared under "Actions" in the device tab, and I was on my way to developming by first HW instrument, but I can't seem to get AM to recognise them again followin the upgrade as they are no longer showing up in the Device tab. Here is what I know

1) Both the Mega and Nano flash fine with flash process in AM 3.7 with the "avrdude.exe done. Thank you" message at the end of the session
2) Both are are showing in Device Manager under Ports (COM and LPT) as Ardrino Mega 2560 (COM3) and USB-SERIAL CH340 (COM5) com ports aligned with what was flashed no other errors showing in AM
3) I read another post about Microsoft .NET frramework instalation, I downloaded the installer but I got a message saying there was a later version installed on my system.
4) I ran the simple simple LED flash programme from Arduino sketch and that worked fine on the Mega (then re-flashed the Mega through AM)

I am sure its not related to the 3.7 AM update and I am doing something silly, I have just spent an afternoon trying to get it to work. All other AM functiins are fine, I have written a load of custom guages (specific to Carenado Products) that I will get round to uplooding to the community soon.

My system in Windows 10 64 Pro.

Any help appreciated!

User avatar
Ralph
Posts: 6625
Joined: Tue Oct 27, 2015 7:02 pm
Location: De Steeg
Contact:

Re: Arduino quick start guide

#10 Post by Ralph »

Be sure that there isn't any other software claiming the Arduino's. Simvim, Mobiflight, Arduino Studio, etc...

Post Reply