Syntax for multiple conditions in compare function

More
23 Feb 2016 17:37 #70530 by djs14
djs14 created the topic: Syntax for multiple conditions in compare function
Hey all,

I'm trying to put multiple conditions in a compare function in classicladder.

The manual says we can use & and | but I can't seem to get them to work.

I'm just trying

%W13<3&%W12!=0 but it doesn't seem to do what I want. I'm thinking it must be a syntax issue because I'm working with a very small ladder trying to debug this.

cheers
More
23 Feb 2016 17:48 #70531 by djs14
djs14 replied the topic: Syntax for multiple conditions in compare function
I got around my dilemma with multiple compare functions but it would be nice how to do it with just one compare function with multiple conditions if possible.

Getting close to testing tool changer ... woohoo!
More
23 Feb 2016 23:28 - 24 Feb 2016 00:01 #70544 by BigJohnT
BigJohnT replied the topic: Syntax for multiple conditions in compare function
Not sure what your trying to do but %W is a word memory location. What are you trying to compare?

Also: < (less than), > (greater than), <= (less or equal), >= (greater or equal), <> (not equal)

I think I cracked the code and I did not get what I expected for sure. Ok the & seems to be if both IF1 and IF2 are equal to some number then the rung is true. So %IF1&%IF2=2 is true only when both are equal to 2. Or | does not seem to work as one expects. The best thing is to have one compare per box.

Ok I cracked it really this time... to have multiple comparisons you need to group them like this:
%IF1=1,|%IF2=2
%IF1<2,&%IF2=2
Note the comma that makes each comparison a group then the and or works on the groups. I'll fix the manual in the morning.

JT
Last Edit: 24 Feb 2016 00:01 by BigJohnT.
The following user(s) said Thank You: djs14
More
24 Feb 2016 17:19 #70575 by djs14
djs14 replied the topic: Syntax for multiple conditions in compare function

BigJohnT wrote: Not sure what your trying to do but %W is a word memory location. What are you trying to compare?

Also: < (less than), > (greater than), <= (less or equal), >= (greater or equal), <> (not equal)

I think I cracked the code and I did not get what I expected for sure. Ok the & seems to be if both IF1 and IF2 are equal to some number then the rung is true. So %IF1&%IF2=2 is true only when both are equal to 2. Or | does not seem to work as one expects. The best thing is to have one compare per box.

Ok I cracked it really this time... to have multiple comparisons you need to group them like this:

%IF1=1,|%IF2=2
%IF1<2,&%IF2=2
Note the comma that makes each comparison a group then the and or works on the groups. I'll fix the manual in the morning.

JT


What I was doing is comparing the tool number requested to the current tool number on the turret. I understand a bit more now and realize I should be using %IW or %QW, but for an internal integer manipulation in classicladder %W is the correct variable yes?

Thank you for clarifying the comparison syntax. I got my tool changer working yesterday. I'm able to select a tool on a pyvcp, click a button, and the turret indexes to tool location. There are 5 limit switches that create a binary code for the turret position and two valves I had to sequence. Really happy with how it's working. Now I'm onto motor interface ... probably start a new post elsewhere ... but if I have your attention here, my encoders are outputting 12V square wave so I'm hoping to use a voltage divider to kick it down to 5V and was hoping someone had a resistance value to start with ...

cheers all
More
24 Feb 2016 17:58 #70577 by BigJohnT
BigJohnT replied the topic: Syntax for multiple conditions in compare function

djs14 wrote: What I was doing is comparing the tool number requested to the current tool number on the turret. I understand a bit more now and realize I should be using %IW or %QW, but for an internal integer manipulation in classicladder %W is the correct variable yes?


Yes internal bits are %B and internal S32 numbers are %W.

Have you seen my Classicladder for my CHNC turret? And the Classicladder turret simulation example?

JT
More
24 Feb 2016 18:13 #70578 by djs14
djs14 replied the topic: Syntax for multiple conditions in compare function

BigJohnT wrote:

djs14 wrote: What I was doing is comparing the tool number requested to the current tool number on the turret. I understand a bit more now and realize I should be using %IW or %QW, but for an internal integer manipulation in classicladder %W is the correct variable yes?


Yes internal bits are %B and internal S32 numbers are %W.

Have you seen my Classicladder for my CHNC turret? And the Classicladder turret simulation example?

JT


No I did not see that. I will check it out.

I'm starting a new thread on my encoder config. Feel free to chime in on that one :).

Thank you.
Time to create page: 0.126 seconds
Powered by Kunena Forum