LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading Data from MS5803-05BA via myRIO

Dear all

I am new in using Labview and myRIO, I need to read data of 4 barometer sensors (MS5803-05BA) via SPI interface.

I have connected SDI pin of the sensor to the MISO of myRIO and SDO pin of the sensor to the MOSI and SCKL is connected and each chip select pin is connected to a Digital Output pin of the myRIO. According to the datasheet (attached) the sensor should send data  when the chip select is low, hence I have made one of them as "false" and rest to "true", and converts the frames read data to unsigned bits, the only output is 255 for it.

I cannot figure out what is the problem?

The Code is attached

I appreciate if anyone would have any suggestion or idea what is wrong?

Cheers

 

0 Kudos
Message 1 of 8
(1,461 Views)

Hello Everyone

I ma trying to communicate with the MS5803-14BA sensor,via SPI protocol using myRIO.

The only output that I get is 255, which I do not know what is wrong.

Does any one have any idea what can be wrong?

my VI is attached.

Thanks

Download All
0 Kudos
Message 2 of 8
(1,431 Views)

Sigh.  I wish chip manufacturers would standardize their terminology for SPI and I²C.  Also, it really helps when dealing with SPI to have a colleague who has a fancy Digital Scope and digital probes that they can put on the SPI lines and look at CS, SCLK, MOSI, and MISO.

 

I do not understand your initialization sequence, nor do I completely understand what the Chip is supposed to do.

  • Where do you do Chip Select?
  • Where do you set up the SPI clock and define whether you are employing Clock Mode 0 or Clock Mode 3?
  • I see where you MOSI the Reset command, but am not sure if you are supposed to MISO back anything.  How are you supposed to determine when/if the Reset is effective?
  • What are the other three Bytes, A, 4, and 0 that you are MOSI-ing to the Chip? 
  • Where is the Conversion?  I don't see you writing 4x or 5x to the Chip.
  • Do you understand SPI?  If not, find a knowledgable EE or CS student and ask for help.

Bob Schor

0 Kudos
Message 3 of 8
(1,367 Views)

Hello Thanks for your reply This is a pressure sensor, that has both I2C and SPI interface, which I want to talk to it with SPI.

1- I have connected the CS (chip select) pin to pin 13 and use Boolean to active it high or low

2- In the SPI configuration box (appears when you click on it) you can set the modes (picture attached)

3- I need MISO signal to read the data, and I think I should set it in the SPI block and try to read it by wiring “Frame read”

4- They should be ADC commands that I tried to understand from the datasheet, but I am not sure if they are right (Datasheet and C-code example is attached)

5- About the question “Where is the Conversion? I don't see you writing 4x or 5x to the Chip” I think the 0x00 and 0x10 is doing the D1 (pressure) and D2 (temperature) conversion.

6- I theoretically understand SPI, but the problem is that I do not know how to define the registry command in the myRIO, I am struggling with the registery implementation in the myRIO, and how to do it.

 

 

I appreciate if you would advise me how to write registry/conversion commands to read the data.

Thank for your time

Download All
0 Kudos
Message 4 of 8
(1,355 Views)

@Saeed1994 wrote:

Hello Thanks for your reply This is a pressure sensor, that has both I2C and SPI interface, which I want to talk to it with SPI.

1- I have connected the CS (chip select) pin to pin 13 and use Boolean to active it high or low

2- In the SPI configuration box (appears when you click on it) you can set the modes (picture attached)

Thanks.  I don't use Express VIs, so I didn't know that was a "hidden feature".

3- I need MISO signal to read the data, and I think I should set it in the SPI block and try to read it by wiring “Frame read”

In my (limited) experience, the way I got data back on MISO was to do a Read/Write command and write (on the MOSI lines) one byte (typically 00) for every MISO I wanted back.  

4- They should be ADC commands that I tried to understand from the datasheet, but I am not sure if they are right (Datasheet and C-code example is attached)

I think you are confusing the Convert command (which is 40+D1/D2) with Read.  You need to tell the Chip to Convert, then when the Conversion is done (which is why there's a Wait), you do the MOSI/MISO sequence to Write/Read the data back.

5- About the question “Where is the Conversion? I don't see you writing 4x or 5x to the Chip” I think the 0x00 and 0x10 is doing the D1 (pressure) and D2 (temperature) conversion.

See previous comment.

6- I theoretically understand SPI, but the problem is that I do not know how to define the registry command in the myRIO, I am struggling with the registery implementation in the myRIO, and how to do it.

I don't know what you mean by the "Registry" commands.  


Bob Schor

0 Kudos
Message 5 of 8
(1,344 Views)

Sorry for late response.

I have attached the complete wiring that give me the result of 255.

Register command: I mean the table of command including the ADC conversion, reset, and etc. (table picture is attached)

 

Can you think of any problem within the code?

Best Regards

Download All
0 Kudos
Message 6 of 8
(1,311 Views)

Attach the FPGA code as a VI so we can really inspect it.  Can't tell much from a picture, certainly can't test it.

 

Bob Schor

0 Kudos
Message 7 of 8
(1,303 Views)

Here you go.

Cheers

0 Kudos
Message 8 of 8
(1,299 Views)