Menu

Input-Output system

dvdouden

The input/output system

ArduinoRCLib uses five centralized buffers to store input and output in.

  • switch.h Digital input like switches and buttons
  • input.h Analog input like gimbals, knobs, sliders
  • output.h Servo output
  • inputchannel.h Channel input like PPMIn, some PCM receiver and ServoIn
  • outputchannel.h Channel output like PPMOut, some PCM transmitter and ServoOut

Each of these buffers has get and set functions and a number of pre-defined indices to positions in the buffer.
The switch buffer has indices for switches A to H, the input buffer has indices for Aileron, Elevator, Rudder, Throttle etc. The output buffer has indices for pretty much any function you may want a channel to have, like Aileron, Elevator but also Camera, Retracts, Airbrakes. Both channel buffers have indices for up to 18 channels

For each type of buffer there are a few base classes available:

  • [buffertype]Source - these classes will write to the buffer. They have an index called "destination".
  • [buffertype]Processor - these classes will read from the buffer and act on what they've read. They have an index called "source".
  • [buffertype]Modifier - these classes will read from the buffer, modify the value, and write it back. They have an index called "index".

Most classes derive from at least one of these. Some act on one buffer, others on multiple buffers. Let's have a look at all the classes.

AIPin

Is a: InputSource
Reads from: analog hardware pins
Writes to: Input buffer
Any processing: Translates hardware pin value [0 - 1023] to normalized value [-256 - 256], applies calibration and reversing.

AnalogSwitch

Is a: SwitchProcessor and InputSource
Reads from: Switch buffer
Writes to: Input buffer
Any processing: Reads switch state and writes analog input value. May do this smoothly if a duration has been set.

BiStateSwitch

Is a: SwitchSource
Reads from: digital hardware pin
Writes to: Switch buffer
Any processing: Writes Up or Down state, applies reversing.

Channel

Is a: OutputProcessor and OutputChannelSource
Reads from: Output buffer
Writes to: OutputChannel buffer
Any processing: Applies servo send points, servo speed, channel reverse

Curve

Is a: InputProcessor and InputSource
Reads from: Input buffer
Writes to: Input buffer (output index my be different than input index)
Any processing: Applies a curve to the input value

DualRates

Is a: InputModifier
Reads from: Input buffer
Writes to: Input buffer (same index as input)
Any processing: Applies a mix

Engine

Is a: InputProcessor, OutputSource and SwitchProcessor
Reads from: Input buffer (THR and RUD) and Switch buffer (user defined)
Writes to: Output buffer (User defined, but usually THR1-4)
Any processing: Applies rudder mix and throttle cut/idle level

Expo

Is a: InputModifier
Reads from: Input buffer
Writes to: Input buffer (same index as input)
Any processing: Applies exponential, this can make gimbals more or less sensitive around the center or edges

FlightTimer

Is a: SwitchProcessor
Reads from: Switch buffer
Writes to: nothing
Any processing: Is active on a switch state, counts down or up, activates buzzer or speaker

FlycamOne

Is a: OutputSource
Reads from: user supplied commands (start/stop/takePhoto)
Writes to: Output buffer
Any processing: Controls a camera based on user supplied commands

Gimbal

Is a: Custom class, has 2 AIPins
Reads from: Analog input pin
Writes to: Output buffer (twice, AIL, ELE, THR or RUD)
Any processing: Same as AIPin

Governor

Is a: SwitchProcessor and OutputSource
Reads from: Switch buffer (and throttle hold switch)
Writes to: Output buffer (GOV)
Any processing: Configurable output based on switch position and throttle hold

Gyro

Is a: OutputSource
Reads from: user supplied parameters
Writes to: Output buffer
Any processing: Outputs gain and gyro type (head hold/rate mode)

InputChannelToInputPipe

Is a: InputChannelProcessor and InputSource
Reads from: InputChannel buffer
Writes to: Input buffer
Any processing: Converts from microseconds to normalized, simply copies values from input channel buffer to input buffer

InputSwitch

