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
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.
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
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.
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!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 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)
