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! 

05/03/2024 - This forum is read-only

The community support for MobiFlight has moved exclusively over to our Discord server. Register for free and enjoy more interactive functions like image and video upload, voice chat. More than 7,000 registered users around the world make it a great experience!

See you on our MobiFlight Community Discord server.

A HUGE Thank You to everyone who participated in the forum, especially obviously to Pizman and Stephan who did an outstanding job over so many years providing an incredible service to the MobiFlight community.

The forum is still providing a lot of good content, hence we keep this information accessible.

icon
Avatar
calx
Posts: 3
Supporter
Hi - for my project I have an encoder that selects different modes.

I've got a small vibrating motor that I want to trigger momentarily as each mode is selected.

Is there a way to trigger an Output for a number of seconds? E.g. when MenuVar = 1, enable my Output (motor) for 1 second?
2022-03-28 12:37
Avatar
kjoussen
From: Hamburg, Germany
Posts: 178
In short: no, as MF does not have a timer functionality
But also iin short: yes, you can play around with the time of the sim and derive 1 or 2 seconds from it.

Maybe this post (https://www.mobiflight.com/forum/topic/6898.html) can help, as it describes the way of playing around with second intervals
2022-03-28 14:22
Avatar
pizman82
Moderator
From: ETSI, Germany
Posts: 6010
Supporter
Yeah. Nice Link ! :love:

The Blink mode is planed within a easy GUI usage in the next release.

But a Real "timer" is currently not planned.... Simply cause its "normaly" not needed.
For example if you like a LED to light 4 Seconds after you press a button..... Here the basic MF idea is... We read the SIM LED, that also have the same behavour.
So we not need to make those timers in case the timer is still in the sim!

BUT for sure.... All is possible ( or better not all, but most of the things) if you know how to handle them.

For Blinking ( until the feature is released) we use the Sim Time Data for a calculation.
Like in the link.... You can use the "SIM-Current Time in Seconds" and a mathematical Modulo2 %2 to define a Value of 0/1 with a 1 second sequence.

Also Timers are Possible.
We say.... IF Aktion occure ( e.g. you press a Button) then COPY the current Time of Sim to a MF Variable ( Like a Memory Slot)
And for the LED we then say "Compare Current Sim Time with the Saved Time Stamp on that Variable"

For example you like a LED Light for 3 Seconds....
On Press of Button we save the current Time ( lets say 10345 ) to our Variable.
In LED we say "Current time MINUS Saved Time" and IF Difference is less then 4 , Then ON else OFF.
So lets say 2 seconds later .... 10347-10345=2 .... 2 is less then 4 so its still on.
Lets say 4 seconds fter Button Press ..... 10349-10345=4 .... 4 is no longer less then 4 ... So LED is now OFF again.

You see.... this system is not very comfortable. But its possible !
Good Luck !
2022-03-28 14:47
Avatar
calx
Posts: 3
Supporter
Thank you! That should sort it out
2022-03-28 23:39
Avatar
calx
Posts: 3
Supporter
Thanks to pizman82 for this example, I've been able to achieve what I wanted! :thumbup:

For anyone with a similar need, here are some screenshots of my configuration:

First I added an Output SimConnect variable called SimTime, (E:SIMULATION TIME, second)



Then I added another Output MF Variable called TimeHold



Then to capture this time for comparison - I added an input Menu Select Timer, this copies the same encoder input that I'm using for my Menu Select Input.



I've added a Config Reference to SimTime so I can use it's value



Now everytime I turn the Menu Select encoder, I copy the current SimTime value to the TimeHold output variable



Then I added Outputs called Vibrate 0, 1, 2 for my 3 menus - ignoring the first TimeHold variable setting (it's not required here).

All we need here is the Transform formula and the two references, TimeHold and SimTime

if(#-!<4,1,0) (If the SimTime - TimeHold < 4 seconds then On else Off)
Or instead of 1 for On, a PWM value 0 - 255



Each Output has a Precondtion so it only triggers on the correct Menu e.g. Menu 1



Then I select my vibrating motor in the Display tab - selecting PWM so I can use different intensities



Here you can see Menu 0 is selected and we are sending a PWM value of 100 to the Motor

[Last edited by calx, 2022-03-29 13:47]
2022-03-29 10:30
icon