Hi Xavier, You must observe the subject line and topic tagging conventions on the Piclist. Your subject line should include the topic tag and a subject appropriate to the email. Don't hijack an old thread with new content! Your new email is not about PICs, it is about driving MOSFETs. The appropriate tag is [EE]. A subject line like this might be good: [EE] Driving MOSFETs Please try again. Thanks, Bob On Tuesday, September 13, 2011 5:26 PM, "xavier" wrote: > Thanks a lot for that valuable info,I m using tha techniques u showed me > here ..i > Could u tell me tha difference between capacitively driven Mosfet and > transformer coupled driven Mosfet coz my circuit uses tha > transformercoupled driver. And due to unavailability I wanted to use tha > Capacitively driven mosfet=20 >=20 > Wondering what would be tha effect ? > =20 > lambs become Lions >=20 > -----Original Message----- > From: cdb > Sender: piclist-bounces@mit.edu > Date: Sat, 3 Sep 2011 20:27:40=20 > To: Microcontroller discussion list - Public. > Reply-To: "Microcontroller discussion list - Public." > Subject: Re: [PIC] Help Needed using Dspic30f4011!!! >=20 > On Fri, 2 Sep 2011 11:05:44 -0700 (PDT), xavierpereira wrote: > :: As the Duty Cycle will be the Function of the Input Volatge and > :: voltage > :: reference(ie 12 V ). > :: I have to set this Duty Cycle Value to the PWM pin.. I need a > :: formula or some hints to write this algorithim >=20 > OK, let's think about this. >=20 > What voltage is going to be at the input pin of the ADC? >=20 > I'm assuming the max voltage is 3v3 or is a DSPIC a 5v part?=20 >=20 > Once you've got that and you know what the maximum count is and minimum=20 > assuming you are referencing the ADC as 0 -> Max Vdd - all you then have > to=20 > do is work out what voltage points you are going to make valid, that is > are=20 > you only responding to per volt or per half volt etc, once you've decided= =20 > that all you need to do is map those counts that equal the voltage to PWM= =20 > values. >=20 > You could use a look up table, but you could also have a either an IF ...= =20 > Else... code block or if many values perhaps a Case block which would be= =20 > something like: >=20 > Case: nought_counts to count_equals_1v;=20 > duty_cycle =3D some_value;=20 > sub_change_duty(); =20 > break; >=20 > repeat for other voltage counts. >=20 > You haven't mentioned what the Mosfet will be switching, so how you > decide=20 > how to allocate the duty cycle to the voltage input will have a great=20 > bearing on what ADC count you assign to what duty cycle value. >=20 > Hoping this won't confuse you, but here is some code for an 8 bit device= =20 > that increments the duty cycle of a PWM as a soft start to drive a fan=20 > motor derived from a humidity reading. >=20 > void trip_check(trips *pTrip) > { > if (rh_adj < pTrip->humidity ) > { //if current humidity < trip humidity switch on with soft start > CCP1CON=3D0x2C; //PWM module1 on, output pin RC2 > =09 > if (++duty1 > 30) > { > duty1=3D31; > } > CCPR1L=3Dduty1; > } > else > { > if(!(duty1 =3D=3D 0)) > duty1--; > CCPR1L=3Dduty1; > #asm > movf duty1,W > btfsc STATUS,Z ;Is duty zero? > movwf CCP1CON ;Yes so turn CCP1 off=09 > #asmend >=20 > Ignore the fact that part of it is in assembler that is purely because > the=20 > compiler produces more assembler code than I like. Note that (if I recall= =20 > correctly) 31 is about the maximum figure that CCPR1L can take for the=20 > 16F87x series, you'll need to check your datasheet for your dsPic to see= =20 > what the maximum number is. >=20 > There is a code example for the dsPIC30F4012 which is for driving a=20 > brushless motor, it takes the ADC value (as a speed control) and applies= =20 > that as a duty cycle to change the speed of the motor. >=20 > http://ww1.microchip.com/downloads/en/DeviceDoc/CE003_Sinusoidal_BLDC_010= 90 > 8.zip >=20 > Strip away the bits you don't want and the general idea if what you need > to=20 > do is there. >=20 > Colin > -- > cdb, colin@btech-online.co.uk on 3/09/2011 > =20 > Web presence: www.btech-online.co.uk =20 > =20 > Hosted by: www.justhost.com.au > =20 > =20 > This email is to be considered private if addressed to a named=20 > individual=20 > or HR department, and public if addressed to a blog, forum or news=20 > article. > =20 > =20 > =20 >=20 >=20 >=20 > --=20 > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist >=20 > --=20 > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist >=20 --=20 http://www.fastmail.fm - Choose from over 50 domains or use your own --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .