01-31-2020 02:56 AM
I just simplified your code. However, it does the same.
09-22-2020 12:23 PM
I'm trying to communicate with an Adafruit 31865 thermistor chip using the USB-8451 SPI DAQ and getting nothing but 0xFF as a response. I've read the NI tutorial on SPI communication and spilled over the Adafruit chip specs without any luck. I've attached the code I'm using. I pulled it almost straight out of the NI tutorial and made it as explicit as possible. I've tried setting the phase, polarity etc. as my understanding from the Adafruit documentation and then just brute forced every combination. No luck. I ever only get 0xFF as a reply. I get the correct number of bytes, but just 0xFF. I've tried creating a SPI script instead of using the NI provided VI and I get the same results. Any ideas?
09-22-2020 02:26 PM
Hello,
I'm trying to work withe the Adafruit MAX 31865 chip using the NI USB-8451 SPI DAQ and getting nowhere. I've tried using the LabVIEW example read/write programs and modifying them as I thought to. I tried implementing your sequence but all I get as a response is 0xFF. Any idea what I may be doing wrong? I've tried every combination of polarity and phase. Nothing is working.
09-23-2020 08:25 AM
HI, I cannot open your vi file because I have the Labview version 15 . Please, save it in version 15 if you want me to see it.
09-24-2020 08:44 AM
I've attached the code in LabVIEW 15. In addition to this approach, I tried the method basically straight out of the NI SPI tutorial using the basic SPI read/write VI provided.
Thanks
09-24-2020 09:04 AM
Hi,
are you sure the connections are right?
can you send a diagram of the connections made?
09-24-2020 10:02 AM
NI USB 8451 Adafruit 31865
GND GND
+5V VIN
CS0 CS
SDO SDO
SDI SDI
SCLK CLK
I've checked for conductivity and power. Everything seems good (5V reads 5V, 3.3V reads 3.3V). I've tried two Adafruit boards. According to Adafruit tech support, the board draw 2-3 mA and the NI USB 5V port can provide 20 mA.
09-24-2020 10:33 AM
Please do not use Stacked Sequences! In fact, unless you are doing FPGA code, you almost never need the Sequence structure. Use the Error Line to serialize your VIs.
It also really helps to think hierarchically and plan sub-VIs to "hide the messy details". Here are three illustrations of sub-VIs I created for the 8451 to handle A/D conversion on a different chip. I'm only presenting "pictures", but with explanations that explain how it works and what you might want to change.
Do you know about VIG's (stands for Virtual Instrument Global, a "do once and remember for future use" routine)? This VIG "finds" the 845x device, sets up SPI, and returns (for subsequent use) the Device Reference and the SPI Configuration Reference. This is called "NI-845x SPI Refs" (you'll see it as a blue box on later pictures).
Notice the "First Call?" function that runs the outer Case structure when you first call this VIG. The little blue sub-VI "Find SPI Master" is pretty simple-minded -- it queries VISA for any device whose names starts with USB and if it finds exactly 1, it says "This must be the SPI Master". You could easily substitute a Constant Device Reference here. Notice that this sets up the SPI configuration and does it once (because First Call? is only true once).
Before doing A/D conversion, you have to configure the A/D Chip. For my chip, this requires a one-byte command (which I build out of bits, why not?). Since the SPI Read/Write requires an Array input, I make the single Byte into a 1-Byte Array, when send it to SPI Read/Write. Note that the Close Reference is not necessary.
To read from the A/D, you need to send two "Commands" -- a Convert command (which is, in my device, another single-byte command, which you can see I put in the appropriate bits by doing left-shifts using the power-of-2 function), followed by a "Read", produced by writing as many bytes as you expect to read back, and then reading them back.
I hope this suggests a clearer way of constructing your code to do similar things with your SPI A/D chip. Again, do not use Stacked sequences without Error Lines -- it makes following the logic difficult. Do use sub-VIs to "hide the messy details".
Bob Schor
09-25-2020 01:34 AM
Hi, I have never used NI USB 8451 yet. However, with myRIO I connect MOSI on myRIO with SDI on MAX31685 and MISO on myRIO with SDO on MAX31685. In addition, the above post of @BOB_Schor should help you to change your vi.
10-19-2020 02:26 PM
Problem found. I interpreted the pins on the slave device as being referenced to the master device; hence, the line marked SDO on the slave was to be connected to the SDO line on the master and the SDI line on the slave was to be connected to the SDI line on the master. That's not the convention. SDO connects to SDI and SDI to SDO which makes sense once one knows what frame of reference is being used.
09-24-2020 10:02 AM
NI USB 8451 Adafruit 31865
GND GND
CS0 CS
SDO SDI
SDI SDO
SCLK CLK