I have a vision software which is connected to UR through Modbus TCP and it sends 2 16bit modbus values. The software sends position(x,y) and orientation(angle) in floating point values as modbus registers. The modbus values are converted using IEEE-754 converter(How it’s done - IEEE-754 Floating Point Converter).
My question is, how to convert these modbus back into floating point values? One way I found was to list it as array of 16 bits(but UR points it out as True/False) but it’s a cumbersome process as it is 32 bits and also the least significant bit is index 0 so it goes backwards.
Is there a workaround or easier way to do this which I am missing? If anyone can shine some light, that would be wonderful!
I think our situation is similar, though we’re pulling data in through a socket.
I don’t completely understand all that’s happening, as this program was written by my predecessor, and I’m still trying to understand a lot of what I’m seeing.
Anyway, it looks like our program does a brute-force reorder of the data:
global camera_header = socket_read_byte_list(6, "Camera_Socket")
global camera_data=socket_read_binary_integer(3,"Camera_Socket")
global max_index=camera_data[0]
global index=1
# Camera and robot disagree about byte order
# So we need to reverse byte order on all data
while (index <= max_index):
global bin_list_orig=integer_to_binary_list(camera_data[index])
global bin_list_new=bin_list_orig
bin_list_new[0]=bin_list_orig[24]
bin_list_new[1]=bin_list_orig[25]
bin_list_new[2]=bin_list_orig[26]
bin_list_new[3]=bin_list_orig[27]
bin_list_new[4]=bin_list_orig[28]
bin_list_new[5]=bin_list_orig[29]
bin_list_new[6]=bin_list_orig[30]
bin_list_new[7]=bin_list_orig[31]
bin_list_new[8]=bin_list_orig[16]
bin_list_new[9]=bin_list_orig[17]
bin_list_new[10]=bin_list_orig[18]
bin_list_new[11]=bin_list_orig[19]
bin_list_new[12]=bin_list_orig[20]
bin_list_new[13]=bin_list_orig[21]
bin_list_new[14]=bin_list_orig[22]
bin_list_new[15]=bin_list_orig[23]
bin_list_new[16]=bin_list_orig[8]
bin_list_new[17]=bin_list_orig[9]
bin_list_new[18]=bin_list_orig[10]
bin_list_new[19]=bin_list_orig[11]
bin_list_new[20]=bin_list_orig[12]
bin_list_new[21]=bin_list_orig[13]
bin_list_new[22]=bin_list_orig[14]
bin_list_new[23]=bin_list_orig[15]
bin_list_new[24]=bin_list_orig[0]
bin_list_new[25]=bin_list_orig[1]
bin_list_new[26]=bin_list_orig[2]
bin_list_new[27]=bin_list_orig[3]
bin_list_new[28]=bin_list_orig[4]
bin_list_new[29]=bin_list_orig[5]
bin_list_new[30]=bin_list_orig[6]
bin_list_new[31]=bin_list_orig[7]
camera_data[index]=binary_list_to_integer(bin_list_new)
global index=index+1
end
if (camera_header[1] == 32):
# make sure main program knows camera_coords is invalid until it's fully updated
global camera_match=0
global camera_x=camera_data[1]
global camera_y=-camera_data[2]