Is a: InputProcessor and SwitchSource
Reads from: Input buffer
Writes to: Switch buffer
Any processing: Reads input, compares it to user defined thresholds and sets switch state

InputToInputMix

Is a: InputProcessor and InputModifier
Reads from: Input buffer (twice, master and slave index)
Writes to: Input buffer (once, slave index)
Any processing: Mixes master input into slave input

InputToOutputPipe

Is a: InputProcessor and OutputSource
Reads from: Input buffer
Writes to: Output buffer
Any processing: none, simply copies values from input buffer to output buffer

Offset

Is a: SwitchProcessor and InputModifier
Reads from: Input buffer and Switch buffer
Writes to: Input buffer (same index)
Any processing: Applies an offset to input buffer based on switch position (conditional trim)

OutputToOutputChannelPipe

Is a: OutputProcessor and OutputChannelSource
Reads from: Output buffer
Writes to: OutputChannel buffer
Any processing: Translates normalized to microseconds, direct copy

OutputToOutputMix

Is a: OutputProcessor and OutputModifier
Reads from: Output buffer (twice, master and slave index)
Writes to: Output buffer (once, slave index)
Any processing: Mixes master input into slave input

PlaneModel

Is a: custom class, multiple InputProcessor and multiple OutputSource
Reads from: Input buffer (AIL, ELE, RUD, FLP, BRK)
Writes to: Output buffer (AIL1-4, ELE1-2, RUD1-2, FLP1-4, BRK1-2)
Any processing: Loads, based on user set mixes and parameters

PPMIn

Is a: custom class, multiple InputChannelSource
Reads from: incoming digital pin
Writes to: InputChannel buffer
Any processing: Detects pin changes and writes channel values as microseconds to InputChannel buffer

PPMOut

Is a: custom class, multiple OutputChannelProcessor
Reads from: OutputChannel buffer
Writes to: digital output pin
Any processing: translates OutputChannel buffer values (in microseconds) to a PPM signal

Retracts

Is a: SwitchProcessor and custom OutputSource (dual output)
Reads from: Switch buffer
Writes to: Output buffer (GEAR and DOOR)
Any processing: Applies user defined delay and speed

ServoIn

Is a: custom class, multiple InputChannelSource
Reads from: digital input pins
Writes to: InputChannel buffer
Any processing: Detects pin changes and writes channel values as microseconds to InputChannel buffer

ServoOut

Is a: custom class, multiple OutputChannelProcessor
Reads from: OutputChannel buffer
Writes to: digital output pins
Any processing: translates OutputChannel buffer values (in microseconds) to a servo signal

Swashplate

Is a: custom class, multiple InputProcessor and multiple OutputSource
Reads from: Input buffer (AIL, ELE, PIT)
Writes to: Output buffer (AIL1, ELE1, ELE2, PIT1)
Any processing: User set mixes, applies CCPM mixing

SwashToThrottleMix

Is a: custom class, double InputProcessor and InputModifier
Reads from: Input buffer (thrice, master (AIL and ELE) and slave (THR) index)
Writes to: Output buffer (once, slave index (THR))
Any processing: Mixes master input into slave input but also takes slave input into account

SwitchToggler

Is a: SwitchModifier
Reads from: Switch buffer
Writes to: Switch buffer (same index)
Any processing: Toggles the output when the input reaches a user defined state

ThrottleHold

Is a: SwitchProcessor and InputModifier
Reads from: Switch buffer and Input buffer
Writes to: Input buffer (same index)
Any processing: Based on switch state will overwrite input buffer with user defined value.

Trainer

Is a: SwitchProcessor, InputChannelProcessor and custom InputModifier or OutputModifier
Reads from: Switch buffer, InputChannelBuffer and Input or Output buffer
Writes to: Input or Output buffer
Any processing: When switch state equals user defined state, will overwrite input or output buffer with student value from InputChannelBuffer, may mix with original value.

TriStateSwitch

Is a: SwitchSource
Reads from: two digital input pins
Writes to: Switch buffer
Any processing: Sets Up, Center or Down state based on pins, may apply reverse.


Related

Wiki: Home

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.