- It depends on the sample rate of the model to determine what upper band of frequency can be realized. Generally, to generate the 10 KHz frequency, the sample time should be less than 50 microseconds.
- There could be other latency due to the operating system being used. I would suggest playing with the model step rate, starting with the minimum frequency, and scaling up the value of frequency. Check the threshold at which things run out of order; that would be the defining point for the maximum frequency generation.
- Ensure that the baud rate used for communication between Simulink and the Arduino is high enough to support the data throughput required for real-time operation.
The square wave output frequency on Arduino digital pin is different than the set frequency on Simulink model
조회 수: 6 (최근 30일)
이전 댓글 표시
I am running a 4.4V 2A stepper motor with 1.8 deg step angle using Arduino Uno with Geckodrive G201X as the stepper motor controller. As a step input to the motor controller I am generating a square pulse of 10kHz on Simulink and sending the signal to the digital output block from the support package. When I run this model on external mode, I used a picoscope to check the waveform on the digital pin and I see the square waves are not consistent and the frequency is much lower than what is set. I am new to this interface and therefore would appreciate any help on this. I am not able to run the motor at different speeds by changing the square wave frequency to the step input to the motor controller. Why does this difference in frequency occur between Simulink and Arduino?
I have attached an image which shows the square wave observed from picosope on the digital pin which was set to output a 10khz sqaure wave to the motor controller.
댓글 수: 0
답변 (1개)
Saurav
2024년 2월 16일
편집: Saurav
2024년 2월 16일
Hey, Tariq Ali,
I understand that you are trying to control the speed of the stepper motor using an Arduino Uno in external mode using Simulink. You are facing issues with the actual frequency not being consistent with the set frequency and also not being able to vary the speed of the motor by varying the square pulse frequency.
I assume you are using the PWM block to vary the frequency. It is not possible to change the frequency via the PWM block; since the signal is generated from the PWM block, it is expected to be stable.
Changing frequency during run time requires significant overhead in re-programming the timer parameters, and the underlying infrastructure does not provide the support for this.
Please refer to the following workarounds for obtaining consistent frequency at the digital pin:
For more information, you can refer the following documentation:
I hope this helps!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Modeling에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!