Jostein,
Thanks for the reply. I'll have to try it out later tonight. It'll be nice to have a working robot again! :^)

Mike Caruso

On Sun, Oct 26, 2008 at 8:19 AM, Jostein Austvik Jacobsen <josteija@stud.ntnu.no> wrote:
Well, to break it down:


     set TCCR1A to 0xAA
     set TCCR1B to 0x1A
COM1A = 0b10 // Clear OC1A, OC1B and OC1C on compare match, set OC1A, OC1B and OC1C at BOTTOM, (non-inverting mode)
WGM1 = 0b1110 // Fast PWM, ICR1 as TOP-value
CS1 = 0b010 // clk_I/O / 8 (From Prescaler)

     set ICR1 to 40000
Gives the PWM a resolution of 40000

     set TCNT1 to 0
Set Timer/Counter to 0, which makes sure that the first pulse also has the correct pulse-width


     set direction b.5 out

     //then to set the duty cycle like the script
     set OCR1A ( {pulsewidth} * 2 )
OCR1A is a 16-bit register taking values between 0 and 40000.

Anyway, your pseudocode seems perfectly reasonable :)

Jostein A. Jacobsen

2008/10/26 Mike Caruso <rufus13@gmail.com>
Hello List,
Recently I've decided to switch my robots drive over to standard PWM servo motors, where pulses range from 1ms to 2ms yada yada yada. I've never used the PWM connectors on the Robostix, just the serial connection and a few of the GPIO pins. I'd just like to know if the following method/pseudo-code for setting the duty cycle makes sense (on PWM 1A based on the servo script in robostix/gumstix/i2c-io/ ):

     set TCCR1A to 0xAA
     set TCCR1B to 0x1A
     set ICR1 to 40000
     set TCNT1 to 0
     set direction b.5 out

     //then to set the duty cycle like the script
     set OCR1A ( {pulsewidth} * 2 )

Seems simple enough to understand, ideally this would be integrated into a C program running off a verdex motherboard using i2c-io. Am I missing anything?

Thanks,
Mike Caruso


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
gumstix-users mailing list
gumstix-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gumstix-users



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
gumstix-users mailing list
gumstix-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gumstix-users