Many function need digital inputs or outputs or analog inputs. Therefore we have have 3 pin module types:
Normally all pins can be used as digital input or output. But make sure to define them correctly. Definig a pin as output which gets an input might be a bad idea. Also assign each pin only one function.
Analog inputs are limited and only available on some of the pins. Moreover also watch out with the numbering scheme. If you use a pin as analog input it has a different pin number then the same as digital pin! So digital pin 63 might be analog pin 2.
All consumers of the outputs assume sending low to disable and high to enable. Some hardwares require the inverted signal. For example if direction of a motor is wrong, you can invert the direction by inverting the signal to direction pin. In such a case use then the inverted variant of an output.
Sets output state of one pin of the processor.
IO_OUTPUT(name, pinNumber)
Parameter | Function |
---|---|
name | The variable name used to reference this pin later. |
pinNumber | Arduino pin number on the board. For many boards you can get the pinout of all pins. We also provide lots of symbolic names for known boards and pins. |
Use the pin in higher leveled modules like stepper drivers.
Sets output state of one pin of the processor to the opposite signal given.
IO_OUTPUT_INVERTED(name, pinNumber)
Parameter | Function |
---|---|
name | The variable name used to reference this pin later. |
pinNumber | Arduino pin number on the board. For many boards you can get the pinout of all pins. We also provide lots of symbolic names for known boards and pins. |
Use the pin in higher leveled modules like stepper drivers.
Dummy output just to get module compile. Normally used during development or if the output is optional and you do not want to waste a pin for a function you do not need.
IO_OUTPUT_FAKE(name)
Parameter | Function |
---|---|
name | The variable name used to reference this pin later. |
Use the pin in higher leveled modules like stepper drivers.
If you are debugging a problem it might be useful to see in hosts console log if a output should be on or off. This output sends all signals through to a real output but logs every call (changesOnly false) or any change in state (changesOnly true). Be careful if you change outputs in an interrupt. This can block and crash firmware if output buffer gets full due to heavy output load.
IO_OUTPUT_LOG(name, output, changesOnly)
Parameter | Function |
---|---|
name | The variable name used to reference this pin later. |
output | Name of the output to forward signals to. |
changesOnly | True if you only are interested in changes. |
Use the pin in higher leveled modules like stepper drivers.
Most sensors work on a digital basis. Typical usages are keys, end stops, filament sensors, ...
Input pin of the processor. Disables pullup resistor and returns the original signal.
IO_INPUT(name, pinNumber)
Parameter | Function |
---|---|
name | The variable name used to reference this pin later. |
pinNumber | Arduino pin number on the board. For many boards you can get the pinout of all pins. We also provide lots of symbolic names for known boards and pins. |
Use the pin in higher leveled modules like end stops, filament sensors and more.
Input pin of the processor. Disables pullup resistor and returns the inverted signal.
IO_INPUT_INVERTED(name, pinNumber)
Parameter | Function |
---|---|
name | The variable name used to reference this pin later. |
pinNumber | Arduino pin number on the board. For many boards you can get the pinout of all pins. We also provide lots of symbolic names for known boards and pins. |
Use the pin in higher leveled modules like end stops, filament sensors and more.
Input pin of the processor. Enables pullup resistor and returns the original signal.
IO_INPUT_PULLUP(name, pinNumber)
Parameter | Function |
---|---|
name | The variable name used to reference this pin later. |
pinNumber | Arduino pin number on the board. For many boards you can get the pinout of all pins. We also provide lots of symbolic names for known boards and pins. |
Use the pin in higher leveled modules like end stops, filament sensors and more.
Input pin of the processor. Enables pullup resistor and returns the inverted signal.
IO_INPUT_INVERTED_PULLUP(name, pinNumber)
Parameter | Function |
---|---|
name | The variable name used to reference this pin later. |
pinNumber | Arduino pin number on the board. For many boards you can get the pinout of all pins. We also provide lots of symbolic names for known boards and pins. |
Use the pin in higher leveled modules like end stops, filament sensors and more.
Writes input changes or all read inputs to serial connection. Should only be used for debugging input states. Can crash firmware if used for inputs checked in interrupts!
IO_INPUT_LOG(name, input, changeOnly)
Parameter | Function |
---|---|
name | The variable name used to reference this input later. |
input | Name of the real input handler. |
changeOnly | If true only report sif the value changes. Should be true to reduce messages. |
Use the pin in higher leveled modules like end stops, filament sensors and more.
Combines 2 input signals into one. Combination is a logical or, so if any of the 2 inputs is high the output will be high as well.
IO_INPUT_OR(name, input1, input2)
Parameter | Function |
---|---|
name | The variable name used to reference this input later. |
input1 | Name of first input to combine. |
input2 | Name of second input to combine. |
Use the pin in higher leveled modules like end stops, filament sensors and more.
Combines 2 input signals into one. Combination is a logical and, so only if both of the 2 inputs are high the output will be high as well.
IO_INPUT_AND(name, input1, input2)
Parameter | Function |
---|---|
name | The variable name used to reference this input later. |
input1 | Name of first input to combine. |
input2 | Name of second input to combine. |
Use the pin in higher leveled modules like end stops, filament sensors and more.
Measures n times the analog value, removes the highest and lowest value and the builds the average. Equation for n is: n = 2 + 2^oversample
Higher values on oversample mean less and even delayed results but also give a more stable value. Normally analog values are only used for temperatures. So it is easy to see if temperature jitters too much. In that case increase oversample. Normally a value of 5 is good compromise. This requires 34 measurements, so lag is neglectible while you get already some smoothing.
IO_ANALOG_INPUT(name, channel, oversample)
Parameter | Function |
---|---|
name | The variable name used to reference this pin later. |
channel | Analog channel of the processor to be used. This is different to pin numbers! Range is 0-15. |
oversample | Oversample quality (0-7). |
Use as input for temperature measurements.
Implements a hardware SPI driver bound to a defined chip select pin.
IO_SPI_HW(name, frequency, mode, msbfirst, csPin)
Parameter | Function |
---|---|
name | The variable name used to reference the spi connection. |
frequency | SPI transfer speed. |
mode | SPI mode (0-3). |
msbmode | True to transfer in msb first mode, false for lsb mode. |
csPin | Chip select pin. |
Use as input for devices requiring SPI input.
Implements a software SPI driver bound to a defined chip select pin. On a Due board a delay of 0 results in nearly 4MHz frequency with a delay of 125ns.
IO_SPI_SW(name, delayus, mode, msbfirst, csPin, clkPin, misoPin, mosiPin)
Parameter | Function |
---|---|
name | The variable name used to reference the spi connection. |
frequency | SPI transfer speed. |
mode | SPI mode (0-3). |
msbmode | True to transfer in msb first mode, false for lsb mode. |
csPin | Chip select pin. |
clkPin | Clock signal pin. |
misoPin | Input pin connected to DO pin. -1 if not connected. |
mosiPin | Output pin connected with DI pin. -1 if not connected. |
Use as input for devices requiring SPI input.