LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus RTU485 comm with digital sensor

Solved!
Go to solution
Highlighted

My register seems not to use zero-indexing.. Is that common?
I have a question about the values I achieve from the typecasting. I am getting confused by
the indexing...
I want to read the Temperature, states register 1010-1011 in the manual. A software used for setting the slave ID gives me some data, (manuf. ID , device ID, it can give me measurements from the sensor at the moment: temp=28,4C, pressure=0.0025 bar etc.)

 

*When I read from starting address 1009, quanity 2:
Holding register gives: approx. 15260 (dynamic) and 32768 (sometimes 0).
SGL result: approx. 0,0051 (dynamic)


*When I read from starting address 1010, quanity 2:
Holding register gives: I get, 32768/0 (switches back and forth between these values. For
10s is it zero and for 1s 32768, then this stops and just begin static 0) and 16867.
SGL result: 2,36357E-41 (For 0, 16867)

 

*When I read from starting address 1011 and quanity 2 (OBS! Reg 1012-1023 are not used =
0):
Holding register gives: 16866 and 0
SGL result: 28.25, which is reasonable if it is in Celsius.

 

What is going on?

0 Kudos
Message 21 of 30
(535 Views)
Highlighted

Reread message #2.  And remember that I have not seen a copy of your manual.

 

It is also possible that the device returns the two words in the opposite order that LabVIEW expects for the typecast.  (e.g most significant word or least significant word first).  Try using the function Swap Words from the Numeric >> Data Manipulation palette.

 

Ultimately, you just have to work with the device and read the manual to figure out what standards their register addresses follow.

 

0 Kudos
Message 22 of 30
(528 Views)
Highlighted

I have attached a snippet of the Read Input Reg. from the manual.

I added a Swap Words function after the Holding Registers and before the typecast and the output from the Swap Words was not even swapped.. hmm. Did I miss something?

 

When reading the Manufacturing ID code (reg. addr. 1000,1 byte) by using starting address 1000, quantity 1 it gives me the correct Manufacturing ID.. So I assume its "one-indexed"?

 

 

 

0 Kudos
Message 23 of 30
(520 Views)
Highlighted
Solution
Accepted by topic author dotis10

Please show your code.

 

It sounds like you placed the swap words on the U16 array, which would do nothing.

I also tried Swap Words on a SGL wire, which I thought would do something, but didn't.

Try typecasting the array of U16's to an array of U32's.  Swap words on that, then typecast to SGL array.

 

Ultimately, you'll need to just dig deep, look at the values, look at them as hex bytes.  Key them into the programmer's view of calculator in Windows.  Keep playing with it until you figure out what works.

Message 24 of 30
(511 Views)
Highlighted

I have attached my VI in the post.

Thank you!!
The swapping works now and I can use 1-based indexing that gives me the right values.

swap32.PNG

 

I have a question about the logging/saving to file - in my excel-file I get a bunch of "#" in the time column. What is the reason for that?

 

saveddata.PNG

0 Kudos
Message 25 of 30
(499 Views)
Highlighted

Try making the column containing the "######"s wider.

0 Kudos
Message 26 of 30
(496 Views)
Highlighted

@arteitle wrote:

Try making the column containing the "######"s wider.


Wow. That was easy 😛

savetime.PNG

So, the Time column shows a static date/time (except the first Time stamp). I have tried to change some time settings in the "Data Attributes"-block before the "Save Measurement to file"-block but this does not change the time.. I want the time to start from 0, without the date..

0 Kudos
Message 27 of 30
(492 Views)
Highlighted

I think we'll need to see your actual code to troubleshoot that. Generally it's advised to stay away from Dynamic Data, because it just obfuscates what's really in the wire.

0 Kudos
Message 28 of 30
(482 Views)
Highlighted

 


@arteitle wrote:

I think we'll need to see your actual code to troubleshoot that. Generally it's advised to stay away from Dynamic Data, because it just obfuscates what's really in the wire.


Here is the VI. 

What is recommended to use? 🙂

0 Kudos
Message 29 of 30
(478 Views)
Highlighted

@dotis10 wrote:

 


@arteitle wrote:

I think we'll need to see your actual code to troubleshoot that. Generally it's advised to stay away from Dynamic Data, because it just obfuscates what's really in the wire.


 



Is there another way to put a header (in the excel-sheet) for the input signal and change the Time column to just showing the sample time and not the date/time stamp?

0 Kudos
Message 30 of 30
(460 Views)