You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

Reply
 
Thread Tools Display Modes
Old September 12th, 2021, 07:22 AM   #1
BAT
Member
Norway

BAT is offline
 
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
  Reply With Quote
Old September 12th, 2021, 08:06 AM   #2
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 5,576
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.
  • Do you want to change (overwrite the 50% larger product to) the output value of the scaling function block itself, or do you want to write the product to a new location?
  • What type of data are being multiplied, single or double, signed or unsigned, binary or BCD or floating point?
If you make a screen dump of the relevant section of the program, and annotate it to answer the questions above, it might help get a better answer.
__________________
_
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
  Reply With Quote
Old September 12th, 2021, 08:28 AM   #3
gclshortt
Member
Canada

gclshortt is offline
 
gclshortt's Avatar
 
Join Date: Dec 2014
Location: Ontario
Posts: 3,219
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/
  Reply With Quote
Old September 12th, 2021, 08:37 AM   #4
BAT
Member
Norway

BAT is offline
 
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
Attached Images
File Type: png 1.png (39.6 KB, 30 views)
  Reply With Quote
Old September 12th, 2021, 09:51 AM   #5
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 5,576
Have you tried
  • 1.5
instead of
  • 1,5
?

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

Last edited by drbitboy; September 12th, 2021 at 09:56 AM.
  Reply With Quote
Old September 12th, 2021, 11:11 AM   #6
BAT
Member
Norway

BAT is offline
 
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
  Reply With Quote
Old September 12th, 2021, 12:10 PM   #7
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 5,576
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

Last edited by drbitboy; September 12th, 2021 at 12:41 PM.
  Reply With Quote
Old September 12th, 2021, 12:43 PM   #8
parky
Member
United Kingdom

parky is offline
 
parky's Avatar
 
Join Date: Oct 2004
Location: Midlands
Posts: 4,292
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.
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Topics
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


All times are GMT -4. The time now is 08:21 AM.


.