Issues with Analog Conversion using a FB

slogannz
2023-04-16
2023-04-17
  • slogannz - 2023-04-16

    Hey everyone, I was hoping I could get some help. I am somewhat new to automation and have been programming on SE M221 PLC's for a few years. I now work for a company and have a license for Machine Expert and have been playing around with trying to teach myself structured text. I have been playing around with function blocks and have a few running but have been running into issues with this one. It is a basic analog scaling FB. Image_1 shows the program that calls the function block, Image_2 is the function block and Image_3 is it running. You can see the variables are getting written into the function block but it is not doing the calculation. Can anyone shed any light on what I might be doing wrong?

    Cheers
    Sam

     
  • ben1 - 2023-04-17

    Hey pal.

    I think it is working - I believe your use of INT's is causing it to 0 out when you divide with the Max_Input, and therefore the result of 0 is in fact correct.

    Convert to REAL's before you do the math instead of after and see if that fixes the issue.

     

Log in to post a comment.