Servo Problems
hello all , this is my micromouse that is going to reach the center of a maze (at least thats the plan).· I am using 7 sensors, 6 to see the top of the maze and 1 to detect the walls infront.··It is running on a BS2 micro and servos. The 6 sensors are·designed to function as QTI sensors and work exactly like there more expensive counterparts.· I am using case statements to get me to the desired subroutines (gosub forward, gosub right...ect).· Everything is working fairly well except that when im in my go forward sub and one side of the sensors is not··detecting any wall my servos still go foward but·they·start studdering which·messes up my alignment.· So as an example if the right group detects the wall it will read 010 and with·corrections it will·try to keep the wall·in the middle, this is the same with the left group 010.....now·a wall is not detected on either side the servos start to·studder.· here is my code for this sub
··Forward:
DO
········ PULSOUT 15, 650
········ PULSOUT 14, 820
···· GOSUB Read_Sensor
··· IF ( RRbit = %0) AND (RMBit = %1) AND (RLbit = %1)AND (LRbit = %0) AND (LLbit = %1) AND (LMbit = %1)THEN
········ DEBUG "Correction left", CR
········ PULSOUT 15, 650
········ PULSOUT 14, 820 -50
··· ENDIF
··· IF ( RRbit = %0) AND (RMBit = %0) AND (RLbit = %1)AND (LRbit = %0) AND (LLbit = %0) AND (LMbit = %1)THEN
········ DEBUG "Correction left extreme", CR
········ PULSOUT 15, 650
········ PULSOUT 14, 820· -65
··· ENDIF
··· IF( RRbit = %1) AND (RMbit = %1) AND (RLbit = %0) AND (LRbit = %1) AND (LMbit = %1) AND (LLbit = %0)THEN
········ DEBUG "Correction right",CR
········ PULSOUT 15, 650··· +60
········ PULSOUT 14, 820
··· ENDIF
··· IF( RRbit = %1) AND (RMBit = %0) AND (RLbit = %0)AND (LRbit = %1) AND (LLbit = %0) AND (LMbit = %0)THEN
········ DEBUG "Correction right extreme",CR
········ PULSOUT 15, 650·· +80
········ PULSOUT 14, 820
··· ENDIF
LOOP WHILE(Fbit <> %0)
RETURN
Now I think the problem is with read sensors sub b/c when i remove there is no studdering but now the little bastard is running blind.· here is the read_sen sub
·'
[noparse][[/noparse]Subroutines Read_Sensor]
'This sub reads the 7 sensor values and converts them to binary
Read_Sensor:
'Middle sensor input
LineSnsrInF = IN9
'Power On
HIGH LineSnsrPwrR ' activate Right group sensors
HIGH LineSnsrPwrL ' activate Left· group sensors
'Right Group
HIGH LineSnsrInRR ' discharge Right right QTI cap
HIGH LineSnsrInRM ' discharge Right middle QTI cap
HIGH LineSnsrInRL ' discharge Right left QTI cap
'Left Group
HIGH LineSnsrInLR ' discharge Left right QTI cap
HIGH LineSnsrInLM ' discharge Left middle QTI cap
HIGH LineSnsrInLL ' discharge Left left QTI cap
PAUSE 1
'Right Group
RCTIME LineSnsrInRR, 1, SenseRR ' read Right right sensor value
RCTIME LineSnsrInRM, 1, SenseRM ' read Right middle sensor value
RCTIME LineSnsrInRL, 1, SenseRL ' read Right left sensor value
'Left Group
RCTIME LineSnsrInLR, 1, SenseLR ' read Left right sensor value
RCTIME LineSnsrInLM, 1, SenseLM ' read Left middle sensor value
RCTIME LineSnsrInLL, 1, SenseLL ' read Left right sensor value
'Power Off
LOW LineSnsrPwrR· ' deactivate Right sensor
LOW LineSnsrPwrL· ' deactivate Left sensor
'Raw data conversion to 1 bit value
LOOKDOWN SenseRR, >=[noparse][[/noparse]500,0], RRbit
LOOKDOWN SenseRM, >=[noparse][[/noparse]1000,0], RMbit
LOOKDOWN SenseRL, >=[noparse][[/noparse]500,0], RLbit
Fbit =·· LineSnsrInF
LOOKDOWN SenseLR, >=[noparse][[/noparse]1000,0], LRbit
LOOKDOWN SenseLM, >=[noparse][[/noparse]500,0], LMbit
LOOKDOWN SenseLL, >=[noparse][[/noparse]1000,0], LLbit
RETURN
Any info will bb great, thanks
··Forward:
DO
········ PULSOUT 15, 650
········ PULSOUT 14, 820
···· GOSUB Read_Sensor
··· IF ( RRbit = %0) AND (RMBit = %1) AND (RLbit = %1)AND (LRbit = %0) AND (LLbit = %1) AND (LMbit = %1)THEN
········ DEBUG "Correction left", CR
········ PULSOUT 15, 650
········ PULSOUT 14, 820 -50
··· ENDIF
··· IF ( RRbit = %0) AND (RMBit = %0) AND (RLbit = %1)AND (LRbit = %0) AND (LLbit = %0) AND (LMbit = %1)THEN
········ DEBUG "Correction left extreme", CR
········ PULSOUT 15, 650
········ PULSOUT 14, 820· -65
··· ENDIF
··· IF( RRbit = %1) AND (RMbit = %1) AND (RLbit = %0) AND (LRbit = %1) AND (LMbit = %1) AND (LLbit = %0)THEN
········ DEBUG "Correction right",CR
········ PULSOUT 15, 650··· +60
········ PULSOUT 14, 820
··· ENDIF
··· IF( RRbit = %1) AND (RMBit = %0) AND (RLbit = %0)AND (LRbit = %1) AND (LLbit = %0) AND (LMbit = %0)THEN
········ DEBUG "Correction right extreme",CR
········ PULSOUT 15, 650·· +80
········ PULSOUT 14, 820
··· ENDIF
LOOP WHILE(Fbit <> %0)
RETURN
Now I think the problem is with read sensors sub b/c when i remove there is no studdering but now the little bastard is running blind.· here is the read_sen sub
·'
[noparse][[/noparse]Subroutines Read_Sensor]
'This sub reads the 7 sensor values and converts them to binary
Read_Sensor:
'Middle sensor input
LineSnsrInF = IN9
'Power On
HIGH LineSnsrPwrR ' activate Right group sensors
HIGH LineSnsrPwrL ' activate Left· group sensors
'Right Group
HIGH LineSnsrInRR ' discharge Right right QTI cap
HIGH LineSnsrInRM ' discharge Right middle QTI cap
HIGH LineSnsrInRL ' discharge Right left QTI cap
'Left Group
HIGH LineSnsrInLR ' discharge Left right QTI cap
HIGH LineSnsrInLM ' discharge Left middle QTI cap
HIGH LineSnsrInLL ' discharge Left left QTI cap
PAUSE 1
'Right Group
RCTIME LineSnsrInRR, 1, SenseRR ' read Right right sensor value
RCTIME LineSnsrInRM, 1, SenseRM ' read Right middle sensor value
RCTIME LineSnsrInRL, 1, SenseRL ' read Right left sensor value
'Left Group
RCTIME LineSnsrInLR, 1, SenseLR ' read Left right sensor value
RCTIME LineSnsrInLM, 1, SenseLM ' read Left middle sensor value
RCTIME LineSnsrInLL, 1, SenseLL ' read Left right sensor value
'Power Off
LOW LineSnsrPwrR· ' deactivate Right sensor
LOW LineSnsrPwrL· ' deactivate Left sensor
'Raw data conversion to 1 bit value
LOOKDOWN SenseRR, >=[noparse][[/noparse]500,0], RRbit
LOOKDOWN SenseRM, >=[noparse][[/noparse]1000,0], RMbit
LOOKDOWN SenseRL, >=[noparse][[/noparse]500,0], RLbit
Fbit =·· LineSnsrInF
LOOKDOWN SenseLR, >=[noparse][[/noparse]1000,0], LRbit
LOOKDOWN SenseLM, >=[noparse][[/noparse]500,0], LMbit
LOOKDOWN SenseLL, >=[noparse][[/noparse]1000,0], LLbit
RETURN
Any info will bb great, thanks
Comments
Say if a 1 was move the servo and a 0 was to read the sensors then your program works like this.
101010101010101010101010101010
you would want it to work like this 1111011110111101111011110.
Or even longer on the move 111111101111111011111110 to get the servo to complete a rotation and not have a stutter or herky jerky motion to it.
By the way you might want to put your move forward last that way if some problem is detected in front of you you do not move forward then correct for what is in front of you.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tia'Shar Manetheren
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tia'Shar Manetheren
Thanks!
Loopcount VAR BYTE
Loopcount = 0
...
PULSOUT Left
PULSOUT Right
Loopcount = Loopcount + 1
IF LoopCount = 5 THEN
· GOSUB Read_Sensor
· LoopCount = 0
END IF
...