Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Motor and servo mounting experiment, Exercises of C programming

Motor and servo mounting: Lab will go smoother if your motor and servo are attached to something. The pictures below show a cardboard box with motors and servos attached using twist-ties and paper clips. If you don’t mount them on something, they have a tendency to walk across the table, potentially becoming disconnected and even becoming irreparably damaged in the process.

Typology: Exercises

2020/2021

Uploaded on 01/29/2024

ali-tarig-1
ali-tarig-1 🇺🇸

1 document

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lab 6: Motors, Servos, and H-Bridges
Name: __________________________________ Section:____
Score: ______ / 100
Pre-Lab Recommendations
Motor and servo mounting: Lab will go smoother if your motor and servo are
attached to something. The pictures below show a cardboard box with motors and
servos attached using twist-ties and paperclips. If you don’t mount them on
something, they have a tendency to walk across the table, potentially becoming
disconnected and even becoming irreparably damaged in the process.
Soldering and Strain Relief: You will need to solder jumper wires to the metal tabs on
the back of the DC motor. Immediately after soldering the wires, use a zip tie to
provide strain relief as shown in the pictures below:
EGR 107 Introduction to Engineering Design II Page 1
pf3

Partial preview of the text

Download Motor and servo mounting experiment and more Exercises C programming in PDF only on Docsity!

Lab 6: Motors, Servos, and H-Bridges

Name: __________________________________ Section:____

Score: ______ / 100

Pre-Lab Recommendations

Motor and servo mounting: Lab will go smoother if your motor and servo are attached to something. The pictures below show a cardboard box with motors and servos attached using twist-ties and paperclips. If you don’t mount them on something, they have a tendency to walk across the table, potentially becoming disconnected and even becoming irreparably damaged in the process. Soldering and Strain Relief: You will need to solder jumper wires to the metal tabs on the back of the DC motor. Immediately after soldering the wires, use a zip tie to provide strain relief as shown in the pictures below:

Lab Activity:

  1. Write an Arduino program that controls a DC Motor using the H-Bridge board. a. Must include a function that sets the direction of the motor and speed i. Input Arguments: int Direction, int Speed b. Program should read from the serial port i. Receiving value ‘0’ sets the motor speed to 0 ii. Receiving value ‘9’ sets the motor speed to 255 iii. Values ‘1’ – ‘8’ are equally spaced speeds between 0 - 255 iv. Receiving ‘F’ sets the motor direction to FORWARD v. Receiving ‘R’ sets the motor direction to REVERSE c. Program should acknowledge the user input by echoing back what it received: i. i.e. “You entered a speed of X” OR “You entered a direction of Y” d. here is an example of checking for serial input from the user: i. https://www.arduino.cc/reference/en/language/functions/communication/s erial/available/ ii. Note: Serial.read() only reads ASCII characters! So, when you type in a 5, the variable is assigned the ASCII code for ‘5’.
  2. Write an Arduino program that moves the position servo in 10 degree increments through its entire range of motion, returning to the starting point. a. Must include a function that accepts the next desired angle as an input argument and sends the appropriate command b. Pause at each angle for 0.5 seconds
  3. Write an Arduino program that combines parts 1 and 2 in such a way that the servos is incrementing or decrementing while the Arduino is also listening for serial input. You must use a state machine. a. the Arduino should respond immediately to any serial input i. the code cannot wait until the servo has reached a certain position before checking for serial input ii. your final code cannot use any delay statements b. Hint: this should be done with a carefully-planned state machine. Start with a state diagram! See next page for rubric and submission details.