#APU control with only one analog input (737)

1 messages · Page 1 of 1 (latest)

acoustic oar
#

HI,
to save on the number of pins used I find myself inventing solutions to exploit the analog inputs to the maximum;
in this case I try to implement the apu control using a switch and a button as I have not found a low cost on-off-push device.
using the attached diagram you have a similar function where apu start works only when the switch is on apu on (open).
I also attach the values detected on the analog input on the mobiflight debug where you can see that transient readings of the input value occur with each maneuver.
finally, the stable values are:
apu off = 14
apu on = 408
apu start = 661

in the end I think my problem is always the correct syntax to use in the preset code:

@ near sp0
l0 25 < if{
50 (L:switch_118_73X) - 10 div == if{ 11802 (>K:ROTOR_BRAKE) }
quit}
(l0 430 <) && (l0 380 >) if{
(L:switch_118_73X) 10 div == if{ 11801 (>K:ROTOR_BRAKE) }
quit}
l0 620 > if{
50 (L:sswitch_118_73X) - 10 div == if{ 11801 (>K:ROTOR_BRAKE) } els{ 11801 (>K:ROTOR_BRAKE)
11801 (>K:ROTOR_BRAKE) }
}

Thanks for your help

haughty hawk
#

There are no parenthesis to control the order of execution in RPN

#

The stack is used instead.

#

If there are two switches, there are four states, not three. What is the value of this fourth state?

acoustic oar
haughty hawk
#

Why only three voltages? Is it not possible to press the button at any time, regardless of the state of the toggle?

#

So 4 states :

  1. Toggle off - button off
  2. Toggle on - button off
  3. Toggle off - button on
  4. Toggle on - button on
#

This is not a theoretical question, as depending on the event code, if this fourth state is not foreseen, then the code could activate a different state not intended.

#

I would much prefer to have the fourth state as a do-nothing option rather than floating and counting on the pilot to know that that option should not be used.

acoustic oar
#

the code should move the apu switch processing the 3 voltage levels,
Unfortunately I can't write this code because I don't understand RPN well yet

#

the 3 voltage levels are read from the analog input and the numerical result in the mobifligh debug is this:
apu off @=14
apu on @=408
apu start @=661

haughty hawk
#

To understand, the toggle on - button on or off states do not provide different voltages.

acoustic oar
#

if I have not misunderstood the concept on press, on release is reserved for digital inputs, but I am using an analogue input and, in this case I have 3 voltage levels;
e.g. in the case of the analog input for the flap lever the voltage levels are 9,
for the efis selector (app, vor, map, pln) there are 4
and they all work properly;
however for APU I can't find the solution

#

probably because I didn't quite understand the function of:
11801 (>K:ROTOR_BRAKE) and
11802 (>K:ROTOR_BRAKE)

haughty hawk
#

the last two numbers are the code for the corresponding mouse action

#

most likely push up and push down.

#

there is no On Press or On Release action in analog input. Just absolute positions.

#

there are several errors in your RPN code.
I suggest the following code adaptation:

@ sp0
l0 100 < if{ 11802 (>K:ROTOR_BRAKE) quit }
l0 500 < if{
   50 (L:switch_118_73X) != if{ 11801 (>K:ROTOR_BRAKE) } quit } 
11801 (>K:ROTOR_BRAKE)
#

I simplified the code because there are only three positions, meaning there is only one position difference possible. The upper position can only move from middle up one and the lower can only move from middle down one and the switch returns from Start to On automatically.
I also deleted the near function at the beginning because @ is always an integer number between 0 and 1023, therefore there are no decimals to round.

haughty hawk
#

you may also want to increase the value of the sensitivity in the analog input (less sensitive) so that the firmware will ignore smaller changes in voltage readings.

acoustic oar
#

HI,
I did some tests but it still doesn't work, I attach the screenshots,
if I enter the default value e.g APU ON, it works,
at each change event the apu switch goes to the ON position, and the same goes for the APU OFF value.
if I enter your code it never moves.
I had already set the sensitivity to minimum.
if in the end I don't solve it I think I will modify the circuit and opt for the use of 2 digital inputs.

haughty hawk
#

I don't have a resistor network like yours so I tested the code with a potentiometer and it works OK for me.

#

Ohh try again with the revised code. I modified the code afterwards but your test in the second image shows a previous version than the latest.

#

The code you show on the first picture has an error.

#

== requires two parameters from the stack, but there is only one number in the stack.

#

If that is a preset it needs to be corrected.

#

An alternate solution to more arduinos, is shift registers or multiplexers.

haughty hawk
#

I have corrected those presets in Hubhop.

acoustic oar
#

Very well,
this latest version works perfectly,
Many thanks for your help and effort,
I will calmly try to understand the code well to learn