Jump to content

Recommended Posts

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)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...