View previous topic :: View next topic |
Author |
Message |
das Guest
|
24-bit ADC |
Posted: Thu Feb 05, 2009 9:35 pm |
|
|
Anyone written a bit banging routine to drive a 24-bit ADC like the ADS1232 or ADS1234? |
|
|
das Guest
|
ADC |
Posted: Thu Feb 05, 2009 9:40 pm |
|
|
Specifically I am using an old PIC16F877 with an older version of the CCS compiler. Just FYI... |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Fri Feb 06, 2009 12:08 am |
|
|
CCS C built-in software-SPI can do. |
|
|
languer
Joined: 09 Jan 2004 Posts: 144 Location: USA
|
|
Posted: Fri Feb 06, 2009 1:07 am |
|
|
Look at ADS8320.C and/or LTC1298.C under "drivers" folder. |
|
|
das Guest
|
ADC 24 |
Posted: Wed Feb 11, 2009 7:55 am |
|
|
The software drivers for the device operate quite differently than the ADS1232 and 1234. I would prefer to drive it with bit banging (easier to debug). What I am finding is strange problems where when I use output_high(PIN_XX) the pin voltage is ~1.5V. Any ideas what cause this to happen? |
|
|
Ken Johnson
Joined: 23 Mar 2006 Posts: 197 Location: Lewisburg, WV
|
|
Posted: Wed Feb 11, 2009 8:09 am |
|
|
Which pin ?
What is connected to it ?
How is it configured ?
Ken |
|
|
das Guest
|
ADC24 |
Posted: Wed Feb 11, 2009 8:14 am |
|
|
Right now I have PIN_C2 connected to the ADC Power Down, PIN_C3 connected to the SCLK, and PIN_C4 connected to DOUT. I am also controlling the gain and address pins. At power up I set the power down to 0. I also set a LED pin (A0) to 1 for debug and the SCLK to 0. I wait 1 second (delay_ms(1000)) then set the power down pin to 1. I enter a while loop and wait for DOUT to be 1. When it is 1 I set a variable true. When DOUT is 0 and the variable is true I clock SCLK to 1 wait 1 ms and read the data using input(PIN_C4). I check if this is 1 or 0 and output a 1 or 0 on the serial port. |
|
|
languer
Joined: 09 Jan 2004 Posts: 144 Location: USA
|
|
Posted: Wed Feb 11, 2009 2:39 pm |
|
|
Quote: | The software drivers for the device operate quite differently than the ADS1232 and 1234 | That is why I suggested these drivers, as a reference to the bit-banging routines. They emulate the SPI through bit-banging and you could modify them to suit your needs.
It looks the pins you are using should work fine for that purpose. Remember A0 is an analog pin so you have to disable the ADC function (at least on that pin), and make the pin as a digital input. Post a small sample code which exhibits what you are seeing (and compiler version number). Make sure you have not configured the SPI port for anything else, as you are driving those pins directly. Also state which pin you think you are having problems with. |
|
|
das Guest
|
ADC24 |
Posted: Sat Feb 14, 2009 10:42 am |
|
|
The CCS compiler information is:
IDE 3.6
PCB 3.050
PCM 3.050
I am using the default standard io. here is a snippet from the code:
Code: | output_low(PIN_B5);//Gain 1
output_low(PIN_B4);//Gain 0
output_low(PIN_C0);//Address 0
output_low(PIN_C1);//Address 1
output_low(PIN_C2);//Power Down
output_low(PIN_C3);//SCLK
int convert = 0;
delay_ms(10000);
output_high(PIN_C2);//Power Down
if(input(PIN_C4) == 1)
convert = 1;
if((convert == 1) && (input(PIN_C4) == 0))
{
data = 0;
convert = 0;
for(i = 0; i < 24; i++)
{
output_high(PIN_C3);
delay_ms(1);
shift_left(&data, 1, input(PIN_C4));
delay_ms(1);
output_low(PIN_C3);
}
delay_ms(1);
output_high(PIN_C3);
delay_ms(1);
delay_ms(1);
for(i = 24; i > 0; i--)
{
if(bit_test(data, i) == 1)
printf("1");
else
printf("0");
}
} |
When I run this typically I don't see any output. When I probe the Power down pin with a multimeter I read 1.5V. Doing some modifications and deletions of the if PIN_C4 line is 1 I get the following output
Quote: | 000000000000000011111111 |
|
|
|
languer
Joined: 09 Jan 2004 Posts: 144 Location: USA
|
|
Posted: Sun Feb 15, 2009 12:04 am |
|
|
You should make the following modification to your code.
Instead of:
Code: | for(i = 0; i < 24; i++)
{
output_high(PIN_C3);
delay_ms(1);
shift_left(&data, 1, input(PIN_C4));
delay_ms(1);
output_low(PIN_C3);
} |
write as follows:
Code: | for(i = 0; i < 24; i++)
{
output_high(PIN_C3);
delay_ms(1);
shift_left(&data, 1, input(PIN_C4));
output_low(PIN_C3);
delay_ms(1);
} |
What pins are you using for RS232? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Feb 15, 2009 12:13 am |
|
|
Quote: | Anyone written a bit banging routine to drive a 24-bit ADC like the ADS1232 or ADS1234? |
Tell us exactly which chip you are using. These chips have different
pinouts. The first one is a 24 pin chip, and the 2nd one is 28 pin.
Quote: | When I probe the Power down pin with a multimeter I read 1.5V. |
Check your connections between the PIC and the ADS chip. On the
ADS1232, the power down pin is on pin 22. On the ADS1234 it's on pin 26.
Which chip are you using ?
Post the rest of your program. Post the #include statement, the #fuses,
the #use delay(), #use rs232(), and any other library or pre-processor
statements. |
|
|
pgarg78
Joined: 19 Sep 2009 Posts: 1
|
ADS1234 |
Posted: Sat Sep 19, 2009 6:35 am |
|
|
Mr. Das - Please let us know if you were able to interface ADS1234.
Regards,
Garg |
|
|
|