Sign in to follow this  
Followers 0
pumpkins

Working with UINTs - Why so hard?

10 posts in this topic

I'm currently working on an application that uses UINT data exclusively. The reason for this is that the server/driver used to communicate to the SCADA package (Wonderware) natively accepts UINTs. All the SCADA addresses would require suffixes to be added to interpret them as signed integers, which is messy and confusing for maintenance. That's the reasoning - now the method. Why is it so hard to work with UINTs in CX-Programmer? Or am i missing a whole set of instructions? Fair enough that I had to do two instructions to convert a Float via Profibus to a UINT (FIX, then MOV). But is there an elegant way of adding two UINTs and putting the result in a UINT, without having to use a bunch of temporary registers? I really hope I'm missing something here - either that or I feel very sorry for anyone using Omron's on an Oil and Gas project...

Share this post


Link to post
Share on other sites
Check out the ADB instruction. And the SBB instruction, if you want to subtract stuff as well.

Share this post


Link to post
Share on other sites
there is no need to do FIX then MOV. Set the Result word in FIX instruction to address you set as destination address in MOV. for ADD you just use instruction + (Signed Binary Add Without Carry) it uses INT but the same is with UINT, and you don't need to use any temporary registers. Hope this helps regards

Share this post


Link to post
Share on other sites
Also read the first post in this thread by Jay. You can also do a search in this forum for "data types". There has been a lot of disscussion and arguments on this topic.

Share this post


Link to post
Share on other sites
Thanks for the feedback - I have searched this site regarding the problem but didn't find anything specific relating to this. I have tried using the FIX and + instructions for UINTs, but the compiler gives me warnings such as: WARNING: Symbol XXX_XXX's data type (UINT) is not compatible with the data type (INT) for this instruction operand at rung 9 ( 8, 0 ). I take it warnings are just that - a warning but the compiler will still compile the code? The only way i can see of removing the warnings is either using a MOV after the FIX, or using temporary registers. If you can in fact use UINTs for any operand stated as INT and just have to put up with the warnings, then that's fine. In that case, should my code check that my UINT will convert directly to a INT (ie. in the range 0 to 32767)? Otherwise i may get any numbers greater than 32767 being treated as a negative in the calculation.

Share this post


Link to post
Share on other sites
compiler compiles the code as long there is no error in program. I think it is possible to shut off this warning about data types, but not sure. if you put INT data type you have -32768 to 32767 range. As you can notice in + instruction you can use numbers as &123342 (decimal), with + sign and with - sign. either case instruction window shows you the range. Generaly, if we exclude REAL and STRING data types, you have only two types: HEX and BCD, in terms of storage type i.e. bits stored in actual memory register. HEX is then interpreted as INT, UINT, or HEX (CHANNEL). regards

Share this post


Link to post
Share on other sites
Please tell me where....I have neve being able to find it....in fact it was one of the point i raised originally for CX-Programmer Improvements.. To Pumpkins.... What PLC model you using ?

Share this post


Link to post
Share on other sites
Yeah, I'd now like to know if you can turn that warning off - had a look but couldn't find it anywhere. I'm using a CS1G-CPU43H. Which means I can't use ADB or SBB as they're not available in this PLC.

Share this post


Link to post
Share on other sites
for uint instructions simple use the + or - instructions..... The type checking as i mentioned, i found a pain i had over 200 warnings which is crap because then it becomes a pain to navigate through to find the actual ERROR codes so you can fix them....

Share this post


Link to post
Share on other sites
It is not SO hard if you understand the basic concepts of the numbering system that a microprocessor uses. Here is a simple and well written explanation of this concept. http://www.plcman.co.uk/numbering/

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0