Very Helpful. I plan to use this technique for an integrator in an earlier version of Simulink which does not provide the reset input on the integrator.
@abhishekm19035 жыл бұрын
Very Nice Tutorial
@garypstrike4 жыл бұрын
Just a note: I noticed that in your example the counter can be made to reset at each 5 second interval (instead of 6) by setting the threshold value to 4 instead of 5. Also seems to be a cleaner waveform.
@angelleal30053 жыл бұрын
Great video. Here is how my application works. I'm using an optical sensor to measure the revolutions on a disk. For that I put a pin on the disk so that every rotation it makes is counted as 1 pass on the optical sensor. I want to implement a counter on simulink that starts counting up once the pin passes through my optical sensor and resets itself on the next pass so that it starts counting back again. I managed to convert the analog signal coming from the sensor to a series of pulses so that its value is either one or zero. Now I'm on the counter part but still trying to figure it out. As I said earlier the idea is that for the first value of 1, the counter begins the counting and then on the next value of 1 it resets back to zero and starts counting again. If you have some idea on how to implement this please let me know. Again, great video. Keep up the good work.
@waleedalsamti5 жыл бұрын
Thank you for very good explanation
@johnwayne79233 жыл бұрын
Thank you kind sir
@Opuskiller15 жыл бұрын
This is so helpful!!
@gauravpatil16303 жыл бұрын
Hi, I have 0 or 1 trigger as a input.. so let's say 1 is shows up for 50 secs and I want to limit it to 10sec. The first step is limit the sum of 1 showing time to 10 sec but the other part is I want to limit it for next 300 sec so that the counter should not start counting and once 300sec over it starts again then 10sec cut the counter hold it for 300 sec and so on. Can you help?
@ajayjoseph46266 жыл бұрын
Great video sir! I have a Simulink model where I have PWM values starting off at around ~160. I want to create a counter to count up to the ~160 approx and then disable the counter and PWM values should take over. From this video, I want to replace the 5 with the varying PWM, so the counter will count up to the PWM value and the counter should disable. Any suggestions will be much appreciated.
@ProgrammerWorld6 жыл бұрын
Hi Ajay, There can be various approach for this. The one I can quickly think of is to use the Enable subsystem block. Have the output of the counter in a switch block (controller input , u). Set the threshold of your switch to ~160. Once this threshold is crossed then switch will turn on one side. You can give Boolean input true or constant input 1 to that port of switch. Connect this switch block output to the enable subsystem condition signal. Thus the enable subsystem will get enabled only once the counter crosses 160. If needed, you can reset the counter value at 160 again to 0 as shown in the video. Hope this information helps.
@ajayjoseph46266 жыл бұрын
@@ProgrammerWorld Thanks for your reply. I ended up hard coding it on the microcontroller. Thank you very much for your suggestion and it's a great tutorial. Much appreciated!
@rebeccabertazzoni44844 жыл бұрын
Hello :) Thanks for the video, it is very helpful. I have one question about it. If I use your example, is it possible to count the time it takes for the counter to rise from 0 to 5? In my case, the time for each step is not 1 second, it varies, but my threshold is always the same. So, everytime when my counter reaches the threshold to switch back to zero, I would like to know how much time it took. Thank you!
@ProgrammerWorld4 жыл бұрын
If your question pertains to real clock time for simulation while counter is counting, then I do not think it can be directly done in the Simulink. You can use certain performance measurement techniques in Matlab (like tic-toc command) to measure the real world clock time it takes to simulate the counter for 5 simulation seconds. However, if you want to measure the simulation time in your model then you can simply use a clock block for the same. Good Luck Programmer World programmerworld.co -
@sangaythinley68023 жыл бұрын
Thank you for the informative video. Actually I have some questions regarding counter time, can this counter time can be feed to stepper motor as this counter time shows the steps as per the time . I will be very happy to have your mail so that I can ask you some questions in personal. Thank you once again
@ProgrammerWorld3 жыл бұрын
For counter time to be fed in the stepper motor, one can easily use the clock block instead. However, yes, this counter can also be used. For contacting us, please reach out to us through our below page: programmerworld.co/contact/ For reference, the complete details of this tutorial is shared in the below link also: programmerworld.co/simulink/design-a-simple-counter-and-reset-counter-in-simulink/ Cheers Programmer World programmerworld.co -
@natarajana.v42623 жыл бұрын
thankyou.
@simaroaerial7237 Жыл бұрын
You shouldn't need to change the solver parameter. Just set the sample time to one second in the delay block and set -1 as initial condition to start it at zero.
@ProgrammerWorld Жыл бұрын
Yes, you are right. Setting the sample time to 1 second in the delay block is a much better solution to set the counter step size equal to simulation time. For reference, details shown in this video is also shared in the below link: programmerworld.co/simulink/design-a-simple-counter-and-reset-counter-in-simulink/ Cheers Programmer World programmerworld.co -
@rajashriwarade17865 жыл бұрын
Sir...if I want the counter only for 2 cycles then what will be the design
@ProgrammerWorld5 жыл бұрын
1st use case: After every 2 cycles you want to reset the counter and begin counting again from 0. This case is explained in the later part of this video (after 6:30 mins) where it is shown how to design reset counter. 2nd use case: The other use case could be that you only want to count for 2 steps irrespective of simulation time of Simulink. In that case you have to use the reset part of the model with Threshold value of switch block being compared with a clock block's output. You can compare that when the clock gives output of more than 2 (2 seconds of simulation time) then your switch block's True condition gives a fixed output of 0. And hence the counter's output will be set to 0 after 2 cycle time. I hope the above explanation helps to design your requirement.
@rajashriwarade17865 жыл бұрын
If We dont want continuous output...if we want it only for two cycles then??
@ProgrammerWorld5 жыл бұрын
Then put a clock block and rest of the implementation in an enable subsystem. Once clock reaches your required threshold of 2 cycles, just disable the complete subsystem.
@sandraprasad39310 ай бұрын
Can you please make a model of timer which is on for 10 sec and off for 5 sec
@ProgrammerWorld10 ай бұрын
Thanks for the suggestion. I will try to come up with such a demo. However, in the meantime you can check my below page. It may help. programmerworld.co/simulink/how-to-create-random-pwm-pulse-width-modulation-signal-with-fixed-duty-cycle-in-simulink-matlab-r2023a-using-random-number-generator-block/
@ProgrammerWorld10 ай бұрын
Below may help. Please check: programmerworld.co/simulink/how-to-design-pwm-signal-with-different-on-and-off-period-in-matlab-simulink/
@sandraprasad39310 ай бұрын
Not this one.. Question is ' model a system inwhich 1) on the timer when the voltage is 5v 2)on the timer for 10second and off for the next 5second and repeat
@hiramansuryawanshi20253 жыл бұрын
How to implement up counter and down counter in same logic.it should make triangle
@ProgrammerWorld3 жыл бұрын
Instead of 0 in the other option of Switch block, just implement the decreasing counter logic. Below video can help in implementing the down counter logic: kzbin.info/www/bejne/b6TIeJxpq7KKd8U kzbin.info/www/bejne/l4a0ZIWEfcSih9U Cheers Programmer World programmerworld.co/ -
@yashm59023 жыл бұрын
If 3 bit how to proceed!
@deepakkumarpandia9175 жыл бұрын
how can we generate a pulse in every 10 seconds in stateflow model??
@ProgrammerWorld5 жыл бұрын
You can watch my below video: kzbin.info/www/bejne/raCTlnyQpp5ml7c This video shows how to generate pulse signals using Simulink blocks. It does not shows the implementation in Stateflow. You can take a hint from this video for implementation in Simulink. If it will be possible then I will create another tutorial showing the implementation in Stateflow.
@Snesvlog6 жыл бұрын
How to stop the counter once it comes to zero??
@ProgrammerWorld6 жыл бұрын
Once the counter reaches to zero you can either reset it as shown in my video tutorial. If you want to stop it completely then you can use conditional subsystems like Enable subsystems or If condition subsystems. In this subsystem once the counter value reaches to Zero you can disable it. So, the value of counter will not be considered anymore.
@josemanuelcaballero11624 жыл бұрын
what if the reset threshold is variable?
@ProgrammerWorld4 жыл бұрын
Please check if the below video helps: (How to design variable step increasing and decreasing counter in Simulink?) kzbin.info/www/bejne/fImqoJhvZtNsfac Good Luck Programmer World programmerworld.co -
@silambuarasan59566 жыл бұрын
I want many different different increment and decrement and another output signal s
@ProgrammerWorld6 жыл бұрын
It can easily be done using a Mask Parameter and taking the value of the parameter in the Add block in the feedback loop of counter. I will try to make a video to explain this.
@ProgrammerWorld6 жыл бұрын
You can refer to below video. This video shows how you can design a variable step counter in Simulink: kzbin.info/www/bejne/fImqoJhvZtNsfac
@Shorts-in-Nutshell6 жыл бұрын
How to design Decrement counter?
@ProgrammerWorld6 жыл бұрын
Hi Ankita, You can watch my other video titled "How to design a Decreasing Counter and reset counter in Simulink?". This video shows how you can decrease the count in each simulation step. You can watch it using below link: kzbin.info/www/bejne/b6TIeJxpq7KKd8U
@drirfankhan20734 жыл бұрын
How to make this statement in simulink : Varying the current from 1 to 25A, in steps of 0.4 ampere, every 40 s over a total simulation period of 2720 s.
@ProgrammerWorld4 жыл бұрын
In this tutorial, the counter shown takes all the default values such as step size, increment value, etc. For your values, the specifications in the counter will need to be modified. Say for example, step-size should be 40s, Total simulation time = 2720s and increment value in every step to be 0.4Amps. Once you these changes in the model, you will get the model for your requirement. For further reference you can watch my other videos on counter topic using the below links: kzbin.info/www/bejne/fImqoJhvZtNsfac kzbin.info/www/bejne/l4a0ZIWEfcSih9U Hope the above helps. Good Luck Programmer World programmerworld.co -
@drirfankhan20734 жыл бұрын
@@ProgrammerWorld thank you sir
@drirfankhan20734 жыл бұрын
Sir can you please tell me how to make this for a system containing continuous states: Varying the current from 1 to 25A, in steps of 0.4A, every 40sec over a total simulation period of 2720sec. Please help sir