Posted 24 Jul 2022 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?? Share this post Link to post Share on other sites
Posted 24 Jul 2022 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
Posted 24 Jul 2022 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
Posted 24 Jul 2022 Can i use a BCD comparison? Which is the BCD comparison block Share this post Link to post Share on other sites
Posted 24 Jul 2022 (edited) 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 24 Jul 2022 by Sergei Troizky Share this post Link to post Share on other sites
Posted 24 Jul 2022 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
Posted 25 Jul 2022 Hi, What if i use a ZCP (88) block. Would that work? Share this post Link to post Share on other sites
Posted 25 Jul 2022 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
Posted 28 Jul 2022 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. 1 person likes this Share this post Link to post Share on other sites
Posted 3 Aug 2022 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. Share this post Link to post Share on other sites
Posted 3 Aug 2022 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