Using MCP3208 with Arduino DUE
hello there!
this first time posting here, please forgive me if forget stuff.
i got problem using adc mcp3208 arduino due.
i want read out flexsensor using voltage divider , said adc. kinda working, value shaking lot , makes impossible read out value.
now read can add coupling capacitators. honest quite bad @ electronics , don't (not mcp datasheet) how use properly. have suggestions or maybe layouts can use orientation?
i not using library, code use read out adc this:
i didn't make myself, got here: https://github.com/oksbwn/mcp3208_arduino/blob/master/mcp3208_with_arduino.ino
this part of current layout. powering (vdd) mcp 5v spi pin header, not 3.3v.
would happy if maybe has got few suggestions!
this first time posting here, please forgive me if forget stuff.
i got problem using adc mcp3208 arduino due.
i want read out flexsensor using voltage divider , said adc. kinda working, value shaking lot , makes impossible read out value.
now read can add coupling capacitators. honest quite bad @ electronics , don't (not mcp datasheet) how use properly. have suggestions or maybe layouts can use orientation?
i not using library, code use read out adc this:
code: [select]
#include <spi.h>
#define _cs_pin_ 52 //pin 10 defined cs pin.
void setup()
{
serial.begin(115200); //initalize serial port print analog readings mcp3208 onto teh terminal.
pinmode(_cs_pin_,output); //pin 10 acting output cs output pin.
digitalwrite(_cs_pin_,high);
spi.begin(); //intialize spi port
spi.setclockdivider(52, 84);
}
void loop()
{
serial.println(readadc(4)); //reads cahnnel 0 mcp3208 , prints value. change if u want t o read other cahnnel.
delay(2000); //delay
}
uint16_t readadc(int channel)
{
uint16_t output;
byte channelbits = channel<<6;
//if(channel>3)
//select adc
digitalwrite(_cs_pin_, low); //select connected mcp3208 pulling _cs_pin_ low.
if(channel>3)
spi.transfer(b00000111); //defines single mode of operation adc. d2=1 start bit. d1=1 sinfgle ended mode d0=0 channel 0-3. 1 channel 4-7
else
spi.transfer(b00000110);
byte msb = spi.transfer(channelbits); //transfers 2nd byte mcu mcp3208 returns msb of read data.
byte lsb = spi.transfer(0x00);//transfers 3rd byte mcu mcp3208 returns lsb of read data.
digitalwrite(_cs_pin_,high); //deselect connected mcp3208 pulling _cs_pin_ high.
msb = msb & b00001111; // make 4 higher bits of msb 0 12 bit resolution provided mcp3208
output = msb<<8 | lsb; //combine msb lsb form 12 bit analog read value.
return output; //output value
}
i didn't make myself, got here: https://github.com/oksbwn/mcp3208_arduino/blob/master/mcp3208_with_arduino.ino
this part of current layout. powering (vdd) mcp 5v spi pin header, not 3.3v.
would happy if maybe has got few suggestions!
not coupling capacitors decoupling capacitors. chips must have 0.1uf ceramic capacitor between power , ground.
connecting analog , digital grounds on chip not taking them different ground pins on arduino.
also capacitor input analogue ground close chip help.
if using solderless bread board noise in readings.
connecting analog , digital grounds on chip not taking them different ground pins on arduino.
also capacitor input analogue ground close chip help.
if using solderless bread board noise in readings.
Arduino Forum > Using Arduino > General Electronics > Using MCP3208 with Arduino DUE
arduino
Comments
Post a Comment