knex robot car · web viewknex robot car a makers guide overview the k'nex robot car is...

17
Knex Robot Car A Makers Guide Overview The K'nex Robot Car is designed to enable primary school children to learn the basic concepts of programming by enabling them to build a robot of their own design and send a sequence of simple instructions for it to follow. An Intel Galileo gen 2 board is used to provide a private wifi hotspot that serves up interactive web pages using websockets protocol, to enable remote operation from a laptop, tablet or phone browser. From there the children can write their commands and send them to the robot for execution. A modified Adafruit v2 motor shield is used to drive the standard K'nex motors, together with ancillary circuits to regulate motor power and provide a battery test facility. All the electronics and batteries are housed in a case to make it robust enough for the school environment with external connectors provided for motors and sensors wired for compatibility with Grove devices. Basic Hardware The original design includes a number of extra features that are not strictly required in order to build the basic Robot Car. These are marked below with ** and links to the detailed design which you can follow if you prefer. Basic Parts List: (**Full Parts List here ) Intel Galileo gen2 Adafruit Motor shield v2 1xmicro SD card 4GB min (original made using 16GB) Batteries o 6 x rechargeable AA batteries o Battery holder for 6 AA & clip to connect to board o DC power jack WiFi o Intel Centrino Advanced-N 6235 WiFi PCIEx1 card (should also work with N135 or 6205) o Full size to half size mini PCIE bracket o 2x Antenna with RP-SMA female connectors o 2x U.FL to RP-SMA cables Hardware o 4x standoffs to mount in each corner of the Galileo board o Small bracket to mount the Antenna on 2x Knex motors Knex to build your robot car Basic Assembly: (** Full Assembly Instructions here )

Upload: others

Post on 27-Feb-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Knex Robot Car · Web viewKnex Robot Car A Makers Guide Overview The K'nex Robot Car is designed to enable primary school children to learn the basic concepts of programming by enabling

Knex Robot CarA Makers Guide

OverviewThe K'nex Robot Car is designed to enable primary school children to learn the basic concepts of programming by enabling them to build a robot of their own design and send a sequence of simple instructions for it to follow. An Intel Galileo gen 2 board is used to provide a private wifi hotspot that serves up interactive web pages using websockets protocol, to enable remote operation from a laptop, tablet or phone browser. From there the children can write their commands and send them to the robot for execution. A modified Adafruit v2 motor shield is used to drive the standard K'nex motors, together with ancillary circuits to regulate motor power and provide a battery test facility. All the electronics and batteries are housed in a case to make it robust enough for the school environment with external connectors provided for motors and sensors wired for compatibility with Grove devices.

Basic HardwareThe original design includes a number of extra features that are not strictly required in order to build the basic Robot Car. These are marked below with ** and links to the detailed design which you can follow if you prefer.

Basic Parts List: (**Full Parts List here) Intel Galileo gen2 Adafruit Motor shield v2 1xmicro SD card 4GB min (original made using 16GB) Batteries

o 6 x rechargeable AA batterieso Battery holder for 6 AA & clip to connect to boardo DC power jack

WiFio Intel Centrino Advanced-N 6235 WiFi PCIEx1 card (should also work with N135 or 6205)o Full size to half size mini PCIE bracketo 2x Antenna with RP-SMA female connectorso 2x U.FL to RP-SMA cables

Hardwareo 4x standoffs to mount in each corner of the Galileo boardo Small bracket to mount the Antenna on

2x Knex motors Knex to build your robot car

Basic Assembly: (** Full Assembly Instructions here)

1) Screw the stand offs into the four corners of the Galileo board so that it stands clear of the work surface.2) The Adafruit v2 Motor Shield is supplied with headers that must first

be soldered into place to enable the shield to plug into the top of the Galileo board.

3) Plug the Motor Shield onto the Galileo4) Solder the DC jack onto the battery clip. Take care to solder the red

wire to the centre pin of the jack and the black to the outer side of the jack as reverse polarity may damage your Galileo and/or shield.

5) Solder a wire onto the battery pack to take a tap off at 3.6V and a second wire to ground for use with Knex motors

6) Screw the mini PCIE bracket onto the Intel Centrino wireless card and insert the resulting module into the underside PCIE socket on the Galileo.

Page 2: Knex Robot Car · Web viewKnex Robot Car A Makers Guide Overview The K'nex Robot Car is designed to enable primary school children to learn the basic concepts of programming by enabling

7) Attach both U.FL to RP-SMA cables to the Centrino card and to the Antenna on the other end of each cable.

8) Wire the motors to the M1 (left motor) and M2 (right motor) screw connectors on the Adafruit shield.

9) Wire the 3.6V tap from the battery holder to the Adafruit shield Motor supply + screw connector. (Warning - test to make sure you have the right voltage tap from the battery connector and that you are applying +3.6V to the + connector and not the ground connector beside it!)

10) Wire the Ground tap from the battery to the Adafruit shield motor supply - screw connector.

Software

1) Download the SD card image from the web site here. It contains everything you need including the pre-loaded sketch to run the Robot Car.

2) Copy the files onto the micro SD using your computer.3) Insert the SD card into the Galileo.

Knex Robot Car

These photographs show the construction of the Knex Robot Car. The design can of course be changed but if the wheel size or distance between the wheels is changed then the calibration and maybe the software would need to be modified in order for the robot to turn exactly 90 degrees.

Operation

1) Insert 6 fully charged rechargeable AA batteries into the battery holder taking care to ensure they are inserted the right way around! The battery taps should be connected to the motor shield as described in the last section.

2) First try the Galileo running from its mains adaptor (with the battery taps connected to the motor shield). Keep the wheels in the air to avoid pulling on the mains adaptor wire.

3) Insert the DC jack into the the Galileo board and wait for it to boot up (1-2minutes). 4) Using a laptop or tablet scan for available wifi hotspots - you should see an open one called Edushield being

broadcast by the Galileo - connect to this.5) Once connected it will say there is a limited connection - this is normal as the Galileo is configured to only

provide a hotspot and not to connect to the internet.6) Start a recent version of Chrome browser (v34 or above) on your laptop or tablet and browse to edu.com -

you should then see the interface screen.7) To program the Robot Car, enter Forward, Back, Right, Left or Pause using the direction keys on the left

hand side. Instructions will then appear in order on the right hand side.8) Pressing Run should start the Robot moving in accordance with your instructions and will be highlighted in

green once each action is completed so you can follow the program.

Page 3: Knex Robot Car · Web viewKnex Robot Car A Makers Guide Overview The K'nex Robot Car is designed to enable primary school children to learn the basic concepts of programming by enabling

9) Once the Robot Car has been shown to work on its mains adaptor it is time to go mobile. Attach the battery clip to the batteries and test the DC jack to ensure that you have a voltage of about 7.2-8.4V with the centre of the jack positive.

10) Unplug the Galileo mains adaptor jack and replace with the jack from the batteries and follow steps 3-8 above and refer below for more detail on how t use the software.

11) Command Options:a. Forward Arrow - Move forward 20cmb. Back Arrow - Move back 20cmc. Right Arrow - Turn right 90 degreesd. Left Arrow - Turn left 90 degreese. Pause - Pause for 1 secondf. Headlights - Toggle headlights on or off each time command used **g. Horn - Sound horn **h. Red LED - Toggle red LED on shield on or off each time command used **i. Yellow LED - Toggle yellow LED on shield on or off each time command used **j. Green LED - Toggle green LED on shield on or off each time command used **** These commands only work if you have built the full version of the board

12) Control Optionsa. Run - Start running the program from the top of the tableb. Stop - Stop the currently running program after current instruction completedc. Reset - Change "Completed" status on each command to be "Not Started"d. Clear Table - Clears the current table of commands (confirm ok to accept)e. Back - Move back to last pagef. Calibrate - Pop-up enables calibration of Robot Car to move more accurately

13) Calibration Pop-Up screena. Note that new calibration values are only saved when Test is pressed. Ll values are kept on the SD

card and will be remembered after a cold boot. Values for each slider are arbitrary numbers between -100 and +100 representing small changes to the Robot Car movement.

b. It is recommended to always calibrate Balance Trim first.c. Balance Trim - Slider biases direction to left or right - press Test and Robot Car will move

forward 1.6 metres. If the car drifts right or left this can be corrected by altering the slider to compensate and testing again.

d. Forward/Back Trim Adjust the slider and press Test to ensure the Robot Car moves forward/back 20cm

e. Right/Left Trim - Adjust the slider and press Test to ensure the Robot Car moves right/left 90 degrees. Note the Test button causes the robot to go forward 20cm and then right or left and then forward 20cm again.

You should now have a fully working system! If you would like more details on the full prototype design and how it works, read on!

-----------------------------------------------------------------------------------------------------------------------------------------------------

Page 4: Knex Robot Car · Web viewKnex Robot Car A Makers Guide Overview The K'nex Robot Car is designed to enable primary school children to learn the basic concepts of programming by enabling

Full Version - OverviewThe full version of the Knex Robot Car adds some key features to the basic design explained previously to make it more suitable for children to learn and explore and provide expansion options to use the system in other lessons throughout the school.

The Galileo, shield, batteries and other circuits are all contained in a strong enclosure to avoid damage through handling.

A power socket is provided for the standard Galileo mains DC jack and a switch enables the system to be powered from mains or internal batteries.

To enable a quick test of the batteries before use a small push button is located on the front. When pressed LEDs indicate how well charged the batteries are (Yellow+Green = Full charge, Yellow=Good, No LED= time to recharge). This is especially useful in a classroom environment where several systems may be in use at once.

Phono/RCA Sockets are provided for up to 4x DC motors (or two stepper motors) avoiding the risk of incorrect wiring

RJ11 connectors provide access to I/O 0,1,2,3 Analogue 2,3 and I2C bus with VCC and Ground available on each socket. These are wired the same as sensors and actuators from Grove making it easy to connect their devices with a suitable adaptor.

Internally there is a stabilised supply for the Motor Shield derived from either mains power or batteries. This helps to maintain the accuracy of the Robot Car as batteries discharge.

Additions have also been made to the Adafruit Motor Shield in the prototyping area to provide 2x push switches, 3xLEDs, 1 Light Dependent Resistor, 1x Tilt swicth and an LCD display. The purpose of these components is to provide a basic framework of sensors and actuators which can be used by older students which can be extended via the external RJ11 sockets.

Full Parts List: Intel Galileo gen2 Adafruit Motor shield v2

o 3 x LEDs (Red, Green, Yellow)o 3 x 300Ω resistorso 2 x Push buttons (push to make, release to break)o 1 x tilt switch o 3 x 10kΩ resistorso 1 x 10kΩ potentiometero 1 x Light dependent resistoro 1 x 3.3kΩ resistoro 2 x 5 way headers as used to connect shield to Galileoo Wire to connect up components on shield prototyping area (wire wrap wire used on prototype)

Battery tester, stabilised motor supply and power componentso Three position double pole slide switch - on-off-ono Prototyping breadboard with copper plated solder pads around each holeo 1 x DC power jack socketo 1 x Push button (push to make)o LM317 variable stabilised voltage regulatoro 1 x 220Ω resistoro 1 x 1kΩ variable resistoro 1 x 100uF capacitoro 1 x 10uF capacitoro 1 x 0.1uF capacitoro 1 x 1N4001 diodeo LM339 quad comparatoro 2 x LEDs (Yellow, Green)o 2 x 220Ω resistorso 1 x 3V Zener diodeo 1 x 330Ω resistoro 1 x 56kΩ resistor

Page 5: Knex Robot Car · Web viewKnex Robot Car A Makers Guide Overview The K'nex Robot Car is designed to enable primary school children to learn the basic concepts of programming by enabling

o 1 x 2k7Ω resistoro 1 x 33kΩ resistoro 2 x 1kΩ resistoro 2 x 1MΩ resistor

1xmicro SD card 4GB min (original made using 16GB) Batteries

o 6 x rechargeable AA batterieso Built-in battery holder for 6 AAo DC power jack socket

WiFio Intel Centrino Advanced-N 6235 WiFi PCIEx1 card (should also work with N135 or 6205)o Full size to half size mini PCIE bracketo 2x Antenna with RP-SMA female connectorso 2x U.FL to RP-SMA cables

External Hardwareo 4x standoffs to mount in each corner of the Galileo boardo 150x80x50mm Translucent Blue Polycarbonate Boxo 4x Phono/RCA sockets for motorso 4 port RJ11 sockets for sensorso 3 position slide switch (on mains/off/on batteries)o Micro push button for battery test facilityo 4 x 0.1uF capacitors to reduce noise on external connector power rails

Components for modifications to shieldo …..

2x Knex motors Knex to build your robot car

Full Assembly (refer to circuit diagrams and external socket diagrams)

1) Screw the stand offs into the four corners of the Galileo board so that it stands clear of the work surface. (You may need to adjust the length later on to fit in the enclosure whilst leaving room for the batteries underneath)..

2) Adafruit v2 Motor Shield a. Solder the supplied headers into place to enable the shield to

plug into the top of the Galileo board. b. Using the prototyping area on the shield, solder the push

buttons, potentiometer , LEDs, LDR, Tilt Switch, Resistors and two 5 way headers for external connectors into place, wiring them up using the circuit diagram.

3) Battery tester, stabilised motor supply and power componentsa. Cut the breadboard to size to fit in the desired position within

the caseb. Solder the slide switch, push button, DC jack socket, LM339,

LM317 onto the top of the breadboardc. For space reasons the remaining components were soldered

underneath the board and wired by soldering with fine wire wrap - referring to the circuit diagram below.

d. Solder wires onto the board to the DC power jack, battery connector and motor supply

e. Test the circuit (without connecting it to the Galileo) to ensure that the correct voltage and polarity are reaching the DC power jack.

i. Put recharegable batteries in the battery holder and slide the switch to the battery position. ii. Measure the voltage at the DC power jack plug - you should see a voltage of around 7.2-

8.4V assuming a set of six charged batteries, with the centre pin positive.

Page 6: Knex Robot Car · Web viewKnex Robot Car A Makers Guide Overview The K'nex Robot Car is designed to enable primary school children to learn the basic concepts of programming by enabling

iii. Plug the Galileo mains adaptor into a socket on the wall and put its power jack into the DC power socket, then slide the switch across to the mains adaptor setting.

iv. Measure the voltage on the internal DC power jack - you should see a voltage of about 12V with the centre pin positive.

v. Finally if you push the battery test button both LEDs should light up for a battery voltage above 7.9V, For voltages between 7.15 and 7.9 just the yellow LED will light. Below 7.15V no LEDs will light indicating that the batteries need to be recharged.

4) Assembling the enclosurea. Test fit the Galilo in the enclosure and mark out where to cut to provide access to the two USB and

Ethernet sockets. Also mark holes in the underside lining up with the four stand offs on the board.b. Similarly test fit the Battery tester and motor supply board and mark out where to cut for slide

switch, DC power socket and battery test push button.c. Mark holes for the wifi antenna, 4 phono/RCA sockets and 4 port RJ11 sockets.d. Mark out a hole in the bottom to accept the battery holder.e. Mark holes in the lid to allow access to the push buttons and potentiometer on the shieldf. Cut out all holes and adjust to fit.g. Glue the 4 port RJ11 socket into place and screw in the four phono/RCA socketsh. Attach the wifi antenna cables/sockets to the end of the enclosure

5) Internal wiringa. Solder wires onto the 4 port RJ11 connector using the circuit

diagram for reference. b. On the other end of the RJ11 wires, solder a pins to insert into

the two 5 way headers soldered to the underside of the shield.

c. Solder wires onto the four phono/RCA sockets to lead up to the motor screw connectors on the shield.

6) Final assemblya. Insert the battery holder into the underside of the enclosure

and position the Battery tester and motor supply circuit board to align with holes in the enclosure.

b. Position the Galileo board into the enclosure and screw into place using the other end of the standoffs to secure the board to the base of the enclosure.

i. Connect the DC jack from the battery tester, motor supply and power board into the Galileo board.

ii. Add the shield and connect the pins from the RJ11 ports to the 10 way header under the shield.

