adjustment of the duty cycle

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • adjustment of the duty cycle

      Hi,
      what can I do, to have minor increases in duty cycle values? (That is a finer adjustment of the duty cycle ...)

      The code I'm using is as follows:

      BASCOM Source Code

      1. $regfile = "m1284Pdef.dat"
      2. $crystal = 16000000
      3. $baud = 19200
      4. $hwstack = 48
      5. $swstack = 24
      6. $framesize = 48
      7. Dim Dutycycle_tmp As Byte
      8. Tccr2a = &B00100011
      9. Tccr2b = &B00001010 'Prescaler 8
      10. Ocr2a = Dutycycle_tmp
      11. Pwm2b = 40 '40KHZ
      Display All
    • atmega64 wrote:

      Hi,
      what can I do, to have minor increases in duty cycle values? (That is a finer adjustment of the duty cycle ...)

      The code I'm using is as follows:

      BASCOM Source Code

      1. $regfile = "m1284Pdef.dat"
      2. $crystal = 16000000
      3. $baud = 19200
      4. $hwstack = 48
      5. $swstack = 24
      6. $framesize = 48
      7. Dim Dutycycle_tmp As Byte
      8. Tccr2a = &B00100011
      9. Tccr2b = &B00001010 'Prescaler 8
      10. Ocr2a = Dutycycle_tmp
      11. Pwm2b = 40 '40KHZ
      Display All
      Why don't you use the commands CONFIG TIMER = ... ?
      Aus datenschutzrechtlichen Gründen befindet sich die Kontaktdaten auf der Rückseite dieses Beitrages.
    • atmega64 wrote:

      (That is a finer adjustment of the duty cycle ...)
      The minimum width of the pulse depends on the prescaler. The pulse width is thus a multiple of the minimum pulse width. Small deviations you achieve only by changing the system clock.

      Die Mindestbreite des Pulses richtet sich nach dem prescaler. Die Pulsbreite ist also ein Vielfaches der Mindestpulsbreite. Kleine Abweichungen erzielst du nur durch Ändern des Systemtaktes.
      Raum für Notizen

      -----------------------------------------------------------------------------------------------------

      -----------------------------------------------------------------------------------------------------
    • One possibility would be to set up an interrupt and perform minimal pauses in the isr with nops to influence the duty. In your case, at pwm2b = 40 the pulse = 20μs. A system clock lasts 0.0625μs, which corresponds to a nop.

      Eine Möglichkeit wäre einen interrupt einzurichten und in der isr mit nops minimale Pausen ausführen und so den duty zu beeinflussen. In deinem Fall ist bei pwm2b=40 der Puls =20µs. Ein systemtakt dauert 0,0625µs, was einem nop entspricht.
      Raum für Notizen

      -----------------------------------------------------------------------------------------------------

      -----------------------------------------------------------------------------------------------------
    • sorry this is the correct code with fixed frequency 40Khz:


      BASCOM Source Code

      1. Tccr2a = &B00100011
      2. Tccr2b = &B00001010 'Prescaler 8
      3. Ocr2a = 49 '40KHZ
      4. Pwm2b = Pwr_pwm_tmp
      and setting PWR_PWM_TMP = 24, I have this signal:

      TEK0001.jpg

      I therefore have 48 steps ...

      how can i increase the number of steps?
    • the 40 khz are given and you want a higher resolution for the pulse length?
      Then I see the possibility with prescale = 1 in an isr to generate the high-pulse and at the next interrupt the low-pulse.
      Raum für Notizen

      -----------------------------------------------------------------------------------------------------

      -----------------------------------------------------------------------------------------------------