Help regarding auto matic Robot using QUICK START BOARD...

RITESH KAKKARRITESH KAKKAR Posts: 254
edited 2012-03-09 - 21:57:29 in Robotics
Hi Guys,

Please help me too complete this automatic robot, the working of this robot start with single press and the bot has to complete the task based on logic used in code...this video has three robot manual, automatic and collector all have to do different task as shown in animation film.
So, please have a look on this video for understanding it rule and task.

The Mechanical design and motor driver with encoder on whel are working, I am using DC metal gear motor for driving Bot and H-BRIDGES of L398 for controlling and encoder are mounted on wheel using photo transistor and IR TX which gives serial output form data....On one revolution 8 serial pulses are form.

The rule and theme are here. http://www.roboconindia.com/frmtheme2012.aspx
and game rule are here. http://www.roboconindia.com/frmtheme2012.aspx

Thanks
12022012403.jpg
a.jpg
12022012400.jpg


12022012402.jpg

Comments

  • GeorgeCollinsGeorgeCollins Posts: 132
    edited 2012-02-15 - 15:53:20
    That competition looks very cool. I am assuming that the robot you are currently working on is the Automatic Robot and not the manual one. I think a good place to start is with your H-Bridge circuit.


    1) You need to get batteries that are appropriate for the motors you have. You may already have that, but since I didn't see it in the picture I need to point that out.
    2) You need a power source for your propeller quick start board, if it is going to be the brains. An alternate approach is to use a lap top as your main cpu and the quick start board as an I/O interface to your H -Bridge, your sensor and your encoder.
    a) If you are using a laptop, your quickstart board will be powered though the USB
    b) If you are using an onboard power supply you can supply 4-9v to pin 40(+) and 39 (-)
    c) If you have a regulated 3.3v supply you can plug that in through J4 (I think)

    3) Connect your H-Bridge circuits to some pins on your board. For each motor you will use two pins on the propeller.
    4) Write some SPIN code (or PASM if you prefer) to set the two pins to the motor code to set the pins low low, high low, low high with a couple seconds pause between each transition. The motor should stop and then go in two directions.

    Getting the quickstart card to control the H-brdige is a good first step. Once you get that started we can help you with the encoder, the sensors, and so on.
  • RITESH KAKKARRITESH KAKKAR Posts: 254
    edited 2012-02-17 - 08:27:11
    I think a good place to start is with your H-Bridge circuit.


    1) You need to get batteries that are appropriate for the motors you have. You may already have that, but since I didn't see it in the picture I need to point that out.
    2) You need a power source for your propeller quick start board, if it is going to be the brains. An alternate approach is to use a lap top as your main cpu and the quick start board as an I/O interface to your H -Bridge, your sensor and your encoder.
    a) If you are using a laptop, your quickstart board will be powered though the USB
    b) If you are using an onboard power supply you can supply 4-9v to pin 40(+) and 39 (-)
    c) If you have a regulated 3.3v supply you can plug that in through J4 (I think)

    3) Connect your H-Bridge circuits to some pins on your board. For each motor you will use two pins on the propeller.
    4) Write some SPIN code (or PASM if you prefer) to set the two pins to the motor code to set the pins low low, high low, low high with a couple seconds pause between each transition. The motor should stop and then go in two directions.

    Hi,
    I have tested the H-BRIDGES with QS using PWM also working fine..!!
    so, I need to go for encoder with propeller using some count depend according to rule (they can be changed after hardware working)..
    so, i want to control both motors and encoder for now .

    thanks
  • Duane DegnDuane Degn Posts: 10,298
    edited 2012-02-18 - 09:45:51
    Hi Ritesh,

    There is an object in the OBEX, written by Kye, for using PWM on two motors.
    I know Kye also has an object for controlling a single motor with a quadrature encoder. The problem with that object is it requires the motor to have a quadrature encoder (two pulses 90 degrees out of phase). I think your encoders are just single pulse types.

    I don't know of an object that monitors a single pulse encoder. I think one could monitor a single pulse encoder with Spin by using counters. I personally have very little experience using the Propeller's counters. I tend to just copy parts of other programs that use counters when I need them in my programs.

    I'll try to find an example of a program that can count pulses.

    If I remember correctly, your encoders output 8 pulses per revolution of the wheel. It might be difficult to control the motors well with only 8 pulses per revolution.

    I've been working on a project off and on to drive four motors each with a quadrature encoder. I've found it difficult to maintain a desired speed with encoders that output 333 pulses per revolution. This doesn't mean one can't control a robot with only 8 pulses per revolution, just that I don't know how to do it.

    Hopefully your motors will be well matched to each other so they will both drive at the same speed given the same PWM signal.

    Have you been able to read the encoders with the QS yet?

    It sounds like you have been able to output a PWM to a motor. Can you control both motors using PWM from the QS?

    If your encoders run on 5V, you'll want to use 3.3K to 10K resistors between the encoder and the QS so the 5V pulses don't damage the Propeller chip.

    Please let us know more information about the encoders. I'll be looking for an example of a program that can count pulses.
  • Duane DegnDuane Degn Posts: 10,298
    edited 2012-02-18 - 10:14:39
    I found the post I was thinking of that showed how to count pulses. The code was written by Ariba.

    Here's the part that counts pulses.
    ctra := 010<<26 + 0     'set counter A for pulse counting at P0
        phsa := 0
        frqa := 1
        repeat until phsa > 0      'wait for first puls
        waitcnt(clkfreq/100 + cnt) 'wait while pulses are counted (10ms)
        id := phsa                 'number in phsa
        ctra := 0
    

    I'm guessing you'd just have the pulses counted in the background and check phsa every so often to see how many new pulses were counted.

    I'm thinking the code would be something like this.
    PUB MonitorMotors
    
      ctra := 010<<26 + 0     'set counter A for pulse counting at P0
      ctrb := 010<<26 + 1     'set counter B for pulse counting at P1 I'm not sure about this.
      phsa := 0
      frqa := 1
      phsb := 0
      frqb := 1
    
      repeat
        ' set motor speeds
        ' do other stuff
        if phsa > phsb 
          ' slow down motor A
        elseif phsa < phsb
          ' speed up motor A
        phsa := 0  ' reset to count again
        phsb := 0
    

    This is just a guess on my part of how the counters are working. You'd probably want to adjust the speeds of the motors based on how different the values of phsa and phsb are from each other.

    I hope someone with more counter knowledge and experience will jump in to correct me.
  • ercoerco Posts: 19,779
    edited 2012-02-18 - 12:14:16
    Duane Degn wrote: »
    I've been working on a project off and on to drive four motors each with a quadrature encoder. I've found it difficult to maintain a desired speed with encoders that output 333 pulses per revolution.

    Mecanum wheels, I'm guessing? :)
  • RITESH KAKKARRITESH KAKKAR Posts: 254
    edited 2012-02-18 - 21:17:07
    Have you been able to read the encoders with the QS yet?

    It sounds like you have been able to output a PWM to a motor. Can you control both motors using PWM from the QS?

    HI,

    I have control one motor only using PWM in one direction...
    and i am not able to read without any code!!

    Here is my algorithm of automatic robot...

    1. on pressing switch the robot start to move straight for few meters that will be counted by encoder mounted on wheel on one revolution 8 pulses will be there.
    2. then stop lift the load with help of rack, then move backward less than starting position.
    3. while moving in back direction stop and rotate 90* with help of encoder.

    Note: i am using PWM to match the speed of both driving wheel both motor rated for same RPM!!)

    so, i need object in which i can change the encoder number and PWM for both motors.
  • Duane DegnDuane Degn Posts: 10,298
    edited 2012-02-19 - 05:00:21
    Ritesh,

    Let's start with just driving both motors using PWM.

    I modified Kye's demo program to drive forward then backward. The backward amount is a little more than the forward amount. These amounts can easily be changed this is just to make sure the PWM object can control your motors.

    When we get this to work, we can add encoders.

    Here's my version of the program:
    CON
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
      _leftFW = 22 
      _leftBW = 23
      _rightFW = 20
      _rightBW = 21
      _LedPin = 16
      _ForwardRamp = 1
      _BackwardRamp = _ForwardRamp
      _DefaultForwardTime = 50 ' one second
      _DefaultBackwardTime = 55 ' 1.1 second
      _ForwardSpeed = 500 ' half speed for now
      _BackwardSpeed = _ForwardSpeed
      _timeStepInMilliseconds = 20  ' updates at 50Hz, similar to a hobby servo
      _updateFrequencyInHertz = 8_000
    VAR
      long nextUpdateTime, updateInterval
      
    OBJ
      hbd: "PWM2C_HBDEngine.spin"
    PUB Setup
      ifnot(hbd.HBDEngineStart(_leftFW, _leftBW, _rightFW, _rightBW, _updateFrequencyInHertz))
        reboot
      updateInterval := ((clkfreq / 1_000) * _timeStepInMilliseconds)
      
      dira[_LedPin] := 1            ' LED pin an output
      
      Main
    PUB Main
    
      DriveForward(_DefaultForwardTime)
      waitcnt(clkfreq / 2 + cnt)  ' wait half a second
      
      DriveBackward(_DefaultBackwardTime)
      repeat ' keep program running and flash LED to show program is done
        !outa[_LedPin]
        waitcnt(clkfreq / 2 + cnt)
    PUB DriveForward(driveTime) | localPwmIndex
      nextUpdateTime := cnt + updateInterval
       
      repeat localPwmIndex from 0 to _ForwardSpeed step _ForwardRamp
        hbd.leftDuty(localPwmIndex)
        hbd.rightDuty(localPwmIndex)     
        waitcnt(nextUpdateTime)
        nextUpdateTime += updateInterval
        
      repeat driveTime
        waitcnt(nextUpdateTime)
        nextUpdateTime += updateInterval
        
      repeat localPwmIndex from _ForwardSpeed to 0 step _ForwardRamp
        hbd.leftDuty(localPwmIndex)
        hbd.rightDuty(localPwmIndex)     
        waitcnt(nextUpdateTime)
        nextUpdateTime += updateInterval
        
    PUB DriveBackward(driveTime) | localPwmIndex
        
      nextUpdateTime := cnt + updateInterval
      
      repeat localPwmIndex from 0 to _BackwardSpeed step _BackwardRamp
        hbd.leftDuty(-localPwmIndex)
        hbd.rightDuty(-localPwmIndex)     
        waitcnt(nextUpdateTime)
        nextUpdateTime += updateInterval
        
      repeat driveTime
        waitcnt(nextUpdateTime)
        nextUpdateTime += updateInterval
        
      repeat localPwmIndex from _BackwardSpeed to 0 step _BackwardRamp
        hbd.leftDuty(-localPwmIndex)
        hbd.rightDuty(-localPwmIndex)     
        waitcnt(nextUpdateTime)
        nextUpdateTime += updateInterval
    

    I chose motor control pins that are connected to LEDs on the QuickStart board. The LEDs (on left side of QS) should get brighter as the motors go faster.

    Here is the section that assigns the motor control pins:
    _leftFW = 22 
      _leftBW = 23
      _rightFW = 20
      _rightBW = 21
    

    The current code only drives the motors up to half speed. We can change the speed and ramp amounts later.

    _DefaultForwardTime is how long the robot will travel forward in 20ms units. So when _DefaultForwardTime is set to equal 50, then the robot will travel forward for one second. This time does not include the time it takes to robot to "ramp up" to speed or the time for the robot to slow down to a stop.

    The LED on the right side of the QS should blink when the program is finished.

    This program compiles but I have not tested it with any motors. I did trying on a QS board and the LEDs on pins 20 and 22 get brighter and then dimmer followed by the LEDs on pins 21 and 23 also getting brighter and then dimmer. So I think it should work.

    I'll try to get some motors and encoders setup here so I can test the program too.

    Please let me know if this works in your robot. Once you can control both motors, we can start working on adding the encoders.
  • Duane DegnDuane Degn Posts: 10,298
    edited 2012-02-19 - 05:07:40
    erco wrote: »
    Mecanum wheels, I'm guessing? :)

    @erco, so as not to hijack Ritesh's thread too much, I posted my reply here.
  • Duane DegnDuane Degn Posts: 10,298
    edited 2012-02-19 - 06:00:37
    1. on pressing switch

    Do you have your button circuit made?

    Are you going to use a button or a switch? I suppose the switch could just be the power switch but if you want to use a push button, use a circuit like this:
                     3.3V
                      &#61463;        button
                      &#61628; 10K&#937;   &#9472;&#9531;&#9472;
      Prop Pin  &#61615;&#9472;&#9472;&#9472;&#9472;&#9472;&#9531;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9496; &#9492;&#9472;&#9488;
                                   &#61464; ground
     
    

    (Sorry if you already know this stuff.)

    In this circuit the pin is normally pulled high. When the button is pressed the pin will go low.

    It is also possible to use the QuickStart's touchpads as a start button. Jose uses the QS touchpads with his converted Boe-Bot. I don't think I'd suggest using the touchpads in this case. They aren't as reliable as a normal push button.

    Let me know what kind of button or switch you plan to use so I can include it in the next update to the code.
  • RITESH KAKKARRITESH KAKKAR Posts: 254
    edited 2012-02-19 - 08:11:21
    et's start with just driving both motors using PWM.

    I modified Kye's demo program to drive forward then backward. The backward amount is a little more than the forward amount. These amounts can easily be changed this is just to make sure the PWM object can control your motors.

    Hi,

    How to change the speed of motor i.e. PWM AND direction of motor from code..
    _DefaultForwardTime is how long the robot will travel forward in 20ms units. So when _DefaultForwardTime is set to equal 50, then the robot will travel forward for one second. This time does not include the time it takes to robot to "ramp up" to speed or the time for the robot to slow down to a stop.
    I am not getting as the calculation is based on encoder distance not by time delay because time delay will not work fine at all..(i think)
  • Duane DegnDuane Degn Posts: 10,298
    edited 2012-02-19 - 10:20:49
    How to change the speed of motor i.e. PWM AND direction of motor from code..

    This part of the code changes the speed of the motors.
      repeat localPwmIndex from 0 to _ForwardSpeed step _ForwardRamp
        hbd.leftDuty(localPwmIndex)
        hbd.rightDuty(localPwmIndex)     
        waitcnt(nextUpdateTime)
        nextUpdateTime += updateInterval
    

    The motors change speed from being stopped to rotating at half their maximum speed since "_ForwardSpeed" was set to 500. The possible speed values in Kye's object range from -1000 (full speed backward) to 1000 (full speed forward). A speed of zero is stopped.
    I am not getting as the calculation is based on encoder distance not by time delay because time delay will not work fine at all..(i think)

    As I said here:
    Duane Degn wrote: »
    When we get this to work, we can add encoders.

    and here:
    Duane Degn wrote: »
    Once you can control both motors, we can start working on adding the encoders.

    I was hoping you could control both motors before adding the encoders.

    Once again, I feel like you don't read my posts very carefully.

    If you're having trouble understanding English, you might be able to use Google Translate to translate the post into a language you are more comfortable reading.

    It would help me understand your posts better if you used question marks when asking a question. There have been several times when I'm not sure if you're just telling me something or asking a question.

    The program I posted above should move your robot forward and then backward.
    Duane Degn wrote: »
    Please let me know if this works in your robot.
  • RITESH KAKKARRITESH KAKKAR Posts: 254
    edited 2012-02-20 - 08:58:24
    This part of the code changes the speed of the motors.

    Code:

    repeat localPwmIndex from 0 to _ForwardSpeed step _ForwardRamp hbd.leftDuty(localPwmIndex) hbd.rightDuty(localPwmIndex) waitcnt(nextUpdateTime) nextUpdateTime += updateInterval

    The motors change speed from being stopped to rotating at half their maximum speed since "_ForwardSpeed" was set to 500. The possible speed values in Kye's object range from -1000 (full speed backward) to 1000 (full speed forward). A speed of zero is stopped.

    Hi,

    The code is working fine in both direction as i change the sign.....but why you are changing speed slowly not fast??
    what the reasons??
  • RITESH KAKKARRITESH KAKKAR Posts: 254
    edited 2012-02-20 - 09:02:58
    I notice one more thing that the motor work in both direction after one another with timing!!
  • Duane DegnDuane Degn Posts: 10,298
    edited 2012-02-20 - 09:28:47
    Hi,

    The code is working fine in both direction as i change the sign.....but why you are changing speed slowly not fast??
    what the reasons??

    How fast the speed changes if determined by the constant "_ForwardRamp". I just set this to equal 1 to test that the motors work correct. You can make the robot change speed much faster by changing this part of code:
    _ForwardRamp = 1
    

    Try:
    _ForwardRamp = 10
    

    or some other value for "_ForwardRamp".

    The robot will likely travel staighter if you ramp up to speed instead of just setting the speed at the highest value. It's also easier on the motors if they are ramped up to speed.
    I notice one more thing that the motor work in both direction after one another with timing!!

    This is good. It would be good to have a way of monitoring the encoder readings.

    You'd you be able to use a computer to use Parallax Serial Terminal with the QS and have the QS also connected to the motors and encoders?
  • RITESH KAKKARRITESH KAKKAR Posts: 254
    edited 2012-02-20 - 19:47:33
    Hi again,

    Yesterday, last year participation of this event has suggest not to use encoder for measuring distance because the surface on which robot will run will be very smooth so, there are chances of slipping wheel so, if this happen using encoder will make incorrect judgment as there are white block on arena line follower with counter will be better..
    Do you think this can happen???
  • Duane DegnDuane Degn Posts: 10,298
    edited 2012-02-20 - 20:22:45
    Hi again,

    Yesterday, last year participation of this event has suggest not to use encoder for measuring distance because the surface on which robot will run will be very smooth so, there are chances of slipping wheel so, if this happen using encoder will make incorrect judgment as there are white block on arena line follower with counter will be better..
    Do you think this can happen???

    My guess is it's easy to get a line following robot to drive straight than it is to use encoders for driving straight. I don't have much experience with either system so I'm hoping someone else will let us know what they think about these alternatives.

    Does the robot drive very straight with the current PWM program? Have you tried driving the robot on different surfaces to see if it has more trouble with one kind of surface than another?
  • RITESH KAKKARRITESH KAKKAR Posts: 254
    edited 2012-02-22 - 19:41:33
    Hi,

    If i want to use counter for many purposes, please tell how to write code for that???
  • Duane DegnDuane Degn Posts: 10,298
    edited 2012-02-22 - 20:32:06
    Chapter 7 (page 125) of the Propeller Education Kit (PEK) teaches how to use counters. The PEK can be found in the "Help" menu of the Propeller Tool v1.3.

    I think I already showed you about all I know about counters. As I mentioned before, I've just copied code from other programs that use counters when I've wanted to use them. Counters are one aspect of the Propeller I'd like to learn more about.
  • TtailspinTtailspin Posts: 1,326
    edited 2012-02-23 - 07:28:43
    @RITESH KAKKAR, could you remind us of which counter you are using for this application?
    It is not clear as to what you wish to count...


    @Duane Degn
    I know you know, but you can learn a lot just by google searching a name...
    You are a patient man Duane Degn... :smile:


    -Tommy
  • RITESH KAKKARRITESH KAKKAR Posts: 254
    edited 2012-03-09 - 08:16:39
    Trip to ROBOCON....

    HI,

    Here are some pic of our team for Robocon (more than 2,000km from my home)....
    720 x 540 - 50K
    720 x 540 - 51K
    720 x 540 - 50K
    720 x 540 - 67K
    720 x 540 - 69K
    720 x 540 - 53K
    720 x 540 - 61K
    720 x 540 - 64K
  • Duane DegnDuane Degn Posts: 10,298
    edited 2012-03-09 - 08:33:49
    Trip to ROBOCON 2012 in Pune(INDIA)....

    HI,

    Here are some pic of our team for Robocon 2012 in pune (more than 2,000km from my home)....

    Those are fun pictures. Thanks for posting them.

    Did you have fun?

    Are you in picture "6.jpg"? If so, which one are you?

    You guys look pretty tired in some of those pictures (especially in 9.jpg).
  • RITESH KAKKARRITESH KAKKAR Posts: 254
    edited 2012-03-09 - 21:57:29
    Did you have fun?

    Yes with learning...
    Are you in picture "6.jpg"? If so, which one are you?
    second from right.
    You guys look pretty tired in some of those pictures (especially in 9.jpg).
    Because we were continuously working 24hrs
Sign In or Register to comment.