I'm new to Labview,and now I'm using NI-8452 & ADXL355 to get the acceleration and Temperature data.
This VI is working properly.
Now,however,I need to communicate with multiple SPI devices(ADXL355) simultaneously.
I thought that I need to change CS line continuously ,but when I put two ADXL355 in parallel (as drawing)
I couldn't get the right data .
Could someone teach me how exactly should I do,thanks for your patiet.
(I know this VI is very Messy,sorry about that)
SPI communication utilizes a Slave Select (SS) line to set slave devices to receive data and there are two ways you configure the physical connection of your slaves to the master. This Whitepaper does a good job of explaining the different physical layer configurations for multiple slaves with a SPI master.
HI Andrew Cole,
Thanks for your reply,assume I got my physical connection correctly.
How should I modify my VI program to communicate with two chip .
I already tried use case structure with to chip and switch two cases continuously
It can work but couldn't get right data.
The chip select input in the 845x api selects which of the cs lines on your 845x device goes low to set a device into receive mode. So, I would revise your statement "I need to change CS line continuously" to "[you] need to change that input whenever you want to tell a device to listen". If you want multiple devices to listen at the same time, use the same cs line for both devices.
Unfortunately, I am travelling at the moment, so I don't have hardware to test your code with. But looking at it, a few things stand out immediately:
1) Your cs control is not inside the loop, which means it is read only before the loop and then never changes inside the loop. The tunnel on the edge of the loop where this wire enters the loop doesn't update every loop iteration - it retains its initial value. In order to change the selected device, you would need that control to be inside the loop so a change could be read on a subsequent loop iteration.
2) Your close reference is inside the loop. You should use shift registers to maintain the reference between loop iterations, and then the reference should pass out of the right side of the loop. That way, your session stays alive for the life of the loop. It's also a good practice to do this with your error wire and use that wire as a stop condition by wiring it and your stop button to an OR function before the loop stop terminal.
3) You could simplify your code quite a bit using array subset over the large array indexers.
What behavior are you going for? Do you want to broadcast to multiple devices at the same time? Do you want to be able to select a device on the fly and send whatever unique data you want? Do you want to sequence multiple predictable transmissions to the devices in a particular order? With a better understanding of the specific behavior you're seeking, I could provide some additional advice on how the structure the code for that behavior.
I added some comments to your code you may find helpful. You're doing the toggling part correctly, but the chip select value is never changing. It will be statically set to the value of that control when you press run. You need to change that value to the device you want to transmit to before you toggle cs low to read/write.
I want to get acceleration & Temperature data from two (ADXL355) simultaneously.
I modify my program ,I use loop iteration to change boolen value .
I'm not sure whether it's correct or not .Hope can get some advice from you.
How does this code behave? It looks like there are still some strange things in the code. I added some notes to your code again (after cleaning it up so I could read it) and I'm going to make an attempt at writing something like what you've requested. I don't have your devices to test with, so it likely won't work perfectly out of the box, but hopefully it will point you in the right direction (SPIExample.vi).
Based on the behavior you're looking for, you might want to look into 845x streaming for the reading portion rather than scripting.
Really appreciate ,your SPI Example work!
When I use one chip I got correct data(acceleration = -g T=30˚C)
However ,When I use two chips and put then in parallel,
I got wrong data from both chip(acceleration = -0.5g T=134˚C)
We couldn't figure out where the problem is .
Is there any possible that hardware connection is wrong?