Simultaneous digital writing and reading w. measurement interval

Hi all

For the last couple days, I've been trying my brain trying to get a program to run.

I am trying to generate a camera digital 4 output bits then simulatanously count edges mounted on its LSB up to an arbitrary number set by the operator of the program, how the program should be a measure.

I note, however, that, on a certain edge County number growing (~ 950 or almost), the program crashes. The problem persists even when I remove the function that reads the LSB, although, in this case, accidents occur to a much higher number. What could cause this? Is there a way I can work around this problem?

Here is my code:

arraySizeInBytes2 = 8
bufferSize = 255

ReDim readArray (arraySizeInBytes2)

publicLifetime = 100' use this to control the duration of the task takes
numSamplesToWrite = 10 * publicLifetime * numSample * 5
numSamplesInArray = 5 * 10 * numSample

"the code that sets the analog and digital output signals

j = 0
k = - 1
<>
If SampPerCycle Mod d = 0, then k = k + 1 other k = k
For m = 0 to 3
If ((k) and (2 ^ m)) = (2 ^ m) then writeArray (m, j) = 1 Else: writeArray (m, j) = 0
Before m
j = j + 1
Loop

publicStatus = DAQmxCreateTask ("", taskHandleDigitalOut)
publicStatus = DAQmxCreateTask ("", taskHandleAnalog)
publicStatus = DAQmxCreateTask ("", taskHandleDigitalIn)
taskIsRunning = True

