spence144db
Member
I need help coming up with some code...I have have an array Part_Number.PreForge_Temp[220]. With a pyrometer I scan the part for 2 seconds and fill the array with a FIFO every at a 10ms interval till its full. I need help coming up with some math or code to search the array and find the element that is closest to my desired temp setpoint.
With the ex. below Part_Number.PreForge_Temp[5] would be the closest to my target temp. I need a way to return this result. Google has only returned ways to do this is a PC environment like Java.
Part_Number.Target_Temp = 1085 C
Part_Number.PreForge_Temp[0] = 1098 C
Part_Number.PreForge_Temp[1] = 1112 C
Part_Number.PreForge_Temp[3] = 1034 C
Part_Number.PreForge_Temp[4] = 1058 C
Part_Number.PreForge_Temp[5] = 1074 C
.
.
.
.
.
Part_Number.PreForge_Temp[220] = 1100 C
Edit: Sorry I assumed most would know by tag structure but just incase..1756-L73S (AB ControLogix PLC)
With the ex. below Part_Number.PreForge_Temp[5] would be the closest to my target temp. I need a way to return this result. Google has only returned ways to do this is a PC environment like Java.
Part_Number.Target_Temp = 1085 C
Part_Number.PreForge_Temp[0] = 1098 C
Part_Number.PreForge_Temp[1] = 1112 C
Part_Number.PreForge_Temp[3] = 1034 C
Part_Number.PreForge_Temp[4] = 1058 C
Part_Number.PreForge_Temp[5] = 1074 C
.
.
.
.
.
Part_Number.PreForge_Temp[220] = 1100 C
Edit: Sorry I assumed most would know by tag structure but just incase..1756-L73S (AB ControLogix PLC)
Last edited: