Hi,
I am using the Teensy 3.6 to talk to the XR18910 amplifier chip(DataSheet). I have the code shown below -
Basically, i am trying to control the different channels from this chip by sending to the appropriate registers and also to select the gain of the amplifier for each channel. Although i am not able to read from the 3 channels as you can see below. Could you kindly assist me in telling me where i am wrong?
I am using the Teensy 3.6 to talk to the XR18910 amplifier chip(DataSheet). I have the code shown below -
Basically, i am trying to control the different channels from this chip by sending to the appropriate registers and also to select the gain of the amplifier for each channel. Although i am not able to read from the 3 channels as you can see below. Could you kindly assist me in telling me where i am wrong?
Code:
#include <TimeLib.h>
#include <WProgram.h>
//#include <Wire.h>
#include <i2c_t3.h>
int StrainInput1 = A0;
float strainValue1 = 0; // variable to store the value coming from the sensor
float strainValue2 = 0;
float strainValue3 = 0;
String sensorOutput;
void strainOutput();
void setup() {
Wire.begin(I2C_MASTER, 0x00, I2C_PINS_18_19, I2C_PULLUP_EXT, 400000);
Wire.setClock(400000L); // Set i2C speed to 400Khz
Serial.begin(115000); // open the serial port at 115200 bps
}
void loop() {
Wire.beginTransmission(0x66); //Address of device is 0x66
Wire.write(0x06); // Gain Select
Wire.write(0x00); // Gain Choice
Wire.write(0x10); // Call Channel 1
strainValue1 = analogRead(StrainInput1);
Wire.endTransmission();
Wire.beginTransmission(0x66);
Wire.write(0x06); // Gain Select
Wire.write(0x04); // Gain Choice
Wire.write(0x12); // Call Channel 2
strainValue2 = analogRead(StrainInput1);
Wire.endTransmission();
Wire.beginTransmission(0x66);
Wire.write(0x06); // Gain Select
Wire.write(0x07); // Gain Choice
Wire.write(0x14); // Call Channel 3
strainValue3 = analogRead(StrainInput1);
Wire.endTransmission();
strainOutput();
delay(100);
}
void strainOutput()
{
sensorOutput ="";
sensorOutput +=strainValue1;
sensorOutput +=',';
sensorOutput +=strainValue2;
sensorOutput +=',';
sensorOutput +=strainValue3;
Serial.println(sensorOutput);
}