publicStatus = DAQmxCreateDOChan (taskHandleDigitalOut, "Dev2/port0 / line0:3","", DAQmx_Val_ChanForAllLines ")
publicStatus = DAQmxCfgSampClkTiming (taskHandleDigitalOut, "Ctr0InternalOutput", # 1000000, DAQmx_Val_Falling, DAQmx_Val_AcquisitionType_FiniteSamps, numSamplesToWrite)
publicStatus = DAQmxCreateAOVoltageChan (taskHandleAnalog, "dev2/ao0","",-10, 10, DAQmx_Val_VoltageUnits2_Volts, "" "")
publicStatus = DAQmxCfgSampClkTiming (taskHandleAnalog, "Ctr0InternalOutput", # 1000000, DAQmx_Val_Falling, DAQmx_Val_AcquisitionType_FiniteSamps, numSamplesToWrite)
publicStatus = DAQmxCreateDIChan (taskHandleDigitalIn, "dev2/port0/line7", "", DAQmx_Val_ChanPerLine)
publicStatus = DAQmxCfgChangeDetectionTiming (taskHandleDigitalIn, "dev2/port0/line7","", DAQmx_Val_AcquisitionType_ContSamps, 8 "')
publicStatus = DAQmxWriteBinaryI16 (taskHandleAnalog, DACwaveFormSize, False,-1, DAQmx_Val_GroupByScanNumber, buffer (0), sampsPerChanWritten, ByVal 0 &)
publicStatus = DAQmxWriteDigitalLines (taskHandleDigitalOut, numSamplesInArray, False,-1, DAQmx_Val_GroupByScanNumber, writeArray (0, 0), sampsPerChanWritten, ByVal 0 &)

publicStatus = DAQmxStartTask (taskHandleDigitalIn)
publicStatus = DAQmxStartTask (taskHandleAnalog)
publicStatus = DAQmxStartTask (taskHandleDigitalOut)
publicStatus = DAQmxStartTask (publicCounterHandle)

r = 0
< (publiclifetime="" *="">
publicStatus = DAQmxReadDigitalLines (taskHandle, 1, 5, DAQmx_Val_GroupByScanNumber, readArray (0), arraySizeInBytes2, SampsPerChanRead, numBytesPerSamp, ByVal 0 &)
If publicStatus = 0 then r = r + 1
If r Mod publicMeasurementInterval = 0 Then ' measure Code here
Loop

publicStatus = DAQmxStopTask (taskHandleDigitalIn)

publicStatus DAQmxWaitUntilTaskDone = (taskHandleDigitalOut - 1).
publicStatus = DAQmxClearTask (taskHandleDigitalOut)
publicStatus = DAQmxStopTask (taskHandleAnalog)
publicStatus = DAQmxClearTask (taskHandleAnalog)
publicStatus = DAQmxStopTask (publicCounterHandle)
publicStatus = DAQmxStopTask (taskHandleDigitalIn)
publicStatus = DAQmxClearTask (taskHandleDigitalIn)
taskIsRunning = False

Thank you.

You were right: it was a buffer overrun. I was using integers when I should have used doubles.

Thank you for your help.

Tags: NI Software

Similar Questions

  • How to equalize tcp/ip writing and reading rate?

    I use NI CRIO-9073 and labview 8.6. I am sending & receiving of real-time data to the host (with swicth) pc. This interval of data communication is 8milisec and milisec 10 so how do I equalize my write and read rates for example 8 miliseconds. If I can do it, I can't lose my logging data.

    In fact my real problem is that real time works 8 milliseconds to 20 milisecond (interval) for sending data, but datalos.vi reads 9 milliseconds and it works when RT works in milisec 8, when my reading speed is less than RT sending rate I see that my system is data loss

  • does anyone have example script writing and reading XML file

    someone at - it an example script for writing to variables affecting and reading variables to an xml file.

    Discover the second to the last link on this page:

    http://www.Cisco.com/en/us/partner/products/SW/custcosw/ps1846/products_implementation_design_guides_list.html

    There are some very good examples.

    HTH, please rate all positions!

    Chris

  • Spectrum of writing and reading spectrum

    Hi, I am currently busy writing read an optics Oceans USB 2000 spectres + I need to take 20 lightspectra of samples and connect these Spectra I have a file for analysis later.  Logging seems to be no problem but read the correctly.  The Spectra does not have the right dimensions. Begin 188 nm and in the graph, it starts at 0. When I put an offset of 188 in the pic is not in line with the right wavelength. That will become clear in the images below. It's the same spectrum, but the reading part is false. Thanks for help.

    You must use an XY graph, whose data are a group of two tables: the array of X (wavelength) and the array of Y (intensities).

  • Develooping app for Windows Store - writing and reading file: file came from another computer

    I am developing an app Store Windows (XAML, c#) and I am writing a file to the user Documents folder.  When writing is complete, the file is marked as «this file came from another computer and can be blocked to protect the computer»  Of course, this isn't what I want - the file did not come from another computer.  Subsequent attempts to read the file in the same application fail unless I have use Windows Explorer to unlock the file.

    How can I write a file in a way that I don't let not blocked for the following readings?

    I am developing an app Store Windows (XAML, c#) and I am writing a file to the user Documents folder.  When writing is complete, the file is marked as «this file came from another computer and can be blocked to protect the computer»  Of course, this isn't what I want - the file did not come from another computer.  Subsequent attempts to read the file in the same application fail unless I have use Windows Explorer to unlock the file.

    How can I write a file in a way that I don't let not blocked for the following readings?

    Probably should be this announcement on the forums for developers (MSDN/Technet).

  • Writing and reading the same excel file

    Hello.

    I wanted to write a few values in the excel sheet and after doing some math here I want to read the same file.

    Can I do this? Or there is a better way to accomplish the same task.

    Kindly help.

    Thank you

    To do this you don't need a file. See the attached example, I guess it will work

  • Keyboard for blackBerry Smartphones stuck in portrait mode when writing and reading messages

    Hi all

    I really hope you can help me solve my problem. Since a few days, my keyboard is stuck in portrait mode when I'm in the Messages menu. No matter what I do, it cannot switch to see the landscape. I tried to rotate in all directions, but without success. Apart from the Messages menu, the keyboard orientation changes as it should. But at the time wherever I press the Messages button, the display immediately switches to portrait. Apparently I blocked it somehow, but I can't unlock it now. I tried all the options, I changed the sensitivity of the change of the screen, but nothing. It's really boring to write e-mail messages using a SMS keyboard. Can someone give me advice how to restore the display of the landscape keyboard?

    Thank you very much in advance.

    Hi and welcome to the Forums!

    Whenever random strange behaviors creep, the first thing to do is a battery pop reboot. With power ON, remove the hood back and remove the battery. Wait a minute, then replace the battery and cover. Power on and wait patiently through the long reboot - about 5 minutes. See if things return to functioning. Like all computing devices, BB suffers from memory leaks and others... with a hard reboot is the best remedy.

    Best!

  • How to set and read cookies in adobe edge animate

    Hi all

    I need help with writing and reading cookies using the tip of adobe, is there a way to do I serached internet, but I found something simlliar?

    Thanks in advance

    To test with this plugin in a simple HTML page, you also need to include jQuery itself.

    For example:

    ...

    ...

    There are several different ways that you can load the jQuery.cookie plugin in your composition. Regardless of the method, I recommend loading compositionReady relaxation. It is the trigger that triggers once the composition is ready to play.

    This blog shows a way to load in external .js files:

    http://chrisgannon.WordPress.com/2012/09/01/loading-external-JavaScript-in-Adobe-edge-Anim ate-the-easy-medium.

    Here's how you would apply this method for the jQuery.cookie plugin:

    Enter a code similar to this:

    () yepnope
    {
    Nope:]
    ' / path/to/jquery.cookie.js'
    ],

    full: init
    }
    );

    function init() {}

    create initial values of your cookie here

    }

    Who is responsible in the jQuery.cookie plugin.

    It would be for you to create/manipulate data of the cookie as necessary for your needs. Most likely, you would do scroll down to a point in the script where you want the data editable or read, add a trigger, and then insert the necessary code.

  • simultaneous monitoring of the digital input lines when executing digital writing tasks

    I'm writing a multithreaded application in C on Windows 7, using the 9.6 DAQmx API and device USB-6509. This requires that we constantly monitor several lines on the 6509 for entry, digital using the change of the device detection feature. You must also write the digital output without having to stop monitoring the input rows. It is very important that the input rows be monitored continuously for the duration of the project.

    In the DAQmx manual reading, it seems that it is impossible to make a digital reading as well as a digital writing occurs, even if these tasks are performed in different threads. (The same I understand, that it is impossible to have several tasks of digital entry running simultaneously.)

    It seems that it would be possible to launch the task for reading (configured with the change detection), to pause playback, start the writing task, pause the task of writing, and then re - start the task of reading. But - and this is the important part - for the duration of the writing task is running, is it possible to configure it to the task of reading will always monitor the lines, even if it's just stores the data in the buffer for these periods? The key is that the data will be lost.

    Thank you

    Danielle

    Each channel is independent. If you can get the input data that you export a value. You need not make a break each task. The two tasks are parallel.

  • The most effective way to log data and read simultaneously (DAQmx, PDM) high data rates

    Hello
     
    I want to acquire the data of several Modules cDAQ using several chassis to
    high data rates (100 k samples per second if possible). Let's say the measurement time is 10 minutes and we got a large number of channels (40 for example). The measured data is written to a PDM file. I guess, the memory or the HARD disk speed is the limits. For the user, there must be a possibility to view the selection of channels in a graph during the measurement.

    My question: what is the best and most effective way to save and read data at the same time?

    First of all, I use an architecture of producer-consumer and I don't want to write and display the data in the same loop. I expect two possibilities:

    [1] to use the 'DAQmx configure logging.vi' with the operation 'journal and read' to write the data to a PDM file. To display the data in a second loop, I would create a DVR samples documented and 'sent' the DVR for the second loop, where the data will be displayed in a graph (data value reference). This method has the disadvantage that the data of all channels is copied into memory. Correct me if I'm wrong.

    [2] use 'DAQmx configure logging.vi', but only with the "journal" operation to write the data to a PDM file. To view the selected data, I had read a number of samples of the TDMS file in the second loop (I'm currently writing the TDMS file). In this case, I have only one copy data from the selected channels (not), but there will be more HARD drive accesses necessary.

    What is the most effective and efficient solution in this case?

    Are there ways to connect and read data with high frequencies of sampling?

    Thank you for your help.

    You say that the measurement time is 10 minutes. If you have 40 channels and you enjoy all CHs at 100 kHz, it is quite a number of values.

    In this case, I always try to approach under the conditions of use. If a measure is only 10 minutes, I just connect all PDM data and create a graphic module that could be in the same loop of consumers where connect you the data. You can always work on the raw data files big offline afterwards, the extraction of all the information you need (have a look at the product called NI DIAdem: http://www.ni.com/diadem/)

    The main issue is that the user needs to see in the graph (or perhaps a chart can be useful too). Lets say that the graph is 1024 pixels wide. It makes no sense to show multiple data to 1024 points, Yes? Every second will produce you 100 data points k per channel. What is the useful information, which should see your username? It depends on the application. In similar cases, I usually use some kind of data reduction method: I use a moving average (Point by point Mean.VI for example) with a size of the interval of 100. This way you get 100 data points of 1000 per channel every second. If you feed your graph every second with these average values, it will be able to data points in 1024 of the store (as a default) by channel (curve), which is a little more than 10 minutes, so that the user will see the entire measurement.

    So it depends on the frequency at which you send data to the consumer. For example, collect you values 1024 by iteration of the producer and send it to the consumer. Here you can make a normal means calc or a bearing (according to your needs) and he draw a graphic. This way your chart will display only the values of the last 10 seconds...

    Once I programmed some kind of module where I use a chart and not a graph, and the user can specify the interval of the absolute timestamp that is traced. If the data size is larger than the size of the chart in pixels, the module performs an average calculation in order to reduce the number of data points. Of course, if you need to see the raw data, you can specify an interval that is small. It all depends on how you program zoom functions, etc... In my case I hade a rate of 1 Hz, so I just kept all data in RAM limiting the berries to keep 24 hours of data, so that technicians could monitor the system. In your case, given the enormous amount of data, only a file read/write approach can work, if you really need access to all of the RAW data on the fly. But I hope that the values of working capital means will be enough?

  • vCO and reading/writing files

    Hello community,

    I am a newbie with vCO, sorry for the basic question perhaps.

    I created a "workflow" for automatic deployment and customization of VMs. job well enough, the model is cloned, sysprep, vCPUs and RAM set and so one. But the final customization tasks is to assign a unique IP address that is in a list in a plain text file. vCO should open the file, take the first IP address in the first line, remove it and close the file (DHCP is not an option). I can open and read the file with the options of '.readall' and a 'player', but which is not exactly what I want. I tried a few '.readline' which translates as "cannot find function readline" and after I I thought to split the entire string that resulted in "no defined split." I really don't know if this is the right way.

    Can someone please guide me in the right direction, perhaps with a few code snippets?

    Thank you very much!

    S.

    OK, here's another example, which reads the entire file into a string, and then use split() for areas exploded in the elements of an array:

    var fr = new FileReader("C://vcoscripts/demo.txt");
    fr.open();
    
    var complete = fr.readAll();
    System.debug("complete: " + complete);
    var lines = new Array();
    lines= complete.split(/\r\n|\r|\n/);
    System.debug("lines: " + lines);
    for (var linenr in lines) {
        var currentLine = lines[linenr];
        System.debug("currentLine: " + currentLine);
        }
    

    With this, you can use methods of standard table (push(), pop()), which might be easier to use.

    The regular expression to split the lines that I got:

    http://StackOverflow.com/questions/1155678/JavaScript-string-newline-character

    (good reading...)

    Edit: I forgot: with Array.strip (), you can remove an element of a table (in your case the IP address used before writing it back to deposit via FileWriter...)

    Kind regards

    Joerg

  • DAQmx start and read series vi low bits before actually reading

    I use DAQmx writing to set the bit on a map of 9403. When I set a little high, then try to read this small in a vi subseqeuent little gets low! Both DAQmx Start DAQmx Read screws seem to back the lower wick. How is that supposed to happen? I was certain that bits would not be initialized weak unless the device has been reset.

    I'm guessing that you create a digital output channel, call start, writing and then create as a separate digital input channel and call start-> reading or reading.

    Create the input channel changes the direction of the line.  This happens to commit (which you cross when they if call to start, or read with no departure).  Once the changes of direction, you no longer drive line.  That's why you always read zero.

    You have two options.  You can call read after write (in the task of digital output), or you can have fun with the tristate property.  TriState is a channel DAQmx (DigitalOutput-> Tristate) property.  Aid that it is good enough.

    Two ways to read the value of the line without changing the current state of the row.

  • Config problem and reading of AI

    Hello

    I have a problem when I use have config and read the structure.

    I use Labview new v12.0 and chassis PXI-1042 NI6120 daq card.

    If I use NI MAX, I can measure approximately 1 V (which is the minimum value for the sensor) or I can measure 1 V using the voltmeter.

    (@ OR MAX, I have set up for voltage analog - NI 6120 - ai0 - 0/5V DC - 20 kHz sampling frequency and number of samples of 4 kHz)

    When I use have config and read the structure, I can't measure 1V! Channel ai0 value is 0 a little.

    Config and read the ai0 channel structure is attached.

    You have an idea what the problem is when I use config and read the structure.

    Best regards

    Serdar

    Two thoughts:

    1 looks like to your acquisition is set to finished samples, then you're exciting the sensor before running the code? Or have you tried to change continuously, so you can change the voltage of the sensor the code runs?

    2. you mention DC in your configuration of MAX, but your coupling in your "10045" code means coupling AC. Do you intend to use the current alternative or continuous? If you want DC, your value of coupling must be 10050 (or you need to create a constant off the coast of the entrance so that you get the enum rather than use a digital).

    Hope that helps!

    -Ryan_S

  • How to read the measurements of the model eye?

    I'm new in LabView. I use an Agilent54855A to capture a model high-speed digital and want to read these measures of model of the eyes, eyes for example height, width & vice versa of the eyes. However, I couldn't find this VI in the palette.  I can read it on the screen, but do not know how to retrieve through LabView. What should I do?

    Steve,

    Thank you. There are commands to read the eye measures model. I'm changing the existing VI to add these new features and then I will check next week.

    Best regards

    KKNG

  • Digital start and stop trigger with restart HW

    Hello

    I am trying to write a program that reads continually samples based on the rise and fall of a digital triggering.  I want the measure to start on the front of the trigger and stop on the falling edge of the trigger.  I want the data that are read to be preserved and then added with the next set of data that the trigger rises again.  I have read the tutorial "Digital start and stop trigger" and can use the reference to stop the measurement process and I looked at the example "Acq & chart voltage - Int Clk - HW Trig restarts ' that comes with LabVIEW and I can get the two of them working separately with my request.  I'm quite confused however try to put the two together (see attachment).

    If I put a "Start.vi" icon inside the while loop then I get an error "you can do this while the measure is still ongoing".  If I put it out of the loop and then the process only runs once.  I tried to put a loop structure case for restart only if necessary, but this has produced another error which the source escapes me.  Is there a standard way to do this and if so someone can point me in the direction of an example?

    See you soon,.

    Glen

    I think that in this situation, it would be preferable to use a Pause trigger.  You can use the break to stop the acquisition when the trigger was low and start when the trigger is high.  In this way, served only for the duration of your trigger pulse.  I've attached a screenshot of a VI that illustrates this principle in action.

Maybe you are looking for