Jump to content

todd

Members
  • Posts

    335
  • Joined

  • Last visited

  • Days Won

    13

Posts posted by todd

  1. I'm not yet able to keep up with this discussion. At the risk of being a distraction from the topic at hand - and at the greater risk of causing more confusion than clarification by posting incomplete code - here is a stripped down project. (Note that queue destruction and error handling are not completely implemented, here. Nor are all the accessor, and such. In the production code, many other helper VIs are in place.)

    The biggest pieces not included are the tests (which interact with instruments only via Data AEs and named queues), and the emulator - which also uses named queues to control what the simulated instruments are doing. A user (or a VI) can move sliders and push buttons in the emulator in order to test the tests.

    Sample Project.zip

  2. My code has evolved into a similar (if less refined and sophisticated) pattern. Each physical instrument's slave loop responds to "show" and "hide" messages to display the front panel. Many of the instruments are streaming, so there are Start and Stop buttons, and appropriate displays of data that's being sent off to data queues (AEs). There are several different test VIs. Each test calls some of the instruments and some of the data queues (flexibility is key). Each test is called by reference so that "Main.vi" can do other stuff - such as run parallel tests with the other instruments, or allow the user to click Show and Hide buttons so they can watch the pretty data stream on by (or view the current collection rates or dropped packet count).

    The way I initially chose to use an instrument in a test is:

    1. create a class in the top-level VI

    2. send it to a dynamically dispatched* "handler" - the slave loop, which has a named queue

    3. from a test, send messages to the named queue

    I'm trying to figure out how to get more flexibility in a test. If I add a duplicate instrument, I have to create a second named queue handler - along with its associated "add to queue" VIs. Perhaps I'll try bundling up all the instruments' classes and send them to the test. However, I also have "simulator" child classes of each instrument. A different top-level VI (separate app) has buttons for sending fake data on any instrument that was defined by the user as being simulated. Class methods are used for setting private data, and are accessed via the named queue. I want to start using a class that holds an instrument's class in private data (due to one version of an instrument having a custom GPIO interface that consists of several NI DAQ resource names, and another version having ethernet), but I haven't figured out how to access that class from another top-level VI without using something like a named queue.

    * This is dynamic because multiple versions of multiple protocols for multiple instances of multiple instruments must be continuously supported.

  3. Ah, yes, thanks! That's a good one. They create four instruments from four children of class DSSP. If I put those constants in an array, and downcast them in a loop, the array of child classes appears as expected. What I'm hoping for is a way to placing the child constants in a sub VI instead of having them on the BD. Perhaps the sub VI would need to be reentrant so as to "create" each class instance.

    Thanks, again!

  4. I wish I'd seen Michael's vishots about classes and instruments a few months ago. I've made it to that level of functionality and am looking for the next baby step of having multiple instruments to iterate over - just for init, status and cleanup functions. (Most of the actual instruments stream data. I put that into a queue as it arrives, and process that queue into an LV2/AE - though it seems a look at classes +| IPE may be in order, as long as the performance is there.)

    I'm playing around with an instrument class that has child classes of dmm, gpio, power supply, serial binary streaming device, etc. Each of those classes has a child class for specific devices - for example, dmm might have child classes: agilent 34401, simulated and custom. I saw someone use a "create" or "new" method somewhere on the forums, here, but I can't find it now. Basically, I want a case statemtent to return a "simulated" or "34401" class, but in a subvi. See the attachment. I apologize for not taking the time to post code.

    The blue circles error out as expected, since real instruments are not installed. The red one does not. All that's in the "get new class.vi" is that case statement. (I added the "base" class instrument in an attempt to use dynamic dispatching and class-casting. Of course I've learned better than that by reading the forums. I remember seeing an example of this in someone's code on the forums, here, but I can't find it. Anyone remember the link - or have any other feedback?

    Thanks,

    --Todd

    post-107-0-40682800-1316135952_thumb.png

  5. I notice your tribot detects a dark line early. Mine (er, my son's) didn't detect at all. A quick change to monitor mode showed the right value to use. I am impressed at the ease-of-use of the new programming app. The original was obutse enough to make me delve into the ngc route. The new one lets me get the program written _before_ my son completes the build.

    As far as cats (outside, at least) a friend of mine set spring-loaded paint stirrers (30cm long sticks) at cat level around his garden walls. He added vaseline to the end so the stick would smack the cat and deposit the petroleum jelly. The surprise and the work required to lick off the jelly deterred the neighbour's cats from any further visits.

  6. You'll need to compile your matlab class with the Matlab's COM Builder (as I said, I'm no Matlab expert, so everybody feel free to correct me.). This shoud create an .exe file. Execute it, it creates a dll and registers it.

    Aitor, given Alex's next question, this may be jumping in a bit deep. It took a while for (even) me to get Matlab's build system understood. It wasn't well documented.
    Sorry if this is a complete stupid question: But what this it mean to run Matlab in batch mode and what is SysExec.vi????
    Read the LabVIEW help for SysExec.vi (search for it) and the Matlab help for 'batch mode'. From the terminal (command line) you can type:
    matlab -r asdf.m

    to start Matlab and have it run asdf.m. If the last command is 'exit', Matlab closes. SysExec.vi lets you do this from LabVIEW. I sometimes use LabVIEW to generate data files that get used in the m-file - which then creates an output file.

  7. Hi Todd,

    I have seen you questioned a thread which was concerning the problem using a Matlab m-file in a Labview VI. One of your suggestions was to use ActiveX, could you provide me with more information how to do this?? :blink:

    thanks in advance,

    Alex...

    I hope you don't mind that I'm posting your PM, Alex.

    When you open a vi that contains a Matlab script node, an instance of Matlab is automatically started that LabVIEW controls over ActiveX. You are only limited by the datatypes allowed into and out of the script node (plots work, too). Once the vi is closed (removed from memory/heirarchy) the Matlab instance closes.

    I have found it most useful to run Matlab in batch mode using SysExec.vi. That way I can programatically create data files and m files.

    --Todd

  8. So, thinking out loud, one person talking (P1) and two other people listening (P2 & P3). P1 asks P2 a question and extracts the answer. P1 then asks P3 a question and extracts the answer. Does your I2C driver allow you to do reads and writes separately? If so, P2 and P3 can each hold their answers until P1 extracts them. In other words, have one subvi that accepts an address and does the read, another subvi that accepts an address and does the write.

×
×
  • Create New...

Important Information

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