This is an old revision of the document!
Table of Contents
ILOGICS Built-in Command Manual
ILOGICS boards support built-in commands developed by ILOGICS. Select an ILOGICS board to use them without installing a separate library.
Using Built-in Commands
- Install the ILOGICS board package. (Arduino SDK)
- In Arduino IDE, select your board under Tools → Board.
- Use the built-in commands.
Built-in Command List
| Category | Commands | Description |
|---|---|---|
| Digital Input Filters | IdigitalRead() | Reads the input several times consecutively and updates the state only when all values match. If HIGH and LOW are mixed, it retains the previous stable state. |
| Ibounce() | Applies a debounce time in both ON and OFF directions of the input. | |
| IbounceOn() | Applies the time filter only when the input changes from OFF to ON. | |
| IbounceOff() | Applies the time filter only when the input changes from ON to OFF. | |
| Edge Detection | Iup() | Returns true only at the instant the input changes from OFF to ON. |
| Idown() | Returns true only at the instant the input changes from ON to OFF. |
|
| State Toggle | Ialt() | Toggles the specified state ON/OFF at each input rising edge. |
| Range Conversion | Iscale() | Converts an integer input value to the specified integer range. |
| Iscalef() | Converts a floating-point input value to the specified floating-point range. | |
| Timers | Iton() | (On Delay Timer) Returns true only after the condition has remained ON for a specified time. |
| Itof() | (Off Delay Timer) Returns false after the specified time has elapsed since the condition turned OFF. |
|
| Itpl() | (Pulse Timer) Returns true for the preset time starting when the condition turns ON. |
|
| Itmon() | (Monostable Timer) outputs a pulse whose duration is not extended by another input during operation. | |
| Itmr() | (Retentive Timer) accumulates the time the condition is ON and clears it with the Reset input. | |
| Timer State | IgetTime() | Returns the current elapsed time of the specified timer. |
| IgetState() | Returns the current output state of the specified timer. | |
| Callback Timers | ItimerSet() | Sets the interval and callback function, or the hardware timer to use. |
| ItimerStart() | Starts the configured callback timer. | |
| ItimerStop() | Stops the default or specified callback timer. | |
| ItimerStopAll() | Stops all running callback timers. | |
| ItimerState() | Returns the running state of the default or specified callback timer. | |
| Counters | Ictu() | Counts input rising edges and returns true when the preset value is reached. |
| Ictd() | Loads the preset value, then decrements the current value at each input rising edge. | |
| Ictud() | Handles increment and decrement inputs in one counter. | |
| IgetCount() | Returns the current value of the specified counter. | |
| IsetCount() | Changes the current value of the specified counter. | |
| IctudDownState() | Returns the lower-limit completion state of the Up/Down counter. | |
| Data Buffers | FIFO() | Outputs the first stored 16-bit data first. |
| FILO() | Outputs the last stored 16-bit data first. | |
| Analog Input | analogReadInit() | Sets the sampling rate of the analog input module. |
| analogRead() | Reads the raw analog value of the specified channel. | |
| analogReadAvg() | Returns an integer average of multiple input values. | |
| analogReadAvgf() | Returns a floating-point average of multiple input values. | |
| Analog Input Filters | IanalogFilter() | Applies a moving average to the supplied value. |
| Analog Range Conversion | IanalogRead() | Converts the analog input value to the specified integer range. |
| IanalogReadf() | Converts the analog input value to the specified floating-point range. | |
| 4~20mA Input | analogRead2() | Reads the corrected 4~20mA input value of the specified channel. |
| analogRead2Avg() | Returns an integer average of 4~20mA input values. | |
| analogRead2Avgf() | Returns a floating-point average of 4~20mA input values. | |
| 4~20mA Range Conversion | IanalogRead2() | Converts the 4~20mA input value to the specified integer range. |
| IanalogRead2f() | Converts the 4~20mA input value to the specified floating-point range. | |
| Temperature Input | ntcRead() | Returns the temperature of an NTC 3950 10kΩ sensor as an integer in 0.1℃ units. |
| ntcReadf() | Returns the temperature of an NTC 3950 10kΩ sensor as a floating-point value in ℃. | |
| pt100Read() | Returns the PT100 sensor temperature as an integer in 0.1℃ units. | |
| Analog Output | analogWriteInit() | Sets the resolution and prescaler of the output timer. |
| analogWriteFreq() | Sets the PWM frequency of the specified output channel. | |
| analogWriteMax() | Returns the maximum value available for the specified output channel. | |
| IanalogWriteInit() | Sets the maximum, minimum and mode of the MPAINO analog output. | |
| IanalogWrite() | Converts a user integer value to the analog output range and outputs it. | |
| IanalogWritef() | Converts a user floating-point value to the analog output range and outputs it. | |
| 4~20mA Output | analogWrite2() | Outputs a raw value for 4~20mA conversion on the specified channel. |
| IanalogWrite2() | Converts a user integer value to the 4~20mA output range. | |
| IanalogWrite2f() | Converts a user floating-point value to the 4~20mA output range. | |
| PWM Output | PWM() | Outputs 8-bit or 16-bit PWM on the specified pin. |
| FDPWM() | Outputs PWM at the specified frequency and duty cycle. | |
| PWMOFF() | Stops or re-enables PWM output on the specified pin. | |
| PWM_RESET() | Resets all PWM states managed by the core. | |
| Pulse Output | NPWM_BEGIN() | Prepares pulse output with the specified frequency, duty cycle and pulse count. |
| NPWM() | Outputs the prepared number of pulses. | |
| PID Control | IpidSet() | Sets PID coefficients, calculation interval and output range. |
| IpidRun() | Calculates the PID output from the current value and setpoint. | |
| IpidReset() | Resets the PID integral value and internal state. | |
| IpidReverse() | Selects direct or reverse PID action. | |
| IpidItermLimit() | Limits the minimum and maximum of the PID integral term. | |
| IpidOutput() | Returns the last calculated PID output value. | |
| TM1637 FND | IsegBegin() | Sets the CLK/DIO pins and device number of a TM1637 FND display. |
| IsegBrightness() | Sets display brightness and visibility. | |
| IsegClear() | Clears the FND display. | |
| IsegWrite() | Outputs segment data at the specified position. | |
| IsegDecimal() | Displays an integer in decimal format. | |
| IsegHex() | Displays an integer in hexadecimal format. | |
| IsegEncodeDigit() | Converts one digit to segment data. | |
| Character LCD | IclcdBegin() | Sets the address and screen dimensions of a PCF8574 character LCD. |
| IclcdClear() | Clears the LCD screen. | |
| IclcdHome() | Moves the cursor to the first position. | |
| IclcdSetCursor() | Moves the cursor to the specified column and row. | |
| IclcdDisplay() | Turns the LCD display on or off. | |
| IclcdCursor() | Shows or hides the cursor. | |
| IclcdBlink() | Enables or disables cursor blinking. | |
| IclcdBacklight() | Turns the LCD backlight on or off. | |
| IclcdScrollLeft() | Shifts the displayed content one position to the left. | |
| IclcdScrollRight() | Shifts the displayed content one position to the right. | |
| IclcdTextDirection() | Sets the text entry direction. | |
| IclcdAutoscroll() | Enables or disables automatic scrolling. | |
| IclcdCreateChar() | Registers a custom character. | |
| IclcdWrite() | Outputs a character code or custom character. | |
| IclcdCommand() | Sends an LCD control command directly. | |
| IclcdPrint() | Prints a string or number on the LCD. | |
| RTC | IrtcBegin() | Checks the DS3231 RTC connection and starts using it. |
| IrtcRead() | Reads the RTC date and time. | |
| IrtcSet() | Sets the RTC date and time. | |
| IrtcUnixTime() | Returns the current time as Unix time. | |
| IrtcGetTemperature() | Returns the internal RTC temperature. | |
| IrtcTimeValid() | Checks whether the RTC time is trustworthy. | |
| IrtcClearOscillatorStopFlag() | Clears the oscillator-stop status flag. | |
| IrtcSetAlarm1() | Sets alarm 1, including seconds. | |
| IrtcSetAlarm2() | Sets alarm 2 with minute resolution. | |
| IrtcAlarmEnable() | Enables or disables the specified alarm. | |
| IrtcAlarmEnabled() | Checks whether the specified alarm is enabled. | |
| IrtcAlarmTriggered() | Checks whether an alarm has triggered and optionally clears its status. | |
| IrtcSquareWave() | Configures the RTC square-wave output. | |
| Irtc32kHz() | Enables or disables the RTC 32kHz output. | |
| Debug | debugStart() | Sets the port and baud rate for debug output. |
| debugStop() | Stops debug output. | |
| debugState() | Returns whether debug output is enabled. | |
| debug() | Outputs values only when debugging is enabled. | |
| debugln() | Outputs a debug value followed by a newline. | |
| Watchdog | WDT_ENABLE() | Sets the Watchdog timeout and starts it. |
| WDT_DISABLE() | Stops the Watchdog. | |
| WDT() | Refreshes the Watchdog before its timeout expires. | |
| High-Speed Counter | TCNTSETUP() | Configures timer external clock input and 32-bit extension mode. |
| TCNTOUT() | Returns the accumulated upper overflow value in 32-bit extension mode. | |
| Modbus RTU Slave | ImodbusRTUMem() | Sets the sizes of M and D memory used by the Slave. |
| ImodbusRTUAdr() | Sets the start addresses of M and D memory. | |
| ImodbusRTUInit() | Sets the communication port, station number and baud rate. | |
| ImodbusRTU() | Checks incoming requests and handles Slave responses. | |
| Modbus RTU Master | ImodbusRTUmasterInit() | Sets the Master communication port and baud rate. |
| ImodbusRTUmaster() | Executes a single Master request immediately. | |
| ImodbusRTUmasterAdd() | Registers a Master request for repeated execution. | |
| ImodbusRTUmasterRun() | Executes a registered request or the specified single request. | |
| LS Industrial Systems Cnet Slave | ICnetMem() | Sets the sizes of M, D and R memory used by the Cnet Slave. |
| ICnetAdr() | Sets the start addresses of M, D and R memory. | |
| ICnetInit() | Sets the communication port, station number and baud rate. | |
| ICnet() | Checks incoming requests and handles Cnet Slave responses. | |
| Mitsubishi MC Protocol | IMcMem() | Sets the sizes of X, Y, M and D memory used by MC Protocol. |
| IMcAdr() | Sets the start addresses of X, Y, M and D memory. | |
| IMcInit() | Sets the communication port, station number and baud rate. | |
| IMcProtocol() | Checks incoming requests and handles MC Protocol responses. |
Digital Input Filters
| Command Syntax | Return Value | Usage Guidelines |
|---|---|---|
| IdigitalRead(pin, samples) | Filtered HIGH or LOW | Update the state only when all samples match; retain the previous stable state when values are mixed |
| Ibounce(pin, ms) | Stabilized input state | Change state when ON or OFF remains stable for the preset time |
| IbounceOn(pin, ms) | Input state with a delayed ON transition | Apply the time filter only to OFF→ON transitions |
| IbounceOff(pin, ms) | Input state with a delayed OFF transition | Apply the time filter only to ON→OFF transitions |
IdigitalRead() repeatedly samples over a short period, whereas Ibounce() checks how long the input has remained stable using millis(). Ibounce() is generally suitable for mechanical switches.
Edge Detection
| Command Syntax | Return Value | Description |
|---|---|---|
| Iup(id, input) | true only on the rising edge | Detect each OFF-to-ON transition once |
| Idown(id, input) | true only on the falling edge | Detect each ON-to-OFF transition once |
id identifies each edge detection state. Using the same id for different inputs may mix their states.
State Toggle
| Command Syntax | Return Value | Description |
|---|---|---|
| Ialt(input, state) | None | Toggle state ON/OFF at each input rising edge |
bool lampState = false; void loop() { bool button = Ibounce(0, 30); Ialt(button, lampState); digitalWrite(64, lampState); // MPAINO first digital output example }
Range Conversion
| Command Syntax | Return Value | Description |
|---|---|---|
| Iscale(x, inMin, inMax, outMin, outMax) | int32_t | Convert the integer input range to the desired integer range |
| Iscalef(x, inMin, inMax, outMin, outMax) | float | Convert floating-point ranges while retaining fractional values |
Timers
| Command Syntax | Operation |
|---|---|
| Iton(id, state, ms) | Turn output ON when the input remains ON for the preset time |
| Itof(id, state, ms) | Turn output OFF after the preset time has elapsed since the input turned OFF |
| Itpl(id, state, ms) | Output a pulse for the preset time starting at the input rising edge |
| Itmon(id, state, ms) | Monostable pulse that is not extended by another input during execution |
| Itmr(id, state, ms, reset) | Accumulate input ON time and clear it with reset |
PLC-style timers do not pause the program like delay(). Instead, call them on every iteration of loop(). Do not reuse the same id for different timers.
void loop() { bool run = Ibounce(0, 30); bool delayedOutput = Iton(0, run, 1000); digitalWrite(64, delayedOutput); }
Timer State
| Command Syntax | Return Value | Description |
|---|---|---|
| IgetTime(id) | unsigned long | Return the specified timer's current elapsed time |
| IgetState(id) | bool | Return the specified timer's current output state |
Callback Timers
| Command Syntax | Description |
|---|---|
| ItimerSet(intervalMs, callback) | Set the default timer's interval and callback function |
| ItimerSet(timerNo, intervalMs, callback) | Configure by specifying a hardware timer number |
| ItimerStart(), ItimerStart(timerNo) | Start the callback timer |
| ItimerStop(), ItimerStop(timerNo) | Stop the callback timer |
| ItimerStopAll() | Stop all callback timers |
| ItimerState(), ItimerState(timerNo) | Check running state |
Callback functions run inside interrupts. Change only flags or short counts in callbacks; do not use delay(), Serial output, I²C, SPI or lengthy calculations.
volatile bool taskFlag = false; void onTimer() { taskFlag = true; } void setup() { ItimerSet(100, onTimer); ItimerStart(); } void loop() { if (taskFlag) { taskFlag = false; // Perform time-consuming work in loop(). } }
Counters
| Command Syntax | Description |
|---|---|
| Ictu(id, CU, RESET, PV) | Count CU rising edges and turn ON at PV |
| Ictd(id, CD, LOAD, PV) | Load the value with LOAD, then decrement at each CD rising edge |
| Ictud(id, CU, CD, RESET, LOAD, PV) | Handle increment and decrement together |
| IgetCount(id), IsetCount(id, value) | Read and change the current count |
| IctudDownState(id) | Check the Up/Down counter's lower-limit completion state |
Keep calling counter commands in loop(). Assign each id without duplicating another counter's ID.
Data Buffers
Analog Input
| Command Syntax | Return Value / Purpose |
|---|---|
| analogReadInit(sps) | Set the sampling rate of the MPAINO ADS1118 analog module |
| analogRead(ch) | Read the selected channel's raw analog value |
| analogReadAvg(ch, samples), analogReadAvgf(ch, samples) | Integer or floating-point moving-average input |
Analog Input Filters
| Command Syntax | Return Value / Purpose |
|---|---|
| IanalogFilter(id, raw, samples) | Apply a moving average to arbitrary user-supplied values |
Analog Range Conversion
| Command Syntax | Return Value / Purpose |
|---|---|
| IanalogRead(ch, min, max), IanalogReadf(ch, min, max) | Convert input to a user integer or floating-point range |
4~20mA Input
| Command Syntax | Return Value / Purpose |
|---|---|
| analogRead2(ch) | Read the corrected 4~20mA input value |
| analogRead2Avg(ch, samples), analogRead2Avgf(ch, samples) | Return an integer or floating-point average of 4~20mA input values |
4~20mA Range Conversion
| Command Syntax | Return Value / Purpose |
|---|---|
| IanalogRead2(ch, min, max), IanalogRead2f(ch, min, max) | Convert 4~20mA input to the user range |
On MPAINO, first check the installed analog input module and DIP switch voltage/current range. Increasing the sampling rate speeds up response but may change noise and measurement characteristics.
void setup() { Serial.begin(115200); analogReadInit(IANALOG_SPS_64); } void loop() { int32_t raw = analogReadAvg(0, 8); float value = Iscalef(raw, 0.0, 32767.0, 0.0, 100.0); Serial.println(value); }
Temperature Input
| Command Syntax | Return Value | Target |
|---|---|---|
| ntcRead(ch) | Integer in 0.1℃ units | NTC 3950 10kΩ temperature sensor input |
| ntcReadf(ch) | float in ℃ | NTC 3950 10kΩ temperature sensor input |
| pt100Read(ch) | Integer in 0.1℃ units | MPAINO PT100 input module |
NTC and PT100 use different sensor types and input circuits. Do not interchange them; verify that the selected product supports the required input.
Analog Output
| Command Syntax | Description |
|---|---|
| analogWriteInit(ch, top, prescaler) | Set PWM timer resolution and prescaler |
| analogWriteFreq(ch, hz), analogWriteMax(ch) | Set PWM frequency and check the current maximum value |
| IanalogWriteInit(ch, max, min, mode) | Initialize the MPAINO analog output range |
| IanalogWrite(ch, min, max, value), IanalogWritef(...) | Convert integer or floating-point user values to the analog output range |
4~20mA Output
| Command Syntax | Description |
|---|---|
| analogWrite2(ch, value) | Output a raw value for 4~20mA conversion on the specified channel |
| IanalogWrite2(ch, min, max, value), IanalogWrite2f(...) | Convert integer or floating-point user values to the 4~20mA output range |
PWM Output
| Command Syntax | Description |
|---|---|
| PWM(pin, value, bit16) | 8-bit or 16-bit PWM output |
| FDPWM(pin, hz, duty) | PWM output with specified frequency and duty cycle |
| PWMOFF(pin, off), PWM_RESET() | Stop an individual PWM output or reset all |
Pulse Output
| Command Syntax | Description |
|---|---|
| NPWM_BEGIN(pin, hz, duty, count), NPWM(pin) | Output the specified number of pulses |
PWM, high-speed pulses, analogWrite() and callback timers may share the same hardware timer. When combining functions, check the timer support table for the product.
PID Control
| Command Syntax | Description |
|---|---|
| IpidSet(id, kp, ki, kd, sampleMs, outMin, outMax) | Set PID coefficients, calculation interval and output range |
| IpidRun(id, pv, sv) | Calculate output from the current value PV and setpoint SV |
| IpidReset(id) | Reset the internal state |
| IpidReverse(id, reverse) | Select direct or reverse action |
| IpidItermLimit(id, min, max) | Limit the integral term range |
| IpidOutput(id) | Check the last output value |
void setup() { IpidSet(0, 2.0, 0.5, 0.1, 100, 0, 100); } void loop() { float pv = ntcReadf(0); float output = IpidRun(0, pv, 50.0); IanalogWritef(0, 0.0, 100.0, output); }
PID output is only a calculated value, not a safety device. Handle sensor open circuits, overtemperature, stuck outputs and emergency stops with separate safety circuits.
TM1637 FND
| Target | Main Commands | Description |
|---|---|---|
| TM1637 4-Digit FND | IsegBegin(), IsegBrightness(), IsegDecimal(), IsegHex(), IsegClear() | Identify up to 7 devices by device number |
Character LCD
| Target | Main Commands | Description |
|---|---|---|
| PCF8574 Character LCD | IclcdBegin(), IclcdSetCursor(), IclcdPrint(), IclcdClear() | Identify up to 4 LCDs by device number |
RTC
| Target | Main Commands | Description |
|---|---|---|
| DS3231 RTC | IrtcBegin(), IrtcRead(), IrtcSet(), IrtcGetTemperature(), IrtcSetAlarm1() | Use date/time, temperature, alarms and frequency output |
For displays and RTC, call each device's Begin command first. Check I²C addresses, connection pins and sharing with other functions.
Debug
| Command Syntax | Description |
|---|---|
| debugStart(), debugStart(baud), debugStart(serial, baud) | Start Debug output and select a port |
| debug(), debugln() | Output values only when Debug is enabled |
| debugStop(), debugState() | Stop Debug and check status |
Watchdog
| Command Syntax | Description |
|---|---|
| WDT_ENABLE(time) | Set the Watchdog timeout and enable it |
| WDT(), WDT_DISABLE() | Reset and disable the Watchdog |
After enabling the Watchdog, delayed WDT() calls cause the board to restart. First check the worst-case communication wait and long-loop execution time.
High-Speed Counter
| Command Syntax | Description |
|---|---|
| TCNTSETUP(timerNo, bit32) | Configure timer external clock input and 32-bit extension mode |
| TCNTOUT(timerNo) | Check the accumulated upper overflow count in 32-bit extension mode |
Currently, MPINO-8A8R and MPINO-16A8R8T support the dedicated high-speed counter using timer external clock mode. For other products, check the product-specific interrupt inputs and use attachInterrupt().
Modbus RTU Slave
| Initial Setup | Command Called in loop() |
|---|---|
| ImodbusRTUMem(), ImodbusRTUAdr(), ImodbusRTUInit() | ImodbusRTU() |
void setup() { ImodbusRTUMem(128, 64); ImodbusRTUAdr(0, 0); ImodbusRTUInit(Serial2, 1, 9600); } void loop() { ImodbusRTU(); }
Modbus RTU Master
| Initial Setup | Execution Command |
|---|---|
| ImodbusRTUmasterInit(), ImodbusRTUmasterAdd() | ImodbusRTUmaster() or ImodbusRTUmasterRun() |
LS Industrial Systems Cnet Slave
| Initial Setup | Command Called in loop() |
|---|---|
| ICnetMem(), ICnetAdr(), ICnetInit() | ICnet() |
Mitsubishi MC Protocol
| Initial Setup | Command Called in loop() |
|---|---|
| IMcMem(), IMcAdr(), IMcInit() | IMcProtocol() |
The Serial numbers for RS-232, RS-485 and UART may differ by product. Before communication, check port roles, electrical standards, baud rate, station number, termination resistors and DIP switch settings.
Integrated I/O Example
The example below uses MPAINO's first digital input 0 and first digital output 64. On MPINO, replace them with the actual Arduino pin numbers of the selected model.
const uint8_t inputChannel = 0; const uint8_t outputChannel = 64; void setup() { pinMode(inputChannel, INPUT); pinMode(outputChannel, OUTPUT); } void loop() { bool stableInput = Ibounce(inputChannel, 30); bool delayedOutput = Iton(0, stableInput, 1000); digitalWrite(outputChannel, delayedOutput); }
Troubleshooting
- Command not found: Check that the ILOGICS board package is installed and the correct product board is selected.
- I/O does not respond: Check that MPINO pin numbers and MPAINO logical channels have not been confused.
- Timer/counter stops: Check that the command is called continuously in
loop()and the sameidis not reused. - Unexpected PWM frequency: Check whether another PWM, pulse or callback function is using the same hardware timer.
- Unexpected analog values: Check the voltage/current/NTC/PT100 DIP switches, channel and sampling rate.
- Communication fails: Check the Serial port, RS-232/RS-485 interface, baud rate, station number, parity and wiring.
- Board repeatedly restarts: Check for code that takes longer than the Watchdog timeout.
Essential Precautions
- Do not mix legacy
#include <ILIB.h>,tempRead()orIpt100Read()examples with the current built-in commands. - Turn off equipment power before changing power connections or wiring. Check polarity, COM, input voltage and load power.
- Distinguish the electrical characteristics and allowable currents of relay and transistor outputs.
- Do not rely solely on program outputs for emergency stop or overcurrent protection.
- Use the relevant product manual as the final reference for pin maps, electrical specifications and supported timers.
