P. 1
ME 4340 MechatronicSystems

ME 4340 MechatronicSystems

|Views: 42|Likes:
Published by cyrenityx

More info:

Published by: cyrenityx on Jan 18, 2010
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PPTX, PDF, TXT or read online from Scribd
See more
See less





ME 4340 MechatronicSystems


Programming PIC18F452 with C18 using MPLAB IDE
Pulse Width Modulation

PWM controls use pulse width modulation to regulate the current sent to a motor or any other modules.  PWM controls produce smoother current at higher switching frequencies, typically between 1 and 20 kHz.  At 20 kHz, the switching frequency is inaudible to humans, thereby eliminating the hum which switching at lower frequency produces.

Pulse width Modulation ( PWM )
§V e ry e ffi e n t w a y o f p ro vi i g i te rm e d i te ci d n n a a m o u n ts o f e l ctri l p o w e r b e tw e e n fu l y e ca l o n a n d fu l y o ff l

DC Brushed Motor Controlling


PWM controller typically contains a large reservoir capacitor and an H-bridge arrangement of switching elements (thyristors, mosfets or transistors).

   
  

Eg :- L298 (typical solid state H-Bridge).

Basics Construction of a H Bridge

§A solid state H-bridge is typically constructed using BJTs or MOSFETs

Interfacing a microcontroller / H - bridge and motor

Parameters of the CCP module

Registers / Modules associate with PWM
     

TMR2 module and associated registers. CCPXCON - capture/compare/pwm x control CCPRXL - capture/compare/pwm x register low CCPRXH (Read only) - capture/compare/pwm x register high Etc.. All these associated registers’ functionality and configurations settings can be found in the PIC18F452 data sheet. X – can be either 1 or 2 for the 2 modules in a 18f452

 

 

Setting up the PWM modules
Set the CCPX pins and directional control I/O pins as out puts.  Set the PWM period by writing to the PR2 register.  Set the PWM duty cycle by writing to the CCPXRL and CCPXCON<5:4> registers.  SET the Timer2 prescaler and enable Timer2.  Configure the CCPX module for PWM operation

Example Using C18 library

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->