Date: Thu, 22 May 2014 19:51:14 +0100 From: fabiodive <fabiodive@gmail.com> To: Luiz Otavio O Souza <lists.br@gmail.com> Cc: "freebsd-arm@freebsd.org" <freebsd-arm@freebsd.org> Subject: Re: Beaglebone Black. PWM minimum frequency of 1.52KHz Message-ID: <AB9D698C-2D12-4836-BF80-15D35AD780C8@gmail.com> In-Reply-To: <CAB=2f8zy7=S_Xh0REsv29_1%2BHk_=h7Ut1SDURjP-otaE9hsxBg@mail.gmail.com> References: <F5705D29-1EFE-4A20-89CC-CB0E52EB57F3@gmail.com> <CAB=2f8zy7=S_Xh0REsv29_1%2BHk_=h7Ut1SDURjP-otaE9hsxBg@mail.gmail.com>
index | next in thread | previous in thread | raw e-mail
Hello Luiz, hello all my friends, Luiz, it is a real pleasure for me to hear you! I didn't try yet your work but I will do that tomorrow, actually your modifications sounds really well done. I will report here, thank you! cheers, Fabio On May 22, 2014, at 15:19 , Luiz Otavio O Souza <lists.br@gmail.com> wrote: > On 10 May 2014 08:56, fabiodive wrote: >> Hello, >> >> PWM on Beaglebone Black >> >> during my laboratory tests I was not able to setup a frequency suitable for servo motors. >> I tried several times with many values but the results was always the same. >> The minimal frequency I was able to achieve was 1.52 KHz. >> Also, I noticed odd results with the most of configuration values, in this case >> I lost the PWM output signal. >> >> I tried some combinations, measuring the results with an oscilloscope, the period >> configuration key appears to loose its nanoseconds meaning beyond a value: > > Hi Fabio! > > The PWM frequency is determined as SYSCLKOUT (100Mhz) / prescaler > settings / period. As the current code uses 1 for the prescaler and > the period is a 16bit value the lower frequency you can have is > actually 1.529Khz. > >> # sysctl dev.am335x_pwm.1.period=1500 >> # sysctl dev.am335x_pwm.1.dutyA=300 >> result frequency: 66 KHz ->should be 666 KHz >> length of period: 15 us ->should be 1.5 us >> length of pulse: 2 us > > As above, this is correct: 100Mhz / 1 / 1500 = 66Khz. > >> >> # sysctl dev.am335x_pwm.1.period=1500000 >> # sysctl dev.am335x_pwm.1.dutyA=10000 >> result frequency: 1.71 KHz -> should be 666Hz >> length of period: 585 us >> length of pulse: 100 us >> >> # sysctl dev.am335x_pwm.1.period=1800000 >> # sysctl dev.am335x_pwm.1.dutyA=10000 >> result frequency: 3.24 KHz -> should be 555Hz >> length of period: 308 us >> length of pulse: 100 us > > These two examples are overflowing the period variable. > > I've the attached patch which enforces the maximum values where needed > (to avoid such overflows) and two new sysctls, one allows you to set > the prescaler for the PWM module and the other (which is probably more > interesting) allows you to check the actual PWM frequency. > > The sysctl.am335x_pwm.X.freq can also be use to set an desired > frequency directly, it will try to get you the better setting it can > find for the desired frequency, which usually means get the bigger > period it can find to give the better PWM resolution that is possible > for a given frequency. > > I've been able to drive R/C servos directly with this patch and the > following set: > > sysctl.am335x_pwm.X.freq = 50 (digital servos may operate at higher frequencies) > > And then, for the cheap chinese servo i have here, i can get it to > travel almost 180o using duty values from 2000 to 6000 (YMMV). > > I've checked the frequencies with a scope and they look fine for me. > > Regards, > Luiz > <am335x_pwm.diff>help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AB9D698C-2D12-4836-BF80-15D35AD780C8>
