I have a NI DAQ usb 6009 device and hooked up a D-sub serial port (TxD line) in to one digital Input port.
What I want to do here is to read TxD and reconstruct the digital signal.
My problem is ..
[dev / port0 ]
I am getting one line binary signal (of course) and looks like this data array is not complete.
Meaning that if I change this signal to HEX, data doesn't have meaning at all.
Baud rate for the serial port is 9600.
I am not sure
1) if my sampling freq. isn't right.: it's like 10Hz fs.
2) is there anyway that I can receive data otherthan true, false but digital bit array?
Can anybody help?
Thanks in advance,
Solved! Go to Solution.
If you only look at the TxD channel of a serial communication you have no clue where a byte starts. Did you try shifting the resulting U32 by 0-7 bits and convert to HEX (or ASCII) then?
Also, reading a U32 gives you 4 bytes, but by converting to U8 you skip 3 of them.
Since I am not so familiar with labview yet, what I did was I generated a txt file and read in Matlab,
Yes, and then changed to 0-7 bit by manually reconstructing as a matrix and changed to ASCII.
That's what I did and could not fine the array I needed.
Do you think the signal I got is complete?
I still think txt file that's been generated is too short..
(*) Can you explain more detail about U32 -> U8 conversion????
You're right. You say the serial port is configured to 9600 baud. So your sampling rate should be 9600 Samples/s. But you might then have synchronization issues with the sender. In a serial protocol they are synchronized using other lines, if you only look at the TxD line this might be difficult.
And you also have to take into account the stop bits and other serial port configuration.
Why don't you just use a serial port to receive the data?
I am looking in cause this signal is GPS signal and I am trying to get time signal to synchronize with my acceleration data.
In your comment, can I ask what " Synchronization issue with the sender" means?
Is it possible to be fixed if I have other lines?
And I figured NI DAQ usb 6009 which I am using does not support the sampling rate as fast as to support 9600 data / s ..?
Thanks a lot,
Serial communication also has other lines, see e.g. here for RS-232: http://en.wikipedia.org/wiki/Serial_port, in particular RTS and CTS lines to synchronize.
If it's not RS-232 but other serial communication (SDI) there are other lines like CLK, LOAD (or CS) that the master sends and the slave uses to synchronize.
If you can't read data at 9600 baud you'll have to find a way to lower the baud rate or use another device to receive it. But I would be surprised if the 6009 can't handle 9600 Samples/s. This might not work in single sample measurements like you've shown, you'll have to read multiple samples at a time.
The 6009 will probably not acquire any faster than 1000 Sample/sec and it seems to be very unwise choice not to just read the data when connected to a serial port. There have been numerous examples posted on how to do this.
What do you mean by "just read data" when connected to a serial port ?
Meaning i can just read data from NI -DAQ? or read data by connecting serial port to a PC?