Soirée Pratique Build your own robot

31
Soirée Pratique Build your own robot Motor control Download: http://www.ieee-sb-leuven.be/soireepratique2014 11/1/14 Nick Vanthienen

Transcript of Soirée Pratique Build your own robot

Page 1: Soirée Pratique Build your own robot

Soirée PratiqueBuild your own robot

Motor control

Download: http://www.ieee-sb-leuven.be/soireepratique2014

11/1/14

Nick Vanthienen

Page 2: Soirée Pratique Build your own robot

Sumo Robots:Roadmap 2014-2015

1) Brains: Arduino2) Muscles: motor and power (03/11)3) Eyes: sensors (24/11)

4) More brains: programming (2nd sem)5) Training session (2nd sem)6) Sumo Competition Leuven (2nd sem)

If you dare: WELEK Competition in Gent (30/04/2015)

11/1/142

Page 3: Soirée Pratique Build your own robot

Information

● https://www.facebook.com/groups/1713711248854304/

● http://www.ieee-sb-leuven.be/soireepratique2014

● Motors:

– http://powerfunctions.lego.com/en-us/ElementSpecs/8882.aspx

– http://www.philohome.com/pf/pf.htm

● Motor Controller:

– http://www.pololu.com/product/2511

Page 4: Soirée Pratique Build your own robot

The game

Dohyō (Dohyō (土俵土俵 ))

Page 5: Soirée Pratique Build your own robot

Some examples

Page 6: Soirée Pratique Build your own robot

Some examples

Page 7: Soirée Pratique Build your own robot

Some Examples

Page 8: Soirée Pratique Build your own robot

Competition Rules

Detailed 2013 rules can be found on http://www.ieee-sb-leuven.be/soireepratique2014

Rules will be approximately the same this year, however:

24x24cm dimensions instead of 25x25cm, to comply with new rules of Ghent.

11/1/148

Page 9: Soirée Pratique Build your own robot

Competition rules: most important robot specifications● Autonomous = no human commands● Harmless to other robots / humans / Doyho● Dimension limits: w x l= 24cm x 24 cm →only

at the start of the round● Unlimited height● Max. 1500g

Ask us first before you try something special :-)

Page 10: Soirée Pratique Build your own robot

Today

MotorsMotor Control

Power

Page 11: Soirée Pratique Build your own robot

Motors: Lego XL Motor

11/1/1411

We use the 2 middle wires of the 4 wire lego cables+9V = forward-9V = backwardPWM = control speed

Unused

Unused

Used

Page 12: Soirée Pratique Build your own robot

Motors: Lego XL Motor

11/1/1412

cut off the lego motor connector- or -

cut optional extension cable in half

Page 13: Soirée Pratique Build your own robot

H-Bridge

Page 14: Soirée Pratique Build your own robot

The motor controller: TI DRV8835 Chip

Dual-H-bridge motor driverMotor supply voltage: 2–11 VLogic supply voltage: 2–7 VOutput current: 1.2 A continuous (1.5 A peak) per motorTwo possible interface modes: IN/IN (outputs mostly mirror inputs) or PHASE/ENABLE (one pin for direction and another for speed)

11/1/1414

Page 15: Soirée Pratique Build your own robot

Motor controller 2013

11/1/1415

Arduino

BatteriesArduino

Page 16: Soirée Pratique Build your own robot

MM

M

+9v GND (-)

Motor Controller 2014

B

A

Option to power arduino from motor controller Remove blue jumper when USB connected!

9 Motor A Enable

7 Motor A Phase8 Motor B Phase

10 Motor B Enable

Batteries

Arduino + 5V and GND(Logic Power)

Page 17: Soirée Pratique Build your own robot

Motor Control 2014

● Motor A Phase (pin 7), Motor B Phase (pin 8)

– HIGH: Forward

– LOW: Backward● Motor A Enable (pin 9), Motor B enable (pin 10)

– HIGH: On, 9V

– LOW: Off, 0 V

– PWM: switch on/off rapidly, 0-9V, control speed

Page 18: Soirée Pratique Build your own robot

Motor Controller

● Soldering● Ask help when it's your first time● Don't toast your controller :-)

Page 19: Soirée Pratique Build your own robot

Motor Controller: soldering

Page 20: Soirée Pratique Build your own robot

Motor Controller: soldering

Page 21: Soirée Pratique Build your own robot

Example code: setup

int enablePinA = 9; // enable of motor A connected to digital PWM pin 9int phasePinA = 7; // phase of motor A connected to digital PWM pin 7int enablePinB = 10; // enable of motor B connected to digital PWM pin 10int phasePinB = 8; // phase of motor B connected to digital PWM pin 8

void setup() { pinMode(phasePinA, OUTPUT); pinMode(phasePinB, OUTPUT);}

11/1/1421

Page 22: Soirée Pratique Build your own robot

Example code: loopint turn_direction = HIGH;

void loop() {

digitalWrite(phasePinA, turn_direction); // set turn direction digitalWrite(phasePinB, !turn_direction);

// turn faster from min to max speed in increments of 5 points: for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) { analogWrite(enablePinA, fadeValue); // sets PWM value (range from 0 to 255) analogWrite(enablePinB, fadeValue); delay(30); // wait for 30 milliseconds to see the effect } // turn slower from max to min speed in increments of 5 points: for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) { analogWrite(enablePinA, fadeValue); // sets the value (range from 0 to 255) analogWrite(enablePinB, fadeValue); delay(30); // wait for 30 milliseconds to see the effect }

// switch turn direction turn_direction = !turn_direction;}

11/1/1422

Page 23: Soirée Pratique Build your own robot

Three ways to power your Arduino

USB5VMax 500 mA

Power Jack7-12VMax 1A

Between Vin and Gnd7-12V

Page 24: Soirée Pratique Build your own robot

Three ways to power your Arduino

USB power disabled when Vin > 6.6V

Compare Vin/2 with 3.3VVoltage RegulatorIn: 7-12V Out: 5V

Power Jack

Vin Pin

Page 25: Soirée Pratique Build your own robot

Power Arduino + Motor

● It is not possible to power the motors through the arduino!

● Therefore, the motor controller has a separate power supply

● It is possible to power the arduino through the motor controller: by adding the blue jumper

Page 26: Soirée Pratique Build your own robot

Power Arduino + Motor

Blue Jumper (removable)

Page 27: Soirée Pratique Build your own robot

MM

M

+9v GND (-)

Motor Controller 2014

B

A

Option to power arduino from motor controller Remove blue jumper when USB connected!

9 Motor A Enable

7 Motor A Phase8 Motor B Phase

10 Motor B Enable

Batteries

Arduino + 5V and GND(Logic Power)

Page 28: Soirée Pratique Build your own robot

Power Arduino + Motor

● Always OK: no blue jumper, USB connected

● Always OK: blue jumper, USB not connected

● OK: blue jumper, USB connected, batteries connected and > 6.6V

● NOT OK: blue jumper, USB connected, batteries connected and < 6.6V

– (the motors are powered through usb, and through the voltage regulator in reverse direction = fail!)

Page 29: Soirée Pratique Build your own robot

USB and low or no battery power, but motor shield connected to Vin (blue jumper)

USB power enabled when Vin < 6.6V

Compare Vin/2 with 3.3V Voltage RegulatorReverse FlowNot Allowed!

Vin PinTo motor controller

Page 30: Soirée Pratique Build your own robot

Batteries

Page 31: Soirée Pratique Build your own robot

Next session (24/11)Sensors

Bring sensors or order them with us

See you all next session!

11/1/1431