LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sensirion EKP-3 Code to read the raw ticks from the SDP6xx Pressure Transducer with LabVIEW

Cameron:

 

I have a happy twos compliment..

 

I really need to know how to talk to the SDP6XX with LabVIEW using the IOWARRIER goodies.

 

I seem to get mixed up with what the IOWARRIOR wants and what the SDP6XX needs..

 

All I want to do is to get the RAW TICKS from the Sensirion SDP6XX.. Nuttin more..

 

I know all I have to do is to WRITE an oxF1 to the silly thing and then READ the result but what do I pass to READ the silly answer?

 

Turns out that I can read the FULL RAW signal by issuing 0xF3 and READING would then give me the happy output..

 

To understand you would want to review the case and you will see videos..

0 Kudos
Message 11 of 28
(2,221 Views)

BTW.. The vi you have is newer than my LV 11 in this machine.... There is a twos compliment in the LLB I gave...

 

Do you know how to use the IOWARRIER stuff? It is pretty nice and the guys there are pertty helpful!

 

I know this is just a silly obvious thing and you are wondering why I ask silly questions. In the end I just want to read the Raw TICKS... I will do all the math and not use thier cool features because they are hard to access! Sad right!!??

0 Kudos
Message 12 of 28
(2,221 Views)

Hi,

 

 

it is difficult for me to understand where your are stuck. Maybe a little summary from you would be helpful. Here is what I understood so far:

 

* you have a SDP6XX Digital Differential Pressure Sensor from Sensirion

* you have plugged it to the USB dongle of the EK-P3 evaluation kit, containing a modified version of Code Mercenaries's IOWarrior24 micro-controller. Is that right?

* you will communicate with the SPD6XX sensor through this micro-controller using iokit.dll functions.

* you have found the hexadecimal commands to be sent to the sensor through. These commands are 0xF1 to ask for a scaled measurement (hF1 as specified in the SDP datasheet), and 0xF3 to ask for a RAW measurement. I wonder how you guessed the latter since it is not written in the datasheet?

* These commands must be passed as argument to the function IowKitWrite(devHandle: IOWKIT_HANDLE; numPipe: ULONG;buffer: PChar; length: ULONG): ULONG; stdcall;

* Now you want to read the measurement, is that right?

 

Then you just have to use the IowKitRead function. See my "IOWarrior_SHT75_ReadMeasurement.vi".

 

Or maybe do you have problems converting from raw values to actual values?

 

Unfortunately I cannot take a look at your examples since you are using a newer version of LabView than I am.

 

BTW, be sure to check whether your sensor uses the Sensibus Protocol (as the SHT2X and SHT75 does) or the standard IIC (I2C) protocol (as the SHT1x). The initialization of the Special Mode Function would be different then.

Message 13 of 28
(2,192 Views)

Claudeuntel:

 

Thanks sooooo much for your remarks.. Very helpful!

 

I will answer your queries within your questions.. AND.. Perhaps I can learn which version of LabVIEW you have and I can ask Cade (NI wizard) to convert to your older version.

 

* you have a SDP6XX Digital Differential Pressure Sensor from Sensirion

YES....

* you have plugged it to the USB dongle of the EK-P3 evaluation kit, containing a modified version of Code Mercenaries's IOWarrior24 micro-controller. Is that right?

YES....

* you will communicate with the SPD6XX sensor through this micro-controller using iokit.dll functions.

YES....

* you have found the hexadecimal commands to be sent to the sensor through. These commands are 0xF1 to ask for a scaled measurement (hF1 as specified in the SDP datasheet), and 0xF3 to ask for a RAW measurement. I wonder how you guessed the latter since it is not written in the datasheet?

I was told by someone at Sensirion to try hF3

 

* These commands must be passed as argument to the function IowKitWrite(devHandle: IOWKIT_HANDLE; numPipe: ULONG;buffer: PChar; length: ULONG): ULONG; stdcall;

 

Not sure how to put the right values to the parameters of IowKitWrite(devHandle: IOWKIT_HANDLE; numPipe: ULONG;buffer: PChar; length: ULONG): ULONG; stdcall;

 

* Now you want to read the measurement, is that right?

YES... It might be a 12 bit value? But how so for 65,535? That is a 16 bit value... 2^16=65,535...

 

Then you just have to use the IowKitRead function. See my "IOWarrior_SHT75_ReadMeasurement.vi".

I am not sure what to pass to this parameter? I say this because I do not get the expected value at the 0 flow as this value is near 32,767 and the high value, at full scale, is 65,535... Works BEAUTIFULLY with their Sensirion application but they do not tell me how to grab this value.

 

