11/3/2022 0 Comments Rslogix copy int to two bytes![]() ![]() 'Put a 16 bit HIGH word and a LOW word into a 32 bit Integer.ĭim aHighWord As Int16 = &H 7FFF '= 32767 is the MAXIMUM value for a Int16ĭim m圓2BitNum As Int32 = ConvertToInt32(aHighWord, aLowWord) Private Sub Button1_Click( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Public Function ConvertToTwoInt16s( ByVal aInt32 As Int32) As Int16() Public Function ConvertToInt32( ByVal highWord As Int16, ByVal lowWord As Int16) As Int32 The 2nd of the 2 functions splits a 32 bit number into 2 equal 16 bit portions using an array to pass back 2 values.Īdd one button to a FORM and PASTE ALL of this code into a FORM window and try this code please.> In &H FFFF EEEE the FFFF is the highWord and the EEEE the low word. ![]() However if it is of any use to you these 2 functions will join two 16 bit numbers into a 32 bit number by taking one as the high word and the 2nd as the low word. I do not know the format of a 32 bit floating point number. I then need to manipulate the data as 32 bit singles, then break the singles into 2 16bit shorts before placing them back into the csv file for consumption by the plc. This has the effect of creating several 32 bit floats from 2 16 bit ints without regard to the actual values. The problem is the source file comes from a plc with fixed sequential registers were 16 bit integers and 32 bit floats are all saved in a sequential series of 16 bit registers whose contents are then placed 16bits at a time into a csv file. ![]() I am trying to convert a csv file of 16 bit shorts (signed ints) variables into singles (32 bit float). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |