Robotics Learning Materials

From CoderDojo Saint Paul Shared Knowledge
Jump to navigation Jump to search

Warning: These instructions are all "wrong". They work, but as a group we have changed the wiring and associated program code settings. This month (September 2019), updates should be posted.

During CoderDojo Saint Paul Event 00000010, ten groups of Ninjas, Parents, and Mentors worked side-by-side building Robocars.

Everyone soon discovered that there are multiple ways that the parts could go together (and assembly is not as simple as LEGO).

The Robocar kit from Amazon cost about $23. https://smile.amazon.com/dp/B01CXVA6IO/

The motor driver that the kit comes with is perfectly good to use. We happened to have 10 of the lower-profile L293D motor driver, purchased at about $1.5 each from a seller in China, via eBay. It is not necessary to switch to using the L293D motor driver.

The Dallas Personal Robotics Group (DPRG) posted a video, demonstrating one way to build this same kit. The plug of the kit in that video differs a little.
https://www.youtube.com/watch?v=d9TXThtSUNM

Another great resource is DroneBot Workshop. The lessons are methodically and well-explained in videos and articles, including instructions on building a Smart Robot Car and other Arduino topics.

Following are the Build Steps Notes, Photos, and Test Code from the build completed by Leonidas and Bruce.

Tools Used: Small Screwdrivers, Wire Cutter, Wire Stripper (see notes below)

Original Build Steps

Note: This original build did not last long, as it had two issues:

1. In the code, the Servo library used disables PWM on Pins 9 and 10, which were used for one of the motors. Oops. 2. On some floor surfaces, the caster did not quickly change direction between forward and reverse, with the weight of the batteries over it.

  1. Mounted Motors and Switch on Bottom, with Motor Wires aligned on inside, towards Rear.
  2. Mounted Caster on Bottom at Rear, using two short Standoffs and four short Bolts.
  3. Mounted Arduino Uno using two short Standoffs and four short Bolts.
  4. Note: Header on Arduino initially obstructed flush/complete inserting of Bolt. Did not force it into place.
  5. Attached wires to Motor Driver VCC, GND, IN1, IN2, IN3, and IN4. We eventually bent all of these pins (forwards, as mounted), to lower the profile, allowing for more ground clearance.
  6. Mounted Motor Driver to Bottom of platform, between Caster base and platform, using two holes in platform where Castor could have attached.
  7. Attached wires to power side of Motor Driver:
    • A-, A+ to Right Motor
    • B-, B+ to Left Motor
    • GND, VCC to Male-to-Male wires (see notes below). The GND will attach to Battery Negative, and VCC will attach to Switch.
  8. Attached Sensor Shield atop Arduino Uno. Careful when inserting, as the Arduino is supported at only two points. Press the Shield pins fully into the Arduino Headers.
  9. Mounted Servo at front, to underside of platform.
  10. Attached wires to Ultrasonic Sensor.
  11. Attached Battery Holder with just one Bolt and Nut.
  12. Unused Parts saved for future use.
  13. At Sensor Shield, attached Motor Driver control wires to Pins 5, 6, 9, 10 -- all are PWM Pins. Any 5V and G Pins work for VCC and GND connections.
  14. At Sensor Shield, attached Ultrasonic Sensor Echo and Trigger control wires to Analog Pins A4 and A5. Any 5V and G Pins work for VCC and GND connections.
  15. At Sensor Shield, attached Servo control wire to Pin 2. Note: Servo needs PWM for full usability. Any 5V and G Pins work for VCC and GND connections.
  16. Changed power wiring such that Red V+ from Battery Pack is attached to one side of Switch. Other side of Switch is connected to power input of plug at Arduino, and VIN at Motor Driver. This change included cutting and leaving disconnected one of the red wires at the power input plug for the Arduino.

The Disc that came with the kit likely has useful information, like diagrams, videos, photos, example code, and instructions, but we have not looked at its contents yet. (Our primary computer does not have an optical disc drive.)

Notes: The kit did not come with any Male-to-Male wires. These were cut from an old electronic toy that no longer worked. This is what the Wire Cutter and Stripper tools were used for.

Updated Build Changes

