Macgman2000 wants my code...
I wrote a new code to protect values which makes out of range.
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
DEFINE ADC_CLOCK 3
DEFINE ADC_SAMPLEUS 100
SYMBOL F=PORTA.0
SYMBOL G=PORTA.1
alta var byte
usta var byte
altb var byte
ustb var byte
ADCON1=2
TRISA=3
TRISB=0
PORTB=0
TRISC=0
LCDOUT $FE,1
pause 4000
adcin 0,ALTa
ADCin 1,usta
t var byte
i var byte
T=150
yap:
adcin 0,altb
ADCin 1,ustb
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
gosub motor
LCDOUT $fe,2,#usta," ",#ustb," ",#altA," ",#altb
lcdOUT $fe,$C0,#T
goto yap
motor:
for i=0 to 25
PULSOUT PORTC.2,T
PAUSEUS 20000-(T*10)
next
return
end
I am using breadboards.A minute ago i tried to connect two parallel power supply.Servo didnt reset MCU.I was glad but sometimes when i turned power on ,servo turned full left sometimes didnt.I think my servos are crazy
.BTW I connected a capacitor.
I have an idea.Can this error(full left error) occur because of my code that i wrote.too many PAUSEUS may make this error.Should I try DUTYCYLE or PWM codes???
Or Is there any power problem???
Bookmarks