Discussion:
Digital Input check and conditional function
(too old to reply)
KevMi
2008-04-09 07:10:06 UTC
Permalink
Hi, I am building a sequencer and have a real challenge. There are 16 digital inputs in sequencer.User can choose which inputs are checked and when. User can also determine what function is with a certain condition. Let me try to explain it little better with an example: User gives a string " (DI1 OR DI2) AND DI3 "  and a function  STOP.   Now the states that fulfilles the condition would be 3 different situations
 
DI3  DI2  DI1     Function
1        0      1        STOP
1        1      0        STOP
1        1      1        STOP
 
There is also "NOT" operand in use. 
Now I need a "key" that could open the condition.Key should also concider paraenthesis, because (DI1 OR DI2) AND DI3 and DI1 OR (DI2 AND DI3) aren't the same condition.
I am not asking anyone to make a completed solution, but it would be great if someone have dealed with something like this or has some VI that could help.
 
Best Regards
Mika
MikeS81
2008-04-09 07:10:06 UTC
Permalink
Hi Mika,
are you using LabView? If yes, which version do you use? I started something in this dirction in LabView.OK, sorry after reading your post again, i saw you asked for an example vi.
See the attachment, hope it helps.
MikeMessage Edited by MikeS81 on 04-09-2008 09:07 AM


logic_parser_LV80.vi:
http://forums.ni.com/attachments/ni/70/8615/1/logic_parser_LV80.vi
KevMi
2008-04-09 09:10:06 UTC
Permalink
Hi,
thank You very much for Your reply. It took me a while to understand how the VI works. It doesn't really care about numbers you put in "condition" field, only about the OR,AND and NOT operations and the location of the numbers in the field. If you put "1 OR 2" in condition field it checks if index 0 or 1 is true, because number 1 is in position 0 and number 2 is in position 1. Good start thought, I believe You have it unfinished.
I try to modify it so that it considers also parenthesis,because "0 AND 1 OR 2" can be understood in two different ways ;(0 AND 1) OR 2, 0 AND (1 OR 2).
 
Best regards
Mika
MikeS81
2008-04-09 09:10:06 UTC
Permalink
Hi Mika,
your are right. I only started to work on it. It would be great if you could upload your solution. Thanks.
Mike
MikeS81
2008-04-09 17:40:07 UTC
Permalink
Hi Mika,
i worked on the program today and here is the result. Now you can use "(), NOT, AND, OR". if you want to use the not i recommand to use the () around it. You can interleave as far levels as you want. Can you please try it and give my a feedback? At the moment there are less checks for errors. The main vi is "Parser.Main_digital.vi".
 
Thanks
MikeMessage Edited by MikeS81 on 04-09-2008 07:29 PM


Parser_LV80.zip:
http://forums.ni.com/attachments/ni/70/8628/1/Parser_LV80.zip
KevMi
2008-04-10 05:40:05 UTC
Permalink
You have been very effective! It works fine. :smileyvery-happy: I was just making some notes yesterday trying to think how it should be done. Only thing I'm missing is some comments on how it works, but I think I'll find it out today.  In my drawings there was also brackets around NOT. In my sequencer there are also buttons(I0 - I15,OR,NOT,AND and so on) that user can write condition with.It's not a must, but it makes a bit easier to write condition with no errors.  GOOD WORK!
 
I have never found out how one can rate these great answers. :smileysurprised:
Please tell me
 
Mika
MikeS81
2008-04-10 07:10:08 UTC
Permalink
Hi Mika,
thanks for your reply. You need a minimum of 50 posts to rate answers.
Mike
JB
2008-04-10 10:10:06 UTC
Permalink
MikeS81 a écrit:

thanks for your reply. You need a minimum of 50 posts to rate answers.
See <a href="http://forums.ni.com/ni/board/message?board.id=250&amp;thread.id=39068" target="_blank">here</a> for more details.
MikeS81
2008-04-10 11:10:06 UTC
Permalink
Hi JB,
how does this link help us here?
Mike
JB
2008-04-10 12:10:09 UTC
Permalink
Ah sorry ! This is obviously not the right link ! <a href="http://forums.ni.com/ni/board/message?board.id=130&amp;message.id=3517&amp;query.id=91133#M3517" target="_blank">Here</a> is the one that gives more details about the reason for this limitation.
MikeS81
2008-04-10 12:10:09 UTC
Permalink
Hi Mika,
to add other logical function you only have to add them on this two places:
<img src="Loading Image...">
<img src="Loading Image...">
MikeMessage Edited by MikeS81 on 04-10-2008 01:42 PM


addon01.PNG:
http://forums.ni.com/attachments/ni/70/8639/1/addon01.PNG


addon02.PNG:
http://forums.ni.com/attachments/ni/70/8639/2/addon02.PNG
KevMi
2008-04-14 06:40:06 UTC
Permalink
HI Mike,
I think I'll manage with these three functions, but it's good to know that anyway.&nbsp;VI's quite complicated, so could You please add some comments in code about how it works?It would&nbsp;be a great help.&nbsp;It's difficult to read code when I don't know why shift registers and arrays are there for.
Mika
&nbsp;
&nbsp;
MikeS81
2008-04-15 09:10:07 UTC
Permalink
Hi Mika,
here is a new version with more comments. Hope it helps. :smileyhappy:
Mike


LogicParserV2_LV80.zip:
http://forums.ni.com/attachments/ni/70/8665/1/LogicParserV2_LV80.zip
Continue reading on narkive:
Loading...