View previous topic :: View next topic |
Author |
Message |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Jul 15, 2014 5:34 pm |
|
|
You misunderstood my earlier comment about spi_xfer(). You changed
all the bit counts to 1, and they should all be set to 8. For hardware SPI,
the compiler promotes your '1' bit count to 8. But you should edit it all
to be correct.
For example, in these lines below, you have it set for 1 bit. They should
all be changed to 8 bits.
Quote: | spi_xfer(ADS, 0x50 | reg_no, 1); //send first byte
delay_us(1);
spi_xfer(ADS, (num_bytes-1), 1); //number of bytes to write less one
delay_us(1);
spi_xfer(ADS, data_ptr[0], 1); |
These other lines need the SPI bit count to be fixed:
Quote: |
spi_xfer(ADS, 0, 2); //read one byte
delay_us(10);
rval=spi_xfer(ADS,0,1); //Clock data back
|
There may be more lines after that. Fix them all.
Here is the section from the CCS manual:
Quote: |
Syntax:
spi_xfer(data)
spi_xfer(stream, data)
spi_xfer(stream, data, bits)
result = spi_xfer(data)
result = spi_xfer(stream, data)
result = spi_xfer(stream, data, bits)
Parameters: data is the variable or constant to transfer via SPI. The pin used to transfer data is defined in the DO=pin option in #use spi. stream is the SPI stream to use as defined in the STREAM=name option in #USE SPI. bits is how many bits of data will be transferred. |
ie., the last parameter it the number of bits to transfer, not bytes. |
|
|
demedeiros
Joined: 27 Dec 2013 Posts: 71
|
|
Posted: Wed Jul 16, 2014 7:05 am |
|
|
PCM,
While looking at Ttelmahs original code, he is sending the number of bytes not bits. What is interesting is that if we look at the data on the logic analyzer, the appropriate amount of bits are being transferred. We will provide a screen shot once Olet96 is here. Also we will change all of them to bits to see if that helps the issue.
Thanks!! |
|
|
olet96
Joined: 09 Jul 2014 Posts: 16
|
|
Posted: Wed Jul 16, 2014 1:46 pm |
|
|
I have changed all the
Code: | spi_xfer(ADS, 0, 1); | to Code: | spi_xfer(ADS, 0, 8); |
I also read out all of the registers to ensure there wasnt any problems there and tied AIN0 to AIN1 which should give me an output of 0 because there is 0v differential between them however I've been getting data such as Code: |
RAW Data is: 0x00EBF76D:
RAW Data is: 0x00EC0D23:
RAW Data is: 0x00EC2BD1:
RAW Data is: 0x00EC2C6D:
RAW Data is: 0x00EC154C:
RAW Data is: 0x00EBF460:
RAW Data is: 0x00EC019B:
RAW Data is: 0x00EC27F2
|
I also put a logic analyzer on it to see exactly what the ADC was sending and it matches up with what im reading out so im not sure why when I connect the two differential inputs of the chip I don't get an out put that's even close to 0.
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jul 16, 2014 7:07 pm |
|
|
What do you get if you connect both AIN0 and AIN1 to the reference voltage ?
The EVM board manual for the ads1256 suggests doing that in this section:
Quote: | Figure 7.1.1 S1: AIN0-1 Input Select |
See page 11.
Referring to the input select switch, it says:
Quote: |
In the ZERO position, both AIN0 and AIN1 are connected to the reference.
This configuration gives a zero-scale reading across AIN0 and AIN1. |
Try that and see if you get the same result.
EVM manual:
http://www.ti.com/lit/ug/sbau090c/sbau090c.pdf |
|
|
olet96
Joined: 09 Jul 2014 Posts: 16
|
|
Posted: Thu Jul 17, 2014 8:06 am |
|
|
That seemed to work much better it didnt go completely to zero but its very very close to zero. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Thu Jul 17, 2014 8:57 am |
|
|
Trying to get a 'real zero' is mighty hard for anything over 12bits in the real world! You have to have a great ground plane, proper wiring, pcb layout, etc.
In the past, I'd run a 'zero' routine. Simply read channel that was 'zeroed' say 8 times, take the average, and use that as the 'reference zero'. Same technique as a 'tare' function.
hth
jay |
|
|
demedeiros
Joined: 27 Dec 2013 Posts: 71
|
|
Posted: Thu Jul 17, 2014 10:17 am |
|
|
That makes sense.
I'm trying to figure out why connecting AIN0 & AIN1 to REF produces a zero output, but connecting them both to GND or +5V does not produce a zero.
If AIN0 & AIN1 are shorted together the differential voltage across them will always be zero, irrespective of the voltage applied to them. Is there something I'm missing here? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Thu Jul 17, 2014 12:16 pm |
|
|
hmmm... 5V/ 24 bits is about .3microvolts. Mighty small,so I suspect that the IF the jumpers you're using to get AN0 and AN1 to ground or +5 aren't EXACTLY the same length.That alone could cause a submicrovolt to be the voltage you're reading. OR your jumper is picking up a wee bit of EMI (noise from PC, cell,etc.) If read at the 'right' time one input will have a larger voltage that the other and with 24bits you'll see that.
Even the PCB layout and cleanliness will play a part in the readings, that's why I use multiple readings and average them. Accuracy is nice but consistency can be more important depending on what the signal source is and what you have to do with it.
hth
jay |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jul 17, 2014 5:55 pm |
|
|
Quote: |
I'm trying to figure out why connecting AIN0 & AIN1 to REF produces a
zero output, but connecting them both to GND or +5V does not produce a zero.
If AIN0 & AIN1 are shorted together the differential voltage across them
will always be zero, irrespective of the voltage applied to them. Is there
something I'm missing here? |
I don't have your A/D. I have an ads1251. I put a short jumper wire
(1" or 2.5cm) into each of the two differential input pins. I then twisted
the ends of the wires together, and left the twisted end hanging up in
the air above the board. The two inputs are connected together, but
they are not connected to Vref or anything. When I move my finger
next to them (1/8" or 3mm) the output value deviates farther from 0.
It gets worse. Clearly there is noise pickup. Just having the two
differential inputs connected together does not produce a zero-level
output from the A/D.
I am not an expert on differential A/D converters. I suggest that you
post your question on the TI support forum:
http://e2e.ti.com/
You can also search the forum using Google. Example:
Quote: | site:e2e.ti.com ads1255 OR ads1256 inputs tied together |
or
Quote: | site:e2e.ti.com ads1255 OR ads1256 input noise |
etc. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Fri Jul 18, 2014 1:26 am |
|
|
In general, all op-amps have a limited voltage range they can handle, and become less linear as you move towards the ends of this range.
There are a lot of factors:
The gain error (I'd suspect this is built to be minimum at Vref, so this is the point where the output value is 'warranted' to be lowest).
Differential non-linearity.
The actual offset error and drift in this.
Then you have no Vref. The supply is not even remotely suitable as a Vref for a circuit at this sort of accuracy level. The comment in the data sheet says it al:
"A high-quality reference voltage capable of driving the
switched capacitor load presented by the ADS1255/6 is
essential for achieving the best performance. Noise and
drift on the reference degrade overall system
performance. It is especially critical that special care be
given to the circuitry generating the reference voltages and
their layout when operating in the low-noise settings (that
is, with low data rates) to prevent the voltage reference
from limiting performance. See the Applications section for
more details."
Then, I think you are running with the buffer on. Look at the restrictions this imposes. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
olet96
Joined: 09 Jul 2014 Posts: 16
|
|
Posted: Fri Jul 18, 2014 8:02 am |
|
|
Im using a LT1461bcs8-2.5#PBF which is a 2.5 volt regulator. |
|
|
olet96
Joined: 09 Jul 2014 Posts: 16
|
|
Posted: Fri Jul 18, 2014 8:45 am |
|
|
This morning I tried removing the long wires I had coming off of the AIN0 and AIN1 inputs and soldered a resistor lead across the inputs and noticed my output went very close to zero, however I'm still getting a random spike in the data which i found very strange. I'm thinking of moving the whole experiment somewhere else in the shop to rule out any possible noise.
Here is a sample of data.
Code: |
RAW Data is: 0x0000000B
RAW Data is: 0x00000012
RAW Data is: 0x0000000E
RAW Data is: 0x00FFFF02
RAW Data is: 0x0000002D
RAW Data is: 0x00FFFFFB
RAW Data is: 0x00000028
RAW Data is: 0x000000F4
RAW Data is: 0x00FFFF09
RAW Data is: 0x0000001F
|
I also did a quick test and tried putting some shielding around that whole section of the board and grounding the shielding and noticed it was actually worse possible because i used tape to prevent any shorts but I'm not sure. |
|
|
olet96
Joined: 09 Jul 2014 Posts: 16
|
|
Posted: Fri Jul 18, 2014 10:11 am |
|
|
Demedeiros and I realized our data that we thought was simply a spike or noise is actually the data going into the negative side since we are displaying the 24-bit data in a 32-bit form the first byte is 00 however if we look at the next byte is an FF which puts the MSB of the 24-bit data a 1 which indicates whether or not the number is a negative or not so if I apply the conversion of Data | 0xFF000000; and display the output in decimal I get a negative around -400 which when I plug that into my formula I end up with 596.05x10^-9 x -400 = -238.42 uvolts. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Fri Jul 18, 2014 11:53 am |
|
|
Welcome to the World of Analog ! As you're finding out, it is very difficult to measure submillivolt levels !!
It takes a mixture of science and black magic to design a real good PCB suitable for analog.You need to KNOW the EMI in the area and properly shiled against it. Use of chokes, caps,wire traces, shileded cables, etc. ALL play an importnat part in the design and execution of a quality product.
You'll probably spend 2-3 months in the lab and still not have the 'perfect' design. Been there..done that.
Without knowing the details of the project, you might want to consider putting the ADC into the 'sensor head' and communicate digitally. Done that a few times over the past 20 years too.
hth
jay |
|
|
|