![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
John Ilicitean
Joined: 07 Jul 2005 Posts: 27 Location: Rotova
|
ACK or not ACK??this is the question. |
Posted: Wed Jan 18, 2006 11:07 am |
|
|
Hello everyone!!
This is the last time that I write on this theme.In my previous post I have not found the solution but I have managed to know that is not a problem hardware.
I carry working in it, al less, four months and I am desperate
I working with PIC 16F877, and I try to comunicate the PIC with ADS1100.I use the i2c bus for comunication. The PIC is the Master and the ADS1100 is the slave. When the PIC send the ADS1100 address(my device is AD2=1001010X) , the ADS1100 not send me the bit acknowledged.
I try all possibles directions and the result is the same,the ADS1100 not send the ACK.
As test I to comunicate PIC to PIC with i2c to observe as I have that to configure the bus i2c for work correctly. I did not have problem.
Apply that way to utilize the bus i2c in the comunication of the PIC and the ADS1100 and the AD not send me the ACK.
Then, I buy the ADS1100EVM.The ADS1100EVM is an evaluation fixture for the ADS1100 analog-to-digital converter. This device to comunicate the ADS1100 with PC . The RS-232 port is who joins the PIC with ADS1100EVM. The ADS1100EVM is : ASD1100+circuit to pass a RS-232 level+program to control the characteristic of AD.
I observe as convert the voltage. Good so, being sure that the ADS1100(AD0) of ADS1100EVM work correctly, I connect this ADS1100(AD0) with my PIC system changing the address(AD0=1001000X), and the AD0 not send me the acknowledged.
This is my code for the AD2:
Code: |
#include <16F877.h>
#use delay(clock=20000000)
#fuses HS,NOWDT,NOPROTECT,NOLVP,NOCPD,NOWRT
#use i2c(Master,fast,sda=PIN_C4,scl=PIN_C3)
byte r,y,x=0;
void main()
{
while(1)
{
i2c_start();
i2c_write(0x94);
i2c_write(0x8c);
i2c_start();
i2c_write(0x95);
x=i2c_read();
y=i2c_read();
z=i2c_read();
i2c_stop();
delay_ms(11);
}
}
|
There is someone that have some idea of because the ADS1100 does not send me the acknowledged????? |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jan 18, 2006 1:25 pm |
|
|
If you look at page 11 in the T.I. data sheet for the ADS1100,
it shows how to do a read operation.
http://focus.ti.com/lit/ds/symlink/ads1100.pdf
It shows:
start
send slave address
read
read
read
stop
Unlike most i2c devices, they don't show a "NACK" on the final read.
Whether this is a typo or not, I don't know.
Then if you go to the Circuit Cellar website, and get their project
notes for the ADS1100, on page 7 they show a complete read routine.
http://www.circuitcellar.com/fi2003/abstracts/F164abstract.pdf
Code: |
unsigned int Measure_ADC(void)
{
BYTE temp;
unsigned int Result=0;
I2C_start();
I2C_write(0x91); // ADC address, then read
Result = I2C_read(1); // Hi byte
Result = ((Result << 8) + I2C_read(1)); // Lo byte
temp = I2C_read(1); // Config register, not used
I2C_stop();
return (Result);
} |
Note that the code above is written for a compiler that defines
an "int" as a 16 bit value. So to convert the code to CCS, you
should change the "unsigned int" declarations to "int16".
(Do this in two places).
I suggest that you study the Circuit Cellar code. Try to do it their way. |
|
![](templates/subSilver/images/spacer.gif) |
John Ilicitean
Joined: 07 Jul 2005 Posts: 27 Location: Rotova
|
|
Posted: Thu Jan 19, 2006 5:41 am |
|
|
In http://www.circuitcellar.com/fi2003/abstracts/F164abstract.pdf shows as to implement the instructions of write, read,start , stop.
but in PCW compiler they are already implemented these actions, not????
I utilize this procedure along time ago,in an articulate previous,changing the instructions to CCS code.
The result was that I do not function anything. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jan 19, 2006 11:25 am |
|
|
Yes, that's true. But use the basic concept of the Circuit Cellar code.
Notice how you are trying to do a read operation. From your post:
Code: |
i2c_start();
i2c_write(0x94);
i2c_write(0x8c);
i2c_start();
i2c_write(0x95);
x=i2c_read();
y=i2c_read();
z=i2c_read();
i2c_stop();
delay_ms(11);
|
Your code above does not look anything like the ADS1100 data sheet
or the Circuit Cellar code. Why do you think this code will work ?
Your code must match the data sheet for chip. The basic concept
of the Circuit Cellar code does match the data sheet. I suggest that
you do things the right way. |
|
![](templates/subSilver/images/spacer.gif) |
John Ilicitean
Joined: 07 Jul 2005 Posts: 27 Location: Rotova
|
|
Posted: Tue Jan 31, 2006 4:38 am |
|
|
Hello!!
I have proven the sequence of above because in another one I articulate said to me that the correct sequence to work in I2C is:
start
send device address
send register address
re-start
send device address with 'read' bit set
read
read
read
stop
Also I have proven the sequences to READ and WRITE,so and as they indicate the manual to me, and the result is the same, the bit ACK not appears. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jan 31, 2006 9:59 am |
|
|
Well, here you said that you've been working on it for 4 months:
Quote: | I carry working in it, al less, four months and I am desperate |
It must be about 5 months now. If you don't follow the data sheet,
you may work on it forever.
Apparently that's what you want to do, so I'm going to leave this thread
and let you do it. |
|
![](templates/subSilver/images/spacer.gif) |
John Ilicitean
Joined: 07 Jul 2005 Posts: 27 Location: Rotova
|
|
Posted: Tue Jan 31, 2006 10:39 am |
|
|
Quote: |
I have proven the sequences to READ and WRITE,so and as they indicate the manual to me
|
First, I followed the datasheet, and don't work the ADS1100.
After, I proved another one secuence, as since that I have put in the code and I do not work.
I don't like your previous answer, if you don't want or don't can , to help me ,this you to the margin. |
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
|
Posted: Tue Jan 31, 2006 11:35 am |
|
|
John Ilicitean wrote: | Quote: |
I have proven the sequences to READ and WRITE,so and as they indicate the manual to me
|
First, I followed the datasheet, and don't work the ADS1100.
After, I proved another one secuence, as since that I have put in the code and I do not work.
I don't like your previous answer, if you don't want or don't can , to help me ,this you to the margin. |
I'm sorry, but what you post, _does not_ follow the data sheet.
Look at it again. Look at the example transfers. How many 'registers' does this chip have?. Hint, '0x8c', is _not_ a register supported by the chip.
In fact the examples show that this chip _always_ automatically selects the first register when addressed, so you only need to send the device address, and not the register address at all...
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
John Ilicitean
Joined: 07 Jul 2005 Posts: 27 Location: Rotova
|
|
Posted: Wed Feb 01, 2006 5:29 am |
|
|
Hi!!!
I programed the PIC with this code:
Code: |
#include <16F877.h>
#use delay(clock=20000000)
#fuses HS,NOWDT,NOPROTECT,NOLVP,NOCPD,NOWRT
#use i2c(Master,fast,sda=PIN_C4,scl=PIN_C3)
byte x,y,z=0;
void main()
{
while(1)
{
{
i2c_start();
i2c_write(0x95); // ADC address, then read
x=i2c_read();
y=i2c_read();
z=i2c_read();
i2c_stop();
delay_ms(11);
}
}
}
|
This is the sequence that it indicates to me in datasheet.
And the problem is the same, not send ACK. |
|
![](templates/subSilver/images/spacer.gif) |
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed Feb 01, 2006 7:03 am |
|
|
Finally you have tried the program as we suggested you to do. It doesn't work... and that is what you expected. Sorry, but we had to make sure it wasn't your program that was at failure.
Just a few questions for double checking:
1) You have both an AD0 and AD2 chip. Did you perform this last test with the AD2 chip?
2) What is your compiler version?
3) You are using the pins for the hardware I2C unit of the PIC. By default the CCS compiler will generate a software I2C driver. Have you tried adding FORCE_HW to the #use I2C line?
I'm not sure I do really understand your problem. You say you don't get an ACK from the AD1100. In your last posted program the only ACK you are expected to receive is on sending the chip's address. How do you know you are not receiving this ACK? I don't see any code in your program testing for the ACK.
In order to test the receiving of the ACK, please try the program below.
Code: | #include <16F877.h>
#use delay(clock=20000000)
#fuses HS,NOWDT,NOPROTECT,NOLVP,NOCPD,NOWRT
#use i2c(Master,fast,sda=PIN_C4,scl=PIN_C3)
byte x,y,z=0;
int8 ack;
void main()
{
i2c_start();
ack = i2c_write(0x95); // ADC address, then read
x=i2c_read();
y=i2c_read();
z=i2c_read();
i2c_stop();
if (ack == 0)
{
// ACK received
output_high(PIN_A0);
}
else
{
// NAK received
output_high(PIN_A1);
}
while(1); // wait forever
} |
|
|
![](templates/subSilver/images/spacer.gif) |
John Ilicitean
Joined: 07 Jul 2005 Posts: 27 Location: Rotova
|
|
Posted: Wed Feb 01, 2006 11:46 am |
|
|
Hi!!!
First, thank you very much!!!
I have programmed your code and the Pin_A1 has been put '1'.
Quote: |
1) You have both an AD0 and AD2 chip. Did you perform this last test with the AD2 chip?
|
Yes, I use the AD2.
Quote: |
2) What is your compiler version?
|
I use the last version of compiler. I downloaded of the web www.ccsinfo.com
Quote: |
3) Do you have pull up resistors on the SDA and SCL lines?
|
Yes, and its values is 1kohm.
Quote: |
[4) You are using the pins for the hardware I2C unit of the PIC. By default the CCS compiler will generate a software I2C driver. Have you tried adding FORCE_HW to the #use I2C line?
|
Yes , I tried, and the result is the same.
Quote: |
How do you know you are not receiving this ACK? I don't see any code in your program testing for the ACK.
|
I see the timing diagrams in the digital oscilloscope.I have tried to put a photo in this forum but I can't.
In this link your can see my timing diagrams.
[url]
http://forum.microchip.com/upfiles.aspx/32748/D8E5125BB24D4657A951626B0B4DC6D6.JPG
[/url]
This are the Timings of my first code, but in my last code is the same(but without the first sequence of START) |
|
![](templates/subSilver/images/spacer.gif) |
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed Feb 01, 2006 5:39 pm |
|
|
Looking at the program and the timing diagram everything looks ok. I also checked the timing in the assembly code of v3.226 and don't see strange things.
You gave us a very long explanation of your problem, but what it comes down to is that you never get a response from the ADS1100. When the ADS1100 receives a valid address after power on it should return with an ACK, this never happens.
Most likely you have a hardware problem. I'm sure you checked everything 10 times, but please do it once more:
- Check the voltage on the ADS1100 power pins.
- Make sure the SCL and SDA lines are not switched (pin 4 of the AD must go to C4 of the PIC, pin 3 of the AD to C3 of the PIC).
If this is all ok, then the ADS1100 might be defect. Do you have another chip that you can try? |
|
![](templates/subSilver/images/spacer.gif) |
John Ilicitean
Joined: 07 Jul 2005 Posts: 27 Location: Rotova
|
|
Posted: Thu Feb 02, 2006 6:07 am |
|
|
Hello!!!
I tested the power pins. The Pin 5 Vdd=5.1V and the Pin 2 GND=0.00V.
I'm sure what the pins of SDA and SCL are corretly connected.
I have three ADS1100 , two AD2 and one AD0 (the AD0 that comes inserted on the board of ADS1100EVM) and none send me the ACK.
In the case of AD2 ,a possibility is that they are broken but in the AD0 I that it works correctly when connects the ADS1100EVM to PC and I controls the AD with the program ads1100evm.exe.
But when I connect directly the AD0(changing the direction by the corresponding to AD0) with my PIC system the result that I see in the digital oscilloscope is the same, not send me the bit acknowledged.
It's utility if somebody has worked with a connected a PIC with ADS1100.
I not that to I do. ![Sad](images/smiles/icon_sad.gif) |
|
![](templates/subSilver/images/spacer.gif) |
rwyoung
Joined: 12 Nov 2003 Posts: 563 Location: Lawrence, KS USA
|
|
Posted: Thu Feb 02, 2006 8:42 am |
|
|
John Ilicitean wrote: | I have three ADS1100 , two AD2 and one AD0 (the AD0 that comes inserted on the board of ADS1100EVM) and none send me the ACK.
In the case of AD2 ,a possibility is that they are broken but in the AD0 I that it works correctly when connects the ADS1100EVM to PC and I controls the AD with the program ads1100evm.exe. |
And your PIC code timing EXACTLY matches that of the PC program's? _________________ Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month! |
|
![](templates/subSilver/images/spacer.gif) |
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Thu Feb 02, 2006 9:29 am |
|
|
The Control byte of the ADS1100 is made up of 7 bits where you can preset (bits 3 thru 1),
leaving bit 0 alone (set to zero) as the I2C routine will use this bit depending if it is
a read or write operation... so the control byte would look like this...
1001yyy0
In your code you are addressing:
i2c_write(0x95); // ADC address, then read
which is wrong because the bit 0 is SET.
If you have the variant AD5 as I guess, the address should be 0x9A
Humberto |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|