Demo-board PWM APIs

Forum related to ERIKA Enterprise and RT-Druid version 2

Moderator: paolo.gai

Post Reply
della
Newbie
Posts: 3
Joined: Fri Oct 10, 2008 9:38 am

Demo-board PWM APIs

Post by della » Tue Oct 14, 2008 11:55 am

Hello everybody,
I don\'t understand how to use the PWM with the demoboard. I\'ve seen that there are 3 functions: EE_pwm_init, EE_pwm_set_duty and EE_pwm_close. When these functions must be called? And the Period is in millisecond or microsecond?

chris
Newbie
Posts: 16
Joined: Mon Sep 29, 2008 1:27 pm

Re:Demo-board PWM APIs

Post by chris » Tue Oct 14, 2008 1:47 pm

Hi!

First of all you have to know that the PWM used in the demo-board works via the output compare interface. This is good if you want to drive a servomotor, otherwise you should use the PWM interface of the dsPIC on your own.

The code with the API for the PWM with the demo-board should be in ERIKA_INSTALLATION_DIR/ee/pkg/board/ee_flex/inc/ee_board.h file, but unfortunately it seems that something is missing.
Anyhow the period should refer to the period of the timer2 bound to the OC interface, but the is commented.

If you want to drive a servomotor you can try to adapt the code I am attaching, I already used and tested, to the demo-board (just choose the right Output Compare - OC - interfaces).

The code as two file to manage the PWM on the OC interface, in order to obtain an abstraction of it, and two file to implement the abstraction of the servomotor (the latter is just a wrapper for the first one, allowing to drive the servomotor in degree).

The init functions should be called before using the start and set functions.

I hope this will help.
Fill free to do any further question.

Regards.
Attachments
servomotors_on_pwmOC.zip
(20 KiB) Downloaded 300 times

della
Newbie
Posts: 3
Joined: Fri Oct 10, 2008 9:38 am

Re:Demo-board PWM APIs

Post by della » Wed Oct 15, 2008 2:17 pm

Thanks for help.
I have to drive DC motor, not servomotor, but your code is very useful for me for the pwm stuff.

In pwmOC.h file is included a microTime.h, may you post also this file?

Regards

chris
Newbie
Posts: 16
Joined: Mon Sep 29, 2008 1:27 pm

Re:Demo-board PWM APIs

Post by chris » Wed Oct 15, 2008 2:59 pm

Sorry, that was because I extracted that code from an old project of mine.
The lines that are required for the pwmOC.h are just the following:

Code: Select all


typedef enum {
	FCY_2_MHz=2,
	FCY_40_MHz=40
} fcy_MHz;
Anyhow I suggest you to have a look at the pwm interfaces that are well-suited for DC motors driving.
Here\'s the link to the microchip specific refman

http://ww1.microchip.com/downloads/en/D ... 70187C.pdf

Bye!

Post Reply