MobiFlight Community Support

Welcome to the forum for MobiFlight! Feel free to reach out to the community in case you have questions, issues or just want to share great ideas or details about your latest home cockpit project.

You like MobiFlight? Donate via PayPal and support the MobiFlight development. Thanks! 

icon
Avatar
crazypilot_uk
Posts: 30
Hi,
I'm looking to use a standard Arduino 8 channel relay board (schematic link below) however all these boards require to operate a low output (a negative signal on the Arduino output pins), would it be possiable to incorparate this feature in the next release of software ? :) or can thisbe achieved already in the software ? I'm sure many cockpit builders would like the use of relays.

relay board schematic link:

http://arduino-info.wikispaces.com/file/view/OptoRelayChannelDataE2.jpg/610811633/800x329/OptoRelayChannelDataE2.jpg

Brgds.
2017-05-30 16:08
Avatar
StephanHo
From: EDDG, Germany
Posts: 1201
Supporter
Hi crazypilot_uk,

you can operate your relay board as you want. Mind the following:

1. Do not use a seperate power-supply! Every relay can be driven by the arduino directly. How the schematic shows is there already a protection diode (D1) built in. A galvanic isolation of the components is not necessary.
2. Leave the jumper so that the relay(s) can be powered directly from the arduino. The arduino is strong enough to drive 8 relays or more.
3. Connect the pins you should connect to the arduino direct to GND
4. Connect the "to Arduino +V5"-lines to the corresponding arduino pin(s). If the output is low your relais is in hibernation, if the arduino set this output to high your relay will switch
5. Change the resistance (R1=1000 Ohms) to another resistance with a value of 330 Ohms (or a value that the LED is bright enough). With a current of 2mA the LED should not light bright enough unless you have low-current-LEDs. Try 10mA.

So you need no other software you only have to change your hardware ;)
Try it and please report us your result.
Grüße,
Stephan
2017-05-30 19:47
Avatar
crazypilot_uk
Posts: 30
Hi Stephan,
I finally got round to trying the relay board :) and everything works fine, no software or hardware change required. I used the compare tap to change the fsuipc value to the opposite value ! and it worked a treat !!

Thank you for your help.
2017-06-08 17:58
Avatar
StephanHo
From: EDDG, Germany
Posts: 1201
Supporter
Great crazypilot_uk!

Sometime it needs only a little trigger to power up the dawn cells. Excellent that you find another way to solve your problem.
Nevertheless don't hesitate to ask here if you got problems.

What's about the LED. Does it shine bright enough?
Grüße,
Stephan
2017-06-08 18:51
Avatar
maggsy
Posts: 7
Supporter
I have noted that the advice is that you do not need an external power supply to power the relays, is the Arduino board capable of powering all 8 simultaneously ? I had thought that 4 would be the maximum without burning out the board? I am looking at a minimum of 5 banks of 8 relays.

I wish to power an OVH panel which for cost reasons I have used 12v illuminated latched switches (36 of them ) they currently do not illuminate when activated and I understand I can use banks of relays supplying each led in the switch with the 12v current which is on a separate circuit to the on/off circuit, and these relays can be controlled by an Arduino board which will activate the switch in the sim and simultaneously close the relay to illuminate the light.
any advice would be appreciated
Maggsy
2017-08-04 15:14
Avatar
StephanHo
From: EDDG, Germany
Posts: 1201
Supporter
Hi Maggsy,

first of all: the control of the relais works via opto-coupler. these opto-coupler need to operate only a current of 1-2mA each, so it is possible to drive the 8 relais (even more) simultaneously without an overload of the MEGA

but

one relais needs to operate a current of 15 up to 70 mA each. That is to much for the MEGA when operating with 8 or more relais at the same time. So I have to revise my statement above.
The result is that you need a seperate 5V and an independent 12V power supply. thereby you have to note the following:

