Posted 16 Dec 2005 I am using a CPW comand to move a word to another file were I need to multiply the word, (or would like to) instead of each bit in the word. can this be done? Share this post Link to post Share on other sites
Posted 16 Dec 2005 You can multiply a word by using the MUL function. Share this post Link to post Share on other sites
Posted 16 Dec 2005 Do you mean multipy each bit in a word or multilpy each word that you are copying by something(example need to multiply N7:0 through N7:5 by 5) Share this post Link to post Share on other sites
Posted 16 Dec 2005 TWControls, Yes that is what I am trying to do. If I just use the MUL it only multiplys one bit! Share this post Link to post Share on other sites
Posted 16 Dec 2005 Which one. If what you stated is what you are trying to do, use techjunki's post. If what I stated is what you want to do, how many are you trying to manipulate and do you need to do it in a single scan. The easiest solution depends on these things. Share this post Link to post Share on other sites
Posted 16 Dec 2005 TWControls, I am trying to do what you wrote. I have copyed a word N15:0 through N15:6 and move it to N80:0 through N80:6 I need to multiply in one scan. Share this post Link to post Share on other sites
Posted 16 Dec 2005 (edited) I think you may be a little confused between a word and a bit: A bit is addressed as N80:0/1 -- one bit (bit 1) of a 16 bit Word The word would be N80:0 -- One 16 bit word A group of seven words is what you are working with N80:0 to N80:6. Are you trying to multiply all seven word together or multiply all words by a certain number?? Explain the math you want to perform?? I assume you are using a Micrologix PLC what version is it, as the instructions vary among the different series. Edited 16 Dec 2005 by TechJunki Share this post Link to post Share on other sites
Posted 16 Dec 2005 (edited) You are right I am confused sorry. I am trying to multiply, N80:0 through N80:6 by 2 at one time. using a Micrologix 1500 Edited 16 Dec 2005 by Brad Share this post Link to post Share on other sites
Posted 16 Dec 2005 Just to clarify this is the math N80:0 x 2 = N80:0 N80:1 x 2 = N80:1 N80:2 x 2 = N80:2 N80:3 x 2 = N80:3 N80:4 x 2 = N80:4 N80:5 x 2 = N80:5 N80:6 x 2 = N80:6 And you would like to do this with only one instruction?? Share this post Link to post Share on other sites
Posted 16 Dec 2005 For just 7 values I would use the MUL 7 times like Techjunki said. If you have a boat load of them to do might be able to do something similiar to RsLogix 5000s FOR statement but it's a real pain in RsLogix 500. Share this post Link to post Share on other sites
Posted 16 Dec 2005 I don't think such an instruction exists. Your only real option (there are other more complex ones) is to have a seperate multiply for each word. Share this post Link to post Share on other sites
Posted 16 Dec 2005 I think the simplest way to do this would just be to branch 7 MUL in one rung and multiply them all individually. There are other ways but they are unecessarily complicated for this. Share this post Link to post Share on other sites
Posted 16 Dec 2005 Easy is better. Thank-you all for your time and the help! Share this post Link to post Share on other sites
Posted 17 Dec 2005 Unfortunately, FAL (which can do math operations on multiple words in a single instruction and scan) is not available on the ML1500. TechJunk has suggested the best option for for the ML1500. Share this post Link to post Share on other sites
Posted 19 Dec 2005 Would a rotate instruction be helpfull here? Since multiplication by two just shifts one space left? Usually bit shifts are quicker than multiplies. Share this post Link to post Share on other sites