Decision entry

Any general or miscellaneous queries that do not fit into the other forum catagories

Moderators: Benj, Mods

Post Reply
steve22
Posts: 7
Joined: Sun Feb 08, 2009 2:23 pm
Contact:

Decision entry

Post by steve22 »

Can a direct entry of a logic function be made in the In the Decision box eg
A = A xor 1
B = B xor 1
this will save me from performing any complicated if-then-else logic to decide which state to set the pin to... performing 'xor 1' against the pin will always flip it to the opposite state. If this can be done can someone suggest a snip of code to see how it can be done, as the number of steps in the flowcode that is taken seem crazy I have run out of blocks in the demo version and have still got the result I want.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Decision entry

Post by Benj »

Hello

Yes you can do exclusive or by simply using the following in a decision icon.

a XOR 1
b XOR 1

Or using a calculation icon you can do the following.

A = A XOR 1
B = B XOR 1

steve22
Posts: 7
Joined: Sun Feb 08, 2009 2:23 pm
Contact:

Re: Decision entry

Post by steve22 »

How do I enter the two lines in the decision icon I keep getting a error i know its in the format but I am not sure of the correct entry do you have a snip of code as this can say a thousand words .

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Decision entry

Post by Benj »

Hello

Well you cannot enter two values into a decision icon. Eg for the example before we can not decide based on both a and b at the same time. If you need to do a combination of the two variables then this should work.

(a XOR 1) AND (b XOR 1)
(a XOR 1) OR (b XOR 1)

What is it your trying to do, Maybe explaining this will help us to provide a workable example.

steve22
Posts: 7
Joined: Sun Feb 08, 2009 2:23 pm
Contact:

Re: Decision entry

Post by steve22 »

I will attempt to explain what I am trying to do as flowcode is still very new I have a piece of control equiptment which has 6 outputs which will on a alarm condition will send a 1 second pulse out to one of the six outputs but for the sake of this question I will use one. When I get this pulse I want to set a port output on the Micro latched HIGH and stay that way until the same output on the alarm pulses high again at which point the latched output which is at a HIGH state will now go to a latched LOW state on the PIc and latch this way, and stay in that state until the same outputs on the alarm outputs a pulse again. One point that needs to be noted is that the output will not ping pong its state on the pic unless there is a valid pulse output. In other words if the alarm was held high for 5 seconds I dont want the output on the Pic to go LOW-HIGH-LOW-HIGH at each loop of the code, which is what is happening at the moment . The part that is causing issue is the PING PONG on the pic outputs. I hope this has gave a good idea as to what I what to obtain.

Post Reply