Hello Lubin,
I have a question about TxMatlab
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 TxMatlab
about TxMatlab
 Attachments

 MC710_ID2.mdl
 Send the QEI Position every 0.002s
 (37.43 KiB) Downloaded 280 times

 Site Admin  Expert
 Posts: 616
 Joined: Wed Mar 07, 2007 11:23 pm
 Location: Marseille  France
 Contact:
Re: about TxMatlab
Hi Magic,
Thanks for this interresting question.
I tried to complete the doc of theInterface_TxMatlab 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_TxMatlab 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 TxLabviewMatlab 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.
I am not very happy of this explanation, but I hope anyway to make it clear enough !
Let me know...
Lubin
Re: about TxMatlab
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: Marseille  France
 Contact:
Re: about TxMatlab
Hi Magic,
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.
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
Magic wrote:after computer received the data,the time interval would be about the sampling time(0.002s)
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.
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
Lubin
Return to “General Remark and Questions”
Who is online
Users browsing this forum: No registered users and 1 guest