Quantcast
Channel: Digital I/O topics
Viewing all 2184 articles
Browse latest View live

cDAQ software PWM options

$
0
0

This post outlines some of the options for generating a PWM signal using cDAQ hardware without using counters and hopefully others will be able to provide further insight, options, and details.

 

For my application I need to generate a PWM signal at 1kHz and update the duty cycle about every second. We need to control 30 signals, so we decided to use a 9477 digital output module with a cDAQ-9184 Ethernet chassis. Our system needs to operate for a long time (6 months) without interruption, which means we need a reliable solution. Considering the high channel count, we decided against using digital output modules that can use counters and PWM features (which would have been much easier).

 

Since we obviously can't write each sample individually at 1kHz, all the options send a 1000 sample array to the digital module to be generated at 1kHz (set with the timing vi). A new 1000 sample array needs to be written to the module every second. If the new array is written faster than once a second, excess data will be in the buffer and there will be a lag between a change in the duty cycle and the actual output. If the data is written slower than once a second, there will be a buffer underrun error and the Task will stop. Below are some options for performing such a task.

 

Option 1) The most appropriate method would be to set the output buffer size to 2000 samples and use the DAQmx write vi to write the 1000 samples. The DAQmx write vi will wait until there is sufficient space in the buffer to write the 1000 samples and then write the samples. Unfortunately, setting the output buffer size to 2000 has no effect when using the cDAQ 9184 chassis. Apparently there is a 12Mb onboard buffer that is used to its maximum capabilities, regardless of what is specified in the output buffer size property node. This means that the DAQmx write vi will run many times without pausing until it fills up the 12Mb buffer. When the 12Mb buffer is full, it starts running once a second. This creates an enormous lag in the system and is not really functional

 

Option 2) Write the 1000 sample array at 1Hz using a software timed loop using the Wait Until Next ms Multiple function. In this case the system is relying on the software (Windows) clock to be synchronous with the hardware (cDAQ) clock. If the Windows clock is faster, the buffer slowly fills up. If it is slightly slower there will be an underrun error. The hardware clock specification of the cDAQ 9184 chassis is 50ppm, which is 130 seconds every month. 

 

Option 3) Create and manage a homebrew "buffer" by keeping track of the current write position in the task (CurrWritePos property node) and the number of samples generated by the task (TotalSampPerChanGenerated property node). In this option, the WritePos and SampGen properties are monitored and if the SampGen value is within 1000 of the WritePos, write another 1000 samples to the task. This option works, but has at least one caveat.

I tested this setup to see what would happen when the values of the property nodes got large (I don't like surprises when my actual system is running). The CurrWritePos property kept increasing as expected up to a value of 1.66E11 when the test was terminated. The TotalSampPerChanGenerated property node did not behave as expected. This value incremented up to 1.289E10 at which point it dropped down to 0.8590E10 and start incrementing again until it reached 1.289E10. It kept incrementing using this same sawtooth pattern.

 

Option 4) Start and stop a task that only writes 1000 samples each time. This method does not buffer the data and wouldn't lead to a continuous PWM signal.

 

Conclusion, Option 3 is the only the only way I can get my system to work, I just have to account for the unexpected sawtooth pattern of the SampGen value.

 

I have asked NI how best to perform this PWM task and haven't really received satisfactory answers. They were unaware of the inability to specify the output buffer size on the cDAQ hardware and they were not aware of the sawtooth pattern of the TotalSampPerChanGenerated property.

 

This is as much a way of documenting my findings so that others can learn from them as a request for further insight on continuous digital sample train generation on the cDAQ platform.

 

tldr: Generating continuous software timed PWM signals with cDAQ is a pain. The best method (I think) is to use the CurrWritePos and TotalSampPerChanGenerated properties to keep track of when to write the next batch of samples. The SampGenerated property does not always increment; it has a sawtooth pattern.

 

Regards,

 

Douwe

 

 

 


Start data acquisition in NI-USB 6501

$
0
0

Hi,

 

I am trying to send triggers to two trigger devices (BioSemi EEG and Delsys EMG) connected to NI-USB 6501. I want to be able to start the data acquisition in both simultaneously. I am using the following MATLAB code to send triggers:

 

