Download presentation
Presentation is loading. Please wait.
Published byMolly Boone Modified over 8 years ago
1
Istituto Tecnico Industriale A.Monaco EURLAB Moving a robot simple example program to control a DC-Motor Next - Press the button (left)
2
Istituto Tecnico Industriale A.Monaco EURLAB Moving a robot Motorspeed controlled by Arduino Next - Press the button (left) The speed of a DC motor depends on the voltage (see diagram). Arduino cannot supply variable DC output. Then you must use the Pulse-width modulation (PWM) to simulate a variable DC supply voltage
3
Istituto Tecnico Industriale A.Monaco EURLAB Moving a robot Pulse-with-modulation Pwm Next - Press the button (left) A Pulse Width Modulation (PWM) Signal is a method for generating an analog signal using a digital source. The wider the pulse width, the more average voltage applied to the motor terminals, the stronger the magnetic flux inside the armature windings and the faster the motor will rotate and this is shown now. http://www.electronics-tutorials.ws/blog/pulse-width-modulation.html
4
Istituto Tecnico Industriale A.Monaco EURLAB Moving a robot Arduinos analogWrite() Next - Press the button (left) A call to analogWrite() is on aanalogWrite scale of 0 – 255. Such that analogWrite(3,255) requests a 100% duty cycle (always on). analogWrite(3,127) is a 50% duty cycle (on half the time) for example
5
Istituto Tecnico Industriale A.Monaco EURLAB Moving a robot Arduinos analogWrite() Next - Press the button (left) Look for the ~ prefix on the digital pin label, e.g. ~3 Arduino Uno has 6 PWM pins: Digital I/O pins 3, 5, 6, 9,10, and 11
6
Istituto Tecnico Industriale A.Monaco EURLAB Moving a robot Arduinos Motorboard L9110S programming needs Next - Press the button (left) If you use the motor board "L9110S," you need some functions to it: -Forward(velocity) -Backward(velocity) -Stop() (velocity is a value for the speed of the motor between 0.. 255) You have to create an object to use these functions. The object has a name. This object is placed in front of each function. So you can use several motors with the same functions.
7
Istituto Tecnico Industriale A.Monaco EURLAB Moving a robot Arduinos Motorboard L9110S programming needs Next - Press the button (left) Examples: // make an object for one Motor A with PWM-Ports 5,6 Motor myfirstMotor; // or Motor myfirstMotor(MotorA); // make an object for one Motor B with PWM-Ports 10,11 Motor mysecondMotor(MotorB); // make an object for one Motor X with PWM-Ports 3,9 Motor mythirdMotor(3,9); Note: A maximum of two motor-objects can be generated.
8
Istituto Tecnico Industriale A.Monaco EURLAB Moving a robot Arduinos Motorboard L9110S programming needs Next - Press the button (left) Call of the functions: // motor A turns with velocity - 50% - forward myfirstMotor.Forward(127); // motor B turns with velocity - 75% - backward mysecondMotor.Backward(191); // Motor A and Motor B stops and wait one second myfirstMotor.Stop(); mysecondMotor.Stop(); delay(1000); // wait one second
9
Istituto Tecnico Industriale A.Monaco EURLAB Moving a robot First step – include „Motorboard9110.h“: If you do not find this Include-File you must download the file „Motorboard9110.zip“ from the MindMap and you must include this zip-file with „Add.ZIP Library...“! Arduinos Motorboard L9110S programming needs Next - Press the button (left)
10
Istituto Tecnico Industriale A.Monaco EURLAB Moving a robot If you do not find this Include-File you must download the file „Motorboard9110.zip“ from the MindMap and you must include this zip-file with „Add.ZIP Library...“! Arduinos Motorboard L9110S programming needs Next - Press the button (left)
11
Istituto Tecnico Industriale A.Monaco EURLAB Moving a robot Arduinos Motor drives forward with velocity of 50% = 127 Next - Press the button (left) PWM - 50% PWM - 75%
12
Istituto Tecnico Industriale A.Monaco EURLAB Moving a robot Arduinos Motor drives forward with velocity of 50% = 127 Next - Press the button (left) PWM - 50% PWM - 75% 127 = 50% / 100% * 255
13
Istituto Tecnico Industriale A.Monaco EURLAB Moving a robot Arduinos Motor drives forward with velocity of 75% = 191 Next - Press the button (left) PWM - 50% PWM - 75%
14
Istituto Tecnico Industriale A.Monaco EURLAB Moving a robot Arduinos Motor drives forward with velocity of 75% = 191 Next - Press the button (left) PWM - 50% PWM - 75% 191 = 75% / 100% * 255
15
Istituto Tecnico Industriale A.Monaco EURLAB Moving a robot Arduinos Motor drives - sample sketch: Next - Press the button (left) Based on the program, the two motors should move forward and backward every two seconds. The orientation may vary depending on the wire connections. includes neccessary functions: ( press button for next)
16
Istituto Tecnico Industriale A.Monaco EURLAB Moving a robot Arduinos Motor drives - sample sketch: Next - Press the button (left) Based on the program, the two motors should move forward and backward every two seconds. The orientation may vary depending on the wire connections. Define two motor objects (Pin 5, 6 for motor1, 10, 11 for motor 2 ( press button for next)
17
Istituto Tecnico Industriale A.Monaco EURLAB Moving a robot Arduinos Motor drives - sample sketch: Next - Press the button (left) Based on the program, the two motors should move forward and backward every two seconds. The orientation may vary depending on the wire connections. no needs in setup ( press button for next)
18
Istituto Tecnico Industriale A.Monaco EURLAB Moving a robot Arduinos Motor drives - sample sketch: Next - Press the button (left) Based on the program, the two motors should move forward and backward every two seconds. The orientation may vary depending on the wire connections. Motor turns forward for two seconds ( press button for next)
19
Istituto Tecnico Industriale A.Monaco EURLAB Moving a robot Arduinos Motor drives - sample sketch: Next - Press the button (left) Based on the program, the two motors should move forward and backward every two seconds. The orientation may vary depending on the wire connections. Motor turns forward for two seconds ( press button for next) Motor stops for one seconds ( press button for next)
20
Istituto Tecnico Industriale A.Monaco EURLAB Moving a robot Arduinos Motor drives - sample sketch: Next - Press the button (left) Based on the program, the two motors should move forward and backward every two seconds. The orientation may vary depending on the wire connections. Motor turns forward for two seconds ( press button for next) Motor stops for one seconds ( press button for next) Motor turns backward for two seconds ( press button for next)
21
Istituto Tecnico Industriale A.Monaco EURLAB Moving a robot Arduinos Motor drives - sample sketch: Next - Press the button (left) Based on the program, the two motors should move forward and backward every two seconds. The orientation may vary depending on the wire connections. Motor turns forward for two seconds ( press button for next) Motor stops for one seconds ( press button for next) Motor turns backward for two seconds ( press button for next) Motor stops for one seconds ( press button for next)
22
Istituto Tecnico Industriale A.Monaco EURLAB Moving a robot Arduinos Motor drives - sample sketch: Next - Press the button (left) Based on the program, the two motors should move forward and backward every two seconds. The orientation may vary depending on the wire connections.
23
Istituto Tecnico Industriale A.Monaco EURLAB Moving a robot Thank you: That was it Next - Press the button (left)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.