11 posts in this topic

Hi everyone<

i need some help with CX programmer i have written a programm as when i enter the Set value on HMI in D892 and press enter the Input 1100.01 energises and this executes Substract block (415) which sbstracts #6 fron D892 and saves it in D896. Them Comparison b;ock (300) compares D896 with #0 and as soon as D896 is equals to 0 the ouput flag W11.01 energises

Now as u can see in the image below the value in D896 in substraction block and Comparison block are different and this is causing the output to energise at wron count . Why is there a difference In the D896 value?? 

InkedUntitled1_LI.jpg

Share this post


Link to post
Share on other sites

You are using BCD subtraction, but the comparison is decimal.  Different interpretation of the bits in the word, so different apparent value.  Why are you using BCD ?

Share this post


Link to post
Share on other sites

the =(300) is displaying decimal like pturmel said. If you are only comparing with 0 though it will still work as 0 is 0 in every datatype. It will just display an odd number most of the time.

Share this post


Link to post
Share on other sites

I will repeat Pturmel's question: Why are you using BCD?
BCD was useful during the era of 7-segment indicators and thumbwheel switches, and is supported by Omron for backwards compatibility with old projects or PLCs.
There is no reason nowadays to use BCD representation. Go binary mode.

 

Edited by Sergei Troizky

Share this post


Link to post
Share on other sites

Hello,

Yes it is a quite old project and old plc and existing programm, i m just trying to add some rungs in the programm for modification 

Share this post


Link to post
Share on other sites

If you must use BCD, just put your comparison constant in using hex.  Integer ordering within BCD is still valid, just the constants look odd if not displayed as hex.  But the right answer is to use decimal in the HMI and in the PLC code for all new stuff, where possible.  Don't add new BCD.

Share this post


Link to post
Share on other sites

His comparison constant is input using hex (#0).  The code is working exactly as intended and is done correctly.  The only issue is that D896 is being displayed as an Unsigned Integer (that is what & means).  To force it to show BCD (HEX), just click the button in the toolbar that has a pair of eyeglasses and the number 16.

62e2a4cfd8fb1_Monitorhex.jpg.0a01c12c856

1 person likes this

Share this post


Link to post
Share on other sites

HI,

I Have changed the substraction block as u can see from BCD to DINT but still in the comparison block the vaklues are showing correct till INT limit (i.e. 65535) and any value above that doesn't work i have attached two pictures of the situation. why does the Equals to block(300) only shows correct value till INT limit and not DINT.

 

InkedNEW1_LI.jpg

InkedNEW2_LI.jpg

Share this post


Link to post
Share on other sites

Use "=L(301)".

CX Programmer and Omron PLCs are very flexible but you must be mindful of your data types.

Apples to apples.

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