Jump to content

Please help me this problem


Ken N

Recommended Posts

My first submission wasn't scalable, this one is (up to 32 LEDs). I have the day off today!

post-7534-12574330615_thumb.jpg

Obfuscated LabVIEW code challenge anyone ?

Rules something like:

Should be programmable using the base LabVIEw 2009 (or earlier) system with no scripting and able to be forward compatible code (i.e. no LabVIEW vi's represented as binary constants) and no private property or method nodes. May use vi's found in vi.lib on the base system but no other dependencies (i.e. no calls to external dlls etc).

Should have undergone code cleanup (i.e. no obfuscation by hiding code under structures or other boringly simple techniques).

Any other restrictions ?

Winner is the code that performs to the specification but in the least obvious and most contorted way possible.

Link to comment

Ken,

The point Ton and I were trying to make is that you need to demonstrate that you've made an effort to solve this problem yourself.  If you're asking for our help you need to explain what you've tried and where you're having trouble.  You won't learn anything if we do the work for you.  Besides, you won't even be able to recognize if someone gives you an obfuscated solution (which has happened on this forum).

We don't know anything about you.  For all we know you're a college student with a homework assignment and you're trying to get us to do it for you.  If this was the case, and you don't learn the material, you may graduate and be hired by my company and be assigned to my team.  I'd have to do your work for the rest of my life.  I'm not interested in that.

Jim

Your mother is a hampster, and your father smells of elderberries? :D

Yes, or "I [shout C syntax] in your general direction."

  • Like 2
Link to comment

When ever obstruficated code is given to a student for a homework assignment, I always assume they just hand it in anyway and come up with an excuse to the teacher on why they did it that way, if they even look at the block diagram.

And if they don't look at the block diagram then they someone like Ken could turn in the password protected code anyway. I never had a LabVIEW class but for Java we had to printout the source as well and send it in. I know of several ways to print out LabVIEW source but none seem like a good idea.

But I do appreciate obstruficated code, especially when I can't understand what is going on but the end result is correct.

Link to comment

Hello,

I am sorry you all. Yesterday morning I tried to send my writing code by Add Reply button and Attachment , but I don't know why it doesn't come on Forum.

I am not a college student. I have been learning labview for a couple weeks by myself because I just bought a book "LEARNING LABEVIEW 6i". I have gone through some chapters and do alot of problems. But this is a problem I couldn't firgure it out.

I used Sequence Structure and each sequence is for each LED and timer. I enclosed the attachment below.

Once again, I am a new learning.

Thanks

K

EXE3LED.vi

Link to comment

I really don't want to come across as mean, but you say you've been learning LabVIEW for a few weeks, and you say you can do alot of the problems in the book...but you didn't change the state of the boolean in your sequence structure. You may want to review some of the chapters you've gone through and play around with some of the VIs you've already made. One pitfall of using a book is that you might just be going through the motions, putting down components and wiring them up without understanding how the code works.

To get the result you're looking for wire a True or a False to the boolean in each state of the sequence. This will change the value seen in led1, 2, and 3. If you're looking to turn off leds (like when led2 comes on turn off led1) you'll need to create a local variable for led1, and when led2 turns on wire a False to led1.

Link to comment

Hello,

Once again, I am a new learning.

Hi Ken,

To turn on the leds feed them with a "true" boolean.

To turn them off place a local and feed them with a 'false' boolean.

I saw you use LabVIEW 5.1, it might be handier if you post images of your code, since LabVIEW 8+ can't open these VIs.

Also try to code without a sequence structure.

ton

Link to comment

 

I used Sequence Structure and each sequence is for each LED and timer.  I enclosed the attachment below.

I think I misunderstood what you were going for, and I didn't even look at your LabVIEW version so you probably didn't get to run my examples.  I turned the LEDs off at the end of their appointed times. Here's how I did it.  Those are Elapsed Time express VIs.

post-7534-125755412054_thumb.jpg

I felt bad after writing this because it would require more code to add more LEDs, and it would get very ugly very quickly.  I wrote this to go up to 32 LEDs without changing the code.  I think it would be easy to add even more, but I'll leave that up to you.  That's a Time Delay express VI.  The thing I really don't like about this approach is that it can't be stopped, only aborted.

post-7534-125755443289_thumb.jpg

PS - the second loop exists only because I HATE local variables.

Link to comment

I think I misunderstood what you were going for, and I didn't even look at your LabVIEW version so you probably didn't get to run my examples. I turned the LEDs off at the end of their appointed times. Here's how I did it. Those are Elapsed Time express VIs.

post-7534-125755412054_thumb.jpg

I felt bad after writing this because it would require more code to add more LEDs, and it would get very ugly very quickly. I wrote this to go up to 32 LEDs without changing the code. I think it would be easy to add even more, but I'll leave that up to you. That's a Time Delay express VI. The thing I really don't like about this approach is that it can't be stopped, only aborted.

post-7534-125755443289_thumb.jpg

PS - the second loop exists only because I HATE local variables.

Hi Jcarmody,

Thank you for your help. Your diagram is a little bit high to my understanding, but I am going to study your diagram and I hope I will understand your way very soon.

KN

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.