profmason.com

June 4, 2010

Motor Driver Board

Filed under: Daily — profmason @ 12:51 pm

Objective:

The goal is to design a motor shield for the purpose of teaching motor control in a modern embedded computing environment.   The popular arduino platform has substantial support and straight forward development tools that allow students to concentrate on developing control algorithms instead of learning software tools.  This also allows students to leverage and improve their c programming while providing a gentel introduction to embedded systems.    While there are a number of motor shields available for the arduino, none of them surveyed allow for closed loop control where current sensing is integrated into the motor driver.  In addition, most of the boards are suitable for lower currents which eliminates their utility for controlling existing equipment.  This project will create  an arduino motor shield for the standard Duemilanove board which can control up the three motors (1 high current (30 Amps) and 2 lower current (2.5 Amp) all with integrated current sensing for closed loop control. In addition, the board will have interfaces for quadrature encoders with analog pre-processing to simplify their implementation.

Details:

The planned board will focus on closed loop control.  An external board (arduino) will drive one high current motor (16V 30amps based on STMICROELECTRONICS  VNH2SP30-E) and two lower current drivers (28 V 2.5Amp continuous 5 Amp peak drivers based on the FREESCALE SEMICONDUCTOR MC33887VW).  Both the controllers will have current sensors routed back the the ADC on the micro for the closed loop control.  In addition there will be three interfaces for quadrature encoders based on a 74XX74 flip flop.

First the schematic for one of the low  current drivers.  (Thanks to pololu and datasheet)

Will need to build this twice sharing the power caps, reverse protection mosfet and power input.

Here is the schematic for the high current driver (Again thanks to datasheet and pololu)

Student Task Sequence:

  1. Understand the Arduino environment.  Install the current arduino environment and work through the basic tutorials on Lady Ada’s site.   Get familiar with checking out equipment from Smeaton 303.    You may be able to do this quickly, but take the time to understand them to save yourself grief later!
  2. Attach the ArduMotor board and interface it with the arduino.  Use the sample sketch on the linked page.  Chat with Dr. Lopes about some suitable motors in the lab to control.
  3. Define some simple objectives that you want to achieve with your test code with the arduoMoto board.  This could be writing routinues to have the motor run for a specified time, forward backwards etc.  If you are waiting for the protoboards to arrive (see next)  rig up some encoders for the motor.  (Either optical or hall effect.)  Interface these to the ardumotor board.  Write some code for the ardumotor board to do position control of the motors based on the encoders.
  4. Check and see if the 33887 and 2SP30 protoboards have arrived.  Assemble these.  (IE solder on headers and connectors.)   Read all the available information on these boards.
  5. Write some arduino code to control the two motor driver boards.  Port what you have done for the ardumotor board to support each of these boards.
  6. Use the current sense outputs from each of the boards.  First connect these to the ADC.  Will you need an amplifier for the current sense output?
  7. Once you understand the proto boards, lay out schematics to include all the parts on one shield.  Meet with Shelia and the staff in SM303 to learn about this process at the Uni.  Do some research to find a default cad model for an arduino shield.  Think about all the things that need to go on the board.  Use all surface mount components.  Try to make the board with one controller(VN) and the other on the opposite(MC)  Minimize the number of vias between the two sides of the board!!!!!!!!  We can’t do plated thru holes.
  8. Order components.  The motor driver chips and mosfets are already ordered.  You will need to sort out all the small components with Shelia. Generate a BOM etc.
  9. Have the board made.  Work with Shelia Storm and Bob to coordinate this.
  10. Populate the board.
  11. Test the board.
  12. While you are waiting for the board to be made start thinking about control code using the current sense data and/or the encoder data.  Read about PID control.   Implement a P, PD, and PID controller on the board.    If you are stuck waiting on hardware, work in matlab and create a model of the transfer function of the system.  Dr. Lopes will advise you during this portion.
  13. Once your board is tested and bugs are worked out, design a final product that takes into account good design criteria relative to an end user perspective.  Convert the design to double sided and 2 or 4 layer using a much finer pitch.  Think carefully about optimal connectors and connector placement.  Get a set of quotes from local (Dr. Culverhouse is the inhouse expert on this.) and international vendors (olimex in romania and golden phoenix in china) to produce a set of 10 of the final board.
  14. Write your report!

June 3, 2010

Updated Competition Robot Code:

Filed under: Daily — profmason @ 3:16 pm

The Bioloid Gait Software has been ported to the new CM-700.  The software has been tested with AX-12+, RX28, RX24, RX64 and DX117 servos and can run them all interchangeably.   Note, no accommodations have been made for the different servo speeds so the servo group speeds will need to be recalculated.  In addition the software has been massively cleaned and streamlined.  All compiler warnings in main.c have been eliminated and substantial commenting has been introduced.  For detailed information see my report on the bioloid real time control software.

How to get started with the CM700:

  1. Unzip the zip file (2June2010ProjectFiles)
  2. Open AVR-Studio.
  3. Open the Project file  (bioloid.aps)
  4. You may modify main.c to implement changes.
  5. Choose Build->Build and wait about 30 seconds
  6. On conclusion it should report “Build Succeeded”
  7. In your project directory you now have a file called “bioloid.hex”
  8. Open Robot Terminal
  9. Hold the # key.
  10. Power cycle the CM700
  11. The prompt “SYSTEM-O.K. CM700 BOOTLOADER 1.51) should appear
  12. Type LD
  13. Select Files->Transmit File and select your bioloid.hex file
  14. It will report “Transmitting Data” and should conclude after about 30 seconds with “Success”

