en-us_commands:reference:itmr
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en-us_commands:reference:itmr [2026/09/08 00:53] – 바깥 편집 127.0.0.1 | en-us_commands:reference:itmr [2026/09/14 20:30] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 14: | Line 14: | ||
| ===== Example ===== | ===== Example ===== | ||
| + | |||
| + | This example selects MPINO-8A4R(T)-S and uses input '' | ||
| <code cpp> | <code cpp> | ||
| - | const uint8_t | + | const uint8_t |
| const uint8_t RESET_INPUT = 1; | const uint8_t RESET_INPUT = 1; | ||
| - | const uint8_t | + | const uint8_t |
| - | void setup() { | + | void setup() {} |
| - | Serial.begin(115200); | + | |
| - | } | + | |
| void loop() { | void loop() { | ||
| - | const bool start = IdigitalRead(START_INPUT, | + | const bool run = digitalRead(RUN_INPUT) == HIGH; |
| - | const bool reset = IdigitalRead(RESET_INPUT, 5); // Read the input repeatedly and update only if all samples match. If HIGH and LOW are mixed, retain the previous stable state. | + | const bool reset = digitalRead(RESET_INPUT) == HIGH; |
| - | const bool ready = Iton(0, start, 1000); | + | const bool elapsed |
| - | const bool stopDelay | + | digitalWrite(OUTPUT_PIN, elapsed |
| - | const bool startPulse | + | |
| - | const bool inspectionWindow = Itmon(3, startPulse, 3000); // (Monostable Timer) Output a pulse whose duration is not extended by another trigger while running. | + | |
| - | const bool batchDone = Itmr(4, ready, 10000, reset); | + | |
| - | const unsigned long elapsed = IgetTime(4); | + | |
| - | const bool savedDone = IgetState(4); | + | |
| - | + | ||
| - | digitalWrite(RUN_OUTPUT, stopDelay && !batchDone | + | |
| - | if (inspectionWindow && elapsed % 1000 < 20) { | + | |
| - | Serial.println(savedDone ? F(" | + | |
| - | } | + | |
| } | } | ||
| </ | </ | ||
| Line 44: | Line 34: | ||
| ===== Precautions ===== | ===== Precautions ===== | ||
| - | * Timer interrupt callbacks run inside an ISR. For safety, change only flags in the callback and perform actual control processing | + | * Call the timer command repeatedly |
| - | * Do not use slow or interrupt-dependent code such as '' | + | * Do not share a '' |
| - | * Normally, call '' | + | * When '' |
| - | * Do not use the default '' | + | |
| - | * Explicitly using Timer1, Timer3, Timer4 or Timer5 may conflict with PWM, analog output or high-speed counter functions using that timer. | + | |
| - | * Configure only one '' | + | |
| - | * Defining an ISR for the same timer directly in the sketch may conflict with '' | + | |
| - | * '' | + | |
| ===== Built-in Commands in the Same Category ===== | ===== Built-in Commands in the Same Category ===== | ||
en-us_commands/reference/itmr.1788796403.txt.gz · Last modified: by 127.0.0.1
