en-us_commands:reference:ianalogwrite2f
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en-us_commands:reference:ianalogwrite2f [2026/09/07 23:35] – 바깥 편집 127.0.0.1 | en-us_commands:reference:ianalogwrite2f [2026/09/14 20:30] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 14: | Line 14: | ||
| ===== Example ===== | ===== Example ===== | ||
| + | |||
| + | Connect a Y output module to MPAINO-8A8R(T) and select **Analog Output Module → Y**. Set the CH0 DIP switch to OFF and measure the 4–20mA output at '' | ||
| <code cpp> | <code cpp> | ||
| - | void setup() { | + | void setup() {} |
| - | Serial.begin(115200); | + | |
| - | } | + | |
| void loop() { | void loop() { | ||
| - | | + | |
| - | int32_t filtered2 = analogRead2Avg(0, 5); // Return the integer average of 4–20mA input values. | + | |
| - | float filtered2f = analogRead2Avgf(0, 5); // Return the floating-point average of 4–20mA input values. | + | |
| - | float currentmA = IanalogRead2f(0, 4.0F, 20.0F); // Map the 4–20mA | + | |
| - | + | ||
| - | if (raw2 == ANALOG_READ2_ERROR || filtered2 == ANALOG_READ2_AVG_ERROR || | + | |
| - | filtered2f == (float)ANALOG_READ2_AVG_ERROR || | + | |
| - | currentmA == (float)ANALOG_READ2_ERROR) { | + | |
| - | Serial.println(" | + | |
| - | delay(500); | + | |
| - | 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 28: | ||
| ===== Precautions ===== | ===== Precautions ===== | ||
| - | * Set the module DIP switches | + | * Set the MPAINO Y 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. | ||
| Line 68: | Line 40: | ||
| * The analog output circuit requires an external 12~24V supply. USB power alone may not provide normal output. | * The analog output circuit requires an external 12~24V supply. USB power alone may not provide normal output. | ||
| * Verify actual current input/ | * Verify actual current input/ | ||
| + | |||
| + | ===== Built-in Commands in the Same Category ===== | ||
| + | |||
| + | * [[: | ||
| + | * [[: | ||
| [[: | [[: | ||
en-us_commands/reference/ianalogwrite2f.1788791733.txt.gz · Last modified: by 127.0.0.1
