Skip to content
Snippets Groups Projects
Commit a8531c40 authored by Adrián Torres's avatar Adrián Torres
Browse files

motor_adrianino

parent d4454c7a
No related branches found
No related tags found
No related merge requests found
Pipeline #187762 passed
......@@ -82,6 +82,7 @@
<ul class="actions">
<li><a href="#outputs" class="button primary">Outputs</a></li>
<li><a href="#lcd" class="button">LCD</a></li>
<li><a href="#motor" class="button">DC Motor</a></li>
<li><a href="#servo" class="button">Servo motor</a></li>
</ul>
<ul class="actions">
......@@ -876,6 +877,68 @@ void loop() {
<p><video controls width="100%"; max-width="800"><source src="images/adrianino/lcd.mp4" type="video/mp4"></video></p>
<h2><a id="motor"></a>DC Motor</h2>
<p>To control a DC motor we will use an H bridge, such as the <a href="https://www.digikey.com/product-detail/en/allegro-microsystems-llc/A4953ELJTR-T/620-1428-1-ND"><b>Allegro A4953.</b></a> With this driver we can control all types of motors through <b>PWM signals.</b> </p>
<li><b>Connection and schematic</b></li>
<p>In this case, being a component without a module, I create my own. I design and manufacture a small board where I solder the Allegro A4953 driver, a 1uF capacitor, a 10uF capacitor and with the flat connectors where there is no room for mistakes when connecting it. It includes two traces to feed with the 9V battery. I use two digital output of the ATtiny1614 PA4 (Arduino pin 0) and PA5 (Arduino pin 1).</p>
<span class="image main"><img src="images/adrianino/a_19.jpg" alt="" /></span>
<p>Here you can find the design in Eagle and the PNG's to create the board.</p>
<p><a href="assignments/adrianino/motor_eagle.zip"><b>- Motor Schematic + Board</b></a>
<p><a href="assignments/adrianino/motor_png.zip"><b>- Motor traces</b></a></p>
<p><img src="images/adrianino/a_20.jpg" width="70%"; max-width="700" /></p>
<li><b>Programming</b></li>
<p>Here you can find a program that moves the motor, but when you press the button it stops, and when you release it, it starts again, accelerating progressively. Here you can find the Arduino file to download.</p>
<p><a href="assignments/adrianino/hello_motor/hello_motor.ino"><b>- Arduino Hello Motor</b></a>
<pre><code>//Fab Academy 2020 - Fab Lab León
//Motor
//Adrianino
//ATtiny1614
const int switch1Pin = 10; // switch 1
const int motor1Pin = 0; // H-bridge pin 0 (in2)
const int motor2Pin = 1; // H-bridge pin 1 (in1)
void setup() {
// set the switch pins as input pins and activate their internal pull up resistors
// so they are not in a floating state because their default state is now HIGH
pinMode(switch1Pin, INPUT);
// set H-bridge pins as outputs:
pinMode(motor1Pin, OUTPUT);
pinMode(motor2Pin, OUTPUT);
}
void loop() {
// if switch1 is pressed, (=LOW because the unpressed 'pulled up' state is HIGH)
if (digitalRead(switch1Pin) == LOW) {
analogWrite(motor1Pin, 127); // set pin 1 of the H-bridge to 50% using PWM
analogWrite(motor2Pin, 0); // set pin 2 of the H-bridge to low state
}
// if neither of the switches are pressed, the motor will stand still
else
{
digitalWrite(motor1Pin, LOW); // set pin 1 of the H-bridge low
digitalWrite(motor2Pin, LOW); // set pin 2 of the H-bridge low
}
}</code></pre>
<p><video controls width="100%"; max-width="800"><source src="images/adrianino/motor.mp4" type="video/mp4"></video></p>
<h2><a id="servo"></a>Servo motor</h2>
<p>A very common output is a servo. A servomotor is a device similar to a direct current motor that has the ability to be located in any position within its operating range, and remain stable in that position. In this case I use a 0 to 180 degree servo.</p>
......
//Fab Academy 2020 - Fab Lab León
//Motor
//Adrianino
//ATtiny1614
const int switch1Pin = 10; // switch 1
const int motor1Pin = 0; // H-bridge pin 0 (in2)
const int motor2Pin = 1; // H-bridge pin 1 (in1)
void setup() {
// set the switch pins as input pins and activate their internal pull up resistors
// so they are not in a floating state because their default state is now HIGH
pinMode(switch1Pin, INPUT);
// set H-bridge pins as outputs:
pinMode(motor1Pin, OUTPUT);
pinMode(motor2Pin, OUTPUT);
}
void loop() {
// if switch1 is pressed, (=LOW because the unpressed 'pulled up' state is HIGH)
if (digitalRead(switch1Pin) == LOW) {
analogWrite(motor1Pin, 127); // set pin 1 of the H-bridge to 50% using PWM
analogWrite(motor2Pin, 0); // set pin 2 of the H-bridge to low state
}
// if neither of the switches are pressed, the motor will stand still
else
{
digitalWrite(motor1Pin, LOW); // set pin 1 of the H-bridge low
digitalWrite(motor2Pin, LOW); // set pin 2 of the H-bridge low
}
}
File added
File added
docs/images/adrianino/a_19.jpg

296 KiB

docs/images/adrianino/a_20.jpg

123 KiB

File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment