#Transformation final value

1 messages · Page 1 of 1 (latest)

meager rampart
#

hi guys. Tell me how to make it so that when the value received from the sim increases, the Final value is -1, and when it decreases, it is 0. I can't find any information anywhere.

mental dome
#

what exactly are you trying to do and which sim and aircraft

meager rampart
#

X plane 12. 154 B-2 Felis. I'm making a controller at home, where I use a 27v motor that should extend when a parameter received from the sim changes from 0 to 1, and vice versa

#

The motor is connected via a relay. The relay should close when the parameter increases and open when it decreases

mental dome
#

ok and what value are reading from the sim?

meager rampart
#

DataRef

#

tu154b2/custom/controls/control_force_pos

#

this DataRef is responsible for the position of the flight loader. I have an original design. which uses a 27v gear motor that extends and retracts the rod

mental dome
#

ok i'm not too familiar with the aircraft does that value change often?

meager rampart
#

during takeoff/landing. Performed when the flaps are extended/retracted or by using the manual switch

tacit tree
#

What are the minimum and maximum values from the sim? If you are looking for a value of 0 to 1, the Min-Max scaling function will work. Here is an explanation.

#

What Is The Formula For Min-max Scaling? In this informative video, we will introduce you to the concept of min-max scaling and its significance in data analysis. Min-max scaling is a method used to transform data into a specific range, typically from zero to one. This technique is essential for making data easier to compare, especially when dea...

▶ Play video
exotic depot
#

OP mentioned using a relay to control the motor so I don't think scaling would work in this context.

mental dome
#

i cant think of an easy way to compare a value as it changes and know if it is increasing or decreasing

meager rampart
#

Yes, scaling is not suitable. You need to get a value of 1 when the parameter starts changing from 0 to 1, and 0 when the parameter changes from 1 to 0

meager rampart
#

I asked GPT, and it advised me to use "Variable". but I couldn't figure out how to do it.

exotic depot
#

what should happen when the variable doesn't change?

#

as you must consider all possibilities in a process that cycles at least 10 times every second.

meager rampart
#

this variable always tends to either 0 or 1.

exotic depot
#

I mean the monitored variable is a float

#

if it increases you want a value of 1

#

if it decreases, a value of -1?

meager rampart
#

Yes

exotic depot
#

if it stays in the same value, what 0?

#

out of curiousity, if this motor is only controlled by pulses with either 1 or -1, how does it know how far it should go?

meager rampart
#

it has an adjustment for the length of the movement, which opens the contact

exotic depot
#

I would try using a MF variable as temporary storage

meager rampart
#

GPT suggested this method, but I can't figure out how to do it

mental dome
#

are you running flywithlua?

meager rampart
#

I have it as a plugin, but I don't know how to program it

mental dome
#

drop this into the scripts folder. it will give you a new dataref tu154b2/custom/controls/control_force_dir which will be -1 if decreasing 1 if increasing and 0 if not moving

meager rampart
#

HUGE THANKS !! This is a brilliant solution!

#

It's working