Table of Contents

IanalogWrite2f()

IanalogWrite2f() converts a user floating-point value to the 4~20mA output range.

IanalogWrite2f command operation flow

void IanalogWrite2f(uint8_t ch, float min, float max, float value)

Commands

Command Arguments Return Value Operation
IanalogWrite2f(ch, min, max, value) uint8_t ch — MPINO: analog pin such as A0; MPAINO: overall module channel number starting at 0
float min
float max
float value — Output value expressed in the min ~ max range
void Converts a user floating-point value to the 4~20mA output range.

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 I+ and .

void setup() {}
 
void loop() {
  IanalogWrite2f(0, 0.0F, 100.0F, 25.0F);  // Scale 25% to the 4–20mA range and output about 8mA.
  delay(500);
}

Precautions

Built-in Commands in the Same Category

← Built-in Command List