Hi there,
My project requires me to collect and log data from a laser micrometer (Boyut Teknik - Lazer 2008) using an ADC (MCP3428 4 channel 0-10V) at 16 bit resolution, continuous conversion, channel 1 with a gain of 1. The ADC communicates with an Arduino UNO with I2C and the Arduino is connected to my laptop through USB. The ADC is powered by a 12 V power supply and the arduino through the USB. The laser has its own connection to mains.
My issue is that when the laser reads a diameter of 0, the raw ADC value seems to differ with each day. A 0 mm reading could return 9500, 6000, 4000, 16 or 17 on different days. As you measure rods of different diameters, 122 for 0 mm could become 10,000,000 for a reading of 3.987 mm one day, whilst for another day, 0mm returns 16 and 10.5 mm returns 7030.
Another problem is that some days it fluctuates. For example, yesterday 0mm was somewhere between 5960 and 7200. Last year, just before the holidays, 0mm was a flat 17.
What could potentially be the reason for this inconsistency? The micrometer appears to be okay because the voltage it outputs is steady when tested with a multimeter. The issue persists as the adc continues to run and warms up.
Please find my code and relevant data sheets attached below. This is my first post, so if I am missing some details, please let me know and I will do my best to provide it.
Thanks!
My arduino code:
// Distributed with a free-will license.
// Use it any way you want, profit or free, provided it fits in the licenses of its associated works.
// MCP3428
// This code is designed to work with the MCP3428_I2CADC I2C Mini Module available from ControlEverything.com.
// https://www.controleverything.com/content/Analog-Digital-Converters?sku=MCP3428_I2CADC#tabs-0-product_tabset-2
// github source
// https://github.com/ControlEverythingCommunity/MCP3428
#include<Wire.h>
// MCP3428 I2C address is 0x68(104)
#define Addr 0x68
double zero = 0.0;
void setup()
{
// Initialise I2C communication as MASTER
delay(1000);
Wire.begin();
// Start serial communication and set baud rate = 115200
Serial.begin(115200);
Serial.flush();
delay(1000);
// Start I2C Transmission
Wire.beginTransmission(Addr);
// Select configuration command
// Continuous conversion mode, Channel-1, 16-bit resolution
delay(1000);
Wire.write(0x18);
// Stop I2C Transmission
Wire.endTransmission();
Serial.flush();
zero = getRawADC();
}
void loop()
{
unsigned int data[2];
int ACK = 0;
double diam = 0.0;
double avg = 0.0;
// int samples = 529;
int samples = 1;
double raw_adc = 0.0;
for ( int cnt = 0; cnt < samples; cnt++) {
raw_adc = getRawADC();
// raw_adc = getRawADC();
avg = avg + raw_adc;
}
avg = avg / samples;
diam = 0.0031 * avg - 19.805;
Serial.println(raw_adc, 3);
Serial.flush();
}
double getRawADC() {
double rawADC = 0.0;
unsigned int data[2];
// Request 2 bytes of data
Wire.requestFrom(Addr, 2);
// Read 2 bytes of data
if (Wire.available() == 2)
{
data[0] = Wire.read();
data[1] = Wire.read();
}
// Convert the data to 16-bits
rawADC = (data[0] & 0xFF) * 256 + data[1];
if (rawADC > 32767)
{
rawADC -= 65534;
}
return rawADC;
}
Boyut Lazer 2008 Data Sheet.pdf (377 KB)
MCP3428-5 Data Sheet.pdf (716 KB)
