2 Replies Latest reply on Jul 2, 2013 1:25 PM by jesusantoniocar

    PSoC 4 Pioneer Kit Community Project#043 – Rise of the Machines (Rolling Robot)




      Today’s post is our first robotics example. In this example we demonstrate driving two DC motors using the LadyAda Motor Shield to drive a robot around in an arbitrary pattern. For this example you will need the following hardware:


      Forum Post Attachments:


      At the bottom of this post we are including the following items:

      • Example Project Zip File
      • Zip File of Images
        • Project Schematic
        • Component Configurations


      Components Used:


      The user can download the example project at the bottom of this post. The project uses the following list of Creator Components:

      • PWM
      • SPI
      • CyClock
      • CyPin


      The components are configured by right clicking on the component in your Top Design schematic view and selecting Configure. Please enable the following selections in the Configuration windows for the listed components above.


      Firmware Description:


      The main.c firmware is included in the example project. Please review the commented sections for more details.


      In this example we have added two firmware files that abstract the motor controls to simple API calls. These APIs will allow you to easily control the direction and speed for four DC motors. In this example we only have two motors, but the files are expandable to four. Please include these files in your project to give you immediate and easy control of the motors. The following is a list of APIs that you will be able to use:


      • void MotorShield_Start(uint8 motors)
      • void MotorShield_Stop(uint8 motors)
      • void MotorShield_SetDirection(uint8 motors, uint8 direction)
      • void MotorShield_SetPWMCompare(uint8 motors, uint16 PWMCompare);


      In our firmware example we have the robot switching between driving one motor at full speed while holding one motor fixed. This will drive the motor in a circle. After a fixed amount of time the robots motors are flipped. The fixed motor is turned on and the spinning motor is stopped. The robot will then circle in the opposite direction. This action will continue to loop forever.


      Hardware Connections:


      In this example the user will need to connect the motor shield to the Pioneer board. Once connected the pioneer board should be fixed to the Robot Chassis using some screws and nuts. The Pioneer board has mounting holes on the four corners of the kit. Double-sided Sticky tape can also be used to hold the kit and battery pack on the Chassis.

      Connect the power Jumper on the Motor Shield.


      The H-bridges on the motor shield must be powered to drive the motors. Connecto your batteries at either the Vin/Ground pins to the right of the power jumper, or the +M/GND terminal block to the left of the motor power jumper.


      The LadyAda board requires a 5V supply for the shift registers. Power the 5V signal using either a differential tap on your batteries (3 AAs should work fine), or a 5V regulator using the Vin rail as the input.


      Connect the left and right motors to the M1 and M2 terminal blocks. If either motor moves backwards, flip the direction logic in firmware, or flip the wires around.


      Test Your Project:


      Program the kit and place the robot on the ground. Then power the kit using the AA battery pack. The kit will pause for 2 seconds and then begin to roll around on the ground. Make sure your dog is put away. There are no refunds for Pioneer kits attacked by dogs!


      I hope this example can help you in your design.