Here is the main loop.  (Now should be readable!)

  1. //——————————————————————————
  2. // Main Function called each time Micro is restarted
  3. //——————————————————————————
  4. int main(void)
  5. {
  6. //——————————————————————————
  7. // Initialization (Done Once)
  8. //——————————————————————————
  9.         InitializeRobot();
  10.         int             Tick = 0;
  11.         RobotFlags = 0;
  12. //——————————————————————————
  13. // Main Loop (Never Terminates)
  14. //——————————————————————————
  15.         for(;;)
  16.         {
  17.                 if (RobotFlags & _BV(MSGRCV))       //Check to see if anything came in on the serial port
  18.                 {
  19.                         cli();   //Clear Interrupts
  20.                         RobotFlags=RobotFlags & ~_BV(MSGRCV);
  21.                         sei();  //Set Interupts
  22.                         if(CheckProtocol())
  23.                                 OnGoodPacket()//This function is in comms.c and is the main messaging function
  24.                 }
  25.                 if (RobotFlags & _BV(HBEAT))  //Check to see if a heartbeat happened, if it did, do the next Tick
  26.                 {
  27.                         cli(); //Clear Interrupts
  28.                         RobotFlags=RobotFlags & ~_BV(HBEAT);
  29.                         sei(); //Set Interupts
  30.                         Set_LED(LED_RXD, LED_OFF);
  31.                         ZigbeeHeartBeat();
  32.                         if(Tick==0)  //Ticks per pose is implemented so that the main motion only happens when Ticks is 0
  33.                         {
  34.                                 IMUReport(IMU_Report_Flag);   //Do IMU sensor reporting if set
  35.                                 ServoReport(Servo_Report_Flag); //Do Servo reporting if set
  36.                                 FootReport(Foot_Report_Flag);  //Do foot sensor reporting if set
  37.                                 if (UsingPoseSystem==2)  //If Usingposesystem = 2 then we are controlling servos directly
  38.                                 {
  39.                                         UpdateServosDirectly();
  40.                                 }
  41.                                 if (UsingPoseSystem==0)  //The UsingPoseSystem is used to turn on and off the dynamic gait.
  42.                                 {
  43.                                         DynamicGait();
  44.                                         PoseNum++;
  45.                                         if (PoseNum >= NumPoses) PoseNum = 0;
  46.                                 }
  47.                         }
  48.                         Tick++;
  49.                         if (Tick >= Ticks_Per_Pose) Tick = 0;  //Restart the Tick Counter
  50.                 }
  51.         }
  52. }

Repairing White Bioloid

Filed under: Daily — profmason @ 3:06 pm

Symptoms:

All servos work normally but when commands are sent rapidly to the robot, the system stutters as if there is an accumulated delay associated with each additional servo.

Solution:

Reflash the servos with the most current firmware:

  1. Open Roboplus
  2. Plug in a USB>Dynamixel
  3. Connect the servos to the USB->Dynamixel
  4. Connect the servos to power (Could be from CM5 with default firmware)
  5. Open Dynamixel Wizard
  6. Open the Port and connect to your USB>Dynamixel
  7. Start Search (If problems, make sure they have power, try them one at a time)
  8. After it finds the connected servos Click firmware update
  9. Update the servos.
  10. If you still have problems check the status return time (0) and the status return level (2) for each servo.

Powered by WordPress