Hallo,
have anyone samplecode how I can make a Software PWM?
I have used the wrong Pins from Attiny 45 and now I have 200!! of wrong Boards
Samplecode for Software PWM
Re: Samplecode for Software PWM
Hi, I don't have any code sorry but I think you must use timer interrupt with 2 variables, "_up" et "_down"
duty cycle is equal to 50% when "_up" = "_down".
It's just little algorithm
Regards
Stéf
duty cycle is equal to 50% when "_up" = "_down".
Code: Select all
procedure on_Interrupt
begin
inc(global_counter)
if (global_counter > _up) then
Begin
global_counter = 0
portx.x = 0
end
if (global_counter > _down) then
Begin
global_counter = 0
portx.x = 1
end
end
Regards
Stéf
Re: Samplecode for Software PWM
corado, what frequency and resolution do you need?
Au royaume des aveugles, les borgnes sont rois.
Re: Samplecode for Software PWM
first, I only want the rpinziple of an PWM Routinge..
I want it to use like Softpwm:=50;
Or nearly this was..
I want to use it to generate negative Voltage with coil, Diode, and Resistor at any Portpin from AVR
I want it to use like Softpwm:=50;
Or nearly this was..
I want to use it to generate negative Voltage with coil, Diode, and Resistor at any Portpin from AVR
Re: Samplecode for Software PWM
for that purpose you would want a rather high frequency , the highest frequency you could get would be a fixed 50% dutycyle driven by timerinterrupt. The interrupt_frequency in that case is only twice the pulse frequency, probably limited to a few kHz.
All you have to do in the interrupt is toggle the pin. ( keep in mind this is NOT pwm)
All you have to do in the interrupt is toggle the pin. ( keep in mind this is NOT pwm)
Au royaume des aveugles, les borgnes sont rois.