Modulus Operation in Mitsubishi PLC

703 Views Asked by At

I am using a Mitsubishi Q Series PLC, Q06UDH.

I am trying to perform a modulus operation, to get a sample rate for data collection, i.e. I have a register R0 which constantly cycles between 0 and 3600, and a register W0 which is related to R0, whose value lies anywhere between -100 and 1300 depending on R0.

What i would like to do is take the value of W0, when the value of:

R0 % 100 = 0  (R0 MOD 100 = 0)

And store this data elsewhere to calculate the average value of W0

So I want it something like this.

--|R0 % 100 = 0|----+--|MOV W0 D0Z0|---     
                    |
                    |
                    +--|INCP Z0|---------

Is there a operator I'm missing? Or a work around I'm not seeing?

2

There are 2 best solutions below

0
On BEST ANSWER

In the end I decided to use a simple 0.1s clock to sample the data. It isnt quite as elegant and nice as I'd've liked, and took a bit of trial and error to get right, but it works.

1
On

If you perform a divide operation in Mits [/ D0 K100 D100] The division result will be in D100 and the modulus in D101. So in your case

|SM400|-----------[/ R0 K100 D100]

[= D101 K0]---------[MOV W0 D0Z0] etc...