Jump to content

Recommended Posts

Posted

Hello world,

I use "Send SMS" block for sending status information from the technology to users. Time-to-time I am facing a strange situation: When an integer variable inside of SMS has positive sign, everything goes OK. Unfortunately, sometimes there is need to send a negative value. Now there is an interesting situation: In some 50% of cases the value is sent normally (value with negative sign) but in the other cases user gets strange value, looking rather as binary complement of value than as a negative number.

Example of correct SMS:

P 74.0kW, Running OK, Total 279 MWh, Nivo -33mm Zadani -20mm +/-10mm, Nivo start -10mm, Diferencija -707mm, regulacija 1.

Example of incorrect format of SMS:

P 64.0kW, Running OK, Total 281 MWh, Nivo 65518mm Zadani 65516mm +/-10mm, Nivo start 65526mm, Diferencija 64829mm, regulacija 1.

SMS is configured via the "SMS Configuration" block which is called once just after the serial port is properly initialized. I tried to format variables in the SMS as Integer or as Long but the result is exactly the same. Do you know how to make the SMS to be sent correctly?

 

Thank you in advance, Michal.
(attached file is a screenshot of the SMS Config block)
  • MVP 2023
Posted

If you notice the incorrect numbers are > 32768, so the SMS block is interpreting them incorrectly as unsigned integers.  It's using the sign bit as part of the value.  

Can you post your code?

Joe T.

Posted

Yes, of course I can but this is impossible to attach here all the code (it is much more than 70 kB). Can you propose some email address? Thank you.
PS: Sorry, the attached screenshot from my last post disappeared, so I try to post it once more..SMS Config-min.JPG

Posted

Thank you Joe,

unfortunately using of two byte variable is not a way. My original design of the SMS config used MI and 4 digits. I changed it to ML after complaints from the plant user. After changing from MI/4 digits to ML/6 digits the problems seemed to be solved for a short time. After one week the wrongly formatted SMS came again. Maybe there is some bug inside of the SMS config function block. Today I will make workaround - I will break the variable into 2 parts - sign and absolute value of the operand. The value in the SMS will consist from one binary and one integer variable.

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

This site uses cookies. By clicking I accept, you agree to their use.