Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Motore.h" //uses the MotCon.h library for controlling the motor ports
- //PC serial connection
- Serial pc(USBTX, USBRX); //tx, rx via USB connection
- DigitalOut led(LED1);
- MotCon m1(PA_2, PA_3); //uses p25 for PWM and p27 for direction
- //------------ Main ------------------------------
- int main() {
- pc.baud(921600);//fast baud rate for USB PC connection
- while(1) {
- //iterate through 2*pi cycles in .01 increments
- for(float cycle=0;cycle<3.14159*2.0;cycle+=.01){
- float m1_dc = .85*sin(cycle);
- m1.mot_control(m1_dc);
- pc.printf("cycle=%.3f m1_dc = %.2f \r\n", cycle, m1_dc);
- wait(.01); //determines period
- led = !led; //toggle LED1 to indicate activity
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement