====== Additional Library Description ======
This library includes many functions. This function was added in accordance with the IEC61131-3 programmable controller international standard.
====== Timer ======
The maximum number of timers that can be used is 50. (0 to 49 can be used) You can use more by modifying timerMaxLimit in the library file.
// This is what's in the library. Don't put this in your code.
#define timerMaxLimit 50
uint8_t Tstat[timerMaxLimit]; // Timer status
uint32_t Tvalue[timerMaxLimit]; // Timer Current Value
* Tstat[timer number] array stores the status of each timer.
* Tvalue[timer number] stores the current value of each timer.
===== onTimer =====
This is a timer that turns on after a set amount of time has passed.
''void onTimer(input source, timer number, elapsed time) ''
| Input source: Timer start input |
| Timer number: Timer number to use |
| Elapsed time: Timer mS(milliseconds) value. 8 means 0.8S. |
{{ :modularfaduino:ton.png?nolink |}}
void logic_proc()
{
onTimer(X00,0,20); // 2Sec On Timer
Y01 = Tstat[0]; // Watch Tvalue
}
===== offTimer =====
This is a timer that turns on when it starts and turns off after a set amount of time has passed when the input signal is turned off.
''void offTimer(input source, timer number, elapsed time) ''
| Input Source: Timer Start Input |
| Timer Number: Timer Number to Use |
| Elapsed Time: Timer mS(milliseconds) value. 8 means 0.8S. |
{{ :modularfaduino:toff.png?nolink |}}
void logic_proc()
{
offTimer(X00,0,20); // 2Sec Off Timer
Y01 = Tstat[0]; // Watch Tvalue
}
===== onceTimer =====
This is a one-time timer that turns On at the start and Turns Off after a certain amount of time has passed.
''void onceTimer(input source, timer number, elapsed time) ''
| Input Source: Timer Start Input |
| Timer Number: Timer Number to Use |
| Elapsed Time: Timer mS(milliseconds) value. 8 means 0.8S. |
{{ :modularfaduino:tonce.png?nolink |}}
void logic_proc()
{
onceTimer(X00,0,20); // 2Sec Once Timer
Y01 = Tstat[0]; // Watch Tvalue
}
===== rTimer =====
This is an accumulating timer. It is similar to the ontimer. It turns on after a set amount of time has passed. However, even if the input signal is turned off in the middle, the timer is not reset and maintains its previous state.
To reset the timer, you must enter 0 in Tvalue[timer number] and Tstat[timer number]. In other words, the reset must be done manually.
''void rTimer(input source, timer number, elapsed time) ''
| Input source: Timer start input |
| Timer number: Timer number to use |
| Elapsed time: Timer mS(milliseconds) value. |
When the sum of Time1 and Time2 reaches the elapsed time, the output is On.
{{ :modularfaduino:rtimer.png?nolink |}}
#include "cfManagedBase.h"
uint16_t tempi;
void user_setup()
{
Serial.begin(115200);
}
void loop() {
Serial.print(Tvalue[0]);
Serial.print("\n");
delay(500);
}
void logic_proc()
{
rTimer(X00,0,100);
Y00 = X00;
Y01 = Tstat[0];
}
====== Counter ======
The Cstat[counter number] array stores the status of each counter. Cvalue[counter number] stores the current increment/decrement value of each counter.
#define counterMaxLimit 20
uint8_t Cstat[counterMaxLimit]; // Counter status
uint32_t Cvalue[counterMaxLimit]; // Counter Current Value
The counter number is currently set to 20. (0~19 can be used) You can use more by modifying counterMaxLimit in the library file.
===== counter =====
Counts the number of incoming pulses.
''void counter(rising input, falling input, reset input, counter number, count value) ''
| Rising input: When this signal comes in, the counter increases by 1. |
| Falling input: When this signal comes in, the counter decreases by 1. |
| Reset input: When this signal comes in, the counter is reset. |
| Counter number: The counter number to use |
| Count value: The value to count, 16-bit unsigned integer, 1~65535 |
void logic_proc()
{
// Up: Input X00
// Down: Input X01
// Reset: Input X02
counter(X00,X01,X02,20); // When X[0] input is input 20 times, counter 0 turns on.
Y01 = Cstat[0]; // Watch Cvalue
}
If you only want to receive the rising signal, write 0 in the falling signal position.
void logic_proc()
{
// Up: Input X00
// Down: Ignore
// Reset: Input X02
counter(X00,0,X02,20); // When X[0] input is input 20 times, counter 0 turns on.
Y01 = Cstat[0]; // Watch Cvalue
}
{{ :modularfaduino:counter.png?nolink |}}
====== Trigger ======
Trigger means an action that executes only once when the input signal changes.
===== rTrig =====
Executes only once when a rising signal occurs.
''uint8_t rTrig(input, trigger number) ''
| Input: Check the input status of this signal. |
| Trigger number: Trigger number to use (available from 0 to 19). This number can be increased by adjusting trigMaxLimet in the library. |
{{ :modularfaduino:rtrig.png?nolink |}}
#include "cfManagedBase.h"
uint16_t tempi;
void user_setup()
{
Serial.begin(115200);
}
void loop() {
Serial.print(tempi);
Serial.print("\n");
delay(500);
}
void logic_proc()
{
if (rTrig(X00,0)) tempi++; // Perform tempi++ (increment) only once when X[0] changes from 0 to 1.
Y00 = X00;
}
===== fTrig =====
Execute only once when a falling signal occurs.
''uint8_t fTrig(input, trigger number) ''
| Input: Check the input status of this signal.|
| Trigger number: Trigger number to use (available from 0 to 19). This number can be increased by adjusting trigMaxLimet in the library. |
{{ :modularfaduino:ftrig.png?nolink |}}
#include "cfManagedBase.h"
uint16_t tempi;
void user_setup()
{
Serial.begin(115200);
}
void loop() {
Serial.print(tempi);
Serial.print("\n");
delay(500);
}
void logic_proc()
{
if (fTrig(X00,0)) tempi++; // Perform tempi++ (increment) only once when X[0] changes from 1 to 0.
Y00 = X00;
}
====== Use like ST language ======
Most high-performance PLCs have ST language functions that comply with the IEC61131-3 standard. ST language is a language that can solve PLC functions with coding instead of ladder logic (LD). Using this library, you can use modular FADUINO as if it were ST language in a high-performance PLC.
===== Notification =====
Please use this source at your own risk. If this source is applied to an actual project, we are not responsible for any errors or accidents. Please use this source only if you agree to this. We are not accepting technical inquiries regarding this source. Please understand this.
[[modularfaduino:index|Modular FADUINO]]