# Logic Builder Clarifications Needed

• 04-21-2009, 04:47 PM
jeffkay
Logic Builder Clarifications Needed
I have now gotten some forward motion on programming in MDX. The next question is: I see that the Logic Builder screens have "individual" chunks. Meaning that there is a blocl like "logic for input0". So how does one "link" other logic blocks to do more complex tasks? I also see "Root logic" blocks... Is that how you do it? How do you make root logic blocks and such? In my case, lets say I am watching the voltage of 8 inputs and then want a "master" logic to turn on a relay output#1 if all 8 are above 3 volts? Like that...
Jeff
• 04-21-2009, 04:50 PM
2k1Toaster
Quote:

Originally Posted by jeffkay
I have now gotten some forward motion on programming in MDX. The next question is: I see that the Logic Builder screens have "individual" chunks. Meaning that there is a blocl like "logic for input0". So how does one "link" other logic blocks to do more complex tasks? I also see "Root logic" blocks... Is that how you do it? How do you make root logic blocks and such? In my case, lets say I am watching the voltage of 8 inputs and then want a "master" logic to turn on a relay output#1 if all 8 are above 3 volts? Like that...
Jeff

Each logic block is essentially a if/then/else statement.

So if you want to monitor 8 inputs, then you use 1 logic block.

Just connect them with AND gates.

if(input0 > 3 AND input 1 > 3 AND input 2 > 3 AND ...) then turn out output
• 04-21-2009, 05:01 PM
jeffkay
I oversimplified the last example--it was clear that you could do that all in one block. Let's say you have two separate tasks like setting a clock running and then using that variable later in an input statement? Anyway, what about those Root logics and how do these labels get created or edited?

My next question is about latching or not latching. In my test, I made an input close a relay after getting above a threshold. Since there was a GUI button onscreen, I noted that the button latched and my relay would not reopen until the GHI button was toggled. So what do I do if I wand to undo the latch made by the Ninja Kitty?
Jeff
• 04-21-2009, 10:58 PM
2k1Toaster
Quote:

Originally Posted by jeffkay
I oversimplified the last example--it was clear that you could do that all in one block. Let's say you have two separate tasks like setting a clock running and then using that variable later in an input statement?

To set the variable, you would create a Then-Do after the first logic block that would change the variable to whatever value. Either "#" or "d#". "d#" is to change it by some amount. So to change it by +2, then it would be "d2". To change by -42 it would be "d-42". Alternatively you can use the "set" feature of variables which will set the variable to the value of whatever is before it. This is done in the actual logic layout.

To then use the value of the variable you place the variable with the "get" feature, and that will insert the current value of the variable into whereever that is.

Quote:

Originally Posted by jeffkay
Anyway, what about those Root logics and how do these labels get created or edited?

Labels as in just the name? If so it is in the properties area of each logic block. It serves no purpose other than to help you organize things.

Quote:

Originally Posted by jeffkay
My next question is about latching or not latching. In my test, I made an input close a relay after getting above a threshold. Since there was a GUI button onscreen, I noted that the button latched and my relay would not reopen until the GHI button was toggled. So what do I do if I wand to undo the latch made by the Ninja Kitty?
Jeff

When a button is pressed, it constantly sends out it's vote. If you want to override the button with a logic function you could set logic's vote priority to something higher than the buttons. So if the button is low priority, set the logic to medium priority. Or you can have the button change a variable. Then a logic block check the variable and if it equals some value turn on. Then you can manipulate the variable elsewhere too to turn it on/off from however many logic blocks you want.

There are many ways to do it and it all depends on what you want to do.
• 04-22-2009, 10:51 AM
jeffkay
..."To set the variable, you would create a Then-Do after the first logic block....">>>>>

What do you mean "after" the logic block? I see the then/do and then/else buttons--I also see how you can have more than one statement. Since they don't have a "linked" picture object like the other objects, how are these implemented? Are the commands done at the end of the linking--like in the green "output" object? Or is the then/do part of the main flow somehow? I don't understand this. Especially if you are changing and rechanging variables within the serial steps of the execution? Can you clarify this portion of the logic builder?
• 04-22-2009, 11:27 AM
2k1Toaster
The first logic block gets executed first. The last gets executed last. Any change is sent into a prioritized queue and gets evaluated all at once at the beginning of the next logic timer sequence. It is a synchronous voting system with 3 priorities.

by "after" I meant after having created your logic, then click on the then/do button, add the votes, and save that logic block. So all within that same screen/area, but technically you could do it at any time if you so desired.
• 04-22-2009, 11:33 AM
jeffkay
Ah, now it is making more sense. So there can only be two instances in the then/do's, yes? Is the voting system like a command buffer with priorities attached? I understand that the PC (USB) and the timers would leave gaps, or like interrupts, right, so this bridges that? This is why the FB can only be Psuedo-real-time? Thanks for the help.
Jeff
• 04-22-2009, 11:48 AM
2k1Toaster
Quote:

Originally Posted by jeffkay
Ah, now it is making more sense. So there can only be two instances in the then/do's, yes? Is the voting system like a command buffer with priorities attached? I understand that the PC (USB) and the timers would leave gaps, or like interrupts, right, so this bridges that? This is why the FB can only be Psuedo-real-time? Thanks for the help.
Jeff

You can have an infinite amount of instances in the then/do's. It is averaged.

Section 2 might be of help, to get a better understanding of how it works: http://www.fusioncontrolcentre.com/T...ual%20b005.pdf

It is a command buffer essentially. But the variables' buffer is actually internal to each variable, and gets evaluated at the beginning of the logic timer. The voting system is used for everything, therefore any object can do any command at any time with the same syntax. A digital output has an internal buffer as well.

It is pretty darned close to real time, and as close as it can get for the voltage in. Evaluating it to be something else through a logic block, means it will be 1 "clock cycle" off where the clock would be fired every XX milliseconds as determined by the timer configuration.