Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Speed control and PWM which module to use?

Status
Not open for further replies.

aredhel_vlsi

Member level 4
Joined
Aug 21, 2009
Messages
72
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
2,013
Hello there, I am reading the modules that PIC 18F 43331 provides and I am a bit confused. I will have to control the speed of a dc brushless motor. So firstly, I want to just give a desirable speed to my motor and watch it move. How do we start?
According to the datasheet Power Control Module, is very good for brushless motors, but why is CCP module (input capture/PWM) available too?
From what I ve found at the internet, there are some simple examples for the CCP modules, but I wanna know if this will be good for me in the future or if I have to change it.
Also, Power Control module has its own timers, so I dont have to use TMR 1 for instance ? Or will I have to combine them?

Thank you very much, I can't understand so many things and I am at the beginning of my project.
 

I am using ccs compiler.

an example.
Code:
//this is a little test PWM program to drive a DC fan. 
// the fan allready has some control circuit built into it. 
//I susspect it has PIC and MOSFET controlling it. 
//Some have been failing on site so I need to test it in the workshop. 
//The fan manufacturers specified the PWM should be 1Khz 
//Fan spec  DC% 0 to 2 invalid run at default 
//              5% motor RPM = 0 
//             10% motor RPM = Minium 
//             90% motor RPM = Maximum 
//             95% reverse at marimum RPM 
//           98 to 100% invalid run at default 
// default speed 4600RPM for 24Vdc fans 
// I know this program is not the best but it was a good learning experience 
// to produce it. I do like making electronics do stuff. 
#include <18F4620.h>
#device ICD=TRUE
#device ADC=10

#fuses HS,NOWDT,NOPROTECT
#use delay(clock=20000000)
#define RIGHT_LED PIN_B0 
#define LEFT_LED PIN_B1 

void main(){ 
      int16 value,potinput,scale; 
      value=25; 
      //Timer 2 set up 124 is calculated duty resolution 500 max 1024 10bit 
      setup_timer_2(T2_DIV_BY_16,124,1); 
      setup_ccp1(CCP_PWM); 
      setup_ccp2(CCP_PWM); 
      setup_port_a(AN0); 
      setup_adc(ADC_CLOCK_DIV_16); 
      set_adc_channel(0); 
      delay_us(20); 
      
while(TRUE){ 
      output_low(RIGHT_LED); //Flashing led's so I know the program is running 
      output_high(LEFT_LED); //I could have used output_toggle() 
      delay_ms (250); 
      output_high(RIGHT_LED); 
      output_low(LEFT_LED); 
      delay_ms (250); 
      potinput=read_adc();
	  potinput=60; 
      //potinput 8 bit ADC therefore 0 to 255 
      //max pwm 90%, 90% of 500 is 450 so max is 450-25=425 
      //425=255*1.6+25 
      //value=25 min5% 
      scale=potinput*1.6; 
      set_pwm1_duty(scale+value);  
      set_pwm2_duty(scale/2+value);  
}
 

Thank you for your example. I 'll see the logic and try to understand. I have a dc permanent magnet dc motor. Is CCP module good for me or is it better Power Control module? Addittionally, I haven't understood, will I have to use Timers 2, 5 in Power control module, or just the PTMR and PTPER registers?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top