Omron CX-Programmer, problem with basic math

Setian

Member
Join Date
Mar 2018
Location
VA
Posts
5
I am stuck on what is likely a misunderstanding of how Omron handles data versus Rockwell.

I need to scale an analog input to monitor the position of a joystick. My attempt at doing this is as follows:

* 203 &100 D1700
* 203 &100 D1704
/ D1704 D1700 D1708

D1700 is "zero value", stored once as a calibration check. It is a one time calibration to save the analog input for when X=0. The unit I am connected to is battery operated and as such I am wanting to be able to watch for a drift in the analog input if the battery voltage drops.

The *100 is meant to move the decimal place over by two for when I do a divide later on.

D1704 then represents the "current value" of the joystick position

D1708 is the ratio of D1704/D1700. Values less than 100 (1.00) representing the analog joystick moving left, values greater than 100 representing the joystick moving right.

Problem is my data in D1708 is garbage. All three data types above are currently DINT.
 
Welcome to the forum.
Not sure we have enough information.
What is the "203" value?
By default the Analog input module will provide a HEX value for the input. You are then trying to multiply by a DECIMAL (&) value of 100. Guessing this may be causing some of the problem.

Omron has multiple math instructions depending on number format.
If you want to use floating point math, you will need to convert the numbers to the appropriate format using FIX or FLT instructions.

You did not indicate which processor you are using. That will be helpful to point you to the correct instruction reference manual.

Hope this will help.
 
Thanks for the replies so far.

Processor is CP1H. 203 represents the fourth embedded Analog Input.

The input (203) doesn't seem to be hex. I seem to be doing fine multiplying, for example right now my input data at 203 is +2444, and my data in D1704 is +24400. The multiplied value in D1704 tracks fine as I move the joystick.

I did try /L and that is getting me closer to where I need to be, thanks. I see now that my *100 did not do it's job, so I've uncovered a second problem. For example:

D1704 (X position) = 307500
D1700 (X at Zero) = 245400
expected ratio = 1.25
Value of D1704/D1700=D1708=1

I am getting data in D1710, presumably the remainder?
 
Great, that lines up with what I was seeing in the second word then. I believe I can get controls off that D1710 word.

Thanks again everyone
 

Similar Topics

Hi there ,i'm using a CQM01 PLC for my project. I was just testing the input and output of my PLC with a very basic program with only one contact...
Replies
5
Views
2,499
In the hand position: Pumps 1 and 2 are controlled and alternated by the hand selector switch. When Hand position is first selected, pump 1...
Replies
2
Views
3,590
Hi there, PLC in question: 240VAC Omron CP1E-NA20DR-A Features: 12 inputs – 2 of which analogue, 8 outputs – 1 of which analogue My question is...
Replies
19
Views
18,904
hi I'm very new to this technology, and my question is very basic. i tried to do simulation in the CX-programmer for a very simple program, but...
Replies
8
Views
8,688
Dear PLC Experts, I am trying to go online with Omron Sysmac CPM2A PLC with CX-Programmer V 6.0 on Windows Vista Operating System. It gives...
Replies
7
Views
9,709
Back
Top Bottom