God bless you guys!
1-I connected 9v 450ma(I hope 450ma is fine) power supply and connected two 7805 paralel and used a 470uf between vdd and vss.Mcu doesnt reset itself and works fine! But I think servo works a little bit slower than past.I dont know why? maybe changing power supply from 5.2 to 5 makes this difference...If its neccessary I can put here its video...
2-I think I finished left-right position and wrote a new code to complete my project.I wrote this
but That doesnt work and servo2(up-down) made some stupid moves (like vibration).Also left-right motion gets very very slower...I know I made too many mistakes.But I learned here this forum too many things that I dont know.Everybody wants to help here and I was a little suprised at the beginning of this Thread.I put my code here.
Can you help me again? t for left-right j for up-down.I bounded "j" between 135 and 115
My code is....
Code:
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 0
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 4
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 5
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
DEFINE OSC 4
DEFINE ADC_BITS 8 'A/D çevirim sonucu kaç bit olacak
DEFINE ADC_CLOCK 3 'Clock kaynağı (3=rc)
DEFINE ADC_SAMPLEUS 100
SYMBOL F=PORTA.0
SYMBOL G=PORTA.1
alta var byte
usta var byte
altb var byte
ustb var byte
sola var byte
solb var byte
saga var byte
sagb var byte
k var byte
t var byte
i var byte
j var byte
ADCON1=2
TRISA=%00001111
TRISB=0
PORTB=0
TRISC=0
LCDOUT $FE,1
pause 2000
adcin 0,ALTa
ADCin 1,usta
adcin 2,sola
adcin 3,saga
T=150
j=125
yap:
adcin 0,altb
ADCin 1,ustb
adcin 2,solb
adcin 3,sagb
if ((((usta+10)*100)/(ustb+10)))>130 and (not (t>194)) then
T=T+15
endif
if (((alta*100)/altb))>130 AND (not (t<51)) then
T=T-15
endif
if ((((sola+10)*100)/(solb+10)))>130 and (not (t>134)) then
j=j+10
endif
if (((saga*100)/sagb))>130 AND (not (j<116)) then
j=j-10
endif
gosub motor2
gosub motor1
LCDOUT $fe,2,#usta," ",#ustb," ",#altA," ",#altb
lcdOUT $fe,$C0,#T," ",#j
goto yap
motor1:
for i=0 to 25
PAUSEUS 20000-(T*10)
PULSOUT PORTC.2,T
next
return
motor2:
for k=0 to 25
PAUSEUS 20000-(j*10)
PULSOUT PORTC.3,j
next
return
end
Bookmarks