Hello Lubin,
I have a question about Tx-Matlab
My baud rate is 115200 and max 23 Bytes/0.002s
I send 3 Datas every 0.002s.
But I found the time interval is about 0.01s or 0.02s(sometime 0.03s) in t_R & t_Rn in workspace.
Is the UART wrong? or some configuration I do not set?
Magic
about Tx-Matlab
about Tx-Matlab
- Attachments
-
- MC710_ID2.mdl
- Send the QEI Position every 0.002s
- (37.43 KiB) Downloaded 918 times
-
- Site Admin - Expert
- Posts: 616
- Joined: Wed Mar 07, 2007 11:23 pm
- Location: Bayonne- France
- Contact:
Re: about Tx-Matlab
Hi Magic,
Thanks for this interresting question.
I tried to complete the doc of theInterface_Tx-Matlab page. I added that :
I am not very happy of this explanation, but I hope anyway to make it clear enough !
Let me know...
Lubin
Thanks for this interresting question.
I tried to complete the doc of theInterface_Tx-Matlab page. I added that :
Code: Select all
T_R is an approximation of time only, and shoudl be used for vewing purpose only. If you need precise data time stapm, follow the following procedure :
* On the simulink model, make sure to not overload the UART. Check that you are sending less data than max allowed by the UART bauds. To count the number of bytes used, when using the Tx-Labview-Matlab block, add one byte for each data sent. For example sending one uint8 data takes 2 bytes, uint16 data takes 3 bytes and uint32 data takes 5 bytes.
* Reconstruct a vector timing corresponding to the simulink's UART timing.
T_R (and T_Rn) approximate the time using the computer clock. Each time Matlab read an UART sequence, time is read. Then, the first byte of the sequence is assigned to the time of the previous clock read, and the last byte of the sequence is assigned with current time. Any bytes in between is assigned to a time using a linear approximation (with time of sequenc start and time of sequence stop). Thus, the time received of the first trame may be much longer if no data is send at the beginning of the logging process.
Let me know...
Lubin
Re: about Tx-Matlab
Hello Lubin,
Thank you for this explanation. I understand now!
Thus,after computer received the data,the time interval would be about the sampling time(0.002s).
Thanks again.
Magic
Thank you for this explanation. I understand now!
Thus,after computer received the data,the time interval would be about the sampling time(0.002s).
Thanks again.
Magic
-
- Site Admin - Expert
- Posts: 616
- Joined: Wed Mar 07, 2007 11:23 pm
- Location: Bayonne- France
- Contact:
Re: about Tx-Matlab
Hi Magic,
If you do not overload the UART (It seems not to be overloaded here) the sampling time of the three data is exactly 0.002s !
for example :
Lubin
That true, but you should really recompute a time vector of exactly 0.002s as the dsPIC quartz is much better than the bad approximation that is done with the RS232GUI.Magic wrote:after computer received the data,the time interval would be about the sampling time(0.002s)
If you do not overload the UART (It seems not to be overloaded here) the sampling time of the three data is exactly 0.002s !
for example :
Code: Select all
R = padr(R,1);
t_Rreconstructed = 0:.002:((length(R)-1)*.002);
%% if you want to generate a file to feed a simulink model :
SimIn = [0:.002:(length(R)-1)*.002 ; R'];
save SimIn SimIn
Who is online
Users browsing this forum: No registered users and 27 guests