![]() ![]() ![]() ![]() ![]() ![]() |
||
![]() |
||
![]() ![]() ![]() ![]() This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc. |
||
![]() |
![]() |
#1 |
Member
![]() ![]() Join Date: Sep 2021
Location: Rogaland
Posts: 5
|
Omron CP1L multiplying
Hi!
Newbie here... Cx-programmer CP1L PLC NB7 HMI I want to multiply something i by 1,5 in CX-Programmer to get a higher number to use in HMI. Example: -I have a 4...20mA scaling in a function block that gives me the GRAPH with +0...+1000. -I want the output in the function block to be multiplied by 1,5 after scaling is done. -So that when output is ex 500 my sourceword is 750, and when output is 1000 i have sourceword 1500 I might be dumb, but I am in a learning process |
![]() |
![]() |
#2 |
Lifetime Supporting Member
|
Welcome to the forum.
I see there are several multiply instructions in CP1L; see here: https://assets.omron.eu/downloads/ma....pdf#G10.33720 and here: https://assets.omron.eu/downloads/manual/en/v1/w451_cp1_cpu_unit_programming_manual_en.pdf#G11.57 824 and here: https://assets.omron.eu/downloads/ma...D847.CS1H.Only But we don't really have enough information to answer the question e.g.
__________________
_ Brian T. Carcich i) Take care of the bits, and the bytes will take care of themselves. ii) There is no software problem that cannot be solved with another layer of indirection. iii) Measurement is hard. iv) I solemnly swear that I am up to no good ![]() v) I probably have the highest ratio of forum posts to actual applications in the field (∞). vi) Hakuna matata. vii) Bookkeeping. |
![]() |
![]() |
#3 |
Member
|
https://accautomation.ca/omron-cp1h-math-instructions/
The above post will discuss the math instruction in the CP1. This is a link to the entire series. https://accautomation.ca/series/omron-plc-cp1h-series/ I hope this helps you out. Regards,
__________________
Garry https://www.accautomation.ca Connect with us on Facebook: facebook.com/accautomation/ |
![]() |
![]() |
#4 |
Member
![]() ![]() Join Date: Sep 2021
Location: Rogaland
Posts: 5
|
Thanks for Reply!
See picture. This is what I want, but I get the wrong result word. I have tried with other numbers in the "first multiplier word" too. * and *D Will not let me use "," in my numbers. Meaning no decimals. -I want to write it to another position. You can see I take one word, and multiply it by a constant, and want a result word for further use. -I think you get the other answer on the picture aswell |
![]() |
![]() |
#5 |
Lifetime Supporting Member
|
Have you tried
Also, the multiplicand appears to be an integer, the [*F] instruction might require casting it to a floating-point value, and you can then then cast the floating-point result from [*F] back to an integer; this approach would take three instructions. Another approach that needs only two instructions would be to use a signed multiply by 3, then a signed divide by 2.
__________________
_ Brian T. Carcich i) Take care of the bits, and the bytes will take care of themselves. ii) There is no software problem that cannot be solved with another layer of indirection. iii) Measurement is hard. iv) I solemnly swear that I am up to no good ![]() v) I probably have the highest ratio of forum posts to actual applications in the field (∞). vi) Hakuna matata. vii) Bookkeeping. Last edited by drbitboy; September 12th, 2021 at 09:56 AM. |
![]() |
![]() |
#6 |
Member
![]() ![]() Join Date: Sep 2021
Location: Rogaland
Posts: 5
|
"Another approach that needs only two instructions would be to use a signed multiply by 3, then a signed divide by 2."
This worked ofc! Thank you for just doing it simple ![]() |
![]() |
![]() |
#7 |
Lifetime Supporting Member
|
I am glad that worked out!
TL;DR Another way to express 1,5 without commas or decimal points is 15e-1 Although given the example, where F* takes arguments of 1000 and 1,5 multiplies them, and gives a result of 750, makes me wonder what else is wrong with that processor/language/brand of plcs. Or maybe the problem was using an integer value for the multiplicand and/or product in a floating-point instruction; in a CX-Programmer manual, I found this: xxx.png
__________________
_ Brian T. Carcich i) Take care of the bits, and the bytes will take care of themselves. ii) There is no software problem that cannot be solved with another layer of indirection. iii) Measurement is hard. iv) I solemnly swear that I am up to no good ![]() v) I probably have the highest ratio of forum posts to actual applications in the field (∞). vi) Hakuna matata. vii) Bookkeeping. Last edited by drbitboy; September 12th, 2021 at 12:41 PM. |
![]() |
![]() |
#8 |
Member
|
Most PLC's to do floating point maths you must make the two variables into floats. so for example if you have a raw analogue this would probably be a 0-32000 or what ever, convert it to a float (some call it a real) then do the maths.
Using PLC's like Omron & Mitsubishi where the registers are 16 bit floats use 2 16 bit registers, I do know that Mitsubishi will not compile if using symbols that have been declared as integers or words in a floating point maths function, however, using direct registers like D100 will assume the float value would be in D100 & D101, so it will compile but give the wrong answer. |
![]() |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
WinCC V15.1 and Omron CP1L | fons04 | LIVE PLC Questions And Answers | 0 | July 24th, 2020 11:26 PM |
Red Lion DA10A and OMRON CP1L communication | krzydec | LIVE PLC Questions And Answers | 0 | March 13th, 2020 06:58 AM |
PLC CP1L with CJ1W-CIF12 connected to OMRON MX2 drivers | joserc | LIVE PLC Questions And Answers | 2 | April 7th, 2019 12:51 PM |
Omron CP1L and Redlion G308 | trespaser5 | LIVE PLC Questions And Answers | 3 | October 30th, 2012 01:18 AM |
Omron CP1L to NT11 Screen Help | Critt | LIVE PLC Questions And Answers | 1 | May 5th, 2012 12:52 AM |