Hi,
I am trying to figure out how to use the PWM Motor Control Mode for my dsPic30F4011. I am trying to send a signal with a period of 2 microseconds. The problem is I have no idea how. I've poured through the dsPic manual and the motor pwm module manual, but the documentation is just not making the process clear. So my questions are:
1) How do I "activate" the motor control module? Do I need to write to a certain register or something? I have written to the PTPER and PTCON register, but I am not getting a PWM signal.
2) How do I set the period to 2 microseconds? I have tried to do the math using equation 15-1 in the dsPIC30F4011 manual, but I do not know what Tcy is. What is Tcy?
3) How do I set a different period for PWM1, PWM2, and PWM3?
Thanks for everyone's help so much! Microchip's support is...lacking. I will soon update this post with the little bit of code I've written.
PS. If you're curious, I am building a highly mobile hexapedal robot, and need to send PWM signals to the Victor 884s I have connected to each of the 6 dc motors I am using to make it walk. The mechanical design and building is finished, and the "nervous system" (speed controllers to motors) is more or less complete. But I've gotten complete stuck at the "brain" programming.
Edit// Code so far. Hope to have it filled with lines that make it, you know, work, quite soon:
I am trying to figure out how to use the PWM Motor Control Mode for my dsPic30F4011. I am trying to send a signal with a period of 2 microseconds. The problem is I have no idea how. I've poured through the dsPic manual and the motor pwm module manual, but the documentation is just not making the process clear. So my questions are:
1) How do I "activate" the motor control module? Do I need to write to a certain register or something? I have written to the PTPER and PTCON register, but I am not getting a PWM signal.
2) How do I set the period to 2 microseconds? I have tried to do the math using equation 15-1 in the dsPIC30F4011 manual, but I do not know what Tcy is. What is Tcy?
3) How do I set a different period for PWM1, PWM2, and PWM3?
Thanks for everyone's help so much! Microchip's support is...lacking. I will soon update this post with the little bit of code I've written.
PS. If you're curious, I am building a highly mobile hexapedal robot, and need to send PWM signals to the Victor 884s I have connected to each of the 6 dc motors I am using to make it walk. The mechanical design and building is finished, and the "nervous system" (speed controllers to motors) is more or less complete. But I've gotten complete stuck at the "brain" programming.
Edit// Code so far. Hope to have it filled with lines that make it, you know, work, quite soon:
//title "Project Zero"
#include <dspic.h>
//PORTB will be the hall effect sensors.
void init(void)
{
TRISB = 1;
PORTB = 0;
PORTD = 0;
TRISD = 0;
PORTE = 0;
}
void main(void)
{
init();
PTCON= 0b1000000000000000; //set PWM mode
PTPER = 0b0000000000010001; //set pwm period
}
Last edited: