en-us_commands:reference:analogread2avgf
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| en-us_commands:reference:analogread2avgf [2026/09/08 00:53] – 바깥 편집 127.0.0.1 | en-us_commands:reference:analogread2avgf [2026/09/14 20:30] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 14: | Line 14: | ||
| ===== Example ===== | ===== Example ===== | ||
| + | |||
| + | Connect an X input module to MPAINO-8A8R(T) and select **Analog Input Module → X**. Set CH0 DIP switches 20mA and GND to ON, then connect the 4–20mA signal. | ||
| <code cpp> | <code cpp> | ||
| Line 21: | Line 23: | ||
| void loop() { | void loop() { | ||
| - | | + | |
| - | int32_t filtered2 = analogRead2Avg(0, | + | |
| - | float filtered2f | + | Serial.println(F(" |
| - | | + | } else { |
| - | + | | |
| - | if (raw2 == ANALOG_READ2_ERROR || filtered2 == ANALOG_READ2_AVG_ERROR || | + | |
| - | filtered2f | + | |
| - | currentmA == (float)ANALOG_READ2_ERROR) { | + | |
| - | Serial.println(" | + | |
| - | | + | |
| - | return; | + | |
| } | } | ||
| - | |||
| - | int32_t percent = Iscale((int32_t)raw2, | ||
| - | |||
| - | IanalogWrite2(0, | ||
| - | IanalogWrite2f(1, | ||
| - | |||
| - | Serial.print(" | ||
| - | Serial.println(raw2); | ||
| - | Serial.print(" | ||
| - | Serial.println(filtered2); | ||
| - | Serial.print(" | ||
| - | Serial.println(filtered2f, | ||
| - | Serial.print(" | ||
| - | Serial.println(percent); | ||
| - | Serial.print(" | ||
| - | Serial.println(currentmA, | ||
| - | |||
| delay(500); | delay(500); | ||
| } | } | ||
| Line 56: | Line 35: | ||
| ===== Precautions ===== | ===== Precautions ===== | ||
| - | * Set the module DIP switches | + | * Set the MPAINO X module |
| * An input of approximately 3.6~4.0mA returns the normal value '' | * An input of approximately 3.6~4.0mA returns the normal value '' | ||
| * Error values help detect open circuits. The user must implement final alarms and safety actions in the program. | * Error values help detect open circuits. The user must implement final alarms and safety actions in the program. | ||
en-us_commands/reference/analogread2avgf.1788796395.txt.gz · Last modified: by 127.0.0.1
