You have no items in your shopping cart.

Subtotal: 0.00

8051 Development Board

The 8051 Development board is specifically designed to help students to master the required skills in the area of embedded systems. The kit is designed in such way that all the possible features of the microcontroller will be easily used by the students. The kit supports in system programming (ISP) which is done through serial port.

NXP’s 8051 (AT89V51RD2), 8051 Development Kit is proposed to smooth the progress of developing and debugging of various designs encompassing of speed 8-bit Microcontrollers.

ADC (Analog to Digital Converter):

The Microchip Technology Inc. MCP3202 is a successive approximation 12-bit Analog-to-Digital (A/D) Converter with on-board sample and hold circuitry. The MCP3202 is programmable to provide a single pseudo-differential input pair or dual single-ended inputs. Differential Nonlinearity (DNL) is specified at ±1 LSB, and Integral Nonlinearity (INL) is offered in ±1 LSB (MCP3202-B) and ±2 LSB (MCP3202-C) versions. Communication with the device is done using a simple serial interface compatible with the SPI protocol. The device is capable of conversion rates of up to 100ksps at 5V and 50ksps at 2.7V.

Pin Assignment with 8051

 

SPI - ADC

8051 Lines

SPI - ADC

MCP 3202

CS

P2.4



SPI - ADC

CLK

P2.5

MISO

P2.6

MOSI

P2.7

Make switch SW28 to ADC label marking position.



SPI - ADC

 

Circuit Diagram to SPI ADC with 8051



Circuit Diagram to SPI ADC with 8051

Source Code

The Interfacing SPI ADC with 8051 program is very simple and straight forward, that uses a delay procedure loop based software delay. In C programs you cannot be sure of delay, because it depends on compiler how it optimizes the loops as soon as you make changes in the options the delay changes.

C Program to SPI ADC using 8051

***************************************************************************************

Title : Program to read digital value

***************************************************************************************

#include

#include

sbit ADC_CS = P2^4;

sbit ADC_CLK = P2^5;

sbit ADC_DO = P2^6;

sbit ADC_DI = P2^7;

void InitSerial(void);

void write_adc_byte(char data_byte);

unsigned int ReadADC(unsigned char channel);

void DelayMs(unsigned int count);

// Initialize serial port

//---------------------------------------

void InitSerial(void) { SCON = 0x52;

// setup serial port control TMOD = 0x20;

// hardware (9600 BAUD @11.05592MHZ) TH1 = 0xFD;

// TH1 TR1 = 1;

// Timer 1 on

}

//---------------------------------------

// read analog from ADC

// Single end mode(2 channel)

//---------------------------------------

unsigned int ReadADC(unsigned char channel)

{

unsigned char i,k;

unsigned int AdcResult;

// 12 bit ADC_CS=0;

// Active chip select k++;

// Delay about 1 uS ADC_CLK=0;

// make clock low first

k++;

k++;

channel = channel? 0xA0 : 0xD0;

//Refer Datasheet of MCP3202 - in Single Mode for Independent Channel Processing

k++;

k++;

// delay about 2 uS /*--- write command 4 bit ----------*/ for(i=0;i< 4;i++)

{

ADC_DI = (channel & 0x80) != 0;

channel<<=1;

ADC_CLK=1;

k++;k++;

// delay about 2 uS ADC_CLK=0;

}

k++;k++;

// delay about 2 uS ADC_CLK=1; k++;k++;

// delay about 2 uS ADC_CLK=0; k++;k++;

// delay about 2 uS /* --- read ADC result 12 bit -------- */ AdcResult=0;

for(i=0;i<12;i++)

{

ADC_CLK=1; k++;k++;

/// delay about 2 uS AdcResult<<=1; AdcResult=AdcResult | (ADC_DO & 0x01);

ADC_CLK=0; k++;k++;

/// delay about 2 uS

}

ADC_CS=1; return(AdcResult);

}

//---------------------------------------

// Delay mS function

//---------------------------------------

void DelayMs(unsigned int count)

{

// mSec Delay 11.0592 Mhz unsigned int i;

while(count)

{

i = 115;

while(i>0)

i--;

count--;

}

}

//---------------------------------------

// Main program

//------------------------------------rminal while(1)

{

CH0 = ReadADC (0);

DelayMs (200);

printf("Ch 0 : %4d %cF ", CH0/2, 176);

DelayMs (200);

CH1 = ReadADC (1);

DelayMs (200);

printf("Ch 1 : %4d \r", CH1);

DelayMs(100);

DelayMs(500);

}

}