- remove the jumper on the relais-pcb as shown on the schematic
- connect the seperate 5V-power-supply as shown in the schematic
- a connection of MEGA-GND and extra-5V-power-supply-GND is not necessary because the opto-couplers are a galvanic separation
- on the output-side of the relais-switches you have another galvanic separation to the circuit you want to switch. here you can operate with your 12V voltage
- if your LED's are 12v-driven you have to control them within the 12V-circuit. If the LED's in the switches are independent from the 12V circuit you can drive them with an Arduino. - think about a resistance (depending of the voltage) for every LED in your latched switches as far as they ar needed.
- if you want to drive 36 relais you also should think about a 2nd extra 5V power-supply because in worst case you need 36 x 75mA = 2,52A !!

You should try your wiring with a breadboard with the three power-levels (5V-MEGA - 5V-relais - 12V-switches) before realizing the final structure.
Grüße,
Stephan
2017-08-04 23:35
Avatar
maggsy
Posts: 7
Supporter
Thanks so much for clearing up my confusion. and for the excellent advice I will certainly take good heed of it as I begin the re-wiring and activation of my OVH panel
as the OVH panel has so many switches and lights I had already planned on dedicated power supplies, especially as you pointed out the 12v led's are separate from the actual on/off circuit in the switch ( which is part of the problem I needed to solve, activate the switch sends the signal to the sim via my board but use the board to recognise when that signal is sent the light needs to be on or off depending of the function on the panel and in the sim)
I have already built my 12v/5v/3.5v supply from an old PC power supply (which works well illuminating the switches but this is just a cosmetic Xmas tree look and I would like them to function as intended), as I have used a PC power unit it has very clean stable outputs of both 12v, 5v and 3.5v so can easily use further connections from the 5v outputs to provide power for the relays.
Regards and many thanks again
Steve
2017-08-05 11:36
Avatar
maggsy
Posts: 7
Supporter
I have the relays and i can run the test on it and the led in the switch works via the relay (pin 2), what I cannot grasp is how to have the switch ( for ease of use I am using pin 53) activate the relay (cycle pin 2 to high and low)

I have the relay set as output/display/ pin/ pin output
the switch is set as input/device/button but do not know what to select next in action type ?

where have I gone wrong
Maggsy
2017-08-07 21:09
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 2330
Supporter
Hi maggsy
I just overfly this topic but i think you missunderstood the basic here.....

