Throttle Quadrant – improved flaps sensor

In the original throttle quadrant that my design is based on a microswitch is used to detect changes in the flaps and speedbrake handle positions. The switch slides along a ‘waveform’ in an MDF panel: the wave tops close the switch, inbetween the tops it opens.

In this way only a single switch is needed to detect incremental updates of the position. To detect in which direction the handle is moving an extra microswitch is controlled by a laundry pinch.

The friction between the laundry pinch and the handle axis enables the pinch to move into the same direction as the handle until it is stopped by either the microswitch or a fixed stop in the other direction. As long as the handle is moving in one direction the microswitch is closed, once the handle moves into the other direction the microswitch is opened.
A nice trick, but disadvantage of this is that it relies on the pinching force of the laundry pinch and that it wears out.
Also the position of the microswitch and the shape of the MDF ‘waveform’ are very critical.

I have been thinking about a more robust way to detect the flaps handle positions.
This video made me realize that a hall effect sensor could be used to detect a position without mechanical contact.
When I ordered some magnets for a different project last year I received some small 5x5x5 mm cube neodymium magnets for free. These could be glued in small pockets in an MDF encoder wheel and detected with a fixed hall effect sensor.
A second sensor could be used to also detect into which direction the handle moves.

But instead of magnets I decided to use an encoder wheel with holes and optical sensors.

By using two optical sensors and a logic circuit called a D-flipflop also the turning direction of the wheel can be detected.

One sensor is connected to the D-input of the flipflop, the second sensor to the CK clock input.
The sensors are placed in such a way that the sensor connected to the CK input generates a rising pulse (when a hole in the encoder wheel moves out of the optical sensor) at the moment that the other sensor sees a hole in the wheel (0) or not (1).
In this way always a 0 will be clocked into the flipflop when the handle moves into one direction and always a 1 will be clocked in when the handle moves into the other direction. So the output of the flipflop represents the direction that the handle moves into.

For the flaps handle the function of the hardware flipflop can be implemented in the SIOC script instead.

// B737 Throttle Quadrant
// Flaps handle input
// 9 flaps positions: 0, 1, 2, 5, 10, 15, 25, 30, 40
// 0v9 May 27, 2017 Theo Deckers

var 0000, value 0
  &FLAPS_POS  = 0          // flaps position
  &FLAPS_DX   = 2047.875   // max flaps value (16383) divided by (nr of detents - 1)

Var 0599, name FLAPS_POS
  &FLAPS_CTRL = &FLAPS_POS // output flaps_pos value to FSUIPC

Var 0597, name FLAPS_DX    // Variable for incremental value of flaps position

Var 0500, name FLAPS_SW_ZERO, Link IOCARD_SW, Input 0     // Flaps zero switch
  IF &FLAPS_SW_ZERO = 1     // Flaps zero
    &FLAPS_POS  = 0         // reset position to 0

Var 0501, name FLAPS_SW_MOVE, Link IOCARD_SW, Input 2     // Flaps handle moving

Var 0502, name FLAPS_SW_DIR, Link IOCARD_SW, Input 8     // Flaps handle direction sensor 
  IF &FLAPS_SW_DIR = 1             // rising edge on direction sensor
    IF &FLAPS_SW_MOVE = 1          // handle inbetween detents
      L0 = &FLAPS_DX               // increase position
      L0 = 0 - &FLAPS_DX           // decrease position
    &FLAPS_POS = LIMIT 0 16383 L0  // increase or decrease flaps position value; between 0 and 16383

Var 0503, name FLAPS_CTRL, Link FSUIPC_INOUT,  Offset $0BDC, Length 4

The FLAPS_POS variable stores the position value that is modified by the handle and that is output to Flightsim via the FLAPS_CTRL FSUIPC offset.
Depending on whether the flaps handle is moving up (FLAPS_SW_DIR = 1) or down (FLAPS_SW_DIR = 0) the FLAPS_DX is set to a positive or negative offset.

The design of the encoder wheel, the aluminum brackets for the optical sensor boards and TQ panel 5 at which the optical sensors are mounted will be available soon in the Downloads section of this blog.
Note that the position of the optical sensors is quite critical: depending on the thickness of the flexible piece of isolation that is used between the sensor PCB and aluminum mount the position may vary a bit, so the holes for the sensor mounts in the design of panel 5 are an indication. I mounted the encoder wheel, powered the sensors and moved them a bit around until the optimal position was found and drilled the holes on that position.

When writing and testing the SIOC script there were some surprises:
– although the signal LED at the optical sensors is ‘on’ for the holes in the encoder wheel this results in a logic ‘0’ at the output. Indeed the schematic of the sensor shows that the output has a pull-up resistor to 5V and the output is pulled to 0 when a hole is seen. (the diagram above already has been updated for this).

Circuit of optical sensor module

This means however that the original timing of the encoder wheel won’t work with the hardware flipflop implementation: instead of a rising edge it gets a falling edge. For the ‘software-only’ solution it is OK: switches attached to the OpenCockpits master card inputs generate a ‘1’ when connected to ground.
In the implementation with the hardware flipflop, with the current encoder wheel design at least the clock signal must be inverted. This could be achieved by either using a logic inverter or moving the sensor a little.

– initially I saw the optical sensor signals toggling in the SIOC monitor. After a problem with a short in the USB cable / PCB socket combination the OC mastercard wasn’t visible anymore in the SIOC monitor however. Whatever I tried, it didn’t appear anymore, so I was afraid that I had a hardware failure in one of the boards. An alternative mastercard or connecting it to a different USB expansion board connector didn’t help either so my conclusion was that either there was a problem with the USB card or something else was wrong.
To rule out a software problem I decided to connect the USB board to an alternative computer with a new installation of the SIOC software. At that computer the master card was immediately visible.

When comparing the sioc.ini files of both computers the main difference I found was a line MASTER=0,4,0,137 on the failing computer.
With the third value the number of connected mastercards is set. If the value is 0 no mastercard is detected.
The new computer didn’t have this line.
I’m still not 100% sure how the wrong value got into the file, but the problem definitely was not caused by the USB short. I had been playing around with the Config Devices page of SIOC and suspect that I accidently entered a ‘0’ for the #Cards entry.

Some very valuable resources for information on SIOC programming and the Opencockpits system are: – SIOC script examples
How to run multiple Opencockpits USB modules
SIOC reference manual

A similar optical encoder wheel will be used for the stab trim wheels. When these spin fast, a lot of SIOC events will be generated by both optical sensors, so it could make sense to use the hardware flipflop solution for that encoder wheel.

I experimented with a number of plexiglass sheets that I had for the encoder wheel and found that some pieces that looked opaque didn’t work, while opal plexiglass (that I ordered for the cockpit panels) did.
When testing the finished, mounted encoder wheel of opal plexiglass to my surprise it didn’t work however.
Investigation showed that although I ordered exact the same opal plexiglass twice at the same web shop apparently the second batch was a bit different.
A possible solution would have been to paint the encoder wheel, but I decided to create another one from the original batch that worked.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s