How to perform handshaking operation

Hello, my project is to transmit data to the analog output pin of MCC USB 205 DAQ. From the DAQ the data goes to ADI Board for further process. To increase the speed of data transmission I am using a C mex file to transmit data. Now I want to implement handshaking operation to transmit the data. I have 3 data's to transmit (a,b,c) based on the rising edge and falling edge of clock. I am totally new to this, can anybody give suggestions like how to do it, where to start with, or any example code or documents.

 Accepted Answer

Unless the clock rate is very slow, there is no realistic way to monitor the clock edge at the MATLAB level in order to determine when to transmit the signal.
This is the sort of task that you use an external device to handle the timing and signal transmission. Some daq boards can handle it: you command them with trigger information and appropriate response and let them run independently.

9 Comments

Hello Walter, Thanks a lot for your quick response. Can you please ellaborate on your point because I am totally new to this. Should I use external digital trigger or external pacer I/O for this purpose?. I didnt find any information In the USB 205 data sheet whether it supports Digital clocked operation. So I am really confused. I have attached the data sheet of USB 205.
The trigger for that device controls starting input measurements, and does not control transmission of data. 32 samples would be collected before anything was transmitted towards the computer; the lowest latency would be if you programmed all 8 channels of input, in which case you can get down to 8/500000 seconds delay in hardware if I put things together properly. About 2 ns?? However it is going to take a fair bit longer to get the attention of MATLAB and have it process a call back. I do not know how short you could make that time. I would think that it would be tough to get the timing accurate enough to be transmitting the third signal in synchronization with the trailing edge of the pulse.
I do not think that this is the right hardware for your needs.
I would tend to suspect that for you it might be easiest to put together a small FPGA to handle the timing.
A R
A R on 27 Feb 2020
Edited: A R on 27 Feb 2020
Walter, everytime I shoot a question, you be the one to reply first. Thanks a lot. I will check about using FPGA. But from your reply I understood that this device is not the right one for sending all the data using clock. But can I perform handshaking using digital output pin? If yes can you please send the documentation or reference to any page that would help me get start with handshaking using mex.
I think I might have been off by a factor of 40 earlier, 32/500000, so about 64 nanoseconds.
The data that you have to transmit: are they individual bits? Are they voltage levels? Is it one of those protocols where you see an incoming pulse and you set a level on a line to signal you are ready, and they send you something and you acknowledge by changing levels... something like that, where the "data" is not information as such but rather just a sequence of level changes because that is what the far end needs to send data?
You talked earlier about rising edge and trailing edge, which tends to imply a single incoming pulse rather than a waveform train? But if so then what is the remote end getting out of it? Is it like an incoming strobe that you are responding to?
I do not know enough about the situation to know if the digital output pin would help. Based on what you described earlier, it seems doubtful. The problems I outlined earlier are not problems based upon whether the output signal is analog or digital: the problems I outlined earlier are problems with latency and response time. Having something at the MATLAB level run a pulse sequence phase by phase is just not realistic except for fairly low frequency. For example you can toggle DTR on a serial port, but reliability would go down quickly beyoned about 2 Hz.
Hello Walter, I need to transmit 1x256 double data (it corresponds to image pixels) to analog output pin 0 and B and C value (each 8 bit binary) to analog output pin 1 of USB 205. I wrote a mex file to transmit the data to USB 205. Now I have to implement handshaking with the microcontroller. I came across few examples like generating a strobe pulse in Matlab.
ULStat = cbDOut(boardNum, lowPort, ((int)doubleData[i]) % 256);
ULStat = cbDOut(boardNum, highPort, ((int)doubleData[i]) / 256);
waitMS(waitTimeMS,frequency);
ULStat = cbDOut(boardNum, strobePort,1);
waitMS(waitTimeMS,frequency);
ULStat = cbDOut(boardNum, strobePort,0);
waitMS(waitTimeMS,frequency);
The other example is
dio = digitalio('nidaq', 'Dev1');
addline(dio, 0:7, 0, 'Out');%8 lines on port 0
addline(dio, 0, 1, 'Out');%strobe on port 1
sendthisvalue=23;
binvec = [dec2binvec(sendthisvalue,8), 0];%the 8bit word plus the strobe bit first set to 0
putvalue(dio,binvec);
binvec(9) = 1;%set strobe bit to 1
putvalue(dio,binvec);
But I dont know what the above 2 examples actually do. Can you please explain about using a stobe pulse for handshaking.
Strobe pulses can vary a lot as to how they are used. It looks to me as if this particular code is working like:
Send a 0 on port 1 to signal to the remote end to start reading the values on port 0. When you send the 1 on port 1, then the remote end should "finalize" the reading.
But it is also possible that the real work is the edge transition between 0 and 1 on port 0, and that the purpose of setting port 1 to 0 is not to signal anything in itself, but rather just to ensure that it is in the proper state to be able to drive an edge transition afterwards.
This is all speculation; this is the kind of reason you need a logic diagram to work from.
There are no overall standards on how to use strobes or why. There are standards within particular protocols such as parallel port.
I need to transmit 1x256 double data (it corresponds to image pixels) to analog output pin 0
You need to transmit the bit sequence corresponding to the IEEE 754 Double Precision representation of each pixel?? If so, in what bit order?
Or for each pixel, you need to transmit a single voltage that corresponds to (say) pixel-value/(2^16) or pixel-value/256 of full voltage, and it is acceptable if the remote end does not exactly reconstruct the same voltage?
Or... ??
Walter, I have planned to do handshaking with the strobe pulse. Thanks a lot for explaining about it.

Sign in to comment.

More Answers (0)

Categories

Find more on Motor Control Blockset in Help Center and File Exchange

Asked:

A R
on 27 Feb 2020

Commented:

A R
on 2 Mar 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!