Can we use pulse generator as input to Embedded Matlab Function
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
Hi Every one, I am trying build a stateflow chart in simulink. This stateflow has a code written in VHDL. As I am new to stateflow I am trying to convert the code in VHDL to Matlab code and use it in Matlab Embedded Function. The stateflow chart has inputs from a pulse generator. My question is can a Matlab Embedded function block have inputs from a pulse generator. If we can't can you suggest me any other options. Appreciate your time and help.
採用された回答
Arnaud Miege
2011 年 4 月 19 日
Yes, as far as I know, it's just a standard Simulink input. Just make sure the chart is updated with a fast enough sample time to capture the PWM switching.
HTH,
Arnaud
7 件のコメント
vishnu p
2011 年 4 月 20 日
Thank you Mr. Arnaud. Is it ok if I send you my state flow chart to verify if I am going in the correct approach.
Yes, or even better, upload it to a filesharing site so that it's available to other members of the community.
vishnu p
2011 年 4 月 20 日
Hi Mr. Arnaud. I uploaded it in mega upload. The download link is
http://www.megaupload.com/?d=5I5DYSR7. Can you please verify it and tell me if I am doing the right approach or should I take a different one. I am also confused how to use the delay in the state flow. Appreciate your time and suggestions.
Well, your state chart is such a mess that it's unreadable... I had to recreate it based on the word document you supplied. You can see a snapshot at:
https://picasaweb.google.com/lh/photo/zMvjoLinf3b8xGCz20EM2g?feat=directlink
I'd make the following suggestions:
- Use entry rather than exit to set the outputs
- Use ; rather than ,
I don't know VHDL but you can use the after construct for delays:
http://www.mathworks.com/help/releases/R2011a/toolbox/stateflow/ug/f0-34084.html
vishnu p
2011 年 4 月 21 日
Thank you very much Mr. Arnaud. I will build a new state chart as per your suggestions and see if it works with my circuit. I will let you know about the result.
vishnu p
2011 年 4 月 21 日
Hi Mr. Arnaud,
I have completed the new state chart with the necessary modifications. The only question for me is how to use the timeout. If 'timeout=1', the inputs should not leave state0. If you have any suggestions please let me know. I have uploaded the state chart in mega upload. The download link is http://www.megaupload.com/?d=D3HL4F7Z . Please have a look at my state chart. Thank you very much for your help and guiding me through the right path.
First, a comment: to make your chart more readable, I would use connective junctions so that you have a single path back to state0, see:
https://picasaweb.google.com/lh/photo/tUh3kDm_07OlIuX5EpYzLQ?feat=directlink
Second, with regards to your question about timeout. You have defined timeout, high and low as rising edge events, so the transition from state0 back onto itself will only happen when the input signal changes from 0 to 1. It it stays at 1, the transition will not occur. For what you want, I would define high, low and timeout as boolean (data) inputs from Simulink, not events. This means that they need to be enclosed in square brackets when annotating the transition, to create a valid condition (see snapshot above).
Third, you need to test your state chart to ensure it does what it's supposed to do. The only way to do that is to run the model with different inputs. You can use the Signal Builder block for that (from Simulink/Sources) or if you want more interactivity, you two constant blocks (1 and 0) and a manual switch, as I have done here (make sure to set the outputs of the constant blocks to boolean, otherwise you'll get an error):
https://picasaweb.google.com/lh/photo/y_mPmlwUcYmdiyou8Ew74Q?feat=directlink
When I did this, I found there was a design error in your chart. If timeout == 1 and high == 1, or timeout == 1 and low == 1 or all three inputs == 1, there are three valid transitions out of state0. Stateflow doesn't know which one to take. I have added an additional conditions to the two transitions to state01 ([high && !timeout]) and state02 ([low && !timeout]). I think this achieves what you want, i.e. stay in state0 while timeout == 1.
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Stateflow についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
