CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

ADC what one to use?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Thomas Hauff
Guest







ADC what one to use?
PostPosted: Fri Nov 22, 2002 8:34 pm     Reply with quote

I need an ADC with serial interface and a min 12 bits and 14 would be better.
I’m looking at the Microchip MCP3201, MCP3301 and the TI TLC3541.
I will be using the 16F876 for the MCU.
Has any one used the on board SPI hardware with the above ADC?
I don’t think that the hardware SPI will work for the TI ADC.
Does any one have a simple read only SPI driver that I can look at to see if I can make it work for the TI ADC?
I have looked at the CCS drivers and programs, but I was looking for some thing that some one has used and knows works at least to a point.

Thank to all of you in advance for the help!
___________________________
This message was ported from CCS's old forum
Original Post ID: 9304
Hans Wedemeyer
Guest







Re: ADC what one to use?
PostPosted: Fri Nov 22, 2002 11:13 pm     Reply with quote

I just looked at the data sheet for the TI TLC3541.
Page 12 says if you ie FS to VDD it is a normal SPI interafce.
The only issues if make sure you initialkize the PIC SPI to match the Ti chip, CCS does not cater for all possible SPI modes.
It a neat ADC and the data sheet implies the SPI can run at 15MHZ! that mean you should be able to ru the PIC at any SPI frequency even if the crystal is 20MHz !

Study the data sheet and look at timing for sample and hold. If your PIC can meet that the rest should be no problem at all.
___________________________
This message was ported from CCS's old forum
Original Post ID: 9307
Charlie U
Guest







Re: ADC what one to use?
PostPosted: Sat Nov 23, 2002 10:39 am     Reply with quote

:=I need an ADC with serial interface and a min 12 bits and 14 would be better.
:=I’m looking at the Microchip MCP3201, MCP3301 and the TI TLC3541.
:=I will be using the 16F876 for the MCU.
:=Has any one used the on board SPI hardware with the above ADC?
:=I don’t think that the hardware SPI will work for the TI ADC.
:=Does any one have a simple read only SPI driver that I can look at to see if I can make it work for the TI ADC?
:=I have looked at the CCS drivers and programs, but I was looking for some thing that some one has used and knows works at least to a point.
:=
:=Thank to all of you in advance for the help!

I have used the MCP3201 with the 'C74, the 'F874, and the 'F877, and they work quite well. I found that CCS changed the setup_spi() function between 2.xxx and 3.xxx. I've tried to get them to change it back, to make some sense, but they say it's working for most people. With 3.xxx the basic setup parameters SPI_L_TO_H and SPI_H_TO_L set the spi to modes 0,1 and 1,0, neither of which will work with the MCP3201.

What I've done, is create a .h file with new definitions to replace the following:

#define SPI_L_TO_H 0
#define SPI_H_TO_L 0x10
#define SPI_SAMPLE_AT_END 0x8000
#define SPI_XMIT_L_TO_H 0x4000

My file includes:

#define SPI_MODE_0_0 0x4000
#define SPI_MODE_0_1 0x0000
#define SPI_MODE_1_0 0x0010
#define SPI_MODE_1_1 0x4010

Actually, you can just add these to a header file.

Then, my setup looks like this:

setup_spi(SPI_MASTER|SPI_MODE_1_1|SPI_CLK_DIV_4|SPI_SS_DISABLED);

You will also need a good reference for the ADC. There are many, but I've used a couple from Linear Tech like the LT1634 and LT1258. I use the 4.096V references.

I use one pin for the chip select, and then just use spi_read and spi_write to move data into and out of the chip. I'll let you work out the details of your program, but if you get stuck, post another question and I, and many others I'm certain, will respond.

Also if you have enough time in you application, look at filtering the data by some sort of averaging algorithm to smooth the data.
___________________________
This message was ported from CCS's old forum
Original Post ID: 9317
Charlie U
Guest







Re: ADC what one to use?
PostPosted: Sat Nov 23, 2002 11:47 am     Reply with quote