s=daq.createSession('ni');
addDigitalChannel(s,'Dev1','Port1/Line0:3','OutputOnly');
addDigitalChannel(s,'Dev1','Port2/Line0:3','OutputOnly');
outputSingleScan(s,[0 1 1 1, 0 0 0 1]);
 
However the 4 bit trigger codes for starting and stopping the acquisition keep changing with every run. Is it possible to have one set of code for starting the acquisition and one for stopping.
 
Thanks,
Neelesh

Regeneration to an offset

$
0
0

I would like to use code which is similar to Digital - Continuous Output.vi from the examples to run a repeating pattern, but to start at an offset the second time around with the full pattern running the first time. I want to do this completely with hardware timing(not sw control) so there are no glitches as the transition. Is it possible to do this?

overwrite digital output buffer error -200292

$
0
0

In another attempt to generate a software timed PWM signal using cDAQ-9184 and a 9401 module I ran across another error. (I'm developing this for another application where I need 30 PWM signals, so using counters isn't practical).

 

I created a 1000 element buffer and am generating 1000 samples per second. I set the task to "Allow Regeneration" and set the write position to "First Sample" and Offset = 0. I then start the task. As long as I don't try to write any more samples, the proper PWM signal is continuously generated. When I try to overwrite the 1000 sample buffer with a new array, I get error -200292. 

 

Is there a way I can avoid this error? I have the problematic VI attached. 

 

Thanks,

 

Douwe

Controlling motor driver using Labview and SC2345?

$
0
0

Hello,

 

I am trying to control a motor driver using labview and I am lost as to what the process would be. I want to use a motor driver like this one https://www.sparkfun.com/products/9457 and I am not sure if I can directly interface it with my equipment. I am using a NI USB-6251 connected to a SC2345. Which pins would I use to control the pins on the driver? Also how would I go about creating a program to do this? I want to be able to start the motor and control the speed of it using PWM. Any help would be greatly appreciated.

 

Thank you,

 

JimboMcJambo

RMC design for sbRIO 9627

$
0
0

Currently, I am designing the RMC board that is used to connected to sbRIO9627. In our application, the GBE (after PHY), High speed USB and C series DIO are not used. How should I address these pins on the RMC connectors? Should these pins be float? or pulled up by a resistor?

 

Finding a proper digital I/O device

$
0
0

Hi, I am looking for a digital I/O device to control the TI DDC264 chip and acquire its data.

That requires the NI device can output two CLK signals of 5MHz, and give four other outputs for CFG and RESET.

The DDC264 has two outputs, one is DVALID to notice the data is valid, and the other is a serial data output, DOUT. Both of the signals need to be acquired by NI device.

I never used the digital I/O ports of any NI device before. So feel confused. Is there a NI digital I/O device can implement these functions, and control the timing?

Anybody who did such things before please give me some advice.

 

PCI 6509 Change Detection

$
0
0

Hello,

I'm a noobie to DAQmx and I'm working on a PCI 6509 to exam a 4-channel device via C#. I prefer to trigger an event when all of these 4 digital inputs are TRUE . I've checked the user guide which refers:

" the NI 6509 does not report which line changed or if the line was rising or falling, After a change, you can read the input lines to determine the current line states".

 

However, these 4 channels might be set to 1 almost at the same time which means 4 events will raise in a very short interval. As I have no idea which line changes, I have to read all 4 lines 4 times during this, which could leads to performance issue(or not?).

  1. Is there any way that I can take advantage of interrupt/event to tell if these 4 channels have all experienced a rising edge?(this project is time crtical and loop reading seems to be resource consuming)
  2. If not, does any NI DIO device provide me the ability to tell which line changes without read them all and check?

Thank you!


Alternating digital waveform on 2 lines

$
0
0

I send two on/off waveforms as an output to port0/line0 and port0/line1 using a PCIe-6363/BNC-2110 to modulate two lasers.
Please see the attached .vi.
Before you run the LabVIEW program one can choose the alternating frequency.
That works pretty fine, you can easily connect an Oscilloscope to the outputs and see the alternating digital waves.
My problem here is, that as soon as I hit the stop button the program stops (obviously) but keeps one of the last modulation outputs on.
I want to alter the program that when I hit the stop-button both outputs switch to 0 (off - basically switching the laser modulation off).

