User Tools

Site Tools

한국어

cubloc:mcp3202_12_bit_a_d_conversion:index

MCP3202 12 Bit A/D Converter

The Cubloc has a 10 bit A/D converter. For greater resolution, meaning greater precision, you can use a chip like the MCP3202. The MCP3202 is a 12 bit A/D converter that supports the SPI protocol. Here we will show you how to implement this 12 bit A/D converter into your project.

Pin Function I/O DirectionExplanation
CS Chip Select Input Low for data communication
CLK Clock Input Clock signal
DI Data Input Input Data input from MCP3202
DO Data Output Output Data output from MCP3202
Const Device = CB220
Const iodi = 7
Const iodo = 6
Const ioclk = 5
Const iocs = 4
Dim i As Byte
Dim ad As Integer
Do
  Low iocs
  i = &b1011 'Channel 0
  'i = &b1111 'Channel 1
  Shiftout ioclk,iodi,0,i,4
  ad = Shiftin(ioclk,iodo,3,12)
  High iocs
  Debug Dec ad,cr
  Delay 100
Loop

The MCP3202 will convert voltage coming into CH0 and CH1 to a digital value and retain it. SPI communication can then be used to read the value from the MCP3202.

The voltage measured on the MCP320 CH0 and CH1 pins must not be greater than the voltage supplied to the MCP3202. The result of the A/D conversion is displayed in the debug window.

cubloc/mcp3202_12_bit_a_d_conversion/index.txt · Last modified: 2017/04/13 18:11 by COMFILE Technology