Arduino simulink gets wrong timing with pulse generator
Hi, I’m facing a problem with the arduino package for simulink. I set up the model to fixed step discrete with a step size of 0.001 s. In the model I’m trying to do 2 things: blink an led each second(for 1 s the led is on and for 1 s is off); Print to the serial a number coming from a constant block of simulink. I tried setting the pulse generator pulse type time based, specifying the 2 seconds period with 50% pulse width, and also sample based, specifiyng the sample time of 0.001s (as the model) and imposing period of 2000 samples and pulse width of 1000 samples, to get the correct timing. Both ways i cannot get the led to blink with the correct timing, it seems like it is taking much longer, while i can see that the arduino is continuously printing the number on the serial, through the serial monitor of arduino ide after i deployed the code. Interestingly, if i delete the serial print block, the led blinks correctly, with both pulse types (time based and sample based). What am i not getting right? Thanks
I leave attached the simulink modelHi, I’m facing a problem with the arduino package for simulink. I set up the model to fixed step discrete with a step size of 0.001 s. In the model I’m trying to do 2 things: blink an led each second(for 1 s the led is on and for 1 s is off); Print to the serial a number coming from a constant block of simulink. I tried setting the pulse generator pulse type time based, specifying the 2 seconds period with 50% pulse width, and also sample based, specifiyng the sample time of 0.001s (as the model) and imposing period of 2000 samples and pulse width of 1000 samples, to get the correct timing. Both ways i cannot get the led to blink with the correct timing, it seems like it is taking much longer, while i can see that the arduino is continuously printing the number on the serial, through the serial monitor of arduino ide after i deployed the code. Interestingly, if i delete the serial print block, the led blinks correctly, with both pulse types (time based and sample based). What am i not getting right? Thanks
I leave attached the simulink model Hi, I’m facing a problem with the arduino package for simulink. I set up the model to fixed step discrete with a step size of 0.001 s. In the model I’m trying to do 2 things: blink an led each second(for 1 s the led is on and for 1 s is off); Print to the serial a number coming from a constant block of simulink. I tried setting the pulse generator pulse type time based, specifying the 2 seconds period with 50% pulse width, and also sample based, specifiyng the sample time of 0.001s (as the model) and imposing period of 2000 samples and pulse width of 1000 samples, to get the correct timing. Both ways i cannot get the led to blink with the correct timing, it seems like it is taking much longer, while i can see that the arduino is continuously printing the number on the serial, through the serial monitor of arduino ide after i deployed the code. Interestingly, if i delete the serial print block, the led blinks correctly, with both pulse types (time based and sample based). What am i not getting right? Thanks
I leave attached the simulink model arduino, simulink, time MATLAB Answers — New Questions