Sign in to follow this  
Followers 0
Sp3llCast3r

Rotate Left

8 posts in this topic

Hi again! I'm having problems working with ROL function. Imagine a production line, where I have 3 cookie sensors. ;) I want to get sure that when "cookies" enter in rolling carpet, they pass throught the 3 sensors and nobody eat the cookie meanwhile. If they eat the cookie, the rolling carpet stops and they have to put another cookie or puke it, so they can restart the carpet. :o So I have two words: IR200 and IR202 IR200 = Checks/Gets data from inputs. (what's happening to the cookies) IR202 = Sequence of entering data. (what should happen to the cookies) Cycle Starts ROL(202) ROL(200) (I only use 3 inputs, so I ROL(200) to get sure the other bits I don't use are equal to 202 bits, because I only want to compare the first 3 bits) 202.0 = Input1 (Did any cookie entered?) 200.0 = Input1 200.1 = Input2 200.2 = Input3 Compare 200 with 202 (compare de sequence that cookie should have with What really happened) If the sequence is not respected. Machine stops until Inputs = Sequence. The problem is: I get crazy HEX values on Sequence Word. I suspect on Carry, but I don't know what to do with it. Can some enlightned mind help me? Any other sugestions for this exercise? CPU: Omron CPM1A20 Software: CX-Programmer 5.0 Thanks in advance, Sp3llCast3r.

Share this post


Link to post
Share on other sites
Hi. The Intruccion ROL sends the Bit 15 to CY and the value of CY al Bit 0. If do not you want that the CY interfere in the displacement uses the Intruccion ASL(25), in the bit 0 puts always a "0"

Share this post


Link to post
Share on other sites
Thanks for your reply. Yes, that's true. But if you read again what I wrote you'll see that I replace the 0 bit of 200 and 202 with the value of the Input1. I don't use any mathematical functions so... problably carry don't affect my program, but it still doesn't work. Sequence Word example with 3 bits for one cookie: 123 > Inputs ---- 000 100 010 001 000 For two cookies: 123 > Inputs ---- 000 100 110 011 001 000 And so on... It should be simple... why I can't get a "logical" value on the sequence word? Sometime I get like.. 65xxx HEX value... sometimes I get the correct value... Help please! :)

Share this post


Link to post
Share on other sites
Are you using the '@' symbol for the ROL instruction? This will cause the instruction to execute only once when the input comes on. If you don't use it the instruction will execute once for each program scan while an input is on. eg: @ROL instead of ROL

Share this post


Link to post
Share on other sites
Hi again. I believe to understand, that you only use the three first Bit of the word, in that case that do with the values once have displaced them but of three positions?? If those Bit they arrive al final of the word, when the value be 1 they activate you the bit of sign, (Bit 7) and depending on as be read the value of the word considers it you like complement to two, that is to say: 65535 - word + 1. If only an operation is done of LSR on the word and in some cases the value is correct and in other appears you 65535 - Value, only occurs itself me that can be that. [sorry for my English. I traslate with www. freetranslation.com]

Share this post


Link to post
Share on other sites
Thanks for your support mates. Although... I can't do it... I need to take an OMRON course urgently... and to read manuals... because I'm used to work with the SIEMENS system. Once again, thanks for your patience! Hugs.

Share this post


Link to post
Share on other sites
Can I ask why you are using the Rotate command and not just a normal shift register? Try using SFT instead and see if it give you the results you want. Another thing, you might try using a mask on the words before comparing so that you ONLY compare the 3 bits. Ex: [CMP 202 200] will compare all 15 bits, if you AND 202 and 200 with 0007 it will mask off all bits except the value in *.0, *.1, *.2 so it would be: [LD 253.13] [AND #0007 202 D0] [AND #0007 200 D1] (do both of these as an always on) [CMP D1 D0] Try these two options and see how they work for you. Edited by Jay Anthony

Share this post


Link to post
Share on other sites
Good call, Chris!

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