Jump to content

Saverio

Members
  • Posts

    137
  • Joined

  • Last visited

  • Days Won

    4

Posts posted by Saverio

  1. The stock controls don't have the capability you're looking for. Other options:

    • trap the value change event, and if you see the "rollaround", change the value back.
    • Hide the up/down arrows and place your own buttons on there to increment/decrement the value

    I am, of course, assuming you're using an event structure.

    • Like 2
  2. This is good practice and I agree with it, but it might be overkill, depending on what OP is doing. I would be satisfied with making the improvement ShaunR suggested wrt checking the error output and letting the loop terminate after one iteration based on that.

    The code is designed on the premise that "everything is working". If the VISA resource control is set to the "correct" value, then the code will run without error (barring communication errors). Opening and closing the serial port on each iteration. How is this a good thing? Yes, checking for the error code will stop the loop, but it does not eliminate the fundamental problem with the code that I pointed out. On the NI forums we see this all the time, and we tell those who do this the same exact thing (all the time): initialize before the loop, close after the loop.

  3. Your fundamental problem is that you are opening/closing the serial port in every iteration of the loop. This is a waste of time and resources. The serial port should be opened once, before the loop, and closed once, after the loop. If you're concerned that someone may choose a VISA resource that does not correspond to a serial port, or to the wrong serial port, then you need to check before you start your loop. You don't show the rest of your code, but a simple state machine could be used for your architecture. You'd have an "Init" state where you mess around with controls (as you appear to be doing below the loop), a "open serial" state where you check the port and verify you're connected to the right port, and a "close" state where you close the serial port, and do any cleanup.

    Additional comment: you can replace the big Concatenate String with a Format Into String function.

  4. Sorry I didn't give more detail, I didn't want to inundate anyone with too much information. I'm doing something similar to Ben's Docking code.

    http://forums.ni.com...cending#M351512

    Here VIs get pulled out (sorta) and become floating windows. In this case the VI always is open, it just may be in its own window, or in the subpanel.

    What crelf said.

    Well, that changes things considerably, now doesn't it? It would have helped to have this information up front. ;)

  5. Isn't that what you were after? If the subVI is running on its own as a "regular" subVI then its front panel would not be open. When in a subpanel the front panel has to be open, so the subVI can check itself based on whether its front panel is open. The property would still be true when the VI is running on its own, but does that matter in this case?

  6. Which "rules for floating point comparison" were you referring to? I'm assuming by the inclusion of NaN in parenthesis you're referring to comparing against NaN. However, there is a more general rule: comparing floating point numbers using Equal or Not Equal is almost always a bad idea and will not always work. Thus, if your clusters contain floats, the top two approaches are null and void. Which makes the choice kind of simple.

  7. [EDIT] I post to LAVA... and that way, LabVIEW knows I've sufficiently embarrassed myself publicly with my lack of knowledge, and so now it can show me the answer.

    For shame! Tsk, tsk.... A less polished version of Mellroth's solution was provided in a post all the way back in 2002 in the LabVIEW forums over at NI (I'm sure you know the place :D ): http://forums.ni.com/t5/LabVIEW/how-can-i-make-a-ring-control-resize-itself-to-display-the-whole/m-p/47562/highlight/true#M30020

    All tongue-in-cheek, of course.

  8. Back for more homework help?

    It sounds like you don't have much programming experience, so it's not clear what kind of answer you are expecting beyond what has already been said. The only other thing I will add is to not use this to search an array of floating point values. If you do not understand why that is, I'd suggest starting here: http://stackoverflow.com/questions/1089018/why-cant-decimal-numbers-be-represented-exactly-in-binary

  9. Again, I've solved the problem. Here the solution to allow others people to do not waste time with this stupid thing. The problem was due to the name of error file I've created. To be loaded from the IDE, it must be named as you want except for the last part of the name which have to be "-errors" and which you have to insert before of the "txt", the extension of the file. This is required but no one says it to you!

    Ummm... right in the article that you linked to it says:

    "The file must be named xxx-errors.txt, where xxx is the supplied name"

    And, in the LabVIEW Help for the page that discusses the custom error codes file it says:

    6. When you are done editing the error codes file, click the
    Save
    button to save the error codes file in the labviewuser.liberrors directory. You must save the error codes file in the format xxx-errors.txt, where xxx is a name that you supply.

×
×
  • Create New...

Important Information

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