You need to use a relais only cause your Switch LED are work with 12v but the Arduino only support 5v Outputs.
BUT: The LED in your switch and the switch itself normaly get NO conection. See it like 2 complete different things !!
( If you use correct Switches... for Flight Sim we NOT want switches where the LED is connected to the Switch curcit !!! .... So i hope you NOT use switches with a common wireing.... Please get shure your switch got 4 Pins 2 For Switch and 2 for LED !

So if i understand you rigth you have the correct switches but now you want again that the LED should get ON always when the Switch is in ON Position !
Thats absolutly wrong in a Cockpit ! The LED in the Switch should NOT show the status of the switch.... it SHOULD show us the Status of the function in the Simulator.
Normaly there are no switches in a Cockpit where you need a logic like this !

***
Finaly.... It is NOT posible with Mobiflight to set the LED direct to the current switch Position.... You have to Readout a value for the LED you like to show.....
BUT shure... you can use the SAME Value that you controll by the Switch readout again for the LED.

I Hope i understand you correct. If not please explane me again and sorry for my confusing !

cu.
Good Luck !
2017-08-08 01:22
Avatar
maggsy
Posts: 7
Supporter
I do apologize I have not explained myself very clearly or what I wish/expect
for simplicity i will use a single sim operation (aerosoft A320 OVH Panel Fuel LH TK Pump 1)
I currently use a Latched Illuminated Switch to turn on or off the Fuel pump ( this is already possible as I do have the offset and I currently use LINDA and fsuipc to operate the switch and interface with the sim)
As the LED circuit and the Switch circuit are NOT connected and could be considered as two separate items just housed in the same plastic shell, the led does not require and change in status of the switch to operate it can be illuminated via a 12v power supply.

I would like to use Mobiflight to interface the arduino and the sim allowing me to assign a button to the sim OVH panel and operate the LH Fuel TK Pump1.
This I can do by setting up an output Button (pin 53) to the fsuipc function for OVH Panel LH Fuel Pump1. so far so good.

Illuminating the led, using the Mobiflight to control the relay feeding the 12v supply using output pin2, this works fine

Is it possible to use Mobiflight to send a signal to OUTPUT pin 2 changing it from HI to LO and back depending on
(A) the status of input (HI/LO) PIN 53
(B) the status of the sim function OVH Panel Fuel LH TK Pump1

obviously not correct code syntax but something like this

basically

Set pin 53 HI function Fuel Pump1 on
or
Set pin 53 LO function Pump1 off

if pin 53 HI
then set pin 2 HI
if PIN2 HI then relay open // led illuminate on

if pin 53 LO
then set pin 2 LO
if pin 2 LO then relay closed //led illuminate off

or

Read FSuipc function?
if fsuipc function LH TK Pump1 on
then set pin 2 HI
if PIN2 HI then relay open // led illuminate on
if fsuipc function LH TK Pump1 off
then set pin 2 lol
if pin 2 LO then relay closed //led illuminate off

A further question could a Precondition be used ?

I hope this explains what I wish to achieve
I do not see why not because if a landing gear lever (Physical Switch )can be operated to "raise the gear" while the same action from a (physical switch) will also illuminate leds that indicate Gear locked down or in transition.
So swap the gear operation up or down for a Pump on or off and the LED on or off for a relay pin hi or low ?

Regards and many thanks for your help
Steve
2017-08-08 14:39
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 2330
Supporter
Ok. Now i understand better.... thanks for detailed expaning again.

First your switches are ok.. Good news ! :thumbup:

With youre example i can explane you the problem perfectly too....

You controll the Fuel Pump with the Switch ! Thats fine.
But now think about WHAT should the LED show us now....

If you use Part 1 of your Syntax Example ( That is not posible with mobiflight in direct way) then your LED simply show you the switch Position. BUT we not need this cause you already can see your switch in your Cockpit if its Up or Down..... you not need a additional LED for that.
If You use Part 2 the question is WHAT Information do you Read out..... If you read out the Position of the VIRTUAL Switch then you get the same Problem like before.
Now the LED light up if the Virtual Switch is ON.... But that tell us not if the Fuel Pump is running !
What we realy like to show with the LED is the STATUS of the Fuel Pump !

Simply eample.... You are on Gate and Cold&Dark..... And Now you switch the Fuel Pump to ON....
In your first Syntax the LED would light up.... In Second Example if you just read the Switch position in Sim it will Light Up again . BUT Fuel Pump is already off cause there is no electrical Power in the Aircraft.....
Same happends if your Fuelpump get a technical issue or the used Tank is out of Fuel.
Finaly what we need is the Information from the Simulator if Fuel Punp is running ! And thats the Output Offset of the LED in the Simulator ( Not of the virtual switch or the status of the Real switch)


The same thing is the Landing Gear example.....
Here the Lights NOT work with the information of the Real Switch or the Virtual switch.... For the 3 green and 3 Red Lights we use a Offset that show us the current Position of the Gear Itself.... NOT of a switch !
Same Situation... If a Gear have a issue and not come out the Light will be RED ( Whatever position your switch is) cause it shows the REAL Gear Status !

******
Finaly...
-Your System 1 is not Posible ( Only with a little trick by a custom Offset .... Again this is not verry usefull....
BUT If you realy like this i can explane you how to set it.
-Your System 2 is working and the correct way. BUT Get shure you use the right offset that Show us the STATUS of the function !

Hope thats help !
Good Luck !
2017-08-08 16:57
Avatar
maggsy
Posts: 7
Supporter
That is a superb explanation of the situation cause and effect.. you perfectly summed up all the variables, it has gone a long way to help me understand thank you.

I think I will have to accept that for my OVH panel to replicate the full functionality of an A320 OVH it will require a far more complex and expensive approach.

I think I will have to design the OVH panel so the switches just offer a hardware input for a simulated action ( I throw/press a switch and the sim uses that signal to change a parameter in the sim,) The OVH panel in its current design stage does not need to be the indicator of faults, issues or the status. (maybe in the future if I can write my own coding and pull and send all the required data to and from the sim without impacting sim performance.

Fot the time being I will settle for the LH TK Pump1 switch on my OVH to operate the switch in the sim and the LED only reports the status on my switch and not the status of the pump.

I have found the code to do that. I will probably add Debounce to the input.

///BUTTON///
int Button = 0;
int Bs1 = 0;

////RELAYS////
int Relay1 = 2;

///DELAY///
//int D = 250;//

void setup(){
Serial.begin(9600);
pinMode(Relay1,OUTPUT);
pinMode(8,INPUT);
digitalWrite(Relay1, HIGH);
}

void loop(){
Button=digitalRead(8);//change A0 to digital pin used for Button///
if(Button==HIGH&&Bs1==1){digitalWrite(Relay1,HIGH);Bs1=2;}//OFF
if(Button==HIGH&&Bs1==0){digitalWrite(Relay1,LOW);Bs1=1;}//ON
//Serial.println(Bs1);
if(Bs1==2){Bs1=0;}
}
2017-08-09 02:00
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 2330
Supporter
Hhhm.... And how do you set this code to the Arduino ?? When Mobiflight firmware is on the Board your own code is deleted.... ( And i think you like Mobiflight here to set the Button to a funtion via Mobiflight.

But please try out your way.... If it not work we can talk about the use of custom Offsets that do what you want !

****
By the Way.... The Aerosoft Airbus is a little problematic to redout the data. Maby you have a look to Jeehell FMGS. This is a freeware A320 Cockpit AddOn. And it supports most of the needed Data simply via FSUIPC. ( Or SIOC for some special things) .

Please do your project like you want.... But let me say... In some time it will be not enough for you when you got a real Overhead but all LED are with Dummy functions or not in use.
THEN you will startup again and build it real with the output offsets.
Just think about it ! Have Fun !
Good Luck !
2017-08-09 20:08
Avatar
maggsy
Posts: 7
Supporter
That arduino sketch is the easy solution and I posted it as the follow up to my simplistic code example, that I thought could provide the easiest route.

I presume from your comments there possibly a better way forward.:w00t: :thumbup:

I use the CFD feature in the aerosoft airbus quite a lot


I have been unable to find the offset for the lua listed below, the only thing i found in the log was 7321 and 735F but I do not know how to use either the Lvars or the fsuipc EventID
I have been going through the documents and forums searching for guidance on how to do this.

function FuelPump_L_1_on ()
ipc.writeLvar("L:AB_OVH_FUELPL1", 1)
SmallOverheadPushButtons ()
DspShow ("PmpL", "1 on")
end

function FuelPump_L_1_off ()
ipc.writeLvar("L:AB_OVH_FUELPL1", 0)
SmallOverheadPushButtons ()
DspShow ("PmpL", "1off")
end

function FuelPump_L_1_toggle ()
if _tl("AB_OVH_FUELPL1", 0) then
FuelPump_L_1_on ()
else
FuelPump_L_1_off ()
end
end
2017-08-09 23:32
Avatar
CaleKee
Posts: 1
Hi...in my case I have used 12v illuminated latched switches they currently do not illuminate when activated and I understand I can use banks of relays supplying each led in the switch with the 12v current which is on a separate circuit to the on/off circuit, and these relays can be controlled by an Arduino board which will activate the switch in the sim.

calculate percentages
[Last edited by CaleKee, 2018-06-25 17:18]
2018-05-14 19:23
icon