Machine expert basic: problem with comparison

Varri

Member
Join Date
Jan 2020
Location
South
Posts
30
Hello!

Im about to pull of all my hair over this:

With this ladder i try to make a retained timer, with the possibility to reset it.

But the comparison in rung 1 keeps failing me, if tm1.p (preset timer value) is 15 min, and the tm1.v + mw130 is 10 the result is true... iv been tesing this on m221 plc. The result is that the pump stops too soon if there has been a fault or pause.


J5rwmXl.jpg

https://pasteboard.co/J5rwmXl.jpg

Thank you for any replies
 
Last edited:
Ive been testing this in simulation aswell, if the timer preset is 150 and the resut of comparison is over 100 the output is true.
 
The code you posted shows the timer preset to be 999 and a time base of seconds, but you refer to 15 minutes - can you clarify



You are acessing the timer preset and value before the timer call - will this give you a problem? (I'm not familiar with this platform so cannot simulate it)
 
Dont worry about the 9999 timer preset, i changed language on tags and such. I want the timer to run in minutes, but ive been testing with seconds. Same results
 
Why not use a counter and clock pulse that way you can freeze it or reset it or even increment a word on a clock pulse.
 
Is Rung 1 evaluating this:


Code:
PUMP1.P <= (PUMP1.V + %MW130)
or this


Code:
(PUMP1.P <= PUMP1.V) + %MW130
?


Not that I know if the latter is even possible
 
This is a WAG. I don't know anything about the platform you're using, but could the unit of PUMP1.P be different than that of PUMP1.V? Perhaps TON instructions in that platform operate in milliseconds while giving you the opportunity use seconds as the preset.
 
Rung 1 is comparing Pump1.p to (pump1.v + %mw130)




I apologize for not being clear, and maybe you answered what I was asking: I was not asking what you want it to do; I was asking what the PLC is actually doing.


Because the former - what you want - is irrelevant, and only the latter matters.
 
  • This is a WAG. I don't know anything about the platform you're using, but could the unit of PUMP1.P be different than that of PUMP1.V? Perhaps TON instructions in that platform operate in milliseconds while giving you the opportunity use seconds as the preset.


this was going to be my second suggestion.


Try assigning the comparison instruction input parameters - Pump1.p and (Pump1.v + %mw130) - to memory variables i.e.

  • %mw200 := TM1.P;
  • %mw201 := TM1.V + %mw130;
and then use %mw200 and %mw201 as the input parameters to the [<] comparison, and then you can see what the instruction is actually comparing.
 
Last edited:
I've installed SoMachine basic - I cannot enter the syntax shown in your program, what am I doing wrong?

t221.jpg
 
I've installed SoMachine basic - I cannot enter the syntax shown in your program, what am I doing wrong?

Insert the comparison block in the start from the left, and draw a line to the output set coil. Also, im using machine expert 1.2, its the new name.
 
Hello!

Im about to pull of all my hair over this:

With this ladder i try to make a retained timer, with the possibility to reset it.

But the comparison in rung 1 keeps failing me, if tm1.p (preset timer value) is 15 min, and the tm1.v + mw130 is 10 the result is true... iv been tesing this on m221 plc. The result is that the pump stops too soon if there has been a fault or pause.


J5rwmXl.jpg

https://pasteboard.co/J5rwmXl.jpg

Thank you for any replies


You are addind %MW130 to %MW130 + timer timed value.
This should be only %MW130:=%Tx.V as otherwise you are adding pause timer from earlier pause also.


Anyway, it would be lot of easier with counter blocks. (%C) or even %MW or %MD (int or Dint) variable, which is added by 1 every second.



Stop or not start -> reset counter (with preset value)

No start and not stop, not pause, not fault -> set counter with new value



start, no stop and no pause and no fault and r_trig of %S6 or %S7 (one secend or minute)
-> count up (or down)


Then you need 2nd rung where you compare counter value or Counter D-output with start, stop etc. bits, Set and reset bit for control
 
Last edited:
I did try to move the timer parameters to memory words, same result.
The syntax i wrote in the program compares op1 to op2 + op3. The same syntax with just = works just fine.

Of course i can write up this function from scratch, also with a counter (will actually be better because it has a reset input). But i locked in on finding out why this didnt work.

Discovered that if i move the timer call to before the comparison it actually works.. Why is that?

Attached is screen of working function, chaning the numbers or rungts etc did not have any impact on the result. It was the moving of the timer block..
 
I did try to move the timer parameters to memory words, same result.
The syntax i wrote in the program compares op1 to op2 + op3. The same syntax with just = works just fine.

Of course i can write up this function from scratch, also with a counter (will actually be better because it has a reset input). But i locked in on finding out why this didnt work.

Discovered that if i move the timer call to before the comparison it actually works.. Why is that?

Attached is screen of working function, chaning the numbers or rungts etc did not have any impact on the result. It was the moving of the timer block..


I don't see any new attachments?


But it have to be from scan order of rungs (from top to down). On other you are saving timed value 1 scan after timer is allready stopped.
 

Similar Topics

Hey Programmers, Heres todays puzzle I was trying to solve... I have a Modbus TCP network with two Modicon M221 controllers live on my work bench...
Replies
0
Views
477
In the last two months I have had an issue after making some online changes between the software and an Schneider M221 PLC via ethernet network...
Replies
0
Views
1,099
Hello, I am using Machine expert - basic with an M221 PLC. I have two 16 bit modbus registers coming in and I want to convert to a 32bit real...
Replies
8
Views
3,918
I've searched and I can't find anywhere to trigger a compilation of the program without going into simulation mode and back out. Does any one...
Replies
0
Views
1,627
Hello, As part of our project, we are using an M241 controller. This controller interfaces with an industrial computer and a router via a switch...
Replies
2
Views
113
Back
Top Bottom