User Tools

Site Tools


en-us_commands:reference:ianalogwriteinit

This is an old revision of the document!


IanalogWriteInit()

IanalogWriteInit() sets the maximum, minimum and mode of the MPAINO analog output.

IanalogWriteInit command operation flow

void IanalogWriteInit(uint8_t ch, uint32_t maxValue = 65535UL, uint32_t minValue = 0, bool mode = false)

Commands

Command Arguments Return Value Operation
IanalogWriteInit(ch, maxValue, minValue, mode) uint8_t ch
uint32_t maxValue = 65535UL
uint32_t minValue = 0
bool mode = false
void Sets the maximum, minimum and mode of the MPAINO analog output.

Example

void setup() {
  Serial.begin(115200);
  IanalogWriteInit(0, 1000, 0, false);  // Set the maximum, minimum and mode of MPAINO analog outputs.
}
 
void loop() {
  const int32_t demand = IanalogRead(0, 0, 1000);  // Map the analog input value to the specified integer range.
  IanalogWrite(0, 0, 1000, demand);  // Map the user's integer value to the analog output range and output it.
  analogWrite2(1, constrain(demand, 0, 1000));  // Output a raw value for 4–20mA conversion on the specified channel.
  delay(20);
}

Precautions

  • Match the module DIP switches, external power supply and output range.
  • Do not configure these together with PWM functions sharing the same timer.
  • Do not output values to uninitialized channels.
  • Currently, MPAINO Y analog output supports channels up to 0~11; do not use 12~15.
  • analogWriteInit(), analogWriteFreq() and analogWriteMax() are for Y analog output channels and must not be used for high-speed pulse channels 20~31.
  • Do not use high-speed pulse GPIO numbers 130~141 with analogWrite().

Built-in Commands in the Same Category

en-us_commands/reference/ianalogwriteinit.1788796397.txt.gz · Last modified: by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki