01-25-2022 09:27 AM - edited 01-25-2022 09:30 AM
I have an ADC of ADS1256, I try to use Myrio to read the data via SPI, but I get stuck when converting the data~ Can you help how to get the correct data?(ADS1256datasheet )
I gave a set of ARDUINO's code which works fine, and I tried to emulate his conversion without success.
I'm trying to put this code on labview now, can anyone help me?
Where am I doing wrong?
Note, FORLOOP is used to read multiple values consecutively.
Solved! Go to Solution.
01-25-2022 09:46 AM - edited 01-25-2022 09:47 AM
Hi koukileo,
@koukileo wrote:
adc_val[i] = SPI.transfer(0);
adc_val[i] <<= 8; //shift to left
adc_val[i] |= SPI.transfer(0);
adc_val[i] <<= 8;
adc_val[i] |= SPI.transfer(0);
for (i=0; i <= 2; i++){ // Single ended Measurements
if(adc_val[i] > 0x7fffff){ //if MSB == 1
adc_val[i] = adc_val[i]-16777216; //do 2's complement
}
What about this one:
01-25-2022 11:22 AM
Thanks for your reply, I finally understand my problem, the ADC is 24bit data, so I want to divide it into three sections with 8bit. The code is as follows~
01-25-2022 11:24 AM
Your code is great too~ Made me understand new ways.
01-25-2022 01:02 PM
Hi koukileo,
@koukileo wrote:
Thanks for your reply, I finally understand my problem, the ADC is 24bit data, so I want to divide it into three sections with 8bit. The code is as follows…
Quite convoluted!
Whenever you start to copy&paste the same code several times you should think about using a loop to call that code repeatedly! (And when you combine this with LabVIEW autoindexing feature it becomes really easy…)
01-25-2022 09:49 PM
Thanks for your advice~ I forgot to have this method. Thank you very much~
01-26-2022 02:09 AM
Hi koukileo,
@koukileo wrote:
Thanks for your advice~ I forgot to have this method. Thank you very much~
Why use a loop (or duplicated code) at all when you only need the result of the first iteration?
01-26-2022 04:31 AM
What you can see in the picture is to demonstrate the use.
I actually have a 3-axis accelerometer, so I end up needing 3 DATA~
Best regards