Hi!
I'm using RPi3 to display panels for my XP11 but would like to do simple thing: connect potentiometer to GPIO and send dataref to my simulator. Any step by step instructions available?
Regards
art
RPi GPIO use
Re: RPi GPIO use
Hi,
The raspberry Pi has no analog (ADC) pins, you need that to read potentiometers.
What you could do is buy an Arduino and connect that to your Raspberry Pi or computer running Air Manager or Air Player.
We support the Arduino Nano, Uno and MEGA 2560. All three have ADC pins, see list below:
https://siminnovations.com/wiki/index.p ... re_id_list
You could do something like that by creating an instrument with the following code:
Hope this makes sense,
Corjan
The raspberry Pi has no analog (ADC) pins, you need that to read potentiometers.
What you could do is buy an Arduino and connect that to your Raspberry Pi or computer running Air Manager or Air Player.
We support the Arduino Nano, Uno and MEGA 2560. All three have ADC pins, see list below:
https://siminnovations.com/wiki/index.p ... re_id_list
You could do something like that by creating an instrument with the following code:
Code: Select all
-- Callback function which is called when the ADC input value changes
function adc_input_change(value)
-- value ranges from 0.0 (rotated far left) to 1.0 (rotated far right)
-- transform the ADC value into something sensible for X-plane
some_value = value * 100
-- Write the dataref in X-plane
xpl_dataref_write("<XPLANE_DATAREF>", "<TYPE>", some_value)
end
-- Read pin A0 (first analog pin) on the Arduino Uno
id = hw_adc_input_add("ARDUINO_UNO_A_A0", adc_input_change)
Hope this makes sense,
Corjan
Re: RPi GPIO use
Cool, just 3 more questions:
1. I see... so how to physically connect Arduino 2560 with the Raspberry Pi 3 (I assume I don't need to buy any additional license if I connect 2560 to RPi3?)?
2. Does is slow down the panel framerate if I use Rpi also to send/recieve the datarefs?
3. Where to put the code?
regards
art
1. I see... so how to physically connect Arduino 2560 with the Raspberry Pi 3 (I assume I don't need to buy any additional license if I connect 2560 to RPi3?)?
2. Does is slow down the panel framerate if I use Rpi also to send/recieve the datarefs?
3. Where to put the code?
regards
art
Re: RPi GPIO use
First configure the Arduino on the desktop, with our Arduino tool on our wiki (there's also a YouTube video). Then connect it to the Pi through USB, just as on the desktop. It won't slow down the Pi, or at least not very much. You send the code to the Pi as an invisible instrument, or add the hardware code to an existing instrument.
Re: RPi GPIO use
How to make an invisible instrument, or add the hardware code to an existing instrument?
a.
a.
Re: RPi GPIO use
Hi,
Air Manager has a feature where you can create your own instruments, or edit instruments others have made.
Each instrument has a piece of logic code (written in lua) that describes how the instrument should behave. Here is described where images should be, text elements, what data needs to be fetched from the flight simulator etc. etc.
This logic code can also contain code to interact with hardware.
See a complete list of stuff you can add to an instrument here:
https://siminnovations.com/wiki/index.p ... _Logic_API
Corjan
Air Manager has a feature where you can create your own instruments, or edit instruments others have made.
Each instrument has a piece of logic code (written in lua) that describes how the instrument should behave. Here is described where images should be, text elements, what data needs to be fetched from the flight simulator etc. etc.
This logic code can also contain code to interact with hardware.
See a complete list of stuff you can add to an instrument here:
https://siminnovations.com/wiki/index.p ... _Logic_API
Corjan
Re: RPi GPIO use
And if you don't add any graphical elements to an instrument, you have an 'invisible' instrument.