LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus RTU485 comm with digital sensor

Solved!
Go to solution
Highlighted

Thanks. I am new to Labview and I think I will continue with the VI and the Modbus library I have now.

0 Kudos
Message 11 of 30
(325 Views)
Highlighted

@dotis10 wrote:

My "Single precision float" seems to be different from the typecast output. Pink vs orange? 😐

typecast.png

 

A couple of values have two register addresses next to each other in the read register (due to float?). For example "Temperature (Secondary Value), degrees C, register 1010-1011".. Does these  values have to be merged before the type casting? Or how does that work? And if I want to read values from different addresses, with different units - how do I handle that?

 

In order logg data from, lets say the temperature over 60sec or so, do I connect the typecast output to the Signal on the Write to Measurement File? 


You wired in a string constant.  You need to wire a constant that is a single precision float.  If you have multiple addresses, make that constant a 1-D array of  single precision floats.  It witll then convert it to an array of 1-D SGL's.

Message 12 of 30
(317 Views)
Highlighted

@RavensFan wrote:

@dotis10 wrote:

My "Single precision float" seems to be different from the typecast output. Pink vs orange? 😐

typecast.png

 

A couple of values have two register addresses next to each other in the read register (due to float?). For example "Temperature (Secondary Value), degrees C, register 1010-1011".. Does these  values have to be merged before the type casting? Or how does that work? And if I want to read values from different addresses, with different units - how do I handle that?

 

In order logg data from, lets say the temperature over 60sec or so, do I connect the typecast output to the Signal on the Write to Measurement File? 


You wired in a string constant.  You need to wire a constant that is a single precision float.  If you have multiple addresses, make that constant a 1-D array of  single precision floats.  It witll then convert it to an array of 1-D SGL's.


Can't get it to work... How do I get the "type" to be orange instead of pink?

0 Kudos
Message 13 of 30
(307 Views)
Highlighted

@dotis10 wrote:

@RavensFan wrote:

@dotis10 wrote:

My "Single precision float" seems to be different from the typecast output. Pink vs orange? 😐

typecast.png

 

A couple of values have two register addresses next to each other in the read register (due to float?). For example "Temperature (Secondary Value), degrees C, register 1010-1011".. Does these  values have to be merged before the type casting? Or how does that work? And if I want to read values from different addresses, with different units - how do I handle that?

 

In order logg data from, lets say the temperature over 60sec or so, do I connect the typecast output to the Signal on the Write to Measurement File? 


You wired in a string constant.  You need to wire a constant that is a single precision float.  If you have multiple addresses, make that constant a 1-D array of  single precision floats.  It witll then convert it to an array of 1-D SGL's.


Can't get it to work... How do I get the "type" to be orange instead of pink?



Nvm, solved that part x)

0 Kudos
Message 14 of 30
(306 Views)
Highlighted

Is this what you meant for the multiple register addresses? 🙂

 

Do I have to merge the two addresses of ex. the Temperature somehow? Before or after the typecasting? How are these two values really divided? And how are they merged in theory?

 

 

sgl.png

0 Kudos
Message 15 of 30
(302 Views)
Highlighted

Yes.  That is what I meant.

 

This assumes you are reading multiple registers in a row.  If you are not, then you need multiple reads anyway.

 

If you read two registers that represent a single floating point number, you get an array of 2 U16 elements.  The typecast will turn that into an array of 1 SGL element.  If you want two floating points, you'll read 4 registers, so that 4 U16's in an array will come out as 2 SGL's in an array after the typecast.

0 Kudos
Message 16 of 30
(290 Views)
Highlighted

Thank you RavensFan!

So if I for example only want to read the temperature in reg. 1010-1011 and the pressure in 1033-1034 for example, in one shot, how can I do that?

Do I add another Read Input Reg?

0 Kudos
Message 17 of 30
(273 Views)
Highlighted

You could try reading registers 1010 to 1034   (start 1010, number 25)  Then index out the first two and last two registers and convert them.  If they were closer together, I would do that.  That far apart, I'd just do them as two separate reads.

 

You can try it out both ways and see if one is faster than the other.

0 Kudos
Message 18 of 30
(265 Views)
Highlighted

@RavensFan wrote:

You could try reading registers 1010 to 1034   (start 1010, number 25)  Then index out the first two and last two registers and convert them.  If they were closer together, I would do that.  That far apart, I'd just do them as two separate reads.

 

You can try it out both ways and see if one is faster than the other.


Okay, nice! I will try index them out.

And by "two separate reads" do you mean I will use two "Read Input Register"-blocks and use the same slave IDs but different starting addresses?

0 Kudos
Message 19 of 30
(260 Views)
Highlighted

@dotis10 wrote:

@RavensFan wrote:

You could try reading registers 1010 to 1034   (start 1010, number 25)  Then index out the first two and last two registers and convert them.  If they were closer together, I would do that.  That far apart, I'd just do them as two separate reads.

 

You can try it out both ways and see if one is faster than the other.


Okay, nice! I will try index them out.

And by "two separate reads" do you mean I will use two "Read Input Register"-blocks and use the same slave IDs but different starting addresses?


Yes

0 Kudos
Message 20 of 30
(254 Views)