Download presentation
Presentation is loading. Please wait.
1
simple example program to control a DC-Motor
Next - Press the button (left)
2
Motorspeed controlled by Arduino
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 Next - Press the button (left)
3
The wider the pulse width,
Pulse-with-modulation Pwm 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. Next - Press the button (left)
4
Arduinos PINs for motordrive
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 Next - Press the button (left)
5
Arduinos Motorboard L9110S programming needs
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 ) 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. Next - Press the button (left)
6
Arduinos Motorboard L9110S programming needs
Name of the first motor object (you can use free names) Examples: // make an object for one Motor A with PWM-Ports 5,6 Motor myfirstMotor(MotorA); // or Motor myfirstMotor; // 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. connected with motorA on motorboard (see „wiring dc-motor“) Next - Press the button (left)
7
Arduinos Motorboard L9110S programming needs
Name of the first motor object (you can use free names) Examples: // make an object for one Motor A with PWM-Ports 5,6 Motor myfirstMotor(MotorA); // or Motor myfirstMotor; // 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. connected with motorA on motorboard (see „wiring dc-motor“) Name of the second motor (you can use free names) connected with motorB on motorboard (see „wiring dc-motor“) Next - Press the button (left)
8
Arduinos Motorboard L9110S programming needs
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 Next - Press the button (left)
9
Arduinos Motorboard L9110S programming needs
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 ...“! If you want to use the motorboard-functions for the L9119S motorboard, you must include the library „motorboard9110.h“ Next - Press the button (left)
10
Arduinos Motorboard L9110S programming needs
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 ...“! Next - Press the button (left)
11
Arduinos Motor drives forward with velocity of 50% = 127
PWM - 50% PWM - 75% Next - Press the button (left)
12
Arduinos Motor drives forward with velocity of 50% = 127
127 = 50% / 100% * 255 PWM - 50% PWM - 75% Next - Press the button (left)
13
Arduinos Motor drives forward with velocity of 75% = 191
PWM - 50% PWM - 75% Next - Press the button (left)
14
Arduinos Motor drives forward with velocity of 75% = 191
PWM - 50% 191 = 75% / 100% * 255 PWM - 75% Next - Press the button (left)
15
Arduinos Motor drives - sample sketch:
Based on the program, the motor should move forward and backward every two seconds. The orientation may vary depending on the wire connections. includes neccessary functions: ( press button for next) Next - Press the button (left)
16
Arduinos Motor drives - sample sketch:
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 one motor object Pin 5, 6 for motorA, (10, 11 for motorB) ( press button for next) Next - Press the button (left)
17
Arduinos Motor drives - sample sketch:
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) Next - Press the button (left)
18
Arduinos Motor drives - sample sketch:
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) Next - Press the button (left)
19
Arduinos Motor drives - sample sketch:
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) Next - Press the button (left)
20
Arduinos Motor drives - sample sketch:
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) Next - Press the button (left)
21
Arduinos Motor drives - sample sketch:
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) Next - Press the button (left)
22
Arduinos Motor drives - sample sketch:
Based on the program, the two motors should move forward and backward every two seconds. The orientation may vary depending on the wire connections. Next - Press the button (left)
23
Thank you: That was it Next - Press the button (left)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.