Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
11 years, 11 months ago.
LPC1758 how to control Motor and Servos at the same time ?
I'm new to this, so i set the PWM frequency to 400Hz. Then i found out i cannot set the rest of the PWM to 50HZ for the servos. What is the right approach to this ?
i noticed the MCPWM for the motors, do those have their own timer ? so i could set that to a different frequency ? Should i disable PWM while switching between Motor to Servo control ?
thanks Dan
2 Answers
11 years, 11 months ago.
The MCPWM could be a solution. However, on regular mbed modules the MCPWM pins are not available externally. You would have to use some other LPC1768 based hardware and run mbed code on it. That will be your second problem: currently I dont think there are any mbed libs to control the MCPWM. The alternative is to do a software driven PWM: A ticker or timer could be used to toggle one or more pins. Depending on how many channels you need and the rate at which the PWM dutycycle changes you would either do the 400Hz or the 50Hz in software. Another alternative is to use some external hardware. There are some serially controlled PWM generators available that are used for RC applications (google for 'servo' and 'I2C' or 'SPI'). You could also possibly use some of the new I2C or SPI LED drivers that support dutycycle control to give you variable brightness.
11 years, 11 months ago.
thanks for your detailed answer, i think i do have the pins for the MCPWM. But like you said the other issue is no libs. i wasn't aware of such limitations with the PWMs... will something like this work :
http://www.adafruit.com/products/1455
another work around that can work for me for now, is it possible to switch between the motor and the servos, when i say switch i mean, to shut down the motor PWM use the servo, turn off the PWM servo and go back to the motor. will that work with changing the frequency between them ? this solution isn't ideal, but may be enough for now.
i'm almost tempted to use a TI MSP430 i have here just for that ....
thanks Dan
That description for that particular board says: "This is the highest-resolution PWM board we've seen! Designed (and ideal) for precision LED control, this board is not good for driving servos. If you need to drive servos, we have a controller for that over here." They refer to this board. That seems to just do what you are looking for.
Its not really an option to switch between motor PWM and servo PWM. Regular servos need a permanent control signal at an update rate of about 50 Hz. They will become unpowered (slipping) or may start moving erratically when the signal is missing for any period of time.
posted by 17 Nov 2013