MATLAB Answers

What is the idea behind data processing for SCI communication in DC/DC Buck Converter Example?

33 ビュー (過去 30 日間)
Karol Kyslan
Karol Kyslan 2018 年 9 月 17 日
Answered: Karol Kyslan 2018 年 12 月 9 日
Dear Antonin, firstly thank you a lot for your model Digital DC/DC Buck Converter Voltage Mode Control (VMC) https://goo.gl/VkdvuD I learnt myself a lot from that model. But there is still one more thing I don't understand. In your model, for target f28377S_DCDC_Buck.slx in subsystem "PI_controller_ISR there is a subsystem Serial Send. Inside that subsystem, I was able to understand everything except: merge blocks and following While Iterator Subsystem. Could you please provide me with the idea, what is happening inside of these blocks? What is the idea in general? You did some data processing, but I don't really understand why. From your video regarding this model, I understand that Simulink is good at handling of big data blocks at low sampling time, whereas target processor is good at handling of small data blocks at high sampling time. But I don't know how to do that. Thanks in advance for your answer. Karol

  0 件のコメント

サインイン to comment.

採用された回答

Antonin
Antonin 2018 年 9 月 17 日
Hi Karol,
Here is what is happening in the Serial Send subsystem:
  • The goal is to send data to the host at a fast rate and insert delimiters around a large sequence so the host reads a large chunk of data at a slow rate instead of small pieces of data at a fast rate.
  • On the host side, it's impossible for Simulink to read 2 Uint16 data points at 200kHz, but Simulink can easily read 12,000 x 2 Uint16 data points every 60ms (~17Hz). The turnaround time makes it easy for Simulink in the second case, though it's the same amount of data.
  • On the target model (DCDC_Buck.slx), the purpose of the Serial_Send subsystem is to send data at a fast rate (2 Uint16 data points at 200kHz) and insert delimiters every 12,000 hits.
  • To do so, I use a counter that counts from 0 to 11,999. When the counter equals 0, I insert the end of the previous sequence ('EE') and the beginning of the next sequence ('SS'). 'EE' (0x4545 in ASCII) and 'SS' (0x5353 in ASCII) are arbitrary delimiters. Just make sure they match what you use on the host, you can use whatever you want, I picked S for Start and E for End, and I used 2 characters for each to match the Uint16 format of the delimiters.
  • When the counter equals 0 I need to send 4 Uint16 data points. The 2 delimiters + the 2 signal data points.
  • When the counter is different than 0, I need to send only the 2 signal data points.
  • The counter feeds an "if" condition for the 2 above cases. The merge blocks are used to combine the outputs of the 2 conditions into one. The merge block will pick the output of the subsystem that is active at that time step.
  • I can only use one Serial send block, and in the start case I need to send 4 Uint16 data points while I need to send 2 in the other cases. To do that I use a "While Iterator Subsystem". It's the equivalent of a "while" loop in C. I will loop 4 times in the Start case to send 4 Uint16 data points and twice in other cases to send signal data.
  • The Serial_Send subsystem is scalable to different widths. Pay attention to the baudrate if changing the width of the signal. Serial communication usually sends 10 bits per data byte (1 start bit and 1 stop bit + 8 bits of data). At 200kHz, 2 uint16 data points mean 2x2x10x200000 = 8Mbps needed, neglecting the delimiters. The baudrate on the target is set to 12.5Mbps which should accommodate for 8Mbps. Increasing to 3 uint16 signals should still work as it will push the baudrate to a little more than 12Mbps, but that is very close to the limit. 4 signals will be too many and will not work at it would require 16+Mbps.
I hope it helps,
Antonin

  3 件のコメント

Karol Kyslan
Karol Kyslan 2018 年 9 月 17 日
Hi Antonin, thank you for very useful information. I need to go through it myself again, so it will take a time. In the meantime, how do you know this?
"Simulink can easily read 12,000 x 2 Uint16 data points every 60ms (~17Hz). (I would like to show to my students only this "slower" communication possibility - before that fast one)."
That (~17Hz) performance of Simulink is given by what? Is there any evidence of that in the literature? What does it depend on? Karol
Antonin
Antonin 2018 年 9 月 17 日
In this particular host Simulink model, we need to read serial data which is coming from the OS (MS Windows). Making the request to read from the COM port takes time. It's much better to ask for a large buffer at a slower pace compared to asking for small pieces very often.
It's hard to be able to give accurate timings as it depends on your computer's performance as well as how busy the OS is at that time. Overall, while using serial blocks on the host it's best to keep the turnaround time above 30ms. Simulink can go much faster if there is no host serial block in the simulation.
I hope it helps,
Thanks,
Antonin.
Karol Kyslan
Karol Kyslan 2018 年 9 月 17 日
Definitively helped. Now I understand limitations of Host PC that I will be able to overcame by using of buffering (and/or) that fast algorithm you have provided.
I have one more question anyway.
By using Host PC and and HOST blocks (SCI receive, SCI Transmit, SCI Setup) in NORMAL mode, I am able to configure it and reach the communication limits when it comes to baud rate and number of received variables. Everything works as expected. Though slowly, but enough. But I don't understand the behavior of Scope block.
What I want to do is to display data coming from SCI receive. In target (f28069) I created sinusoidal waveform (sine wave, sample based, 10 Hz) changing its output every 0.001s. I am sending it to Host PC every 0.001s, where I receive it with SCI receive at 0.1s. To display it, I want to use Scope block (with default setting). Here comes the question: If I set Simulation stop time to "inf", what does it precisely mean the time displayed at the bottom of Simulink window (T= xxx). This time is faster than real time but what does it represents and how it is connected to the algorithm running in my target?

サインイン to comment.

More Answers (1)

Karol Kyslan
Karol Kyslan 2018 年 12 月 9 日
Dear Antonin.
it took me a time, but I have implemented it and it works like a charm! I modified it to slower sampling rate (~10 kHz), but the principle remained the same. I find very useful is that by using this principle, there is no need to use external mode and you have a total control to each algorithm step. Many thanks for support!
Karol

  0 件のコメント

サインイン to comment.

サインイン してこの質問に回答します。


Translated by