:=:=I need an ADC with serial interface and a min 12 bits and 14 would be better.
:=:=I’m looking at the Microchip MCP3201, MCP3301 and the TI TLC3541.
:=:=I will be using the 16F876 for the MCU.
:=:=Has any one used the on board SPI hardware with the above ADC?
:=:=I don’t think that the hardware SPI will work for the TI ADC.
:=:=Does any one have a simple read only SPI driver that I can look at to see if I can make it work for the TI ADC?
:=:=I have looked at the CCS drivers and programs, but I was looking for some thing that some one has used and knows works at least to a point.
:=:=
:=:=Thank to all of you in advance for the help!
:=
:=I have used the MCP3201 with the 'C74, the 'F874, and the 'F877, and they work quite well. I found that CCS changed the setup_spi() function between 2.xxx and 3.xxx. I've tried to get them to change it back, to make some sense, but they say it's working for most people. With 3.xxx the basic setup parameters SPI_L_TO_H and SPI_H_TO_L set the spi to modes 0,1 and 1,0, neither of which will work with the MCP3201.
:=
:=What I've done, is create a .h file with new definitions to replace the following:
:=
:=#define SPI_L_TO_H 0
:=#define SPI_H_TO_L 0x10
:=#define SPI_SAMPLE_AT_END 0x8000
:=#define SPI_XMIT_L_TO_H 0x4000
:=
:=My file includes:
:=
:=#define SPI_MODE_0_0 0x4000
:=#define SPI_MODE_0_1 0x0000
:=#define SPI_MODE_1_0 0x0010
:=#define SPI_MODE_1_1 0x4010
:=
:=Actually, you can just add these to a header file.
:=
:=Then, my setup looks like this:
:=
:=setup_spi(SPI_MASTER|SPI_MODE_1_1|SPI_CLK_DIV_4|SPI_SS_DISABLED);
:=
:=You will also need a good reference for the ADC. There are many, but I've used a couple from Linear Tech like the LT1634 and LT1258. I use the 4.096V references.
:=
:=I use one pin for the chip select, and then just use spi_read and spi_write to move data into and out of the chip. I'll let you work out the details of your program, but if you get stuck, post another question and I, and many others I'm certain, will respond.
:=
:=Also if you have enough time in you application, look at filtering the data by some sort of averaging algorithm to smooth the data.

Ooops. I used the 4 channel version of the ADC which is MCP3204.
___________________________
This message was ported from CCS's old forum
Original Post ID: 9320
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

Re: ADC what one to use?
PostPosted: Sat Nov 23, 2002 3:13 pm     Reply with quote

Look at these sites for ADC's they have some very good products.

<a href="http://www.linear.com/" TARGET="_blank">http://www.linear.com/</a>
<a href="http://www.analog.com/" TARGET="_blank">http://www.analog.com/</a>

When you get ready to impliment SPI I have found using a software solution can be better than a hardware solution in terms of code size and speed of execution. (Unless you have to run at a slow SPI speed)


This code is for the ADC2402

/*-------------------------------------------------------------------
Read ADC
-------------------------------------------------------------------*/
OUTPUT_LOW(PIN_A3); //ADC CS low to verify reading is ready
if (!input(PIN_A2)) //ADC SDO low = sample ready
{
ADCreading = 0;
OUTPUT_HIGH(PIN_A1);
OUTPUT_LOW(PIN_A1);
Channel = input(PIN_A2); // read input channel
OUTPUT_HIGH(PIN_A1);
OUTPUT_LOW(PIN_A1);
OUTPUT_HIGH(PIN_A1);
OUTPUT_LOW(PIN_A1);
for (x= 1; x<= 24; x++)
{
OUTPUT_HIGH(PIN_A1);
OUTPUT_LOW(PIN_A1);
shift_left(&ADCreading,4,input(PIN_A2));
}
OUTPUT_HIGH(PIN_A3);
if (Channel) ADCreading1= ADCreading;
else ADCreading0 = ADCreading;
}
OUTPUT_HIGH(PIN_A3); //ADC CS high to begin new reading
___________________________
This message was ported from CCS's old forum
Original Post ID: 9325
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group