iii. Connect the phono/RCA wires to the four motor terminals (M1-M4) on the shield. (If you find the motors work in reverse to that expected, swap the wires over.

iv. Connect the motor supply wires (+ and ground) from the battery test and motor supply board to the motor supply screw terminals on the shield.

Page 7: Knex Robot Car · Web viewKnex Robot Car A Makers Guide Overview The K'nex Robot Car is designed to enable primary school children to learn the basic concepts of programming by enabling

7) External devicesa. Wire each Knex motor to a phono/RCA plug with the white stripe wire going to the centre pin. These

can then be plugged into the phone/RCA sockets on the enclosure.b. The RJ11 ports provide the same signals and power as the Grove range of sensors. Therefore it is

possible to make up an adaptor cable with an RJ11 plug on one end and a Grove connector on the other to allow different sensors to be plugged in.

c. The software includes the ability to switch on headlights and sound a horn. This is achieved by wiring a cable with an RJ11 plug on one end (plugged into the I/O 2/3 RJ11 socket) and two LEDs and a piezo speaker on the other. (Refer to the circuit diagram for more detail).

Software

1) Download the SD card image from the web site here. It contains everything you need including the pre-loaded sketch to run the Robot Car.

2) Copy the files onto the micro SD using your computer.3) Insert the SD card into the Galileo and then switch on.

OperationOperation is as described earlier.

Software Overview

For those interested in adapting the software for their own uses, the following provides some information to help. This project was developed using the same approach as the Intel Connectanything code and shares a number of dependencies.

Galileo code (backend8_1.ino) outline:1) Updates the calibration array from the SD card2) Starts an access point script StartAP on the root of the Galileo3) Initialises Websockets to allow bidirectional asynchronous data transfer with client4) Loop() continuously checks flags to see if any execution is required eg:

a. Move motors, light LEDs or make a soundb. Update calibration data and save to SD card

5) If a websocket request is detected one of the following actions occursa. Serve up a web page from the SD card (note must be on white list in code)b. Command from web site received - set flag for loop() to respond to

6) If a websocket can be sent to the client thena. Check if a command confirmation is due to be sent and if so, send it

7) All data is sent and received using aJson which provides a method for standardising data structure

Environment

In order to recompile and change the code there are a few changes that need to be made to the standard setup as follows (assuming the Galileo already has Knex Robot Car SD card image loaded).1) Install the Adafruit Motor v2 from the Adafruit web site https://learn.adafruit.com/adafruit-motor-

shield-v2-for-arduino/install-software 2) The Adafruit Motor library requires a small change to the Adafruit_MotorShield.cpp file contained in

the library - comment out the lines as shown below near the top of the file. The reason is that Adafruit software assumes that if the board does not respond as an Arduino Uno, it must be a Due. However the Intel Galileo requires a standard Uno interface. (Notepad++ is a good free editor for this step).

//#ifdef __AVR__ #define WIRE Wire//#else // Arduino Due// #define WIRE Wire1//#endif

Page 8: Knex Robot Car · Web viewKnex Robot Car A Makers Guide Overview The K'nex Robot Car is designed to enable primary school children to learn the basic concepts of programming by enabling

3) Download the Knex Robot Car source files here.4) Install the aJson and libwebsockets libraries via the Galileo IDE5) Find the libwebsockets library folder and follow these instructions:

a. Copy libwebsockets.so and libz.so to : arduino-1.5.3-Intel.1.0.3\hardware\tools\x86\i586-poky-linux-uclibc\lib

b. Find platform.win.txt in arduino-1.5.3-Intel.1.0.3\hardware\arduino\x86 and rename it old.platform.win.txt

c. Copy the platform.win.txt from the folder arduino-1.5.3\hardware\tools\x86\i586-poky-linux-uclibc\lib to arduino-1.5.3-Intel.1.0.3\hardware\arduino\x86

d. Note: Revert to the normal platform.win.txt if you don't use the libwebsockets library6) A useful free tool to provide wireless access to the Galileo when running the Knex Robot Car software

(or Intel's Connectanything) is WinSCP. Provided you have the SD image on the Galileo up and running, this enables you to log into the Galileo remotely and move files between your PC and the Galileo - eg to update the front end web pages. There is also a terminal client that enables you to access the Linux command line. Use the following login credentials:

a. File Protocol: SCPb. Host name: 192.168.0.10c. User name: rootd. (no password)e. Click login to begin

7) Serial.print is used throughout the program to provide updates and debug info on data transfer between the Galileo and the client. To view these plug the USB cable from your PC into the Galileo, start the IDE and press <ctrl><shift>M to start the serial monitor. If you refresh the client browser you should see a stream of files being served to the client.

Known bugs

1) The system only works with recent Chrome browsers and more front end coding is required to take account of other browsers

2) Similarly the code does not scale to smaller screens.3) Numbers in the calibration screen only show up when the slider is moved

Page 9: Knex Robot Car · Web viewKnex Robot Car A Makers Guide Overview The K'nex Robot Car is designed to enable primary school children to learn the basic concepts of programming by enabling

123456 123456 123456 123456

I/O Table

I/O Pin Function5, 6, 9 Red, Yellow, Green LEDs (HIGH = on)0,1,2,3 External digital I/O on RJ11 sockets 1 (pins 3 & 4) and 2 (pins 3 & 4).

White LED headlights and horn use external I/O 2 and 3 respectively4, 7 Switch 1 and 2 (LOW = button pushed)8 Tilt switch (LOW = tilted)10-13 Not usedA0, A1 External Analogue I/O on RJ11 socket 2 (pins 3 and 4)A2 Light dependent resistorA3 Potentiometer

External Sockets & Controls

RJ11: Wiring view looking into sockets - note pins 1 & 6 not used.

Phono Sockets:

End Panel:

5V IO0 IO1 Gnd 5V IO2 IO3 Gnd 5V A0 A1 Gnd 5V SDA SCL Gnd

M1 M2 M3 M4

Antenna

Bat Off Mains

DC In

Battery Test

When Battery Test button pushed, Yellow+Green LED = Freshly charged batteries, Yellow = Batteries good, No LEDs = time to recharge batteries.

Back to Full Instructions

Page 10: Knex Robot Car · Web viewKnex Robot Car A Makers Guide Overview The K'nex Robot Car is designed to enable primary school children to learn the basic concepts of programming by enabling

Red LED300Ω

300Ω

300Ω

10KΩ10KΩ

Sw1 Sw2

5V

Gnd

Yellow LED

Green LED

5V

Gnd

5V

Gnd

A3

3K3Ω

LDR

10KΩ

123456 123456 123456 123456

0.1uF 0.1uF0.1uF 0.1uF

Shield Circuit diagrams

Back to Full Instructions

Header to RJ11 Header to RJ11

I/O 5

I/O 6

I/O 9I/O 4 I/O 7

A2

5VI/O 0I/O 1I/O 2I/O 3

GndA0A1SDASCL

Light Dependent Resistor Potentiometer

SwitchesLEDs

Page 11: Knex Robot Car · Web viewKnex Robot Car A Makers Guide Overview The K'nex Robot Car is designed to enable primary school children to learn the basic concepts of programming by enabling

240Ω

1KΩ

Internal DC Jack to Galileo

330Ω

3V Zener

56KΩ

2K7Ω

33KΩ

1MΩ

1MΩ

1KΩ

1KΩ

220Ω220Ω

GreenLED

YellowLED

Battery Test, Motor Supply and Power Circuit Diagrams

Back to Full Instructions

Power to centre pin

0.1uF

LM317

1N4001

100uF 10uF

Motor Supply +

Motor Supply -

Slide switch

Battery Holder

DC In Jack Socket forexternal power supply

Battery Test Circuit

Stabilised Motor Power Circuit

LM339

-+

+-

3

12

5

4

10

1113

2

Battery Test switch

Page 12: Knex Robot Car · Web viewKnex Robot Car A Makers Guide Overview The K'nex Robot Car is designed to enable primary school children to learn the basic concepts of programming by enabling

123456

300Ω

300ΩWhiteLEDs

PiezoSpeaker

RJ11 Plug rear view

NC

External Headlights & Horn Wiring

Back to Full Instructions