11-09-2007 03:51 PM
11-12-2007 04:07 AM
11-12-2007 08:26 AM - edited 11-12-2007 08:27 AM
Hi Guys-
Please keep in mind that this is only an example; you will have to modify it to match the requirements of your application.
ILLGG-
In order to modify the behavior of the "clock" line you may need to add another millisecond wait function after the second update to the clock task within the loop. The timing from one iteration to the next could vary because everything is done with software timing- the mS wait function is not precise because it relies on the Windows system timer. If you need more precise timing then you will have to use a device that supports hardware-timed digital operations or a device that is meant specifically for SPI communications (for example, the NI 8451)
Techiess-
It's not possible to answer your question without knowing what type of protocol your microcontroller uses for communication. Nevertheless, the example linked in this thread shows how to create software-timed clock pulses and how to shift data out via the 650x digital lines. It should hopefully be enough to get you started with your app. Please take a look and see if you can make modifications according to the requirements of your microcontroller.
Thanks-
11-13-2007 01:33 PM
03-13-2008 09:50 AM
Hi Tom,
I have a question that how can i write a C that can have a same functionality as this VI.
thanks,
tnk
03-13-2008 12:29 PM - edited 03-13-2008 12:31 PM
Hi tnk-
I never had a chance to code up my example in C, but it should be easy enough to do by looking at the LabVIEW VI. Here's the LabVIEW code:
The error cluster (green line) shows the proper order of execution. The subVIs that say Digital Output or Digital Input are DAQmx Create Virtual Channel calls. The subVIs with pencils and eyeglasses are DAQmx Write and DAQmx Read, respectively. The subVIs with yellow triangles and pencil erasers are DAQmx Start Task and DAQmx Clear Task, respectively.
The large square in the middle of the code is a For loop, and the inputs and outputs are indexed through a point at a time by the tunnels (squares on edges of For loop) that have an empty square in the middle. The tunnels with solid squares represent constants that do not change from one loop iteration to the next.
You should be able to use this image and the existing DAQmx examples for static digital input and output ( C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Digital ) to come up with something similar.
Hopefully this helps-
03-18-2008 08:41 AM
03-18-2008 10:58 AM - edited 03-18-2008 10:58 AM
Hi tknp-
Assuming you're using an NI 6508 device, you will not be able to perform a hardware-timed (clocked) generation. You can perform a continuous software-timed generation by simply playing a loop around the DAQmxWrite function. It is not necessary to call DAQmxStartTask and DAQmxStopTask inside the loop, and actually doing so would hurt the performance of your application. I don't have a C-based example, but it should be fairly simple and would look something like this pseudo-code:
DAQmxCreateTask
DAQmxCreateVirtualChannel
DAQmxStartTask
while(!err)
{
err = DAQmxWriteDigitalLines
}
DAQmxStopTask
DAQmxClearTask
03-18-2008 04:59 PM
03-18-2008 05:20 PM - edited 03-18-2008 05:20 PM