Or maybe do you have problems converting from raw values to actual values?

YES, this could be true.. I might be doing the right calls but not reading the values properly.

 

 

Unfortunately I cannot take a look at your examples since you are using a newer version of LabView than I am.

I will ask Cade to help here if you can give me your LV version.

 

BTW, be sure to check whether your sensor uses the Sensibus Protocol (as the SHT2X and SHT75 does) or the standard IIC (I2C) protocol (as the SHT1x). The initialization of the Special Mode Function would be different then.

SInce I can talk to it and see values coming out I would assume I am but I do not know and I do not think Sensirion has people who know the answer to that question. Do you think that since I can get SOMETHING out that I am using the right protocol?

0 Kudos
Message 14 of 28
(2,172 Views)

Here is the Sensirion Spec Sheet... SDP6xx

 

http://www.sensirion.com/nc/en/products/differential-pressure-sensors/download-center/?cid=901&did=9...

 

Hmmm.. can not get link to work... Crazy!

0 Kudos
Message 15 of 28
(2,162 Views)

davekorpi wrote:

 
"Not sure how to put the right values to the parameters of IowKitWrite(devHandle: IOWKIT_HANDLE; numPipe: ULONG;buffer: PChar; length: ULONG): ULONG; stdcall;"

 


Ok, so, first of all here ishow I declared the function within Labview:

uint32_t IowKitWrite(uint32_t devHandle, uint32_t numPipe, uint8_t *buffer, uint32_t length);

 


* The first argument is the dongle handle which is the output of the function IowKitOpenDevice(void)

* The second argument is the pipe number : "The IO-Warriors have two communication channels. In USB terminology this is called an interface or pipe. Pipe 0 is used to directly access the I/O pins, whereas pipe 1 allows access to the special functions of the IO-Warrior". So you should set it to 1.

* The third argument is the write request to be sent to the IIC. It has to be formatted as a Report. A report is a USB thing, always of 8 bytes long.

* The last argument is the length of the report, i.e. length=8

According to IOWarrior's datasheet, page 15, this write request Report is made of the following bytes:

0  ReportID=$03
1  count
2  command
3  0
4  0
5  0
6  0
7  0

"command" holds the command byte to be send to
the IIC. "count" is the number of bytes that should
be read off the IIC after sending the command
byte, values 1 to 255 are valid (Multiple reports
may be returned in reaction to a read request).

Data is returned in input reports with ID=3. The
data is returned in chunks of up to six bytes each
with an error flag and byte count.

=> The command would be hF3 in your case.
=> You have to check with your specific device, but in my case I set count=4, because in the data report sent back by the device I expect :

* ReportID (1 byte)
* flags (1 byte)
* up to 2 data bytes

I suppose you can set count=8 to be safe. On the contrary, I think that if you set this value too low, something goes wrong.

In terms of Labview programming, you have to build an array with all these bytes in the right order and wire it to "buffer".

 

"YES... It might be a 12 bit value? But how so for 65,535? That is a 16 bit value... 2^16=65,535..."


I dunno. You can try assuming 12bit and 16bit and comparing with what the software says. Pressure should not change rapidly if the device is left unperturbed.

 



"I am not sure what to pass to this parameter? I say this because I do not get the expected value at the 0 flow as this value is near 32,767 and the high value, at full scale, is 65,535... Works BEAUTIFULLY with their Sensirion application but they do not tell me how to grab this value."

 


First of all, here is how I declared the function:

uint32_t IowKitRead(uint32_t devHandle, uint32_t numPipe, uint8_t *buffer, uint32_t length);

This time, the buffer is to be received, not sent, hence you have to wire an empty array control to it, to store the incoming values. If you expect more than 1 USB Report, you will have to store the successive 8 bytes buffers, but that should not be the case.

After that, you will have to chunk the report into pieces. According to IOWarrior's datasheet, page 15, this report is made of the following bytes:

* 0  ReportID=3 (you can discard this byte, or check it is equal to 3 as expected for error handling)
* 1  flags (see below)
* 2-7  data

flags contains the following bits:
7 - error, set if slave does not ack command byte
6 - unused, zero
5 - unused, zero
4 - unused, zero
3 - unused, zero
2 - data count MSB
1 - data count
0 - data count LSB

You can discard the flags or check the values of the bits for error handling (this is why I created a "byte to binary" sub-VI).
Whatever your value is 12 or 16 bits, it should be contained in the first 2 data bytes, i.e. in byte #2 and #3. Then you can try to interpret it as 12 bit and 16bit and check which one makes sense.

 

 


"I will ask Cade to help here if you can give me your LV version."

I am using Labview 8.6.1

 
"Since I can talk to it and see values coming out I would assume I am but I do not know and I do not think Sensirion has people who know the answer to that question. Do you think that since I can get SOMETHING out that I am using the right protocol?"


Yes, I think so.

According to the SDPXXX datasheet, the protocol is IIC (I²C) and not Sensibus.


Hence, you should initialize communication using the IowKitWrite function as follows:

uint32_t IowKitWrite(uint32_t devHandle, uint32_t numPipe, uint8_t *buffer, uint32_t length);

* devHandle
* numpipe = 1
* buffer = (report, see below)
* length=8

Report bytes:

* ID=1
* enable=1
* flags=(see below)
* timeout=0 (writing a zero sets timeout to 256x500µsec)
* 0
* 0
* 0
* 0

flags is used to deactivate the internal pull up
resistors for SDA and SCL (only on IOW24) and/
or select the use of the Sensirion protocol:
7 - Disable Pull Ups (1 = disable) - IOW24 only
6 - Use Sensibus Protocol (1 = enable)
5 - unused, write zero
4 - unused, write zero
3 - unused, write zero
2 - unused, write zero
1 - unused, write zero
0 - unused, write zero
Bit 7 - "Disable Pull Up" is available only on
IOW24. When this bit is set the internal pull up
resistors of the IIC pins are disabled. The status of
the pull up resistors can not be changed while the
IIC function is active. Disabling and again
enabling the IIC function is necessary to change
the status of the pull-up resistors.
Bit 6 - "Use Sensibus Protocol"

So in your case, flags=00000000
I think that the pull up transistor of the dongle should be left enabled (first bit=0) because your device needs it but has none included ("The recommended pull-up resistor value depends on the system setup (capacitance of the circuit or cable and bus clock frequency). In most cases, 10 kO is a reasonable choice.")

 

 

In my SHT75 device (as in the SHT2X) a pull up transistor has been added internally so the one of the dongle must be disabled, it seems.

Good luck.
 

0 Kudos
Message 16 of 28
(2,150 Views)

A video showing more detail with the simple idea of Sending a write to start the

 

Write the byte string of.... 0x2, 0xC2, 0x80, 0xF1
THEN we READ, using this, $03 $03 $81

 

http://www.screencast.com/t/wDCZOmneba

 

 

 

0 Kudos
Message 17 of 28
(2,144 Views)

Hi Dave,

 

 

after looking at your video, here is what I can say at first:

 

* the "init" table looks OK, although I still don't know whether pull-ups transistors should be disabled (i.e. 10000000 instead of 00000000)

* the "write array" table should not be useful here ; the "write array 2" should be used instead (I think it's what you're doing)

* what's that dll that needs "0 to write" and "1 to read" ? IowKitRead and IowKitWrite both need "numPipe" as the 2nd argument, which should be 1 in your case.

 

 

0 Kudos
Message 18 of 28
(2,129 Views)

Here are the THREE variables I need to send to the device: 1, 2, and 3... I have tried many combinations but have not hit the right one..


Any hints? I just need some viable numbers to try.. I can see what happens on the output easily with the ReadDP indicator...

 

What2PutIn.png


Below is what IOWarrior commands are used to talk to the device.

 

ReadSecond.png

 

Any help would be greatly appreciated...

 

I have been told this..

 

Write the byte string of.... 0x2, 0xC2, 0x80, 0xF1
THEN you would READ, using this, $03 $03 $81

 

I am thinking this could be right but these are the FIRST 2 bytes to send and I need yet another set of bytes to send to get the data out...

 

This thing is driving me NUTS!

 

 

0 Kudos
Message 19 of 28
(2,113 Views)
Dave,

I insist : to me the right array is "Write Array 2" and not "Write Array"
You need to understand what a Report is and what kind of different reports the USB micro-controller can handle. Please read IOWarrior's manual again. I think that my previous posts contain all the useful information, unless your device does not act at all like mine.
The hexadecimal notation for bytes is compact, but it may "hide" individual bits and complicate full understanding of the Reports.
At this point I'm afraid I cannot help you further, excepted if you can send me your VI for labview 8.6.
Maybe you should give it a rest for 1 week. A brain I a machine that needs some rest (besides water and sugar).
0 Kudos
Message 20 of 28
(2,108 Views)