Posted 12 September I have a small piece of code I have been using in GE 90-30 PLC's thats works great controlling my message base, I use Omron PLC's as well, but I can't put my finger on how to duplicate the same instruction on an Omron CJ2M PLC, The 2 instructions are Bit Position Word and Bit Test Word in the GE ladder. Basically the bit position instruction scans the word (R1) until it finds the first bit set to (1) then sets that same bit in position in (R10) Then remains that way until that first bit it found gets sets back to (0) then scans again until it finds the next bit set to (1) ETC. Then I block out and other bits until I see the first bit go low "Bits not equal" Does Omron have an instruction that works the same. Please see the attached PDF for example of code. Thanks! Dean Bit Position.pdf Share this post Link to post Share on other sites
Posted 12 September I'm not familiar with those instructions, but there's math that can perform the same task when searching from low bit to high bit: Output = Input AND ((NOT Input)+1) That takes and input word with any bits turned on, and yields an output word containing just the lowest 1-bit. (I'm not aware of any math trick that yields the highest 1-bit instead of the lowest.) Share this post Link to post Share on other sites
Posted 12 September Interesting, How would I apply that using H1 Thanks! Dean Share this post Link to post Share on other sites
Posted 12 September 3 hours ago, Dinos said: using H1 No idea. Not familiar with the CJ family of processors. Only lightly exposed to the NJ family (with Sysmac Studio). I used AB pseudocode for a CPT instruction. You'll have to translate that to the appropriate bit-wise logical operations in CX-programmer. Share this post Link to post Share on other sites
Posted 12 September I'm unaware of a similar instruction in the CJs (but I'm not an expert). You're dealing with bits in a word on an address-based platform - I would just make 16 rungs to analyze the first bit that's true and report that number. Share this post Link to post Share on other sites
Posted 13 September Yes I considered doing just that with using 16 rungs, but was hoping for a simpler way like I do it in the GE 90-30 PLC. If I find an answer I will post it. Thanks! Dean Share this post Link to post Share on other sites
Posted 13 September Data Encoder:- DMPX(077) Instruction might be what you are looking for? 1 person likes this Share this post Link to post Share on other sites
Posted 14 September Thank you Bits N Bytes for the suggestion that does work well to a point. I failed to mention in my earlier post about the amount of messages I have. That DMPX instruction did work up to the 16 bit, but I have 3 words worth the alarm messages, could you us this be applied to accommodate 3 words, if so how would I approach that. Thanks! Dean Share this post Link to post Share on other sites
Posted 14 September The DMPX instruction control word C specifies how conversion occurs. Setting third digit of the C word to 0 specifies 16-to-4bits conversion. Between 1 and 4 words can be processed based the setting of digit 1 by setting it between 0-3. Setting digit of the C word to 1 specifies 256-to-8 bits conversion. In this case a block of contiguous block of 16 or 32 words is searched by setting digit to 0 or 1. For a full explanation and sample code for this instruction in Omron Manual W340. Here is link:- http://www.edata.omron.com.au/eData/PLCs/CJ1/W340-E1-17.pdf 1 person likes this Share this post Link to post Share on other sites
Posted 15 September On 9/13/2023 at 6:23 AM, BITS N BYTES said: Data Encoder:- DMPX(077) Instruction might be what you are looking for? First let me give BITS N BYTES a great big THANK YOU for pointing me into this direction, with experimenting I was able to get the results I wanted. Here is my final code that seems to be working flawlessly "At lest it appears to be" Omron Message Control.pdf 1 person likes this Share this post Link to post Share on other sites
Posted 16 September There is TST.. https://forums.mrplc.com/index.php?/topic/42330-test-bit-instruction/ Share this post Link to post Share on other sites
Posted Sunday at 3:59 AM 20 hours ago, lostcontrol said: There is TST.. https://forums.mrplc.com/index.php?/topic/42330-test-bit-instruction/ Yes that is what I used to mask other bit's until the first bit is cleared. Share this post Link to post Share on other sites