07-24-2023 02:44 AM
Due to the special circumstances of the project, it is necessary to use the DO and DI of DAQ to output and receive digital signals and communicate with standard UART devices at a specified baud rate. The DAQ card I am currently using is PCI-6221. I am first short-circuiting P0 and P4 to confirm whether it can realize self-emission and self-reception of custom waveforms, but I have encountered some problems:
So I have some questions:
The waveform is like:
bit time is 4.34us (baudrate: 230400)
If anyone can answer, I would be very grateful.
07-24-2023 08:44 AM
You did not set the default values for the front panel controls. What is your sample clock source and sample rate?
NI 6221 only supports digital waveform at Port 0 with sample clock frequencies from 0 to 1 MHz only. The closest bit time you can get is 4 uSec.
The datasheet also states that The digital subsystem does not have its own dedicated internal timing engine. Therefore, a sample clock must be provided from another subsystem on the device or an external source.
07-24-2023 07:49 PM
Thank you for your reply.
I just tried selecting Ctr0Source as the sample clock on the front panel and it ran without errors. I will continue to make progress.
Previously, when I chose other sample clocks (PFI0, RTSI0, aiSampleClock, aoSampleClock), I still received the same error after running the VI. Are these clocks not usable for DODI?
07-24-2023 08:29 PM
@RIchardLee0 wrote:
Previously, when I chose other sample clocks (PFI0, RTSI0, aiSampleClock, aoSampleClock), I still received the same error after running the VI. Are these clocks not usable for DODI?
PFI0 and RTSI0 are just digital lines. You can connect external clocks to them.
For aiSampleClock and aoSampleClock, you need to create a dummy task to generate the clock.
If you specify those channels without supplying any clock signal, no samples will be acquired and you will be getting error -200284
07-24-2023 09:44 PM
It seems that Ctr0Source does not support high sample rates:
So, to use PFI0 and RTSI0, I can only connect an external clock. Currently, I only have one 6221 card, so my choice is to use the ai and ao clocks. I need to create a virtual task in the VI to use them.Is that right?
07-25-2023 10:19 AM
The sample rate is too high for the CPU to write enough data to the onboard FIFO.
Try to use the DMA transfer method instead. Configuring the Data Transfer Mechanism (Interrupts or DMA) in DAQmx and Traditional DAQ
07-25-2023 11:13 AM
You should create a clock using a counter task. I don't know why you didn't get errors when designating "/Dev1/Ctr0Source" as your DO sample clock source because that alone shouldn't have particularly helped.
To start, just open up a shipping example for continuous pulse generation. Generate continuous pulses with Ctr0 at a requested frequency of 230400 Hz, and choose a PFI pin as the output terminal for those pulses. Start the task then come back to this DO app.
Specify that same PFI pin as the sample clock source and try running your DO app under *those* conditions.
Notes: as mentioned by ZYOng, the pulse frequency you can actually achieve won't be exactly the baud rate you want. By requesting what you want, DAQmx will give you a neighboring frequency that's actually possible.
Also, I'm not up on the details of UART timing but I kinda wonder whether you might need to do some further tricks to make sure your data bits are valid at the instant the clock transitions. On the DAQ device, the clock edge causes the data bits to transition to their next state, so the data bits may not be stable and valid for some very brief period of time. You may need a scheme that accounts for that, but again, I don't know enough about UART details to say for sure.
-Kevin P
07-27-2023 03:58 AM
Yes, you are correct.
Currently, I use a counter clock as the DI's clock and an AI's clock as the DO's clock because the device requires different baud rates for input and output. This setup allows for transmission and reception.
I use 1Mhz for the input clock, and the input baud rate is 166666, which is 6us/bit, collecting 166666 samples.
I use 230400Hz for the output clock, and the output baud rate is 230400, which is 4us/bit.
At present, I want to convert the signals collected from the input into byte data, with 1 start bit, 7 data bits, and 1 stop bit, each bit should be 6us.
However, when I use the received waveform directly to transform it to Binary U8, the program treats 1us as 1 bit unit, a 6us 0 would be transformed into six 0, sometimes seven 0.
I wonder if there is any other function in LabVIEW that allows me to convert a digital waveform into binary numbers using a specified bit time (dt)?
I am attaching my program below, the data received begins at 0.0363 seconds.