Converting Two SINT Values to Float: Troubleshooting Methods and Approaches

Question:

Hello, I am new to this topic so please be patient with me. I have been researching and experimenting with different methods, as some aspects are unfamiliar to me. I am currently working with a CompactLogix device running version 32, connected to an ethernet device with an EDS file. This setup generates SINT input and output arrays, including MSB and LSB pairs, whole numbers, and two-digit decimal numbers ranging from 0.00 to 100.00%. I have attempted various approaches, such as transferring the SINT values to an INT and then to a REAL, but have not found the correct solution yet. I also explored the BTD function to manipulate bits, but I am unsure if that is the right approach. Another method I tried was using a CPT block to calculate SINT[1] + (SINT[2]/100) to achieve the desired outcome, although I am uncertain if this is the most effective method. Additionally, I am working with three SINT numbers, but I am unsure of their arrangement, with one representing revolutions and another representing hours. Thank you for your understanding.

Top Replies

If you're looking for documentation for the "ethernet device" with the EDS file, that would be a great starting point. It may seem unconventional to store whole percent and fractional percents in two SINTs, but if it works for you, then "if it ain't broke, don't fix it!" What led you to use the CPT statement initially? Have you checked for external sources to confirm the accuracy of the result?

I possess the documentation for a Blue White Industries Peristaltic pump, according to the label. I have assumed that the offsets correspond to the SINT array, but I have not yet connected any pumps for testing. The use of CPT was a result of my laziness and lack of expertise in adding decimal points between numbers. Additionally, I struggled with manipulating bits due to my unfamiliarity with the process. There are a few other numbers that I am uncertain how to integrate into the overall setup.

The four-byte numbers found in Tube Revolutions (offsets 16-19) and Tube Hours (offsets 20-23) may require a conversion to DINT, UDINT, or possibly REAL data types. It is important to note that byte order issues may potentially arise during this process.

When analyzing the document provided, it is noted that one SINT corresponds to a value of 50, while another SINT represents a value of 34, resulting in a total of 50.34 for Motor Percent. To accurately calculate the real value, a CPT of REAL = MSB + LSB/100 can be performed. It is important to combine the 4 SINTs into a DINT using a BITD to prevent potential byte order complications. It is likely that the MSB and LSB pair constitute a DINT, rather than a float, especially when dealing with counters. This approach will help avoid any issues related to byte order, as mentioned by Drbitboy.

Robertmee mentioned that based on the provided document, one SINT equals 50 and the other equals 34, making the total value 50.34 for Motor Percent. To calculate the real value, perform a CPT with REAL = MSB + LSB/100. In the event of a MSB and LSB pair, combine the 4 SINTs into a DINT to prevent byte order issues. For converting a human-entered number like 12.34 into separate SINTs, consider using MOD to separate the decimal and then performing multiplication and subtraction. If the digits represent parts of a larger number, a simple formula like (SINT[1]*1000)+(SINT[2]*100)+(SINT[3]*10)+SINT[4] could be used, as long as the numbers in the hundreds, tens, and ones digits are below 10.

Welcome to the forum! Your experimentation sounds quite extensive so far. Have you considered using a COP instruction to move your SINT data into a DINT? This could help you handle the SINTs as an accumulative 32-bit DINT, which might simplify your process. Regarding your three SINT numbers, they seem to be part of a larger structure - perhaps consider them as elements of the same array represented in different units (revolutions, hours, etc.) rather than separate entities. Sharing more about the logic behind their arrangements might help us provide more targeted advice. Keep pushing, and don't hesitate to ask questions, everyone here is willing to help.

Hey there, welcome to the forum! Your commitment to understanding the topic deeply is truly impressive. For the task you're engaged in, might I suggest using the COP instruction? This is very useful in copying arrays and could resolve your issue with getting the correct SINT values into a real format. It’s tricky to provide a precise solution without knowing the exact structure of your SINT arrays, but this method might certainly help. Regarding your arrangement of the three SINT numbers, typically, in a time-specific situation, one refers to hours, one to minutes, and one to seconds but again, it depends on the specific use-case. Hope this helps somewhat. Keep exploring and don't hesitate to ask more questions.

More Replies β†’

Streamline Your Asset Management
See How Oxmaint Works!!

βœ…   Work Order Management

βœ…   Asset Tracking

βœ…   Preventive Maintenance

βœ…   Inspection Report

We have received your information. We will share Schedule Demo details on your Mail Id.

To add a comment, please sign in or register if you haven't already..   

Frequently Asked Questions (FAQ)

FAQ: 1. Question: What is the purpose of converting two SINT values to a float in this scenario?

Answer: Answer: The purpose of converting two SINT values to a float is to manipulate and process input and output data in a CompactLogix setup, particularly for values ranging from 0.00 to 100.00% in this case.

FAQ: 2. Question: What methods have been attempted to convert the SINT values to a float?

Answer: Answer: Various methods have been explored, including transferring SINT values to an INT and then to a REAL, using the BTD function to manipulate bits, and employing a CPT block to calculate a specific formula to achieve the desired outcome.

FAQ: 3. Question: Are there any specific challenges faced when converting SINT values to a float in CompactLogix devices?

Answer: Answer: Challenges may include determining the correct approach for conversion, understanding the arrangement of multiple SINT numbers representing different parameters such as revolutions and hours, and ensuring the accuracy and effectiveness of the chosen method.

FAQ: 4. Question: How can one effectively convert SINT values to a float in a CompactLogix setup?

Answer: Answer: To effectively convert SINT values to a float in a CompactLogix setup, it is essential to experiment with different methods, consider the data range and precision required, and possibly consult relevant documentation or forums for insights and troubleshooting tips.

Ready to Simplify Maintenance?

Join hundreds of satisfied customers who have transformed their maintenance processes.
Sign up today and start optimizing your workflow.

Request Demo  β†’