XStore
View Categories

NORVI EX-ANQ 04 – USER GUIDE

5 min read

Programming #

NORVI-EX-ANQ 04 uses I2C communication for Analog Outputs on devices with address configuration support. The addresses of the devices can be configured with the DIP switches at the bottom of the controller. It can Daisy chain up to 8 expansion modules. NORVI-EX-ANQ 04 module communicates with a host controller through an I2C. This allows the host controller to set output values for each channel.

Expansion Port #

The expansion port of the NORVI IIOT Controllers can be utilized for external sensor connections where raw GPIO connections are required or they can be used to plug NORVI Expansion Modules. Connect the left side expansion port of the NORVI expansion modules and the right side expansion port of the main module using an expansion cable to connect the NORVI expansion modules.

I2C Address Setting #

In the NORVI Analog output Expansion on modules with Address configuration options, the I2C Address of the expansion module can be configured by switching DIP Switches at the bottom of the expansion module. The device can be configured in 4, I2C addresses using the 4, switches.

4 – 20 mA Analog Outputs #

Wiring Analog Outputs #

The Analog output of the NORVI Analog output Expansion should be connected to the ground input of the controller. I2C Master can command the NORVI Analog Output expansion to output analog values.


The NORVI Analog Output expansion module provides four separate analog output channels that can be configured from the I2C. Each channel can independently generate an analog voltage or current signal.

Reading Analog Outputs #

Reading the relevant I2C address of the ADC gives the value of the Analog Input.

Programming Analog Inputs  #

The following example code reads the analog outputs on the NORVI analog output expansion. This example code is configured to get a 0 – 10V output from the first two channels and a 0 – 20mA output from the last two.

#include "Wire.h"
#define I2C_DEV_ADDR 0x5F
uint32_t i = 0;
unsigned int send_value = 2000;

void write_channel(byte device_address, unsigned int channel, unsigned int value) {
  unsigned int tft_value = 0;
  Wire.beginTransmission(device_address);
  Wire.write(1 + (channel * 2)); // Pointer Register
  tft_value = value >> 8;
  Wire.write(tft_value); //  Register [1] Config
  tft_value = value & 0xFF;
  Wire.write(tft_value); //  Register [1] Config
  Wire.endTransmission();
}

void config_dac(byte device_address, unsigned int c1, unsigned int c2, unsigned int c3, unsigned int c4) {
  unsigned int tft_value = 0;
  Wire.beginTransmission(device_address);
  Wire.write(0x01); // Pointer Register
  tft_value = c4 << 3;
  tft_value = tft_value | (c3 << 2);
  tft_value = tft_value | (c2 << 1);
  tft_value = tft_value | c1;
  Serial.print("BINARY PRINT  ");
  Serial.println(tft_value, BIN);
  Wire.write(tft_value); //  Register [1] Config
  Wire.endTransmission();
}

void setup() {
  Serial.begin(115200);
  Serial.setDebugOutput(true);
  Wire.begin(16, 17);
  delay(200);
  SCAN();                 // Scan and Print I2C Address of connected devices
  delay(1000);
  config_dac(I2C_DEV_ADDR,0, 0, 1, 1);
  send_value = 2000;      }

void loop() {
  config_dac(I2C_DEV_ADDR, 0, 0, 1, 1);
  for (int i = 1; i < 5; i++) {
    write_channel(I2C_DEV_ADDR, i, send_value); // Write channel sends the ADC value to the channel
    Serial.println(i);
    Serial.println(send_value);
    delay(100);
  }
  send_value = send_value + 100; // Increase output value by 100 each cycle.
  if (send_value > 4095)
    send_value = 0; // If the value exceeds 4095 , reset the value to zero
  delay(5000);
}
void SCAN() {
  byte error, address;
  int nDevices;
  Serial.println("Scanning...");
  nDevices = 0;
  for (address = 1; address < 127; address++) {
    Wire.beginTransmission(address);
    error = Wire.endTransmission();
    if (error == 0) {
      Serial.print("I2C device found at address 0x");
if (address < 16)
        Serial.print("0");
Serial.println(address, HEX);
      nDevices++;
    } else if (error == 4) {
      Serial.print("Unknown error at address 0x");
      if (address < 16)
        Serial.print("0");
      Serial.println(address, HEX);
    }
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found");
  else
    Serial.println("done");
}

Example Code Functions #

write_channel ()
DescriptionAddress: I2C address of the Analog Output expansion. Channel: Number of the channel that output should be updated. Value: a 12-bit value to be written to the analog channel.
Syntaxwrite_channel (address, channel, value)
ParametersAddress: I2C address of the Analog Output expansion. Channel: Number of the channel that output should be updated. Value: a 12bit value to be written to the analog channel.
ReturnsNothing
config_dac ()
DescriptionThis function configures all the four channels of the I2C expansion.
SyntaxThis function configures all four channels of the I2C expansion.
ParametersAddress: I2C address of the Analog Output expansion.
Channel 1: output configuration of channel 10 = 0 – 10V Output1 = 4 – 20mA Output
Channel 2: output configuration of channel 20 = 0 – 10V Output1 = 4 – 20mA Output
Channel 3: output configuration of channel 30 = 0 – 10V Output1 = 4 – 20mA Output
Channel 4: output configuration of channel 40 = 0 – 10V Output1 = 4 – 20mA Output
ReturnsNothing

 I2C Control From a master #

Control Register
Bit PositionDescriptionValues
B7
B6
B5
B4
B3Analog Channel D Config0 = 0 – 10V          1 = 4 – 20mA
B2Analog Channel C Config0 = 0 – 10V          1 = 4 – 20mA
B1Analog Channel B Config0 = 0 – 10V          1 = 4 – 20mA
B0Analog Channel A Config0 = 0 – 10V          1 = 4 – 20mA
Status Register
Bit PositionDescription0 – 10V Output Mode4 – 20mA Output Mode
B7AVDD Power Supply Monitor Error.
B6Power Supply Monitor Error
B5Charge pump error detected
B4High temperature detected
B3Channel D Status1 = Short Circuit 0 = Normal1 = Open Circuit 0 = Normal
B2Channel C Status1 = Short Circuit 0 = Normal1 = Open Circuit 0 = Normal
B1Channel B Status1 = Short Circuit 0 = Normal1 = Open Circuit 0 = Normal
B0Channel A Status1 = Short Circuit 0 = Normal1 = Open Circuit 0 = Normal
Bit PositionB7B6B5B4B3B2B1B0
Analog Output 1

12 bit ADC Code Last 12 bits will affect the output                                                          
4095 = 10V / 20mA 0 = 0V / 0mA
Analog Output 1
Analog Output 1
Analog Output 1