LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

spi with an ltc 2400

Caluctra,

Lets take a step back.  Since I didn't have time to read through the spec sheet for your device we will need to clarify what exactly you need.  Your sensor returns 32 bits.  You are able to get this into LV.  How many of these bits actually corespond to your data?  From the first diagram it looks like 27:4 (or is it 29:4)?  Should the upper or lower bits be padded with 0s?

Which (if any) of these is what you need to do?

Example.png

-Sam K

LIFA Developer

0 Kudos
Message 11 of 19
(1,959 Views)

sam,

this is what the output format of the adc states in page 11 of the datasheet.

"The LTC2400 serial output data stream is 32 bits long. The first 4 bits represent status information indicating the sign, input range and conversion state. The next 24 bits are the conversion result, MSB first. The remaining 4 bits are sub LSBs beyond the 24-bit level that may be included in averaging or discarded without loss of resolution.

 

->Bit 31 (first output bit) is the end of conversion (EOC) indicator. This bit is available at the SDO pin during the conversion and sleep states whenever the CS pin is LOW. This bit is HIGH during the conversion and goes LOW when the conversion is complete.

->Bit 30 (second output bit) is a dummy bit (DMY) and is always LOW.

->Bit 29 (third output bit) is the conversion result sign indicator (SIG). If V IN is >0, this bit is HIGH. If VIN is <0, this

bit is LOW. The sign bit changes state during the zero code.

->Bit 28 (forth output bit) is the extended input range (EXR) indicator. If the input is within the normal input range 0Ê £ ÊVIN £ VREF, this bit is LOW. If the input is outside the normal input range, VIN > VREF or VIN  < 0, this bit is HIGH.

->Bit 27 (fifth output bit) is the most significant bit (MSB).

->Bits 27-4 are the 24-bit conversion result MSB first.

->Bit 4 is the least significant bit (LSB).

->Bits 3-0 are sub LSBs below the 24-bit level. Bits 3-0 maybe included in averaging or discarded without loss of resolution.

Data is shifted out of the SDO pin under control of the serial clock (SCK), see Figure 3. Whenever CS is HIGH, SDO remains high impedance and any SCK clock pulses are ignored by the internal data out shift register.

pretty much i would like to have a reading with sign included, also have a boolian that tell me if iam out f range and also i would like bit 3-0 averages and added to LSB to improve accuracy.

bit 30 can be taking out.

in regards to the padding you showed on the picture, iam not sure where to put it, maybe instead of 0000 maybe 00 in the front for bit 31 and 30. just an idea

0 Kudos
Message 12 of 19
(1,959 Views)

Caluctra,

I believe the number you are getting is the ADC count.  Again I encourage you to thourougly read the sensor datasheet to understand what exactly the 4 bytes your get from it mean.  If it is the ADC value you will need to convert to to a voltage.  If you are using a 24-bit ADC to measure a 5 V range each ADC count is:

ADC Count = 5v / [ (2^24)-1] = 5/16777215 = .00000029802324164052257779375182352971

So for each count of the value returned by the sensor represents .00000029802324164052257779375182352971 volts.  To convert this to a voltage simply multiply the number you get from the sensor by 0.000000298023223876953125.

Here is a simply way to pull out the 24 useful bits.

Simple.PNG

-Sam K

0 Kudos
Message 13 of 19
(1,959 Views)

sam,

thanks to your guidance i have been successfull in reading from the adc, i have compared the output with an agilent 34401A multimeter and they are pretty even.

iam sorry to bombard you again but questions are plenty.

-> on the .pdf i posted it is stated that up to 19 bit of resolution was achieved. and i dont hink the agilent gets to 16 bit.

please tell me your thoughts regarding this.

-> how possible would a scenaio where i have several of this configurations each one belonging to a different sensor i were to meassure them on a single application using say UNO. (sort of a datalogger)

if possible will multiplexing be the way to go, say one mux for every SPI line. (maube?)

i would like your opinion about this.

-> another important point i would like to ask you is about calibration labview uses robusts softwares such as Measurement and automation to calibratevarious sensors. this on the other hand (up to what i know) is more complicate to achieve with an arduino.

for example i have used pressure transducers say (0-100 psi) which using meassurement and automation explorer and a MASTER to apply the pressure of interest you use the scales (different types) and the wizzard etc.

is there something that i can do to have some decen calibration method for whatever sensor(s) i might have?

-> some sensores come with 4-20 ma and with a 250 ohms resisto you get 1-5 vdc.

if i were to meassure such sensor using this method (ltc2400) how should AREF pin be used to not hurt the resolution. as per what i read i would need to connect a reference of 1v at the AREF pin so that my range be 4v instead of 5.

please confirm this if it is true.

0 Kudos
Message 14 of 19
(1,959 Views)

Caluctra,

What exactly is your question regarding the resolution of the sensors?

If you want to talk to multiple ltc2400's you can use the chip select to choose which one should listen to commands.  Using this method all chips share the same clock and data lines and the CS pin is used to tell an individual chip to 'listen'.  Check out the wikipedia article on SPI specifically the "master and three independent slaves" image.  You could always do some sort of multiplexing but this seems overly complicated since SPI can be used to talk to multiple devices on the same bus.

You cannot use scales from MAX as you would with a NI DAQ card because you will not be using the DAQmx drivers to talk to the Arduino.  Can you provide an example of what you would like to do with scales?  I would probably just make a sub VI that takes a raw value from the Arduino and scales it based on a user input type def. 

