04-21-2010 04:53 AM
Hi,
I need to measure on a digital port in exactly the same time steps (delta t).
I thought of using a timed loop in order to measure. In order to keep the time step variable, I used as timing source a digital clock (ctr0).
Attached you can find the vi screen. It is not working, why this?
Thanks
04-26-2010 08:20 AM
Hi,
What exactly is the purpouse of your application? Could you be a bit more specific please.
What hardware are you using?
What OS and what version of LV?
Thanks,
Christian
04-27-2010 05:48 AM
Hi Christian,
see my other thread: http://forums.ni.com/ni/board/message?board.id=250&thread.id=56999
for more information about my applicaton.
Thanks
Stefan
04-27-2010 07:20 AM
Hi Stefan,
We will continue with the discussion here. Please don't duplicate threads or post questions in more then one thread.
Still your other thread doesn't really explain what you want to do, neither which hardware you are using.
Please describe what is your hardware and in some words what the task should be? ...and my questions from before.
Thanks,
Christian
04-28-2010 12:21 AM
Hi Christian,
Hardware: NI DAQ USB-6259 with 1,2 MSamples/sec
Software: LabView 8.5.1 on Windows XP
I need to use the USB DAQ as a measurement device and as a control device. Which means I need to output certain voltage levels on the 4 AO which can control a µC (works fine). For measurement I need to measure on 24 digital channels a PWM signal. The PWM can be different on every single channel from 10Hz up to xMHz (the limit of the USB DAQ). It should be possible to display all duty cycles and time periods simultanously for every channel on the LabView GUI, let's say every second or on a click on a refresh button.
I tried to use the predefined DAQ task, PWM measurment which gives me the duty cycle and time period for the measured channel, this works fine with limits. Unfortunatly it is only possible to measure one/two channels at a time because of the two ocunter inputs. And if one signal has a very low frequency the measurement would take very long to acquire full time period and duty cycle. So this is not the solution as I would loose information from all the other channels.
Now I was thinking of a different way. I have a timed loop, in it a DAQ task to read a single sample from port 0 (32 channels) on every loop round. The loop cycle must be adjustable in the GUI. And maybe it is possible that after measurement it writes the values in an array. In my main while loop (similar to the producer/consumer example from NI) I want to call every 1 second or on clicking the "refresh button" a small sub VI which calculates out of the array for every channel the duty cycle and time period. After the calculation it should display the values on the GUI and go back to the main while loop, and so on...
I think the calculation is no problem, but I am stuck with the timings and building the right loops to handle the events. i know this method won't be accurate, but I can watch all channels and wouldn't loose too much information.
Do you have any suggestions?
Thanks
Stefan
04-28-2010 08:04 AM
Hi Stefan,
Since your hardware has only two counters it's not possible to do PWM Measurements for more then two channels.
Also your other solutions are not applicable because everything is just done in software and since Windows is not a RTOS you will definitely get wrong measurements.
You will need to choose another hardware for your task. I would recommend an FPGA based card like the 7831R or 7833R.
Christian
04-28-2010 08:10 AM
It doesn't sound like using a software-based timed loop will be enough for you. Since you're going to interpret duty cycle based on sampling your digital bits, you need to observe Nyquist and have a sample rate at least 2x as high as the highest PWM freq you anticipate. If you need to approach the MHz realm, the USB bus may become a bottleneck.
You may be better off capturing port0 using change-detection sampling that's sensitve to both rising and falling edges of all bits. Then also setup a buffered counter task that counts an internal 20 MHz timebase and uses the "Change Detect Event" as its sample clock. (The net effect is to capture timestamps of every bit transition on port 0.) There are two main problems with this approach. One is that your software has to do more work to interpret the data as PWM duty cycles. The other is that sooner or later, you're liable to get 2 or more transitions that occur almost but not quite simultaneously. Based on other threads I've been in, this could lead to a situation where the digital task buffers up 2 samples while producing only 1 "Change Detect Event" for the counter task. And if they get out of sync, there's really no way to go back after the fact and figure out when.
-Kevin P
04-30-2010 01:27 AM
Hi Kevin,
thank you for your suggestion.
Ok I have no problem to create a task using "change detection" to read port0 and if I get your point I need to start another task which gives me for every detected change on port0 a proper time to interpret my duty cycle and time period.
But I am failing to start the second task. Is there any example on how to setup this two tasks?
@Christian: I have the 7831R FPGA card too, but I have specific requirments for my current application. So i have to use the USB DAQ and get the best measurement results that are possible with it.
Thanks
05-03-2010 01:20 AM
Hi Kevin,
I tried to setup the two tasks, one for reading port0 on change detection and the second one for counting the time, to assume the correct time between two detected changes.
See my vi and screenshot attached. What did I miss here, because it is not working?
Thanks
Stefan
05-03-2010 01:38 AM
sorry I attached the old vi, please find here the corret one: