C code conversion for labview

Hello

As I'm not familiar with C code, can anyone please help me convert this function in Labview (8,6)? See attached txt file.

Thank you

LabVIEW 8.6

This is a very direct translation.  If you know that the length parameter will be equal to the length of the array, then you don't need the length parameter and you can use an automatic indexing for loop, cut just the last element if the parameter 'create' is true.  (Code snippet is LV 2009 but attached VI is saved to 8.6)

Tags: NI Software

Similar Questions

  • 2651 a conversion of TSP Script for LabVIEW

    Hello

    I have a problem on the conversion of all TSP scripts that contain functions and appeal for the end loops. I'm new to the TSP with models of trigger scripts. I used the Script Builder (TSB) Test tool and am able to run any TSP and generate raw data, but I don't seem able to convert most of the codes in the command of LabVIEW VISA or loader LV TSP TSP and run it to generate data... I can't find any tutorial or examples how to do it.

    Let's say that... Use the example of KE2651A_Fast_ADC_Usage.tsp (pulse) and I'll just focus on the portion of function CapturePulseV (pulseWidth, pulseLimit, pulseLevel, numPulses). I have seen a few examples of LV that says loadscript myscript and close on endscript.  I did a lot of different approaches, and I kept getting errors in particular the print function that I am not able to generate data through LV by to read the data in the buffer to inside the instrument. Some approaches, I have had no errors but no data... Some approaches, I got error-285.

    The part of the code TSP pulse that works in TSB is here (I'm not including loadscript and endscript) and what is the RIGHT way to modify the code for LabVIEW and run it and obtain data? Thank you:

    function CapturePulseV(pulseLevel, pulseWidth, pulseLimit, numPulses)
        if (numPulses == nil) then numPulses = 1 end
    
        -- Configure the SMU
        reset()
        smua.reset()
        smua.source.func            = smua.OUTPUT_DCVOLTS
        smua.sense                  = smua.SENSE_REMOTE
        smua.source.rangev          = pulseLevel
        smua.source.levelv          = 0     -- The bias level
        smua.source.limiti          = 5     -- The DC Limit
        smua.measure.autozero       = smua.AUTOZERO_ONCE
    
        -- Use a measure range that is as large as the biggest
        -- possible pulse
        smua.measure.rangei         = pulseLimit
        smua.measure.rangev         = pulseLevel
    
        -- Select the fast ADC for measurements
        smua.measure.adc            = smua.ADC_FAST
    
        -- Set the time between measurements.  1us is the smallest
        smua.measure.interval       = 1e-6
    
        -- Set the measure count to be 1.25 times the width of the pulse
        -- to ensure we capture the entire pulse plus falling edge.
        smua.measure.count          =
                        (pulseWidth / smua.measure.interval) * 1.25
    
        -- Prepare the reading buffers
        smua.nvbuffer1.clear()
        smua.nvbuffer1.collecttimestamps    = 1
        smua.nvbuffer1.collectsourcevalues  = 0
        smua.nvbuffer2.clear()
        smua.nvbuffer2.collecttimestamps    = 1
        smua.nvbuffer2.collectsourcevalues  = 0
        -- Can't use source values with async measurements
    
        -- Configure the Pulsed Sweep setup
        -----------------------------------
        -- Timer 1 controls the pulse period
        trigger.timer[1].count          = numPulses - 1
        -- -- 1% Duty Cycle
        trigger.timer[1].delay          = pulseWidth / 0.01
        trigger.timer[1].passthrough    = true
        trigger.timer[1].stimulus       = smua.trigger.ARMED_EVENT_ID
    
        -- Timer 2 controls the pulse width
        trigger.timer[2].count          = 1
        trigger.timer[2].delay          = pulseWidth - 3e-6
        trigger.timer[2].passthrough    = false
        trigger.timer[2].stimulus       =
                    smua.trigger.SOURCE_COMPLETE_EVENT_ID
    
        -- Configure SMU Trigger Model for Sweep/Pulse Output
        -----------------------------------------------------
        -- Pulses will all be the same level so set start and stop to
        -- the same value and the number of points in the sweep to 2
        smua.trigger.source.linearv(pulseLevel, pulseLevel, 2)
        smua.trigger.source.limiti      = pulseLimit
        smua.trigger.measure.action     = smua.ASYNC
        -- We want to start the measurements before the source action takes
        -- place so we must configure the ADC to operate asynchronously of
        -- the rest of the SMU trigger model actions
    
        -- Measure I and V during the pulse
        smua.trigger.measure.iv(smua.nvbuffer1, smua.nvbuffer2)
    
        -- Return the output to the bias level at the end of the pulse/sweep
        smua.trigger.endpulse.action    = smua.SOURCE_IDLE
        smua.trigger.endsweep.action    = smua.SOURCE_IDLE
        smua.trigger.count              = numPulses
        smua.trigger.arm.stimulus       = 0
        smua.trigger.source.stimulus    = trigger.timer[1].EVENT_ID
        smua.trigger.measure.stimulus   = trigger.timer[1].EVENT_ID
        smua.trigger.endpulse.stimulus  = trigger.timer[2].EVENT_ID
        smua.trigger.source.action      = smua.ENABLE
    
        smua.source.output              = 1
        smua.trigger.initiate()
        waitcomplete()
        smua.source.output              = 0
    
        PrintPulseData()
    end
    
    function PrintPulseData()
        print("Timestamp\tVoltage\tCurrent")
        for i=1, smua.nvbuffer1.n do
            print(string.format("%g\t%g\t%g",
                                smua.nvbuffer1.timestamps[i],
                                smua.nvbuffer2[i],
                                smua.nvbuffer1[i]))
        end
    end
    

    I finally solved it myself! I first create support shell, according to the documents, but the problem was with functions of scripts but I solved by introducing VISA separate, feature writing and THEN retrieve the data from the instrument directly by VISA buffer read more. I did TSP_Function Script Loader that allows simply copy/paste codes teaspoon (any * .tsp) of: TSB program or incorporated into this type of function and loader.vi, name (parameters), defined by its own pasted script then it will generate RAW files directly in the array of strings that can be broken into pieces or restructured into what you want as for the graphics, etc..

    That's all I really need to do, I can do codes of tsp in LV and get the data off of it easily via the function defined. Now, this Loader.VI behaves in the same way that TSB keithley-made program I use.

    Here I add Loader.vi Script TSP_Function (in LV 2011 +).

  • epm2000 driver for labview 8.5

    I try to open EPM2000 website of molectron driver, but he's too old. Anyone have a version that has been converted to 8.5 or something that can open the 8.5? Thank you.

    Hi, Steve,.

    Attachment - llb, which turns into LabVIEW 8.5.

    Best regards

    Andrey.

    PS

    DJ Dave, strange answer, OR engineer.

    First of all, the LLB can be open in LabVIEW 6.1, then registered, then open in LabVIEW 8.5 and still saved. LabVIEW 4.01 is not necessary for the conversion.

    Second, LabVIEW 4.01 can be started under WinXP (Yes, officially incompatible with the latest version of Windows, but sufficiently compatible for purposes of code conversion).

  • modulation toolkit for labview for embedded controller PXI-8106

    Hello

    I have an on-board controller: 8106 PXI OR PXI 5661 and 5671. He came with DAMA RFSG but not the Modulation Toolkit (TM). Now I cannot access some screws RF Toolkit as NI DAMA close.vi etc. I opened a code that uses this DAMA close.vi and since I donot have probably MT, I can't run since the claim code to choose the path!

    I checked for the TM in the start menu-> all programs-> national instruments-> modulation but in vain. Also, I opened MAX and under "Software", I could find DAA, pilots RFSG etc but not the Mt.

    When I checked online it says I have to buy the cd/dvd of MT. If I do, how I run on my controller?  What are my other options?

    PK

    Hello

    I think I solved the above problem. I had to install the RFSG and ACD for labVIEW. For some reason, the equipment was delivered to me with DAMA and RFSG, but only for C. This part was misleading because I saw on my National Instruments system but not the DAMA DAMA and RFSG vi. Also spectral measurement Toolkit (SMT) has not been installed. SMT is a MUST for the good functioning of the RF VSA. After you install the required drivers and tool boxes, I am able to run and use the VI completely.

    Thanks for your support Abhishek.

    PK

  • Convert VB2005 read routine file for Labview

    Hello everyone,

    I am very NEW to Labview (using Labview 2010) and I am trying to convert a Net in Visual Basic 2005 dot program to format of Labview.

    My question to the group is, I would like to convert the VB code below in Labview.  This is one of the many readings of text file which makes my VB program.

    ' * Read data from frequency of files and convert them to Double *.
    List = 0
    oRead = IO. File.OpenText("C:\TPS_Data\PA_Freq_List.txt")
    All in oRead.Peek <> -1
    LineIn = oRead.ReadLine)
    TFL (List) = LineIn
    TestFreq (List) = Convert.ToDouble (TFL (List))
    List = + 1
    End while
    oRead.Close)

    These files are calibration/offset and rate data for my RF ATE test equipment.  Once the operator selects an amplifier to test, the program loads into memory these specific files in amplifier.  These variables they are whole, double or whatever store them in a table under (ex: TestFreq (0), TestFreq (1), etc.).  Each frequency has its own offset and calibration data which are sent to the test apparatus by each tested frequency.  This line of code is possible, or do I have to find another way to do this?  If so, how to store and retrieve these data at any time during the test.

    I appreciate all of the information provided by this group.  Thank you in advance.

    Kind regards

    Scott

    Greetings smercurio_fc,

    Thank you for your recent reply.

    Between your most recent response and another post that I fell today by searching on google, I was able to accomplish what I wanted to do.  The basic function was to read the text file, which is a list of test frequencies and move a generator of RF signals at each frequency in the list.

    Thanks again for your time.

    Kind regards

    Scott

  • Implement the Std::Vector &lt; &lt; Point2i &gt; &gt; Std::Vector in dll wrapper for LabVIEW

    Hi, I'm writing a wrapper dll that using OpenCV function. I had been sucessfully implement Std::Vector by referring to "An array of clusters to a dll C sending".

    And now, I want to implement the Std::Vector<>> who is a lot like table 2D but each line items may be different.

    In LabVIEW, I attribute a range of cluster of the dashboard cluster of 2 I32 elements, structure which is shown below:

    I think it has the same functionality as Std::Vector<>> in C++.

    So I plug this data on the "Call library function node" structure and generate C code that indicated below:

    /* Call Library source file */
    
    #include "extcode.h"
    
    /* lv_prolog.h and lv_epilog.h set up the correct alignment for LabVIEW data. */
    #include "lv_prolog.h"
    
    /* Typedefs */
    
    typedef struct {
        int32_t elt1;
        int32_t elt2;
        } TD4;
    
    typedef struct {
        int32_t dimSize;
        TD4 elt[1];
        } TD3;
    typedef TD3 **TD3Hdl;
    
    typedef struct {
        TD3Hdl elt1;
        } TD2;
    
    typedef struct {
        int32_t dimSize;
        TD2 elt[1];
        } TD1;
    typedef TD1 **TD1Hdl;
    
    #include "lv_epilog.h"
    
    void funcName(TD1Hdl arg1);
    
    void funcName(TD1Hdl arg1)
    {
    
        /* Insert code here */
    
    }
    

    Then, I write this code show below in dll wrapper:

    void funcName(TD1Hdl Blobs)
    {
        vector < vector > blobs;
    
        // Distribute contents of blobs to Blobs from LabVIEW
        MgErr err = mgNoErr;
        size_t arraySizeInBytes = Offset(TD1, elt1) + sizeof(TD2)*blobs.size();     // Determine row size
        err = DSSetHSzClr(Blobs, arraySizeInBytes);
    
        if (err != mgNoErr)
            return;
    
        (*Blobs)->dimSize = blobs.size();
    
        for (size_t i = 0; i < blobs.size(); i++) {
            arraySizeInBytes = Offset(TD3, elt) + sizeof(TD4)*blobs[i].size();  // Determine col size of each row
            err = DSSetHSzClr((*Blobs)->elt[i].elt1, arraySizeInBytes);
    
            if (err != mgNoErr)
                return;
    
                    /*......................*/
            }
    }
    

    When I call LabVIEW dll, the program get interuption(i.e shutdown) on line where I want to determine the size of each row.

    Could someone give me some suggestions on this subject or promote another application of this requirement?
    Thank you very much.

    MgErr funcName(TD1Hdl Blobs)
    {
        vector < vector > blobs;
    
            Labeling(image_binary, blobs);         // the prototype of this function is: Labeling(Mat &binary, Vector> &blobs)
    
        // Distribute contents of blobs to Blobs from LabVIEW
        MgErr err = mgNoErr;
        size_t arraySizeInBytes = Offset(TD1, elt) + sizeof(TD2)*blobs.size();      // Determine row size
    
            if (contours == NULL)        {                Blobs = (TD1Hdl)DSNewHClr(arraySizeInBytes);                if (Blobs == NULL)                         err = mFullErr;        }        else                err = DSSetHSzClr(Blobs, arraySizeInBytes);
            if (err != mgNoErr)                return err;    for (size_t i = 0; err == mgNoEerr && i < blobs.size(); i++) {
            arraySizeInBytes = Offset(TD3, elt) + sizeof(TD4)*blobs[i].size();  // Determine col size of each row
    
                    if ((*Blobs)->elt[i].elt1 == NULL)                {                        (*Blobs)->elt[i].elt1 = (TD3Hdl)DSNewHClr(arraySizeInBytes);                        if ((*Blobs)->elt[i].elt1 == NULL)                                    err = mFullErr;                }                else               err = DSSetHSzClr((*Blobs)->elt[i].elt1, arraySizeInBytes);
                    if (err == mgNoErr)                {                        (*((*Blobs)->elt[i].elt1))->dimSize = blobs[i].size();
    
                            /*......................*/
    
                    }
            }
            (*Blobs)->dimSize = i;        return err;}
    

    Personaally I've usually done like this. Already, the tar of DSSetHSzClr() indicates if there was something wrong and that the handle cannot really become NULL to call this function.

    To be entirely correct and safety integrated, you must do more than that. But as long as you assume that the incoming picture is always smaller that the outgoing Board will be (usually it be 0 items when you enter this function, but if you reuse sort table in the diagram, by storing it in a registry change for example, this may not be true more) this will be enough.

  • 3532 HIOKI driver is for labview 5.1 but I have labview 8.5.

    I found HIOKI-3532 driver for labview 5.1 but I have labview 8.5. I got the error message you see in the image below. Is it possible to convert the pilot? All solutions?

    Hi Zancis,

    have you noticed the Version Conversion Board at the top of the forum of LabVIEW?

  • Is there a decompiler for LABView v4 - v6

    Hello

    One of our customers (pharmaceutical industry) has a LABView application compiled on Win98 + 10 years. The source code is not available, and it seems that no one knows what is under the hood. According to the dates of Win98, I expect to run a version of LABView between v4 and v6.

    Is there a decompiler software, ways to look at the source code or to retrieve information of bases to start reverse engineering.

    Thanks for you answers!

    Alex

    [email protected]

    The whole issue is a bit more complicated. Prior to LabVIEW 8.6 the internal resources of the executable was indeed an archive VI LabVIEW (LLB) and since LLBs didn't have a single hierarchy depth that is somewhat like a single directory. This caused trouble with the latest library LV based instruments as well as classes LVOOP drivers that uses the same name of VI, but with another library prefix each, so that LabVIEW had to move these files to directories external during the generation of executable files, to avoid name collisions.

    In all new versions of LabVIEW, the internal executable resource in which the screws are stored is actually a default ZIP file. You can always force LabVIEW use a LLB format to store files, options by checking the 'use LabVIEW 8.x file layout' in the advanced compile options. Now the ZIP resource was initially stored as a simple ZIP to the format of data resources, and that caused some problems because most ZIP utilities simply analyzes a file for the header of the ZIP file and open it as such, even if the ZIP file resource is anywhere within the file, so that almost all ZIP tools could open an executable of LabVIEW. NEITHER changed this format: ZIP tools can recognize him either.

    Now, yes you can look in the resource LLB and ZIP in the past (and still with a little extra effort) but before everyone screams oh "My precious IP is in the street" Please be aware that the only thing you can do for this resource is to obtain the names of VI and if you manage to load in the fall version of LabVIEW exactly just generic icons on a diagram to see the component connector. Unless of course you also check the "enable debugging" checkbox in the advanced build options, that leaves patterns and the frontpanels in the VIs and actually create something similar to a source distribution packaged.

    So without activate debug compilation option, someone is actually not much more than what he can do by opening any binary DLL created from C, C++, or any public compiler with the tool of Microsoft dependence and MUCH MUCH less than what you can get in any just put such DLL through a disassembler.

    And to my knowledge there isn't a disassembler as tool for LabVIEW VIs to date, and I would consider about 1 billion things more interesting to do than to try to create such a thing.

  • How to create own IDE for LABVIEW (such as vision builder)

    Hi all

    My pretty funny question, I know that.

    I like to create Labview Application IDE like Vision Builder.

    How to do this?

    As far as I know that Vision Builder is developed with LabVIEW, the source code of course is not public... But why do you want to create a new IDE for LabVIEW? LabVIEW is an IDE, no?

    I think also Vision Builder uses a lot of scripts and sub-panels, I can't help you much more than that.

    For us - outside NI - script cannot be used in an EXE file, they reserve that for their applications not it will be a difficult task.

  • Is there a bar code scanner / code reader for iOS which displays the information in legible characters human bar?

    Is there a bar code scanner / code reader for iOS which displays the information in legible characters human bar?

    Hello. Have you looked in the app store? There are many people who can do this by using the camera in the phone or iPad. Some also work on images in the Photos.

  • find the code forgot for new iPhone 5SE

    What is the best way to find my code forgotten for my new iPhone 5Se.

    I put my iPhone in airplane mode and after a few hours of walking, my itouch asks after the code to unlock the iPhone again. Because I don't remember my code, is there any other possibility to open

    If you have forgotten the password. Unfortunately, these are the only options available. Good luck.

    https://support.Apple.com/en-us/HT204306

  • What is the code name for intex fx cloud (required to manually build 2.0)

    I want to manually build the last B2G for an intex phone fx cloud. The build process requires executing the script "config.sh' with the name of the phone code:
    https://developer.Mozilla.org/en-us/Firefox_OS/Preparing_for_your_first_B2G_build#Configuring_the_B2G_build_for_a_mobile_device

    The phones operating system supported firefox page does not display the code name for new devices:
    https://developer.Mozilla.org/en-us/Firefox_OS/Developer_phone_guide/Phone_specs

    Is it possible to get the code for intex phone name. If the list of the devices supported by "config.sh" does not include the code name of intex, is there a way to still be able to build the latest os from firefox for the intex device?

    Hi Notalex,

    The code name for the Intex Cloud FX device is Tarako. However, it uses another optimized codebase that the regular B2G is based so that it can run on lower range with little memory devices.

    Unfortunately, version 2.0 of the B2G code base would go not on the Fx cloud Intex due to material limitations.

    For more information and advanced issues on customizing your Firefox OS device, you can visit the following pages:

    I hope you find this information useful. Please let us know if you have any questions of usability with your new Firefox OS device.

    Thank you!! =)

    -Ralph

  • ICloud Keychain how can I change the phone number needed to verify the code text for me? The number it was sent is an old phone number of my friends that I do not have access to the.

    ICloud Keychain how can I change the phone number needed to verify the code text for me? The number it was sent is an old phone number of my friends that I do not have access to the.

    Try this from another thread I saw.

    On iOS, go to settings > iCloud > keychain and tap button to disable iCloud keychain. (you will be asked to delete or keep the passwords on device) I chose to delete...

    Then turn it back on, and pop - up chose reset iCloud trousseau, on a chosen pop-up confirmation reset

    In the new window pop up use iPhone password like iCloud cryptogram? has chosen the use code

    Enter your secret code (4 digits) then choose country and your new phone number

    Although, to "Restore the iCloud Keychain," I took to erase the data and essentially set up a new keychain.  Not the case.  Strangely, after essentially bypassing the security system, setting a new password and verification number, I see my cards, passwords and other data have been restored.  Maybe it's all the iCloud account and this master password.  Or maybe it's a bug.  With Apple, we'll never know.

    Also have a look here: get help using iCloud Keychain - Apple Support

  • Pavilion a6230n: How can I get the product code (UPC) for an HP computer?

    Hello, I'm selling an old HP desktop that I hang out on Amazon.

    But in order for me to post on Amazon, I need to create a new list, since nobody else is for sale. To create a new list, I need a product code unique for the desktop computer. I'm looking for the Universal Product Code (UPC). A UPC code is the bar code that would be tested at the point of sale when someone buys something.

    I have a few other computers, I'm trying to sell, and on the site Web of Toshiba, the first manual I opened a laptop shows me the UPC. HP manuals don't.

    I tried to call customer service. And both times I'm hung up or disconnected. It's very frustrating because I have a very basic question, and does not have I gotten a response yet.

    If someone can find the UPC for HP Pavilion a6230n and tell me how to get the Cup for HP products in the future, I would be very happy. Thank you!

    Hello @RYoder15,

    There is not much else I can suggest.  I tried at length to see if I could find anything in what concerns this information without success.  Maybe if you are able to find the product packed in the store?  I was able to find the product on Amazon here: HP Pavilion a6230n desktop PC

    I hope this helps.

    Kind regards!

  • create the code lock for computer book note

    How to create the code lock for computer book notices

    Enter the BIOS, select the Security tab and set the power on password.

    I strongly recommend that you write the power on password and put somewhere safe. If you have forgotten the password turned on, you will find that you will need to send your laptop to be repaired by HP. This is not free of cost. Once a button inside the laptop password reset are over.

    I can't be more precise, as you have not identified your laptop with its full product name or product number.

Maybe you are looking for