LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

NI Traffic Light CLD Soln vs mine

whoops here the code
0 Kudos
Message 31 of 85
(2,232 Views)
Altenbach,

I had the impression that you wanted to write your whole code into one XControl.

Off course, the traffic light can be easily packaged into an XControl.
Intermediate 1 did have (at least 2 years ago) a scope on writing master/slave patterns using queues.

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 32 of 85
(2,200 Views)
In this case, I do the Certified Labview Developer "Sample Car Wash Exam". I find the specs to be quite involved, maybe got carried away. Unlike the "Stop Light" exam above, each case in the Car Wash specs has its twist. It must have taken the author a while to come up with a soln. You can find it here https://lumen.ni.com/nicif/us/ekitcldexmprp/content.xhtml.
 
Anyhow, I took a look at NI soln and I would take a few points off for how the final block diagram is done. I'll let you be the judge and see for yourself. I also include pics of the steps leading up to my .... shall I say loosely defined "Style". I did go ahead and use a subVI this time, the block was littered. This was done only after probing like hell that my code works. In an exam, you'd want to do this once for points of course.
 
My exam soln, attached, is not fully complete. It should make good learning exercise for CLD candidates. Guess if time allows I'll finish it completely and post.
 
Ho hum, ladi da, the only example left is "Sample Security System"....
Download All
0 Kudos
Message 33 of 85
(2,178 Views)
Hi Richjoh,

I assume the 12.png is you solution of the CLD?
I have a few points:
  • You should update the state in a queue OR a shift register, using locals for this is not good
  • How can it be there is a type-def conversion?
  • Your shift register's are unlabeled
  • I don't fully understand the Invert Arithmic OR of an inverted boolean, it looks like nothing is changed there.
  • No error handling
  • For the Car-Wash indicators, you start with a constant with all 'F', you convert one of them to 'T', you should do that in the constant directly
Grasp the idea of the state machine, having a conversion dot is killing, it makes sure your code is not expandible.

Ton


Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 34 of 85
(2,144 Views)
TonP,
 
I agree, the better choice is for state update is shift register... A queue well thats more stuff on the block diagram...at least 3 or more queue func.
 
Thank the Author of this exam for the Type def conversion. I copied his/her front panel and some ctrls are Typedef. Your correct on labelling shift registers, I don't make it this pretty, when I'm doing programming for real (the pressure for time usually doesn't allow it. Besides can't we read some wire, do I have to label every single nickel dime... here there.
 
OR need to see a 1 to trigger, two ZEROs does nothing, thus the need for the double invert but check the code for yourself. "No error handling", once more does this mean I drop a error popup on my block diagram? If this is a test yes of course. Does the spec say handle some error, NO, from what I read.
 
I think my way of setting the const are better when you need to make a change especially all the debugging. I will follow this with a post of the final soln. Anyhow, much thanks for the response! Your comments are welcome
0 Kudos
Message 35 of 85
(2,132 Views)

Here the FINAL soln for the sample Car Wash CLD exam. Maybe someone can learn from this cus NI example is well, I'll let you be the judge. I also post all my steps that includes my debugging...

Well on to the sample Security System exams... whey. This one was over-kill I think for any walking into an exam and doing this cold turkey

Download All
0 Kudos
Message 36 of 85
(2,130 Views)

@richjoh wrote:

Here the FINAL soln for the sample Car Wash CLD exam. Maybe someone can learn from this cus NI example is well, I'll let you be the judge.


Thank you, I will be the judge. Frankly, I prefer the NI solution. It's cleaner. Your solution:
  • Still has no error handling.
  • Duplicates cluster constants unnecessarily.
  • Mixes enum datatypes - this is always a bad idea.
  • Has wire bends all over the place.
  • Uses local variable where you should be using a shift register.
  • Uses unnecessary logic calculations (in your "Vehicle OOP" state):



  • Still doesn't use the standard 4-2-2-4 connector panes.
  • ...


Message Edited by smercurio_fc on 04-18-2008 11:27 AM
0 Kudos
Message 37 of 85
(2,126 Views)
OK the VI attached above did not include the dependencies.Tthe attached VI INCLUDES dependencies (2 TypeDef Controls) this time.... You should be able to open this Solution for the Car Wash example....
0 Kudos
Message 38 of 85
(2,120 Views)
smercurio,
I explained my error handling issue in my response to TonP above. Not sure what you mean by Duplicate cluster const unnecessary. Take your choice of more wiring (that some liked to be labelled) or duplicate error cluster. Anyhow is this a way to nickel and dime code... lets leave that for NI CLD exam graders. I create 1 and only 1 enum during this soln. My enum connects to a TypeDef (a given exam variable). I don't see a problem with wire bends, once more what purpose does this serve. I seen lots of real code with lots of wire bends, if you can't trace code there is a triple click mouse button to trace. Your logic show above is correct. but in my VI I use THREE booleans, can you show me this using 3 booleans, I have not back checked this yet, it appear a trivial matter during a test... does this mean points off regarding your comment on unnecessary logic?
 
I would go through my real code and not nickel and dime the pics just yet...
 
Attached is another post of NI block diagram case anyone didn't see this case... you can take off points, I see bent wire on here too


Message Edited by richjoh on 04-18-2008 11:55 AM
0 Kudos
Message 39 of 85
(2,115 Views)


richjoh wrote:
Not sure what you mean by Duplicate cluster const unnecessary.
For example, your "car wash indicator" cluster is duplicated in each case of the case structure. If you would place it outside, you only need one instance. (Same amount of wires!)
 
If you would ever need to modify it, you currently would need to make identical changes in 6 different cases instead of one. This is 600% more work and at the same time dramatically increases the chance of coding errors (what if you forget one case or accidentally switch one of the booleans?). 😮
 
 


Message Edited by altenbach on 04-18-2008 10:04 AM
0 Kudos
Message 40 of 85
(2,106 Views)