Includes changes for Motor Driver Wiring and Center of Mass (Batteries Location).

  1. Moved positions of Arduino and Battery Pack, such that Center of Mass is closer to drive wheels, away from pivoting caster.
  2. On the Motor Driver, removed jumpers from EN1 and EN2, connected two more wires to EN1 and EN2, and bent Pins down to increase ground clearance. Note: The wire on the VCC Pin (next to the black wire) appears light gray, but it is white on the opposite side.
  3. On the Sensor Shield, the wiring for the Motor Driver is in the photos, and described in the code example.
  4. On the Sensor Shield, the white wire from the Motor Driver VCC Pin was intentionally left disconnected, because the Motor Driver logic circuitry shares power from the Motor VIN connection (which was unexpected and unwanted and I could not figure out how to disable this -- I wanted all of the power to go to the motors).
  5. On the Sensor Shield, the PWM Pins were marked red, for easier identification.
  6. On the Sensor Shield, the Ultrasonic Sensor wires were connected to URF01, which uses Pins A0 and A1.
  7. On the Sensor Shield, the yellow Power SEL jumper was disconnected, to not share power with the V Pins in the Digital Pins Block. Maybe this keeps more voltage available to the motors -- I do not know and did not measure it.
  8. Across the bottom in the photo of all Sensor Shield wiring, note the three exposed Pigtails.
    • The Pigtail on the left with two red wires connects V+ Battery output to one side of the Switch.
    • The Pigtail in the middle with three red wires connects the other side of the Switch to the Power of the round Plug into the Arduino, and to VIN of the Motor Driver.
    • The Pigtail on the right connects GND of Motor Driver to Ground of the round Plug into the Arduino. The other Ground wire from the round Plug connects to V- of the Battery Pack.

Original Build Photos

VKmaker Build 01 - Parts.jpg VKmaker Build 02 - Mounting Motors.jpg VKmaker Build 03 - Switch Mounted.jpg VKmaker Build 04 - Caster Position.jpg VKmaker Build 05 - Standoffs Positions for Arduino Uno.jpg VKmaker Build 06 - Header Obstructed Bolt Head.jpg VKmaker Build 07 - Arduino Uno Mounted.jpg VKmaker Build 08 - Motor Driver Mounting Prep.jpg VKmaker Build 09 - Motor Driver Mounted.jpg VKmaker Build 10 - Caster Mounted at only 2 Points.jpg VKmaker Build 11 - Caster Moved for more Motor Driver Wiring.jpg VKmaker Build 12 - Motor Driver Power Wiring.jpg VKmaker Build 13 - Sensor Shield Positioned.jpg VKmaker Build 14 - Servo Prep.jpg VKmaker Build 15 - Servo Mounted.jpg VKmaker Build 16 - Mounting Bracket for Ultrasonic Sensor.jpg VKmaker Build 17 - Wiring at Ultrasonic Sensor.jpg VKmaker Build 18 - Battery Holder Mounted.jpg VKmaker Build 19 - Unused Parts.jpg VKmaker Build 20 - Wiring View 1 at Shield.jpg VKmaker Build 21 - Wiring View 2 at Shield.jpg VKmaker Build 22 - Wiring View 3 at Shield.jpg VKmaker Build 23 - Power Wiring View.jpg VKmaker Build 24 - Ultrasonic Sensor Holder.jpg VKmaker Build 25 - Completed.jpg

Updated Build Photos

VKmaker Build 26 - Wiring at Motor Driver.jpg VKmaker Build 27 - Sensor Shield Wiring for Servo and Motor Driver.jpg VKmaker Build 28 - Sensor Shield Wiring for Servo and Motor Driver.jpg VKmaker Build 29 - Sensor Shield Wiring for Motor Driver.jpg VKmaker Build 30 - Sensor Shield Wiring for Ultrasonic Sensor.jpg VKmaker Build 31 - Sensor Shield Wiring.jpg VKmaker Build 32 - Completed again.jpg

Test Code

Following is a link to Arduino C code to compile and upload with a tool like Arduino IDE.

https://gist.github.com/ProgrammerBruce/9ec68b5dcee3fdf0ece9b3d1291668e3

At future events, we will learn more about using mBlock to write and deploy code to our robots. mBlock uses blocks, like the Scratch coding environment, which is especially great for kids who are not yet ready for typing.

Warning on the Servo

I tried to use the servos to swivel the ping sensor and I had several findings:

  • The servos are not very reliable. I had several that didn't work well out of the box or after moderate use.
  • The plastic gears in the servo are very easy to strip. The kids stripped 1/2 of them in the first event.
  • Most kids didn't understand the code needed to look right, look forward, look left and compare the distances.

My advise is to keep the initial labs simple and just use a fixed ping sensor. If the kids get that mastered with the turning logic then add the servo.