*just to add that the aim of the microcontroller function is to move the motor until the diference between the two LDR voltage values becomes zero every time.
Embedded Matlab function for Microcontroller modelling with PWM
4 次查看(过去 30 天)
显示 更早的评论
Hello!
I am modelling a solar tracking system in simulink, and i want to include an embedded matlab function with 'if' statements to represent a microcontroller. The inputs will be 2 values of voltage representing the LDR values, and within the matlab function i will compare the input values and create an output which will commmand a motor to rotate clockwise or counterclockwise. I have built the motor model in simulink, which will recieve an input voltage(coming from the microcontroller) and will output an angle of rotation. My question is what should be the output of the microcontroller? I think maybe the microcontroller could output a duty cycle of a PWM which will correspond to a voltage(maybe use a look up table) but i am not sure. I also want to include a PI controller but i am not sure were should be connected and what the error input should be. I want to model this operation as simple as possible because i am a beginner at electronics, and also the simulation time is very long,(10*3600s) so a complex system will make my simulation slow. Any response will be very helpful.
Thank you
8 个评论
采纳的回答
Mohsen Aleenejad
2020-7-30
Hi Eleni.T,
The correct answer to this question really depends on your final design. What paramters are being controlled and what topology is driving the motor? (Type of the motor and Drive. Parameters: Position/Speed of the motor. Control algorithm: Speed Control/Torque and Direction Control, Current Limiting Circuit). If a general answer helps, then assume that you wanna control a dc motor position:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/339511/image.jpeg)
If you wanna increase the model accuracy and get closer to the real problem then:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/339514/image.jpeg)
The real world problem needs a very accurate system with more complexity.
0 个评论
更多回答(0 个)
社区
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!