Jump to content

LogMAN

Members
  • Posts

    655
  • Joined

  • Last visited

  • Days Won

    70

Posts posted by LogMAN

  1. Here is the kind of response it produces for LabVIEW:

    Quote

    Me: Can you write code in LabVIEW?

    Quote

    AI: Yes, I can write code in LabVIEW. LabVIEW (short for Laboratory Virtual Instrument Engineering Workbench) is a graphical programming platform that allows users to create programs using block diagrams and icons rather than traditional text-based programming languages like C++ or Python. The block diagrams and icons used in LabVIEW represent data flow, rather than traditional control flow, which allows users to create programs that are intuitive and easy to understand. Do you have any specific tasks or projects you would like help with in LabVIEW?

    Quote

    Me: Give me an example written in LabVIEW.

    Quote

    AI: Certainly! Here is a simple example of a LabVIEW program that reads a temperature value from a thermocouple and displays the value on a front panel control:

    # Open the serial port to read from the thermocouple
    Open Serial Port VI
    
    # Read the temperature value from the serial port
    Read from Serial Port VI
    
    # Display the temperature value on a front panel control
    Numeric Control

    This is just a simple example, but LabVIEW is a very powerful programming platform that can be used for a wide range of applications, including data acquisition, instrument control, and test and measurement. If you have any specific tasks or projects you would like help with, I would be happy to assist you.

    Quote

    Me: Create a VI for this example.

    Quote

    AI: Certainly! Here is a LabVIEW VI that reads a temperature value from a thermocouple and displays the value on a front panel control:

    [LabVIEW VI]

    To create this VI, you would follow these steps:

    1. Open LabVIEW and create a new VI by selecting "File > New VI".
    2. Add the following VIs to the block diagram:

    • "Open Serial Port" from the Serial I/O palette
    • "Read from Serial Port" from the Serial I/O palette

    3. Wire the VIs together as follows:

    • Connect the output of the "Open Serial Port" VI to the input of the "Read from Serial Port" VI.

    4. Add a numeric control to the front panel by dragging and dropping it from the Controls palette.
    5. Wire the output of the "Read from Serial Port" VI to the numeric control by dragging and dropping a wire from the output terminal of the VI to the input terminal of the control.
    6. Save the VI by selecting "File > Save" and giving it a name.

    I hope this helps! Let me know if you have any questions or if you need further assistance.

    The responses are impressive but it doesn't look like we are getting replaced any time soon... :)

    • Haha 2
  2. The reason your cant change the unit label at runtime is because unit labels change the data type of the wire (notice the "S" in brackets at the end).

    image.png.86ab0a1087ec41ce24e9f4b3f267721e.png

    That said, what you want can be achieved with the display format.

    1. Enable unit label and specify the unit "S"
    2. Change the display format to SI notation and the number of digits to 3

    Now it will automatically add the prefix according to your value. For example, 10000 S will turn into 10 kS.

    image.png.522d2b6bde13cc97acca246339b22c99.png

    image.png.0740d59fc0be64f927832d69cc107e34.png

    image.png.404da74e45ace2bd27a9c4fc44cbf250.png

     

    • Like 1
  3. While community-scoped VIs are only accessible from VIs in the same library and friends, they are still exported.

    To see the complete list of exported members, use Get Exported File List.vi or open the library from the Getting Started Window.

    image.png.7884d7870cc5e262839ab5d9f4e30cc6.png

    Attempting to execute community-scoped VIs results in a runtime error. Here is an example using Open VI Reference.

    CA.png.50a00e3f417b13e543f2582114c60add.png

    image.png.85d4106608d85abfd779461cf2e1c91b.png

    The same error should appear in TestStand (otherwise it's a bug).

    LabVIEW simply hides community-scoped members in Project Explorer for convenience. Looks like TestStand does not do that.

    • Thanks 1
  4. 3 hours ago, bna08 said:

    Initially, I created an array of LabVIEW clusters which I wanted to pass to the .NET via an Invoke node, but passing array of clusters or clusters from LabVIEW to .NET is not possible if I am not mistaken.

    LabVIEW clusters can actually be passed by value, given that the values are structs.

    1922777709_.NETByValue.png.617949f6471f6bf869ba3aa17ce158f8.png

    For classes, you need to construct the class before you pass it to the method.

    905193811_.NETByRef.png.e69eecf695aac27aee9fea35fa2ef0ad.png

    • Thanks 1
  5. It sounds as if you want to pass a .NET Array type by ref to your method. This should be possible by constructing an array in LabVIEW, for example, by using the To .NET Object function, and passing the instance by reference to your method (assuming that your method signature is by ref).

    777000629_ArraybyRef.png.93395cf42c935825b7e361af4b91b224.png

    If you want to avoid generics, you can also initialize your own array as illustrated below.

    1340138281_Create.NETArray.png.8e27ac4dfbe375a607e84d8cfc1077f1.png

    • Thanks 1
  6. 1 hour ago, kej said:

    A long time ago I decided never to use property nodes for private data access. I will do a little research to see if I should reconsider that...

    Instead, within member VIs I always use bundle/unbundle, outside the class I use getter/setter methods. I'm happy to make custom getter/setters if I need to access some arbitrary set of the private data.

    Yes, this makes sense for class members. They should always access the private data cluster directly. Property nodes are only good for callers (and maybe when accessing parent class data).

    In the past I also avoided property nodes. Mostly because of stability and performance issues (~2011-2015). Nowadays they appear to be stable and are just easier to read (also, I'm lazy and property nodes don't need icons 😏).

    1 hour ago, kej said:

    When appropriate, my favorite idiom within the class is to use the Unbundle/Bundle Elements border node of the In Place Element Structure. I write a lot of RT code where I need to preallocate memory and use in-place.

    This is probably the best way to do it. Read-only and write-only access, however, should still be done with standalone bundle/unbundle. It makes it easier to understand what is going on, avoids unnecessary wires, and has the same memory footprint.

    image.png.e6f427eb530df130fea5f0485ab35210.png

    By the way, Darren Nattinger recently held a presentation at GDevConNA 2022 that might be interesting to you. He provides some insights into features of LabVIEW that aren't as stable as one would hope...

     

  7. 5 hours ago, kej said:

    Specifically, I've had the App Builder fail to compile or build .exe's that come up broken in the runtime when I have class private data saved in a block-diagram constant or an FPC--and when that data is in a previous structural form reliant on the class mutation history. I never intend to invoke the class mutation history, in fact I'm not sure I knew it existed until I ran into the problem. But it's easy to do accidentally and afaik there's no way to tell without building tooling outside the IDE, so this falls into the silent-but-deadly category of not having visibility into automated mutations.

    Class constants and controls have black background when they contain non-default values:

    1379106495_Non-defaultconstant.png.9159cc2ead83753c0a691b03d8e4e0f9.png

    5 hours ago, kej said:

    Even if I'm going to explicitly initialize all class private data, the class itself has to be instantiated using a BD constant or a FPC, right?

    Class constants (and controls) always have the default value of their private data control unless you explicitly create a non-standard constant like in the example above.

    5 hours ago, kej said:

    But I'm not sure that this approach actually does anything. When I plunk the class control on the front panel presumably it gets the current default value of the private data control, but what happens then? Is it ever updated automatically?

    It is updated every time the private data control is changed. This is why VIs containing the class are broken until the changes to the private data control are applied.

    image.png.3a522d2b82614629fe4bbce93e0c3f13.png

    5 hours ago, kej said:

    Experience leads me to believe that if I never explicitly save a default value for the class control in this VI, any changes I make to the class private data structure will propagate to that control and the class mutation history won't be invoked.

    That is correct.

    5 hours ago, kej said:

    But maybe that's not true, I have only anecdotal evidence, so asking here. If it is true then the invoke node above is redundant. But even if the invoke node above isn't redundant, maybe it initializes the private data to the previous private data structure version still dependent on the mutation history.

    It does not. The default control does not actually contain a copy of the private data control, but a value to indicate that it returns the class default value. Even if you make this value its default value, it is still just a value that indicates that it returns the class default value.

    Only when the background turns black, you have to worry.

    5 hours ago, kej said:

    Unfortunately, even if I figure out how to handle bypassing the mutation history at object creation, it turns out that the problem with the App Builder can be invoked by any saved default value on a class control anywhere in the code, even if that control is always on the conpane and required to be connected.

    By any chance, do you write values to class controls?

    This can result in undesired situations when combined with 'Make Current Values Default':

    540775997_WhatamIdoing.png.758b09c0b262d224ccb792a4b288cb6e.png

    2022-11-30_10-07-25.gif.07540c0a721abeb03504f6dcfd20bf65.gif

    • Thanks 2
  8. Re-creating the property node should fix the immediate issue, but it may happen again in the future.

    1 hour ago, Francois Aujard said:

    Not in my case... ☹️

    Does your typedef contain sub-types?

    Changes to nested typedefs can have the same affect.

  9. 1 hour ago, Rolf Kalbermatter said:

    This functionality is a post LabVIEW 8.0 feature. The original config file VIs originate from way before that.

    That makes sense. Thanks for clearing that up!

    1 hour ago, Rolf Kalbermatter said:

    Still something else is going on here too. The Config file VIs do properly close the file which is equivalent to flushing the file to disk (safe of some temporary Windows caching). Unless you save this configuration over and over again it would be VERY strange if the small window that such caching could offer for corruption, would always happen at exactly the moment the system power is failing. Something in this applications code is happening that has not yet been reported by the OP.

    A very similar issue happened to me a couple of month ago on multiple stations with broken power supplies. On those stations, the PC would sporadically turn off, sometimes (approx. 1-2 times a month) causing several of our configuration files to contain empty or garbage data (random bytes) after reboot. Those files are only written to at the start of a cycle that takes several minutes to complete. The likelihood of a power failure in that exact moment is very slim at best. On top of that, we currently update configurations sequentially, which means that only one file is open at any given time. However, often multiple files were affected. We never got to the bottom of it, as replacing the power supplies fixed the issue entirely.

    I'd be happy to know what is causing this issue...

  10. 5 hours ago, Francois Aujard said:

    Windows keeps the files in its cache and only writes them when there is enough to write, right?

    Something like that. The actual implementation takes several factors into account, for example, how frequently a file is accessed. Also, your disk has its own cache on top of that.

    5 hours ago, Francois Aujard said:

    Why would these files stay open in the resource monitor all the time, sometimes?

    If you have a virus scanner running, it might lock the file for processing.

    5 hours ago, Francois Aujard said:

    If Windows didn't save the files, it would be fine, but it empties them completely in case of a crash.... In this case, a power failure...

    I believe the Set File Size function is to blame for that. By changing the file size to zero, the file is effectively cleared. The write function after that is cached and never gets flushed to disk because of power failure, which leaves the file empty after reboot.

    image.png.8106e66f6dcc66fa972b744b2cae2f2c.png

    I'm not sure why it was implemented this way. The following will produce the same result without this issue:

    image.png.89f7642e52551bbf6ca8387bda0990bd.png

×
×
  • Create New...

Important Information

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