Whatever I do here, e.g. adding some if-condition, adding an additional DAQmx write behind the loop, etc.... gives me 1) an error (like: 200557, 200587) and 2) never sets the modulation to 0 (off).
Maybe someone here has an idea how to solve that?

USB-6501 DIGITAL OUTPUT

$
0
0

Hello all,   I have a brand new NI USB-6501, and I'm looking for some help with operation. I want to use 6501 as a 8:1 multiplexer controller.  This table below are the signals that I want to generate. 

 

Step     P0.0     P0.1     P0.2     P0.3

  1           0           0           0           1

  2           0           0           1           1

  3           0           1           0           1

  4           0           1           1           1

  5           1           0           0           1

  6           1           0           1           1

So there are 6 steps, 4 lines generate signal at the same time. I want to set the step time as 10 second. I am just not too familiar with LabView.  Please help!

Using a hamamatsu MPPC C13366-3050GD

NIDAQmx analog output C++ constant voltage

$
0
0

Hi,

 

I'm currently implementing a DAQ in my C++ software which will generate the user voltage. It works fine with Matlab and I get nice changes when I put different voltages.

In spite of that, when I implement in my main the following code:

 

TaskHandle taskHandle = 0;
  float64 data[1000];
  int var=1;
  while(var<10){
    cin >> var;
    for (int i = 0; i < samplesReceived; ++i){
      data[i] = var;
// - Initiation PART - // DAQmxCreateTask("",&taskHandle);
DAQmxCreateAOVoltageChan(taskHandle,"Dev1/ao1","",-10.0,10.0,DAQmx_Val_Volts,NULL);
DAQmxCfgImplicitTiming(taskHandle, DAQmx_Val_HWTimedSinglePoint, 1000);
DAQmx // - WRITE PART - //
//DAQmxWriteAnalogF64(taskHandle,1000,0,10.0,DAQmx_Val_GroupByChannel,data,NULL,NULL);
DAQmxWriteAnalogScalarF64(taskHandle, 0, 1, var, NULL);
// START
DAQmxStartTask(taskHandle);
//DAQmxStopTask(taskHandle); } }

I don't see any changes on a oscilloscope graph U=f(t).

However, when I put something this way:

 

  TaskHandle taskHandle = 0;
  float64 data[1000];
  int var=1;
  while(var<10){
    cin >> var;
    for (int i = 0; i < samplesReceived; ++i){
      data[i] = var;
      // - Initiation PART - //
      DAQmxCreateTask("",&taskHandle);
      DAQmxCreateAOVoltageChan(taskHandle,"Dev1/ao1","",-10.0,10.0,DAQmx_Val_Volts,NULL);
      DAQmxCfgSampClkTiming(taskHandle, "", 10000.0, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, 1000);
      DAQmx
      // - WRITE PART - //      
      DAQmxWriteAnalogF64(taskHandle,1000,0,10.0,DAQmx_Val_GroupByChannel,data,NULL,NULL);
      //DAQmxWriteAnalogScalarF64(taskHandle, 0, 1, var, NULL);

//START DAQmxStartTask(taskHandle); //DAQmxStopTask(taskHandle); } }

 It works but with graphs not smooth at all and if I put var=1 it evolves with big noise to 1V and if I write it again it switches to 0V (it depends in fact, sometimes it stays for 2 or 3 times at 1V ...).

 

I don't understand why on Matlab using just something like (after createSession etc.) outputSinglescan(s, 1) gives me really nice results while in C++ I get noisy graph.

 

Probably I'm not using the right commands, so if someone could help me having the Matlab equivalent of outputSinglescan for C/C++ NIDAQmx,

 

Thanks,

 

Complementary informations; I work with a NI USB-6221 with an oscilloscope in BNC ao1.

 

Finding the correct device for CMOS control and LVDS Input

$
0
0

I am trying to help configure a test setup for an unconventional set of devices. I need to generate a total of 13 control signals (10-20ns minimum times)  at 0-3.3V (nominal) conditions (including a master clock) and gather data from between 1 and 10 LVDS outputs (which have available clocks to sync with) at 250ks/sec each. It doesnt look like the normal digital IO boards have LVDS capability, am I missing something? Any suggestions on how to configure such a control/DA system?

Button to log data in text file

$
0
0

I need a button to log data in text file. When button clicked then data will be written into the file. 

NI 9403 Input Impedance

$
0
0

Hello everybody,

 

I'm trying to use a 9403 as digital Input to test a device.

This device uses 46k4Ohm Pull-ups with 3,3V

I asumed the input impedance of the Input is very large.

 

Now i figured out, that this seems not to be the case.

Could anyone please tell me what the input impedance of this module is?

I searched all available documents of the 9403 but to no avail.

 

Thanks in advance!

 

Best regards

 

Balze


Help with taking and storing date from LMT01 LPG 2 pin temperature sensor.

$
0
0

Hey everyone,

 

I'm using a LMT01 temperature sensor, I need to count the number of pulses in 100ms in a pulse train, each pulse is 5us on and then 5us off (square wave) i need the total number in 100ms to post process into a temperature. I'm having issues with counting the pulses. 

 

But currently i am only picking up the start of each pulse train (the timer is at 5 seconds so i could work out if this was the case.). I am using the FPGA of the Myrio. 

 

Has anyone had experience with the LMT01 LPG -  Data sheet

 

Kindest Regards,

Aaron Page

create digital pulse on rising edge of analog output using USB-6211

$
0
0

Hello,

 

I'm working on a project that I am sending analog output, sawtooth pattern with 1024 samples @  7 usec steps. And I need to send digital pulse on each rising edge of that step (need to send 1024 pulses for each sawtooth pattern). I am using USB-6211 which maybe not a good choice but I'm stuck with this one. I'm trying to use counter output but I'm having a hard time syncing the pulse with rising edge of each step in the sawtooth pattern. Is there a way to sync the counter to rising edge of each sawtooth step?

 

Any suggesting is really appreciated. Thank you in advance.

 

6211_pulse_test.PNG

Digital pulse trigger I/O to LabView - simplest hardware available?

$
0
0

Hi all,

 

Not sure if this is in the right subforum, but I thought this is closest to digital I/O since it's mostly hardware related.

I have a piece of equipment in the lab that can send triggers, 5V pulses with adjustable width of 10-1000 ms, and also receive a similar trigger as input. I generally use 100 ms pulses. My challenge is to let my LV software communicate to this machine via these triggers. Simply put: my LV needs a start trigger from the machine, and it should return a trigger when finished.

Of course this was easily built using a USB-6008 or NI-9403 that we have in the lab. Unfortunately, these are not available off-site where this has to work, so I'm looking for a small and cheap piece of hardware to do this task. I figured I could do this with an FTDI TTL232R cable (with the FT232R chip) using bit banging, but that has gotten me quite the headache via LabView (and Python for that matter) by now. I'm sure there must be an easy, cheap way to do this. Interfacing via USB is fine, I also have RS232 and RS485 available if that helps.

Does anyone have a good suggestion for this? Thanks in advance!

GPS tracking

$
0
0

Hello everyone. Before I buy something that might not be useful to me, I have preferred to ask for help to you. I'm making an industrial accounting project. I need to locate the coordinates of a gecko area of size. That's what I have to understand who comes in and out of that area. Which microcontroller to program should I buy to do this?

Heat Exchanger Controller

$
0
0

I have a couple of Heat Exchangers that I'm trying to get to communicate with lab view and have been unsuccesfull so far. I have a working program that sends the correct voltage to the machine but I can't seem to get it to turn on and I'm running out of ideas as to why. I'm sure im using the right device pinouts and everything seems to be in working order. I'm measuring the correct voltages at the device plug but I can't start the heat exchanger in remote mode. I'm sending a 24V signal via power supply through a NI 9482 electromechanical relay to the Pump control pin. I have verified the voltage is getting to the machine correctly with a multimeter. Any ideas what im missing?

Viewing all 2184 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>