What's new
What's new

Wrong use of OR function?

Tomaz

Plastic
Joined
Oct 26, 2020
Hi to all,

before execution of a third line of the subprogram O7015 an alarm appears - PS0004 INVALID BREAK POINT OF WORDS. I really don't know where is the problem.
Maybe a wrong use of OR function.
I tried also:
IF[#600EQ2OR3]THEN[#654=44.2]
and the same alarm appears.
AND function is working well.
The controller is DOOSAN Fanuc i Series

Maybe someone knows how to solve this problem?

Thanks

Tomaz


%
O3840 ( MAIN PROGRAM )

#600=1
#601=4
#602=40.
#603=100.
#604=2.5
#605=39.
#608=1500
#609=0.2
#607=1.
#606=2.


M98P7015
M53
G28 U0.
G30 W0.
...
...

%
O7015 ( SUBPROGRAM )
IF[[#600EQ1]AND[#602EQ38.]]THEN[#654=37.9]
IF[[#600EQ1]AND[#602EQ40.]]THEN[#654=39.9]
IF[[#600EQ2]OR[#600EQ3]]THEN[#654=44.2]
IF[#600EQ3]THEN[#654=44.2]
IF[[#600EQ4]AND[#602EQ38.]]THEN[#654=45.9]
IF[[#600EQ4]AND[#602EQ40.]]THEN[#654=47.9]
IF[[#601EQ1]OR[#601EQ4]OR[#601EQ5]]THEN[#650=36.9]
IF[[#601EQ2]OR[#601EQ3]]THEN[#650=46.9]AND[#656=2]
IF[#601EQ1]THEN[#651=108.]AND[#655=42.785]AND[#656=2]AND[#660=31.25]
IF[#601EQ2]THEN[#651=110.]AND[#660=31.75]
IF[#601EQ3]THEN[#651=79.]AND[#660=9.5]
IF[#601EQ4]THEN[#651=82.]AND[#655=29.785]AND[#656=2]AND[#660=25.]
IF[#601EQ5]THEN[#651=52.]AND[#655=14.285]AND[#656=1]AND[#660=8.]
#652=[#651-18.]
#653=[#651-[#650+6.1]]
#657=#652/#656
IF[#656EQ1]THEN[#658=2]
IF[#656EQ2]THEN[#658=1]
#659=8
#661=65.
IF[#601EQ5]THEN[#661=60.]
IF[[#600NE1]OR[#600NE2]OR[#600NE3]OR[#600NE4]]GOTO1001
IF[[#601NE1]OR[#601NE2]OR[#601NE3]OR[#601NE4]OR[#601NE5]]GOTO1002
IF[[#602NE38.]OR[#602NE40.]]GOTO1003
IF[#605GT#654]GOTO1004
M99
 
Your "THEN" condition does not have to be in brackets. Example:

IF [#24 EQ #0] THEN #24=#5041

Not sure if that's your problem. Another note - if you put spaces between everything like in my example, it makes it much easier to spot the inevitable missing brackets or punctuation.
 
Ah, speaking of brackets, pretty sure I see your problem. The IF statement should not be in brackets. It should read:



IF [#600 EQ 2] OR [#600 EQ 3] THEN #654=44.2
 
Hello Tomaz,
I see no problem with the syntax of your following Block.

IF[[#600EQ2]OR[#600EQ3]]THEN[#654=44.2]

The "[#600EQ2]OR[#600EQ3]" statement does have to be enclosed in square brackets, as you want to prioritize the two statements within to form the one condition. Normally, enclosing something like #654=44.2 in brackets wouldn't cause an issue and I doubt that is the issue, but the brackets in the above example of THEN[#654=44.2] are not required.

In terms of syntax, there is no difference between the use of "OR" or "AND". Accordingly, if you were to have an issue with IF[[#600EQ2]OR[#600EQ3]]THEN[#654=44.2], then you would also have issues with the two Blocks preceding it:

IF[[#600EQ1]AND[#602EQ38.]]THEN[#654=37.9]
IF[[#600EQ1]AND[#602EQ40.]]THEN[#654=39.9]

How are you sure that the error relates to that third Block. Unless you have parameters set so that you can step through the Macro Statements in Single Block mode, the error may be further ahead. At a quick glance, you're more likely to have an issue with the following Block

IF[[#601EQ2]OR[#601EQ3]]THEN[#650=46.9]AND[#656=2]

as a Logical Operation ([#650=46.9]AND[#656=2]) is being attempted as a result of a Conditional statement.

Although you show 3 leading zeros in "PS0004", generally they are irrelevant and the error number equates to P/S4. In a Fanuc control, error P/S4 relates to Address Not Found.

Regards,

Bill
 
Last edited:
Thank you boosted and Bill,
You're both right, the square brackets after THEN are not required, but in my example is nothing wrong if they are. That is not a problem.
I will review your tips and let you know how it went.

Tomaz
 
Thank you boosted and Bill,
You're both right, the square brackets after THEN are not required, but in my example is nothing wrong if they are. That is not a problem.
I will review your tips and let you know how it went.

Tomaz
Hello Tomaz,
I've had time to look at your code again, and your first three blocks are not the issue, the problem starts with the following block:

IF[[#601EQ2]OR[#601EQ3]]THEN[#650=46.9]AND[#656=2]

If you were to delete that block, the error would be raised by the next block that has similar syntax after the THEN reserved word as the above example.

OR and AND are logical operands and can't be used to execute a group mathematical function as you're attempting to do in the above example. To get your basic logic to work, you could do something like the following:

IF[[#601EQ2]OR[#601EQ3]]THEN #650=46.9
IF[[#601EQ2]OR[#601EQ3]]THEN #656=2

or

IF[[#601EQ2]OR[#601EQ3]]THEN #650=46.9
IF[#650=46.9]THEN #656=2

Regards,

Bill
 
Thank you Bill,
You're right, AND or OR after THEN cannot work. I thought the error was in the third block, because the cursor stopped on the second block.
Bottom is the revisioned subprogram (slightly longer):

%
O7015
( PODPROGRAM ZA IZRACUN DIMENZIJ )
( NE SPREMINJAJ )
IF[#600EQ1]AND[#602EQ38.]THEN#654=37.9
IF[#600EQ1]AND[#602EQ40.]THEN#654=39.9
IF[#600EQ2]OR[#600EQ3]THEN#654=44.2
IF[#600EQ4]AND[#602EQ38.]THEN#654=45.9
IF[#600EQ4]AND[#602EQ40.]THEN#654=47.9
IF[#601EQ1]OR[#601EQ4]OR[#601EQ5]THEN#650=36.9
IF[#601EQ2]OR[#601EQ3]THEN#650=46.9
IF[#601EQ2]OR[#601EQ3]THEN#656=2
IF[#601EQ1]THEN#660=31.25
IF[#601EQ1]THEN#656=2
IF[#601EQ1]THEN#655=42.785
IF[#601EQ1]THEN#651=108.
IF[#601EQ2]THEN#651=110.
IF[#601EQ2]THEN#660=31.75
IF[#601EQ3]THEN#660=9.5
IF[#601EQ3]THEN#651=79.
IF[#601EQ4]THEN#651=82.
IF[#601EQ4]THEN#655=29.785
IF[#601EQ4]THEN#656=2
IF[#601EQ4]THEN#660=25.
IF[#601EQ5]THEN#651=52.
IF[#601EQ5]THEN#655=14.285
IF[#601EQ5]THEN#656=1
IF[#601EQ5]THEN#660=8.
#652=[#651-18.]
#653=[#651-[#650+6.1]]
#657=#652/#656
IF[#656EQ1]THEN[#658=2]
IF[#656EQ2]THEN[#658=1]
#659=8
#661=65.
IF[#601EQ5]THEN[#661=60.]

( VARNOSTNI STAVKI )
IF[#600NE1]OR[#600NE2]OR[#600NE3]OR[#600NE4]GOTO1001
IF[#601NE1]OR[#601NE2]OR[#601NE3]OR[#601NE4]OR[#601NE5]GOTO1002
IF[#602NE38.]OR[#602NE40.]GOTO1003
IF[#605GT#654]GOTO1004
M99

N1001
#3000=1( SAMO STIRJE TIPI PUS - 1 2 3 ALI 4 )

N1002
#3000=2( DEFINIRAJ PRAVO SKUPINO ABCDE - 1 2 3 4 ALI 5 )

N1003
#3000=3( SAMO PREMERA 38 ALI 40 )

N1004
#3000=4( SVEDER JE VECJI OD NOTRANJEGA PREMERA )

M99
%





Now I have other alarm: PS1137 IF STATEMENT FORMAT ERROR.
I have noticed that if I delete the first eight blocks the subprogram works.
I will try to delete the blocks individually and then I will inform you of the results.

Regards

Tomaz
 
Now I have other alarm: PS1137 IF STATEMENT FORMAT ERROR.
I have noticed that if I delete the first eight blocks the subprogram works.
I will try to delete the blocks individually and then I will inform you of the results.

Regards

Tomaz

Hello Tomaz,
The alarm will continue to be raised as you delete individual blocks until you have deleted all eight; accordingly, you may be none the wiser at the end of that exercise. For your program to work with the first eight blocks included, you have to set parameter bit 6006.0 to "1". This allows Logical Operations (AND, OR etc.) to be used in conditional statements.

Also, you can only have 26 characters, including spaces, as the Message in the Alarm System Variable block (#3000). An error won't be raised, only the message will be truncated to 26 characters long.

Regards,

Bill
 
Hello Bill,
I changed #6006.0 to 1, please check the image below.
#6006.0.jpg
The error still persists…

Updated subprogram:

%
O7015
( PODPROGRAM ZA IZRACUN DIMENZIJ )
( NE SPREMINJAJ )
IF[#600EQ1]AND[#602EQ38.]THEN#654=37.9
IF[#600EQ1]AND[#602EQ40.]THEN#654=39.9
IF[#600EQ2]OR[#600EQ3]THEN#654=44.2
IF[#600EQ4]AND[#602EQ38.]THEN#654=45.9
IF[#600EQ4]AND[#602EQ40.]THEN#654=47.9
IF[#601EQ1]OR[#601EQ4]OR[#601EQ5]THEN#650=36.9
IF[#601EQ2]OR[#601EQ3]THEN#650=46.9
IF[#601EQ2]OR[#601EQ3]THEN#656=2
IF[#601EQ1]THEN#660=31.25
IF[#601EQ1]THEN#656=2
IF[#601EQ1]THEN#655=42.785
IF[#601EQ1]THEN#651=108.
IF[#601EQ2]THEN#651=110.
IF[#601EQ2]THEN#660=31.75
IF[#601EQ3]THEN#660=9.5
IF[#601EQ3]THEN#651=79.
IF[#601EQ4]THEN#651=82.
IF[#601EQ4]THEN#655=29.785
IF[#601EQ4]THEN#656=2
IF[#601EQ4]THEN#660=25.
IF[#601EQ5]THEN#651=52.
IF[#601EQ5]THEN#655=14.285
IF[#601EQ5]THEN#656=1
IF[#601EQ5]THEN#660=8.
#652=[#651-18.]
#653=[#651-[#650+6.1]]
#657=#652/#656
IF[#656EQ1]THEN#658=2
IF[#656EQ2]THEN#658=1
#659=8
#661=65.
IF[#601EQ5]THEN#661=60.

( VARNOSTNI STAVKI )
IF[#600NE1]OR[#600NE2]OR[#600NE3]OR[#600NE4]GOTO1001
IF[#601NE1]OR[#601NE2]OR[#601NE3]OR[#601NE4]OR[#601NE5]GOTO1002
IF[#602NE38.]OR[#602NE40.]GOTO1003
IF[#605GT#654]GOTO1004

M99

N1001
#3000=1( SAMO STIRJE TIPI PUS - 1 2 3 ALI 4 )

N1002
#3000=2( DEFINIRAJ PRAVO SKUPINO ABCDE - 1 2 3 4 ALI 5 )

N1003
#3000=3( SAMO PREMERA 38 ALI 40 )

N1004
#3000=4( SVEDER JE VECJI OD NOTRANJEGA PREMERA )

M99
%


Something else must be wrong.
Tomorrow I will try a simple program with a few blocks only. With AND and OR functions.

Regards

Tomaz
 
Hello Bill,
I changed #6006.0 to 1, please check the image below.
View attachment 302993
The error still persists…

Updated subprogram:

%
O7015
( PODPROGRAM ZA IZRACUN DIMENZIJ )
( NE SPREMINJAJ )
IF[#600EQ1]AND[#602EQ38.]THEN#654=37.9
IF[#600EQ1]AND[#602EQ40.]THEN#654=39.9
IF[#600EQ2]OR[#600EQ3]THEN#654=44.2
IF[#600EQ4]AND[#602EQ38.]THEN#654=45.9
IF[#600EQ4]AND[#602EQ40.]THEN#654=47.9
IF[#601EQ1]OR[#601EQ4]OR[#601EQ5]THEN#650=36.9
IF[#601EQ2]OR[#601EQ3]THEN#650=46.9
IF[#601EQ2]OR[#601EQ3]THEN#656=2


Hello Tomaz,
That is definitely the correct parameter bit, see the following picture:

Logical Operation Parameter1.JPG

I just noticed that you don't have the two expressions being ANDed and ORed enclosed in brackets; wright the above as follows:

IF[[#600EQ1]AND[#602EQ38.]]THEN#654=37.9
IF[[#600EQ1]AND[#602EQ40.]]THEN#654=39.9
IF[[#600EQ2]OR[#600EQ3]]THEN#654=44.2
IF[[#600EQ4]AND[#602EQ38.]]THEN#654=45.9
IF[[#600EQ4]AND[#602EQ40.]]THEN#654=47.9
IF[[#601EQ1]OR[#601EQ4]OR[#601EQ5]]THEN#650=36.9
IF[[#601EQ2]OR[#601EQ3]]THEN#650=46.9
IF[[#601EQ2]OR[#601EQ3]]THEN#656=2


You will have to do the same with the following blocks towards the end of the program.

( VARNOSTNI STAVKI )
IF[#600NE1]OR[#600NE2]OR[#600NE3]OR[#600NE4]GOTO1001
IF[#601NE1]OR[#601NE2]OR[#601NE3]OR[#601NE4]OR[#601NE5]GOTO1002
IF[#602NE38.]OR[#602NE40.]GOTO1003


Regards,

Bill
 
Hello Tomaz,
That is definitely the correct parameter bit, see the following picture:

View attachment 303016

I just noticed that you don't have the two expressions being ANDed and ORed enclosed in brackets; wright the above as follows:

IF[[#600EQ1]AND[#602EQ38.]]THEN#654=37.9
IF[[#600EQ1]AND[#602EQ40.]]THEN#654=39.9
IF[[#600EQ2]OR[#600EQ3]]THEN#654=44.2
IF[[#600EQ4]AND[#602EQ38.]]THEN#654=45.9
IF[[#600EQ4]AND[#602EQ40.]]THEN#654=47.9
IF[[#601EQ1]OR[#601EQ4]OR[#601EQ5]]THEN#650=36.9
IF[[#601EQ2]OR[#601EQ3]]THEN#650=46.9
IF[[#601EQ2]OR[#601EQ3]]THEN#656=2


You will have to do the same with the following blocks towards the end of the program.

( VARNOSTNI STAVKI )
IF[#600NE1]OR[#600NE2]OR[#600NE3]OR[#600NE4]GOTO1001
IF[#601NE1]OR[#601NE2]OR[#601NE3]OR[#601NE4]OR[#601NE5]GOTO1002
IF[#602NE38.]OR[#602NE40.]GOTO1003


Regards,

Bill

Curious if that is the issue. In the example I posted I'm definitely not enclosing the IF statement in brackets, and that code definitely works.
 
Hello Bill,

Thank you for your support.
Today I'm busy with other jobs. Tomorrow I will continue with this thread.

Regards

Tomaz
 
Today I found that the program works in this version.
I find strange that the program at
IF[[#600NE1]OR[#600NE2]OR[#600NE3]OR[#600NE4]]GOTO1001
jump to N1001 - alarm
despite the parameter #600=1
As i sad I will check tomorrow.

Regards

Tomaz



%
O7000
( PODPROGRAM ZA IZRACUN DIMENZIJ )
( NE SPREMINJAJ )
IF[[#600EQ1]AND[#602EQ38.]]THEN#654=37.9
IF[[#600EQ1]AND[#602EQ40.]]THEN#654=39.9
IF[[#600EQ2]OR[#600EQ3]]THEN#654=44.2
IF[[#600EQ4]AND[#602EQ38.]]THEN#654=45.9
IF[[#600EQ4]AND[#602EQ40.]]THEN#654=47.9
IF[[#601EQ1]OR[#601EQ4]OR[#601EQ5]]THEN#650=36.9
IF[[#601EQ2]OR[#601EQ3]]THEN#650=46.9
IF[[#601EQ2]OR[#601EQ3]]THEN#656=2
IF[#601EQ1]THEN#660=31.25
IF[#601EQ1]THEN#656=2
IF[#601EQ1]THEN#655=42.785
IF[#601EQ1]THEN#651=108.
IF[#601EQ2]THEN#651=110.
IF[#601EQ2]THEN#660=31.75
IF[#601EQ3]THEN#660=9.5
IF[#601EQ3]THEN#651=79.
IF[#601EQ4]THEN#651=82.
IF[#601EQ4]THEN#655=29.785
IF[#601EQ4]THEN#656=2
IF[#601EQ4]THEN#660=25.
IF[#601EQ5]THEN#651=52.
IF[#601EQ5]THEN#655=14.285
IF[#601EQ5]THEN#656=1
IF[#601EQ5]THEN#660=8.
#652=[#651-18.]
#653=[#651-[#650+6.1]]
#657=#652/#656
IF[#656EQ1]THEN#658=2
IF[#656EQ2]THEN#658=1
#659=8
#661=65.
IF[#601EQ5]THEN#661=60.
( VARNOSTNI STAVKI )
IF[[#600NE1]OR[#600NE2]OR[#600NE3]OR[#600NE4]]GOTO1001
IF[[#601NE1]OR[#601NE2]OR[#601NE3]OR[#601NE4]OR[#601NE5]]GOTO1002
IF[[#602NE38.]OR[#602NE40.]]GOTO1003
IF[#605GT#654]GOTO1004
M99

N1001
#3000=1( SAMO STIRJE TIPI PUS - 1 2 3 ALI 4 )

N1002
#3000=2( DEFINIRAJ PRAVO SKUPINO ABCDE - 1 2 3 4 ALI 5 )

N1003
#3000=3( SAMO PREMERA 38 ALI 40 )

N1004
#3000=4( SVEDER JE VECJI OD NOTRANJEGA PREMERA )

M99
%
 
Today I found that the program works in this version.
I find strange that the program at
IF[[#600NE1]OR[#600NE2]OR[#600NE3]OR[#600NE4]]GOTO1001
jump to N1001 - alarm
despite the parameter #600=1
As i sad I will check tomorrow.

Hello Tomaz,
Its quite logical actually. If, as you say, #600=1, then that being the case, #600 can't equal 2, 3 or 4, because its equal to 1. Therefore, in your above conditional statement, if #600 doesn't equal ANY of the numbers 1 trough to 4, the conditional statement will test True and execute the GOTO command. In your above conditional statement #600 doesn't equal 2,3 or 4 and any of those will trigger the conditional statement to test True.

If you wanted the logic of the conditional statement to test True only when #600 is not equal to 1,2,3 and 4, then you have to AND all of the components of the conditional statement as in the following example:

IF[[#600NE1]AND[#600NE2]AND[#600NE3]AND[#600NE4]]GOTO1001

In this example, the conditional statement will test true when #600 has a value other than 1,2,3 or 4, and will branch to block number N1001. If #600 equals any of the numbers in the specified set, for example #600=1, then the conditional statement will test False and the program will advance to the next block.

Regards,

Bill
 
Curious if that is the issue. In the example I posted I'm definitely not enclosing the IF statement in brackets, and that code definitely works.
Hello boosted,
By the OP's program listed in his Post#13, it appears that the only change made to have the program work, is the addition of brackets around the statements being ANDed, or ORed.

IF[[#600EQ1]AND[#602EQ38.]]THEN#654=37.9, and so on.

Its well documented that the syntax for an IF conditional statement is in the following form:

IF[conditional statement]THEN

In the above, THEN can be replaced by some other action such as GOTO, or a mathematical algorithm, but the syntax of the conditional statement to the left of the action, should be as shown.

In the OP's code example F[[#600EQ1]AND[#602EQ38.]]THEN#654=37.9, the single condition that will result in the statement testing True is the ANDing of two conditions that must also be True. Accordingly, these two conditions form the one conditional statement and therefore, should be in the form of:

IF[conditional statement]THEN

with all the Sub Set conditions making up the Conditional Statement, contained within the brackets.

Regards,

Bill
 
Last edited:
Hello Bill,

I recognized the error:

IF[[#600NE1]OR[#600NE2]OR[#600NE3]OR[#600NE4]]GOTO1001
[ false true true true ]= true

If any value inside of brackets and using OR function, is false, then the conditional statement is true

As you suggested, the right solution is:

IF[[#600NE1]AND[#600NE2]AND[#600NE3]AND[#600NE4]]GOTO1001

The same mistake I made in the next two blocks:

IF[[#601NE1]OR[#601NE2]OR[#601NE3]OR[#601NE4]OR[#601NE5]]GOTO1002
IF[[#602NE38.]OR[#602NE40.]]GOTO1003

The only accepted entry values for #601 are 1,2,3,4 and 5. For #602 are 38. and 40. If other values are inserted then the machine goes to error.

The right function is AND:

IF[[#601NE1]AND[#601NE2]AND[#601NE3]AND[#601NE4]AND[#601NE5]]GOTO1002
IF[[#602NE38.]AND[#602NE40.]]GOTO1003

Tomorrow I will check the whole program.

Regards

Tomaz
 
Hi to all,

upon successful implementation of the parametric program in the first stage, I'm now upgrading it to the next level.
New problems and challenges...
Please look this 3 blocks:

#600=5
#600=20.
IF[[#600EQ2]OR[#600EQ3]]AND[[#602EQ19.]OR[#602EQ20.]]THEN#654=24.5

It doesn't work, the machine show: PS1137 IF STATEMENT FORMAT ERROR


My explanation is this:

IF[[#600EQ2]OR[#600EQ3]]AND[[#602EQ19.]OR[#602EQ20.]]THEN#654=24.5
[[false] OR [false]] AND [[ false ]OR[ true ]]
[[false]] AND [[ true ]] THEN--> false - the whole statement should be false

Hope you understand what I want.

For example:

#600=2
#600=20.

the whole statement should be TRUE

I'm doing something wrong but I don't know what.
Maybe I should write in a different way?

Regards

Tomaz
 
Hi to all,



#600=5
#600=20.


#600=2
#600=20.

I'm doing something wrong but I don't know what.
Maybe I should write in a different way?

Regards

Tomaz

I wont pretend to know anything about marcos because I dont. but I noticed in your code above for example.
you have a period after 20. but nothing after the 5 or 2 could that be a problem
 
Hi Delw,

thank you for your response.
If I omit the period, the machine show me the same alarm PS1137 IF STATEMENT FORMAT ERROR, so I think this is not an issue.
 
Insert an extra bracket
IF[[[#600EQ2]OR[#600EQ3]]AND[[#602EQ19.]OR[#602EQ20.]]]THEN#654=24.5
 








 
Back
Top