Omron Function Block

bdmfab

Member
Join Date
Jun 2011
Location
MI
Posts
2
First time with structured text and something isn't working correctly. Simple block, copy of the SCP in Allen Bradley (scale with parameter). The math is off, I think its syntax. Driving me nuts.o_O Its a CJ2M series. Thanks.
 
Thanks Hooey,

The conversion to real was helpful.

Getting roughly the same result. I'm running the simulator, here are the values I am using.

In = 1000

InMin = 100

InMax = 20000

SclMin = 1

SclMax = 100

SclOut = -49597.80.

My trusty excel sheet yields 5.48

This is only my second Omron project so I am still green on this. I attached the .cxp with the FB. Am I using the correct registers? Cheers.
 
Thanks Hooey,

The conversion to real was helpful.

Getting roughly the same result. I'm running the simulator, here are the values I am using.

In = 1000

InMin = 100

InMax = 20000

SclMin = 1

SclMax = 100

SclOut = -49597.80.

My trusty excel sheet yields 5.48

This is only my second Omron project so I am still green on this. I attached the .cxp with the FB. Am I using the correct registers? Cheers.
bdmfab
you use of d registers might need reviewing, d registers are 16 bit storage locations so used to store a real type number will use 2 16 bit locations d0 and d1 and as you have used d1 as a input to the function block as constant you will end up with corrupted results . define symbols for inputs to the function block as type real ie. InMin type real, InMax type real, SclMin type real, SclMax type real, SclOut type real and give that a go.
Hooey
 
I have basically given away using FBs for almost everything - too slow and painful. I used to use FBs for floating point maths. I often have to extract data from Caterpillar, and other brands, engines. It is extr5acted by Modbus RTU but is in J1939 format - absolute pain. Value, precision and offset. I have attached a routine I recently used on a job - fairly obvious what is going on. Admittedly not scale with parameters nut may help you get a handle on floating point in Omron.
It is part of a standard routine I developed - the engines all come with different information available. I stick in the standard routine and then delete what I do not get from the engine. The only other thing I do is use FIXL (fix long) to read the values in decimal. I then delete the FIXL function when I am happy with the readings I use the floating point values on Omron NS screens.
Hope this helps you get a handle on things.
Float all values first, including the constants you have to use for precision, multiples to make the values useful and offset values.
 

Similar Topics

Hello Someone know an Function Block or example code for Fins TCP/IP or UDP working for CJ2M CPU33? Thanks for help
Replies
0
Views
1,195
Hi All Omron Experts I need help to create a FB for Omron PLC CP1L-E Task: Detect and Monitor Oil Level in a Hyd. Tank Using Incorporated...
Replies
1
Views
1,723
Is it possible to create User Defined Functions in CX-Programmer? You can do this in CODESYS no problem. I would like to be able to do this, and...
Replies
3
Views
2,583
Hi all, I am trying to add a function block to a PLC program written for an Omron CJ1M PLC. However, CX Programmer has thrown a compile error...
Replies
0
Views
5,273
Now I working to make Function Block using CX-Programmer Ver9.3 After compiling this FB, I have message "WARNING: Unreferenced Function Block Body...
Replies
2
Views
2,246
Back
Top Bottom