For example you could make a 'Read LTC2400' VI that reads from the device and returns the voltage as a double.  Then pass that value into a 'Scale LTC2400 Reading' VI that takes the voltage and a scale typedef enum.  Based on the enum value selected execute a case in the Scale vi.  This sub VI could even be part of the Read LTC2400 VI depending on how modular you want it to be.

When you refer to AREF do you mean on the Arduino?  If so this has nothing to do with your sampling.  It controls the sample range of the Arduino's analog input.  If you are refering to Vref on the LTC2400 a quick glance and the data sheet suggests that the LTC2400 can read voltages in the range of –0.12VREF TO 1.12VREF.

Once again the data sheet is your best friend.  I've never used the LTC2400 everything I've posted here about it can be found in the datasheet.  Take a look at that link to the proper datasheet and not just the tutorial you started with.  You can get much better info directly from the data sheet.

-Sam K

0 Kudos
Message 15 of 19
(1,959 Views)

sam,

my question regarding the resolution is shown (in my opinion) on the .jped i attached

Untitled.png

every year calibration is done to every test stand (which contain sensors)

the calibraiton company uses the meassurement and automation explorer wizzard after i scale the ideal output of each sensor using the scales. (y=mx+b) if it is linear and so on. with masters for every type of sensor.

pretty much something that i could verify that the sensor is within parameters. that would be my example of what i would like to do.

i was not refering to the reference for the adc (ltc 2400) when i mentioned the AREF pin on the arduino. I had underestood that when the reading scale is not (say 0-5 v) and instead is (1-5 v); (ex when the trasducer outputs current); that AREF pin is connected to 1v (in the case of 4-20 ma transducer) so that that 1v gap of no information can be avoided.

is it possible to extend analog reading range of the arduino to more than 5 and/or less than 0?

some position transducers (LVDTS) after being conditioned have bipolar dc output +-10 o +- 5.

i will try to communicate with two or more ltc tomorow, and share experience.

just wondering, if the spi vis do all the work (beside selecting the pins) how will i tell the different ltcs that i need the reading of just one at a time. i looked at the wikepedia article and all three pins are shares throug the different slaves spis but if i initialize the spi etc similarly to the 4th post, how am i going to change slaves devices.

on page 11 on the data sheet mantion THIS "EOC changes real time from HIGH to LOW at the completion of a conversion. This signal may be used as an interrupt for an external microcontroller."

maybe running a for loop just once every time, to make sure ot reads only one, and see if it does it sequencially maping all the slaves spis. just a thought.

0 Kudos
Message 16 of 19
(1,959 Views)

Caluctra,

The difference in the number of digits after the decimal could be due to rounding or truncating.  The voltage range that your device is configured to read will determine the overall resolution and accuracy.

For example if you have a 10 bit ADC and are reading 0-5v each ADC count represents 5/ [(2 ^ 10) -1] = .0048875 v.  If instead you use a 10 bit ADC to measure 0-3 v you get a resolution of 3 / [(2 ^ 10) -1] = .00293255 v.  So you just need to look at your sensor, and the voltage range its configured for and determine how much accuracy you should get, and if you are actually getting that accuracy.

As for useing MAX to calibrate your Arduino that is not currently possible and we have no plans to include this.  You can create your own scaling VIs like I described in my last post.  If you need higher accuracy and more scaling you would need to use a proper NI DAQ card.

As far as I know you cannot set the analog input voltage range on the Arduino above 5 or below 0.  Read the Arduino documentation on arduino.cc to confirm this.

The slave device is determined by the CS pin.  The CS pin is set each time you read or write.  It is not configured in the initialization.

-Sam K

LIFA Developer

0 Kudos
Message 17 of 19
(1,959 Views)

Thanks Sammy. This is where I was lost with SPI.

Sammy_K wrote:

Caluctra,

It looks like you are miss-using the SPI Send Receive VI.  You configuration look good except where you call the two SPI Send Receive VIs.  These VIs are actually used to shift out data and read incoming data from the device.  You are correct in setting the word size to 4 bytes (32 bits), however you only need to tell it which pin to use as chip select when you actually want to send data.  The chip select pin is toggled automatically for you based on the word size you select.

For example:

Say you want to send four 1 byte words to a sensor with chip select wired to DIO 4.  Call the SPI Send Receive VI with a Data array containing the 4 bytes cs set to 4 and word size set to 1.  This will do the following:

Set CS (Pin 4) Low

Shift out 1 byte

Buffer 1 byte input

Set CS High (because the word size is set to 1 byte)

Set CS (Pin 4) Low

Shift out 1 byte

Buffer 1 byte input

Set CS High (because the word size is set to 1 byte)

Set CS (Pin 4) Low

Shift out 1 byte

Buffer 1 byte input

Set CS High (because the word size is set to 1 byte)

Set CS (Pin 4) Low

Shift out 1 byte

Buffer 1 byte input

Set CS High (because the word size is set to 1 byte)

Return array of 4 bytes read.

So in your case when you actually want to write or read data you would call the SPI Send Receive VI with CS set to your CS pin, word size set to 4 and an array of 4 bytes.  This will set CS low, send 4 bytes to the device, read 4 bytes from the device and then return the 4 bytes read.  Also check to make sure you don't use a CS pin that is being used as a Clock of data line for example you cannot use pin 13 as CS on the Uno because it is SCK http://arduino.cc/en/Main/ArduinoBoardUno

Let us know if this helps you out or if you have more questions.

-Sam K

LIFA Developer

Your example helped a lot since I was coming from the arduino programing method.

0 Kudos
Message 18 of 19
(1,959 Views)

Caluctra,

Could you have a look at my post. I think I came with one similar problem here. Thank you

0 Kudos
Message 19 of 19
(1,959 Views)