Omron - Real values

alekbeck

Member
Join Date
Mar 2009
Location
Tønsberg
Posts
40
This time i need help with real values.

First - how do i write real values ?

I want to multiply the analoge input a with number (for example 1.14)

Do i first convert the input to real, multiply by 1.14 and then convert back to INT ?
 
Took me a minute to research the REAL data type.

This is a double floating point value (CX-Programmer Op Manual)
You can use the FLT or FLTL instructions to convert a 16 bit or 32 bit value to floating point format.

Then you can use the floating point math instructions to manipulate your values.

You may want to take a look at the W340 manual (CS/CJ Series Programming Manual). You may also want to look at the CX-Programmer Operation Manual, it should have installed with the program and is accessible from your Start Menu.

Hope this helps.
 
Maybe i just are thinking wrong. This is my problem:

I want to multiply analoge input signal (lets say it is &2000) by a factor (lets say its 1,22). I will use the result as input in a PID block, so the result has to be INT doesent it ? The multiply factor will be set in in a controllscreen (NS10)
 
Okay, thanx i think i understand. But how do i move a float number to D100 ? I tryed: MOV +7,4 D100 , and made sure that D100 had REAL as datatype , but this did not work
 
will someone please ban this guy? (Phil, anyone?)

there is no "floating point move" instruction. you can still use DMOV to copy value (floating point as well)
from one register to another. to actually assign floating point value to a register, I simply use
floating point ADD instruction (add zero to be precise since n+0=n):


+F D50 +0.0 D100 // floating point MOV

or

+F +3.124 +0.0 D100 // assigning floating point constant
this way you can actually see the value in floating point.
 
Last edited:
Thanx for all help ! Wy dident i think of just add/multiply ?? My head isent thinking straight.. I am suppose to turn in my bachler assignment next week so i am greatfull for all youre help
 
To use floating point all values have to be floating point.
Move your values (whatever they are) to DMs. Be careful if you are using a constant - use &1234 not #1234 or you will get an incorrect number. & is decimal, # is BCD/HEX.
If the values are in one word then use the FLT instruction to float the value, if in 2 words use FLTL (long). Be careful as floating point takes up 2 words so watch your boundaries. Then use *F for multiply, /F for divide, +F for add and -F for subtract.
You can then use FIX (1 word result) or FIXL (2 word result) to convert the value back to an integer.
I use this method all the time for calculating values received from Caterpillar engines (CAB bus J1939 protocol via Modbus RTU).
By the way, FIX and FIXL will truncate the decimal point of course.
 
This requires just one mulitply and no floating point required

multiply by one works too, but this is bad practice, multiply and divide are slow and result is written to four registers (64 instead of 32-bit)
32bitx32bit=64 bits? Does Omron have 32 bit analog? Wouldn't the multiply be 16bitx16bit=32bit?
Does Omron have signed and unsigned multiply?
Does Omron have a 32 bit shift left?
Does Omron have a 64 bit shift left?
If so there are a lot of cool tricks that can be done.

A trick I use is to multiply two 16 bit numbers and use the result out of the top 16 bit of the 32 bit number. Think about it. Has anybody heard of Q15 fixed point arithmetic?

Assuming that Omron has unsigned multiplies available, I can multiply N by 1.414 by multiplying nx(65536*0.4) and then adding the result from the high 16 bits to n. Obviouly I must precalculate (65536*0.414) which is 27132 and then I add the high 16 bits to n. Basically this is n*(1.0+0.414). No floating point or division required!!
 
that was floating point multiplication. floats in Omron are 32-bit. i just checked it in simulator, floating point multiplication only writes 32-bit (long integer multiplication does write 64-bit)
 
The Omron CS1, CJ1 and CP1 (shoebox) all have 32 and 64 bit floating point maths available as standard functions.
By the way. it does not really matter that D100 is not a REAL data type. You can use the old default CHANNEL. I do not usually bother with specifying data types for data memories but allow the fefault CHANNEL to be the type. This data type is not that I am aware an IEC data type but is an old Omron data type that is still included for backward compatability.
 

Similar Topics

I am working on a project using a NB screen and NX1P2 PLC. I am having a really hard time getting a real number to properly translate through to...
Replies
3
Views
121
Hello, I am using Omron PLC: NX1P2 Software:-Sysmac Studio Plc in which I have to read data from an energy meter over Modbus RTU The data that I...
Replies
3
Views
884
hi all i have used a real time clock to turn on a bit after 1 month. the plc was off for this whole month and when i turned on the plc after a...
Replies
2
Views
1,418
Hi Guys, i'm begginer and i'm trying to convert a real value (not fix value) to BCD. It works if i put fix real value but when i put variable...
Replies
2
Views
1,941
Hello, We have this SCADA system Vijeo Citect 7.2 Windows 7. PLC: OMRON C200HG Protocol UNITY MODNET30 OMRON OMRON OFSVIJEO MODCELL All...
Replies
2
Views
1,836
Back
Top Bottom