alexxx
Advanced Member level 4
OK, since 50% and 100% pwm is required, things are not so complicated.
Set a timer interrupt. If you need 1KHz for example, the interrupt must be coming every 500us. Inside timer interrupt declare a flag. Each time interrupt comes, this flag will be toggled.
Now you said that the solution of post #27 worked well. With small effort and this timer interrupt involved, you will do this quickly.
If sensor is intercepted, then the corresponding output will be driven with 1 (100%), no changes on that. But if it is not intercepted, then it will not be 0 in any case. It will depend on the value of the flag toggling inside timer interrupt. If it is 1, then the output will go to 1. Else, it will go to 0.
In this simple way, you will quickly adjust the output to be 50% or 100%, instead of 0 and 100% as it is now.
Hope that helped,
Alexandros
Set a timer interrupt. If you need 1KHz for example, the interrupt must be coming every 500us. Inside timer interrupt declare a flag. Each time interrupt comes, this flag will be toggled.
Now you said that the solution of post #27 worked well. With small effort and this timer interrupt involved, you will do this quickly.
If sensor is intercepted, then the corresponding output will be driven with 1 (100%), no changes on that. But if it is not intercepted, then it will not be 0 in any case. It will depend on the value of the flag toggling inside timer interrupt. If it is 1, then the output will go to 1. Else, it will go to 0.
In this simple way, you will quickly adjust the output to be 50% or 100%, instead of 0 and 100% as it is now.
This is something your experiments will tell. The only thing you have to change for such a test, is the frequency of timer interrupt.varunme said:Its to control LEDs so, is the frequency really accounts ?
Hope that helped,
Alexandros