I am currently in a project where i am building a universal calibrator with mV, mA and RTD sourcing and sinking. Everything is displayed on LCD. I successfully did it with MCP3421 but later i was not getting 0.01 Volts accuracy with it, so i decided to go for Mcp3551. Now i have interfaced it with 2.5V Vref. I used its library and while testing on serial, i am getting adc values. I actually want to convert these adc values to the respective mV. My total millivolt input range is 0 to 200 mV which i am feeding to ADC. I will upload my code soon. I need some suggestions getting value in millivolts.
My Code :
/*
This example demonstrate the usage of the A/D Converter with MCP3551 library.
*/
#include <MCP3551.h>
#include <SPI.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
const int MCPPin = 10;
double adc;
double vin = 0;
/*
Connect SCK to CLK (pin 13 on Uno)
Connect SDO/!RDY to MOSI (pin 12 on Uno)
Connect !CS to MCPPIN (pin 10 on Uno)
*/
//Create an instance of MCP3551 connected to the MCPPIN
MCP3551 myADC(MCPPin);
void setup() {
Serial.begin(9600);
lcd.begin(16, 2);
}
void loop() {
lcd.print(" UniCal");
if(myADC.getCode())
{
adc=myADC.byteCode;
adc= adc*2;
delay(1000);
float vin = (adc*(5/419304));
//vin= (4194304*adc)/5;
Serial.println("ADC Value "); Serial.println(adc);
//vin=vin*1000;
Serial.print("Voltage "); Serial.println(vin);
lcd.setCursor(0, 1);
lcd.print("mV:");
lcd.print(vin,3);
lcd.print(" ");
delay(500);
}
}
Thank you.