LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Convert byte to integer, have troube in type cluster

The 2 bytes should be interpreted as a single 16 bit integer. So, 0x3193 would equal 12691, which does not seem correct for the temperature since that would equate to 1269.1 degrees Fahrenheit according to the documentation. Are you sure that you are using the correct 2 bytes. Based on the limited snippet of the documentation you posted I think your temperature would be 0x0231, which would equate to 56.1 degrees.

 

Without having all of the details, I would guess that the values for your inside temperature, humidity and out temperature would be the bytes 0xF902319303, with the temperatures in little endian format.

 

This would mean that the inside temp would be 76.1, humidity is 49% and the outside temp is 91.5. I am not sure what the extra bytes in the beginning of your data would be then.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 11 of 57
(1,026 Views)

I think you're correct! This is very close to the real temperature here. And my capture pic includes the beginning of the data. There is no extra data before 064C, 06 as ACK, 4C as L. 

Since it is in little endian, I guess I'd better use Unflattern from String so that I can set the byte order. Sorry I still don't know how to set type. I changed the representation of constant 0 to U16. But this didn't work.

Capture.PNG

0 Kudos
Message 12 of 57
(1,019 Views)

@feelsomoon wrote:

Yes, I did. I tired the original example and it worked. But the return data in the indicator is like. Can I add your code after the read Serial VI?

 

random.PNG


Why is your command Loop 1/n in normal display which means you are sending a literal forward slash "n" at the end.  That is not a new line character.

Your command should be Loop 1\n with the control set to \codes mode which means "Loop 1<LF>"  a linefeed/newline character!

Message 13 of 57
(1,007 Views)

What I would do is define a cluster to match the definition of the protocol and unflatten the entire set of data, all 12 bytes, into that cluster. That way you have access to all of the data.

 

Without the entire protocol definition there was no way to know that the 0x064C was and ACK and an L, nor why they are there. The brief snippet of the protocol definition indicated the external temperature started at byte 12. In the picture you posted the temperature was located at byte 14, hence my comment about the extra data in the beginning.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 14 of 57
(978 Views)

@Mark_Yedinak wrote:

Without the entire protocol definition there was no way to know that the 0x064C was and ACK and an L, nor why they are there. The brief snippet of the protocol definition indicated the external temperature started at byte 12. In the picture you posted the temperature was located at byte 14, hence my comment about the extra data in the beginning.


The snippet is actually showing starting with ACK "LOO".  Seems like the protocol is stating what it is acknowledging.  But, again, this is pure conjecture without having documentation on the full protocol.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 15 of 57
(968 Views)

@crossrulz wrote:

@Mark_Yedinak wrote:

Without the entire protocol definition there was no way to know that the 0x064C was and ACK and an L, nor why they are there. The brief snippet of the protocol definition indicated the external temperature started at byte 12. In the picture you posted the temperature was located at byte 14, hence my comment about the extra data in the beginning.


The snippet is actually showing starting with ACK "LOO".  Seems like the protocol is stating what it is acknowledging.  But, again, this is pure conjecture without having documentation on the full protocol.


It's true. It is started with ACK LOO. I splited the part I need so its type should only be U16. I'm sorry I'm still confused about defining the type. I put a constant 0 in the cluster. Then change its representation to U16. This didn't work. Then I tried makedef. It didn't work, either. Could you teach me how to define the type for the Unflatten from String function? I know it's super basic but I've looked through many tutorials and didn't find the answer.

protocol.PNG

0 Kudos
Message 16 of 57
(957 Views)

@RavensFan wrote:

@feelsomoon wrote:

Yes, I did. I tired the original example and it worked. But the return data in the indicator is like. Can I add your code after the read Serial VI?

 

random.PNG


Why is your command Loop 1/n in normal display which means you are sending a literal forward slash "n" at the end.  That is not a new line character.

Your command should be Loop 1\n with the control set to \codes mode which means "Loop 1<LF>"  a linefeed/newline character!


Thanks for your correction. Could you give me some suggestions about defining type in a cluster? I put a constant 0 in the cluster. Then change its representation to U16. This didn't work. Then I tried makedef. It didn't work, either. Could you teach me how to define the type for the Unflatten from String function? I know it's super basic but I've looked through many tutorials and didn't find the answer.

0 Kudos
Message 17 of 57
(955 Views)

@feelsomoon wrote:

Thanks for your correction. Could you give me some suggestions about defining type in a cluster? I put a constant 0 in the cluster. Then change its representation to U16. This didn't work. Then I tried makedef. It didn't work, either. Could you teach me how to define the type for the Unflatten from String function? I know it's super basic but I've looked through many tutorials and didn't find the answer.


My question now is what is the rest of the data string you are getting?  There are a lot of 0xFFs in there.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 18 of 57
(944 Views)

@crossrulz wrote:

@feelsomoon wrote:

Thanks for your correction. Could you give me some suggestions about defining type in a cluster? I put a constant 0 in the cluster. Then change its representation to U16. This didn't work. Then I tried makedef. It didn't work, either. Could you teach me how to define the type for the Unflatten from String function? I know it's super basic but I've looked through many tutorials and didn't find the answer.


My question now is what is the rest of the data string you are getting?  There are a lot of 0xFFs in there.


I guess it's because we put the sensor indoor. So there is no available precipitation or wind data. Sorry if I misunderstand, are you just put constant number 0 in the cluster? How does it know what size is each parameter? I did the same for the part just Outside Temperature, it didn't work. Do you know what's the problem?

ufs.PNG

0 Kudos
Message 19 of 57
(929 Views)

@crossrulz wrote:

@feelsomoon wrote:

Thanks for your correction. Could you give me some suggestions about defining type in a cluster? I put a constant 0 in the cluster. Then change its representation to U16. This didn't work. Then I tried makedef. It didn't work, either. Could you teach me how to define the type for the Unflatten from String function? I know it's super basic but I've looked through many tutorials and didn't find the answer.


My question now is what is the rest of the data string you are getting?  There are a lot of 0xFFs in there.


I was just in the process of posting the same thing. You beat me to it. It appears that wind speed is not included in the data, or it is VERY windy there.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 20 of 57
(928 Views)