View Full Version : Mosfet stable Volt out
jetpr
- 19th February 2005, 23:18
MosFet out volt
i need help how stable Volt out with PWM and MosFet
the out put is up and down for one volt
example: v1.0
v1.1
v1.0
Bat: 7.2v souce
mister_e
- 19th February 2005, 23:50
HEIN.. have you some schematic and/or more details of your stuff ???
I really try to understand but... not sure enough to provide a good answer to that.
Try to tell us what you really expected as output swing... can i understand you want from 0 - 1 Volt or a 0.1 volt steps with a 7.2V battery as power source???
if i'm right... if not please somebody slap me
7.2 / 256 = 0,028125 volts by 8 bit PWM definition duty step
to get 0.1 volt: duty = 0.1/0.02823529 = 3.55555 = 3 or 4 test it
to get 1 volt : duty = 1/0.02823529 = 35.5555 = 35 or 36 test it
to get 1.1 volt: duty = 1.1/0.02823529 = 39.1111 = 39
jetpr
- 20th February 2005, 18:09
I am driving a dc motor with MosFet and when i read the volt out clamp to the motor is up and down so me robot a fast and slow ...
Example : out v is shut be 2.0 and not 2.1 but after liter of time change to 2.1 so my robot run i liter fast for a second and then go back so is not stable
my source is 7.2v
my MOSFET is Rectifier IRLU3103
I use 10K resistor, with a 12K resistor gate to ground. Higher gate to ground
resistance reduces resolution of the byte Duty Cycle variable.
mister_e
- 20th February 2005, 23:39
mmm, in all my motor speed control, i read the voltage on the motor with an A/D input of the PIC. Kinda feedback control.
Once you have the voltage reading from the motor, simply monitor it and do the according change in your PWM statement or routine.
10K in serie look a bit high... is 220 Ohms to 1K do the same with the same pull down on the gate?
May be a stupid question but, is your PIC output is an open drain?!? RA4 ???
jetpr
- 21st February 2005, 01:15
Hi ken you send schematic or some help who i made that...
my pic is pic18f252 and i conect to the pwm pin with 2 res. one to ground and the other to the gate in the same line like a volt divider..
my code
MotorDC VAR CCPR1L
MotorOut VAR PORTC.2
MotorOn CON %1111110 '16 Pre/Scale
MotorOff CON %1111010
MotorEnable VAR T2CON
PumpDcSet=15
CurrentStep = 0 to 100 of rc pulse
MotorScaleFactor = 255 - 15
MotorScaleFactor / CurrentStep
MotorDC = MotorScaleFactor / 100 * CurrentStep + PumpDcSet
Pause PauseScalefactor * 1000 / MotorScaleFactor Factor
mister_e
- 21st February 2005, 13:22
here's something to play with
' PIC18F2220
DEFINE OSC 20
TRISC = 0 ' PORTC as output
TRISA = 3 ' RA0 & RA1 as input
PR2=$FF ' load frequency period (PWM freq=1.2 KHZ)
ADCON1 = %00001101 ' Set RA0 & RA1 as analog
ADCON2 = %10000110 ' Right justified result
' Fosc/64
' Tad = 0
ADCON0.0 = 1 ' enable a/d
TMR2DutyVar var word
AdResult var word
Voltage var word
Source var word
SelectedVoltage var word
Quanta con 125 ' (5Volt/1024)*256=0.125 = 125
SelectedVoltage = 110 ' mean 1.1 volt
tmr2dutyvar = 156 ' according duty to get 1.1Volt = (1.1/7.2)*1024
Start:
gosub InitPWM
' Read Motor voltage supply line
' ------------------------------
'
ADCON0 = %00000101 'select channel 1
pauseus 100
ADCON0.1 = 1 'start conversion
while ADCON0.1 ' wait for end of conversion
wend
Adresult.highbyte = ADRESH
adresult.lowbyte = ADRESL
Source = (adresult */ quanta )
Source = source * 288 ' to have a range of 7.2volt
Source = div32 100
' Read feedback motor voltage
' ---------------------------
'
ADCON0 = %00000001 ' select channel 0
pauseus 100
ADCON0.1 = 1
while ADCON0.1 ' wait for end of conversion
wend
Adresult.highbyte = ADRESH
adresult.lowbyte = ADRESL
voltage = (adresult */ quanta )
voltage = voltage * 144 ' to have 7.2V range
voltage = div32 100
voltage = source - voltage
' Voltage regulation
' ------------------
'
if voltage < selectedvoltage then
if tmr2dutyvar < 1023 then TMR2DutyVar=TMR2DutyVar+1
gosub initpwm
endif
if voltage>Selectedvoltage then
if tmr2dutyvar then TMR2DutyVar=TMR2DutyVar-1
gosub initpwm
endif
goto start
InitPWM:
'set Duty cycle
CCP1CON.5=Tmr2dutyvar.1
CCP1CON.4=Tmr2dutyvar.0
CCPR1L =(tmr2dutyvar>>2)
T2CON=%00000110 ' start timer 2
' set prescaler = 16
CCP1CON = %00001100 ' pwm mode for CCP1
return
jetpr
- 22nd February 2005, 19:41
Hi thanks for the help...
Hi what type of software do you use for draw the Schematics ...
mister_e
- 23rd February 2005, 07:07
Hi jetpr, I use P-CAD. I heard also some good comment on something called EAGLE.
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.