Interfacing w/ Software on the Computer
(Read 25169 times)
Nov 13, 2013, 11:00 am
I wish to implement sine pulse width modulation (compare a sine function with a triangular function and give a high pulse when the sine is above triangular wave).
I am implementing it with Simulink 2013 and Arduino Uno .I wish to obtain the output of SPWM on the digital pin of Arduino Uno. I have attached the Simulink model for reference.
The sine wave is at 50 Hz while the triangular carrier is at 2000 Hz. Although the output that I observe on the DSO from arduino has proper shape, yet its frequency is not 2000 Hz. The frequency keeps on varying arbitrarily.
Please let me know what modifications would result in proper output.
downloaded 174 times
Nov 13, 2013, 02:11 pm
post Arduino code
Nov 13, 2013, 05:05 pm
When we make model in simulink and burn it on arduino uno it automatically generates the code and burn it on the board. I don't think the code can be viewed .
Nov 14, 2013, 12:10 am
At 2KHz, the board needs to attend output pin every 0.5 ms, so to get stable output frequency, must make certain that the board is not involved in some time consuming routine like serial comm or continuous analogue reading at the instant when it must change output state
Nov 14, 2013, 06:39 am
As the code is automatically build by simulink .. Then in any way i retrive the code so check if the program is long enough that takes longer than .5ms to loop again ? More over niether i have any serial comm... nor any analog i/p for causing delay ..