با سلام خدمت دوستان.من یه برنامه نوشتم که یک پتانسیومتر به adc میکرو mega32 وصل میشه و با چرخاندن مقاومت موتور به صورت چپ گرد و راست گرد حرکت می کند. با استفاده از l298.مشکلی که پیش اومده اینه که وقتی پتانیسومتر ثابت هست خروجی های میکرو که به l298 وصل هستن خود بخود موتور رو به چپ و راست حرکت می دهند. من فکر می کنم که از نویزی هست که در مدار تولید میشه. برنامه رو می فرستم تا این مشکل حل بشه
config ADC = Single , Prescaler = Auto , refrence = off
Start ADC
config portc.7 = output
config portc.6 = output
declare sub G1
declare sub Gr
declare sub S
dim a as word
dim b as word
do
a = Getadc(7)
waitms 100
b = Getadc(7)
if a > b then
call G1
endif
if b > a then
call Gr
endif
if a = b then
call s
endif
loop
end
sub G1
portc.7 = 1
portc.6 = 0
end sub
sub Gr
portc.7=0
portc.6=1
end sub
sub S
portc.7 = 0
portc.6 = 0
end sub
Start ADC
config portc.7 = output
config portc.6 = output
declare sub G1
declare sub Gr
declare sub S
dim a as word
dim b as word
do
a = Getadc(7)
waitms 100
b = Getadc(7)
if a > b then
call G1
endif
if b > a then
call Gr
endif
if a = b then
call s
endif
loop
end
sub G1
portc.7 = 1
portc.6 = 0
end sub
sub Gr
portc.7=0
portc.6=1
end sub
sub S
portc.7 = 0
portc.6 = 0
end sub
دیدگاه