#Karl's Cyclic Stepper Control

1 messages · Page 1 of 1 (latest)

gilded lynx
#

Curently there is no native support for long press in Mobiflight, so I think you need to use RPN and MSFS2020 to do this, as explained in the tutorial.
I am interpreting you don't use MSFS2020?

gilded lynx
#

Because there is no native support for long press, you can increase a variable value by a set increment, but only by repeating the button press. Whereas, if you read the tutorial, with RPN you would set up an output config that takes care of repeating whatever you need to do... in this case just increase a variable value (Lvar in this case). Because RPN runs in the sim, but MF variables only exist within Mobiflight, that is the reason that in this use case, you cannot use a MF variable. The sim knows nothing about MF variables, only Lvars.

gilded lynx
#

In the video, if I understand correctly, you show how by repeatedly pressing the button you can move the stepper. Is that correct? But what you want to do is to have the button auto repeat the event so that it repeats for as long as you hold the button. Correct? As I said, there is no long press support in Mobiflight, and that requires you to use RPN to do the repetitions for you in an output config. You would use instead of an MF variable, an Lvar that you can read back into Mobiflight and do the same as you were doing with the MF variable.

gilded lynx
#

You got me thinking about this problem and I think I found a way to do this with just one MF variable as control and the new blink function to generate the repetitions. No RPN, no Lvars.

gilded lynx
#

Ok, what is the range of values you are feeding to your stepper motor?

#

I have a way to increment an output for as long as you press a button

#

You first set a MF variable to 1 on press and to 0 on release of the button.

#

Do you know how to activate the blink function. This is a new function that was included in MF but it doesn't yet have access through the user interface. It has to be activated by editing the mcc file

#

yeah, I wrote that about a year and a half ago, but that is not what I mean

#

that is done with RPN and it was a good solution until MF could do the blink

#

now it has it but not yet in the user interface

#

there is no documentation yet... that is how new this is

#

I will send you the line you need to copy into your mcc file

#

have you edited an mcc file before?

#

you can open it in any code editor

#

<blink active="True" blinkValue="0" onOffSequence="100,100" />

#

keep this handy somewhere. you will copy this into the mcc file, but not yet

#

ok, you have an input config for the button you use to control the stepper?

#

is that one or two buttons?

#

ok, that's what I expected

#

one for cw and one for ccw, yes?

#

ok, I will cover one direction, then you can just follow the same pattern for the other button.

#

ok... open the cw button config

#

erase the code or event you had there}

#

the config is very simple

#

what name are you using for the MF var

#

?

#

this is the one that goes -100 to +100?

#

in this setup I only needed one MF var to control the process

#

the rest were regular output configs.

#

ok, but now the input is going to come from an output config

#

you need to output the value to the stepper anyway, so I figured this is just fine being an output

#

hmm I am thinking if we should just use a new name

#

I am trying to figure how to do the CW and CCW with just one variable

#

for example CW +1 and CCW -1

#

I don't want to destroy your current config

#

ok I understand

#

yeah that disable and add new configs

#

lets add one new input

#

CW button

#

Use type MF variable

#

and let's name it Rotate

#

Value is just 100 on press and 0 on Release

#

Oh I am thinking we might be able to do both directions in one event by just changing the sign of this variable

#

no $

#

just 100

#

on release 0

#

ok so, with this input, the button will turn the variable to 100 when pressed and back to 0 when released

#

now we go to ouputs

#

create an output for the same variable

#

Rotate

#

good

#

now another output

#

call it Repeat

#

we can use better names later

#

Open Repeat

#

In config references add a reference with Rotate

#

use placeholder #

#

Now go to the Transform field, activate it and enter just #

#

click on the Display tab

#

select Choose: Input Action

#

click On Change

#

select MF variable

#

Type Number

#

Name Stepper

#

wait, what are the values to the Stepper motor? did you say -100 to +100?

#

To understand, the stepper rotates to the position given by -100 and to +100 correct?

#

-100 and +100 are positions

#

not increments, correct?

#

that is not how steppers are configured in Mobiflight, sorry

#

the value of the output config is the position to which the stepper moves

#

so the range of movement is say 0 to 360

#

degrees

#

or whatever scale you need to make

#

it can be 2400 to 16500, it is whatever you want to make your scale.

#

see in the first picture... the scale you set there is 1000 units per revolution.

#

that sets the stepper to rotate 360 degrees in 1000 parts

#

so in that setup, the value to the stepper will vary from 0 to 1000

#

yes, so moving in increments of 100 will rotate 10% or 36 degrees with each button press

#

is that what you intend to do? just checking

#

ok

#

Value for the MF variable

#

Max(Min($+#,1000),0)

#

this will increment the stepper variable by the value of the Rotate variable

#

yes in Display tab

#

not Transform.... it is the value to set the Stepper MF variable

#

yep

#

the min and max are to limit the value from 0 to 1000

#

ok

#

now press ok

#

save the mcc file in MF

#

now go to your code editor and open this mcc file

#

good

#

look for the Repeat output config

#

ok now look for the <modifiers>

#

you should have transformation

#

and comparison

#

after comparison, add the blink line

#

save and exit notepad

#

go back to MF

#

Add one output config

#

lets call it Stepper Control

#

type MF variable

#

Name: Stepper

#

great

#

now in Display

#

configure the output for the stepper just the same

#

ok, time for a test

#

save your config

#

keep MF in the outputs page

#

heheh I told you to copy it into the mcc file

#

the "blink line"

#

you didn't understand me?

#

ok you need to reload MF for the change to be taken

#

great

#

now press Run... keep MF in the outputs page

#

as you press the button, you should see Rotate go to 100

#

and Repeat should cycle 0 and 1 repeatedly

#

increasing Stepper by 100 on each cycle

#

ok, open Repeat

#

we need to edit theTransform

#

if(#!=0,1,0)

#

See, I did my tests with Rotate = 1, not 100

#

Rotate needed fixing?

#

Rotate should just go to 100

#

and back to 0

#

yes?

#

the stepper is moving?

#

thats great

#

now the CCW you need is just to set Rotate variable to -100 and nothing else.

#

-100 on press, 0 on Release

#

🥳

#

no problem, glad I was able to help

#

Now I go to sleep

#

you too