+ Reply to Thread
Results 1 to 5 of 5

Thread: Servo Problems

  1. #1

    Default 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

    ˇ'---------[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, >=[500,0], RRbit
    LOOKDOWN SenseRM, >=[1000,0], RMbit
    LOOKDOWN SenseRL, >=[500,0], RLbit
    Fbit =ˇˇ LineSnsrInF
    LOOKDOWN SenseLR, >=[1000,0], LRbit
    LOOKDOWN SenseLM, >=[500,0], LMbit
    LOOKDOWN SenseLL, >=[1000,0], LLbit




    RETURN



    Any info will bb great, thanks
    Attached Thumbnails Attached Thumbnails Click image for larger version

Name:	100_2138.jpg‎
Views:	69
Size:	278.0 KB
ID:	63200  
    Last edited by ForumTools; 10-03-2010 at 01:28 AM. Reason: Forum Migration

  2. #2

    Default

    The studering is caused by it reading the sensor, then moving the servo, then reading the sensor, then moving the servo, then reading the sensors again. I had the same problem with a Ping sensor and found that you only needed to read every so often not every pass through the program inorder to get the correct readings and not hit anything. It is a fine ballancing act between getting readings and causing the bot to move forward.
    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
    Last edited by ForumTools; 10-03-2010 at 01:28 AM. Reason: Forum Migration

  3. #3

    Default

    By the way neat project. Do you have any other pics or drawings or a maze layout yet?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tia'Shar Manetheren
    Last edited by ForumTools; 10-03-2010 at 01:28 AM. Reason: Forum Migration

  4. #4

    Default

    I'm having the exact same issue with my code, but I'm not really sure how to implement a solution. If my main function loops everytime, how do I separate out the checking of the sensors so they aren't checked with every run.

    Thanks!
    Last edited by ForumTools; 10-03-2010 at 01:28 AM. Reason: Forum Migration

  5. #5

    Default

    Implement a variable:

    Loopcount VAR BYTE


    Loopcount = 0
    ...

    PULSOUT Left
    PULSOUT Right
    Loopcount = Loopcount + 1
    IF LoopCount = 5 THEN
    ˇ GOSUB Read_Sensor
    ˇ LoopCount = 0
    END IF
    ...
    Last edited by ForumTools; 10-03-2010 at 01:28 AM. Reason: Forum Migration

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts