Society of Robots - Robot Forum
Software => Software => Topic started by: mstacho on February 03, 2011, 01:33:40 PM
-
Possibly a weird question, but let's say I change the PWM duty cycle to 50%, then carry on in a while loop or something to do something completely different. I assume the PWM will still be working even though the control flow of the program is locked in the loop, is that right? If so, does the PWM routine take up a lot of system resources?
I only ask because I'm eventually going to have to control 7 motors independently while doing some lower level processing and might need to squeeze every bit of speed out of the axon as possible :-P High level stuff will be done on a PC, though, but fast, reactive control is what I'm using the axon for!
MIKE
-
You assume correctly. Provided you configure hardware pwm using the timers and associated pins then there is no processing overhead at all, other then updating the value in a register when you want to change duty cycle. Microcontrollers are clever wee beasties!
-
Depends on several factors.
If its hardware PWM, your software can do whatever you want and the PWM will still work perfectly no problem. The original Axon has 7 easy to use hardware PWM ports.
If its software PWM, it gets a little fickle as it requires interrupts for your other software to work. If you use WebbotLib, it'll handle everything for you in the best way possible (and easy enough for a beginner). You can use any pin on the Axon for software PWM, but hardware PWM (only certain pins) is always the better option if it's available.
You can also use both methods, if you have more than 7 motors. :P