Lab #2: Arduino Programming Basics

The Arduino Programming Basics Lab was designed to introduce students to the automatic control system hardware components of the AEV and demonstrate the purpose of these components in this project. To do this, students were given an AEV controller, an AEV motor mount desktop stand, two motors, a USB cable, and a Li-Po Battery. The component focused on the most throughout this lab was the AEV controller. The AEV controller is made up of an Arduino Nano microcontroller and two motor chips, but the heart of the AEV Controller is actually the Arduino Nano. This component is used to control the motor speed, the time or distance the motors are set to run for, and the recording system data. Once the lab equipment was assembled, students were taught basic function cells used in the Arduino Integrated Development Editor software. To accelerate or decelerate the motors, “celerate(motor number, start % speed, end % speed, time span for celeration in seconds)” was used. In order to change the motor speed, “motorSpeed(motor number, % speed)” was used. To run the motor at the initialized state for dt seconds, “goFor(dt)” was used and to brake the motors “brake(motor number)” was used. The final basic function call students learned was “reverse(motor number)” to reverse the polarity of the motors. The basic function cells were used to create a simple program that followed the scenarios provided in the Lab Manual.

This lab was important because the team of engineers was able to familiarize themselves with the Arduino program and the commands necessary to drive the motors propelling the AEV. The simplicity of the Arduino code allows all group members to understand and modify the code in order to make the AEV as efficient as possible. The lab succeeded in teaching the team the commands necessary to manipulate the vehicle such as accelerating the motors over a time, running the motors at a certain power percentage, reversing the motors direction, and breaking the motor which doesn’t break the AEV, but only stops the power being supplied to the motor. Based on the observations of the students, the Arduino commands given by this lab will be enough for the engineers to create and control an AEV, and modify it to make it as efficient as possible.


Code 1—Scenario 1:
celerate(1,0,15,2.5);     //accelerate motor 1 from 0% to 15% in 2.5 seconds
motorSpeed(1,15);     //set motor 1 to 15% power
goFor(1);                  //go for 1 sec
brake(1);                  //brake motor one
celerate(2,0,27,4);     //accelerate motor 2 from 0% power to 27% power in 4s
motorSpeed(2,27);    //set motorspeed to 27% power
goFor(2.7);                //go for 2.7 seconds
celerate(2,27,15,1);   //accelerate motor 2 from 27% power to 15% power in 1s
brake(2);                 //brake motor 2
reverse(2);                //reverse the direction of motor speed 2
celerate(4,0,31,2);    //accelerate all motor from 0% to 31% power in 2 seconds
motorSpeed(4,31);   //set motorspeed to 31% for all motors
goFor(2);                  //go for 2 seconds
brake(2);                  //break motor 2
motorSpeed(1,35);  //set motor 1 to 35% power
goFor(3);                  //go for 3 seocnds
brake(4);                  //brake for 4 seconds
goFor(1);                  //go for 1 seconds
reverse(1);                //reverse the speed of motor 1
celerate(1,0,19,2);   //accelerate motor 1 from 0 to 19% in 2 seconds
motorSpeed(2,35);  //set motorspeed 2 to 35%
motorSpeed(1,19);  //set motor 1 to 19% power
goFor(2);                  //continue for 2 seconds

Code 2—Scenario 2:
reverse(4);               // Reverse all motors
motorSpeed(4, 25);        // Set all motors to 25% power
goFor(0.5);               // Run last command for 0.5 seconds (all motors at 25%)
brake(4);                 // Set all motors to 0% power immediately
goFor(0.1)                // Run last command for 0.1 seconds (brake all motors)
reverse(4);               // Reverse all motors
motorSpeed(4, 25);        // Set all motors to 25% power
goFor(0.5);               // Run last command for 0.5 seconds (all motors at 25%)
brake(4);                 // Set all motors to 0% power immediately
goFor(0.1)                // Run last command for 0.1 seconds (brake all motors)
reverse(4);               // Reverse all motors
motorSpeed(4, 25);        // Set all motors to 25% power
goFor(0.5);               // Run last command for 0.5 seconds (all motors at 25%)
brake(4);                 // Set all motors to 0% power immediately
goFor(0.1)                // Run last command for 0.1 seconds (brake all motors)
motorSpeed(4, 15);        // Set all motors to 15% power
goFor(0.3);               // Run last command for 0.3 seconds (all motors at 15%)
brake(4);                 // Set all motors to 0% power immediately
goFor(0.05);              // Run last command for 0.05 seconds (brake all motors)
motorSpeed(4, 40);        // Set all motors to 40% power
goFor(0.3);               // Run last command for 0.3 seconds (all motors at 40%)
motorSpeed(4, 25);        // Set all motors to 25% power
goFor(0.5);               // Run last command for 0.5 seconds (all motors at 25%)
motorSpeed(4, 15);        // Set all motors to 15% power
goFor(0.3);               // Run last command for 0.3 seconds (all motors at 15%)
brake(4);                 // Set all motors to 0% power immediately
goFor(0.05);              // Run last command for 0.05 seconds (brake all motors)
motorSpeed(4, 40);        // Set all motors to 40% power
goFor(0.3);               // Run last command for 0.3 seconds (all motors at 40%)
motorSpeed(4, 25);        // Set all motors to 25% power
goFor(0.5);               // Run last command for 0.5 seconds (all motors at 25%)
brake(4);                 // Set all motors to 0% power immediately
goFor(0.5);               // Run last command for 0.5 seconds (brake all motors)
motorSpeed(4, 55);        // Set all motors to 55% power
goFor(0.5);               // Run last command for 0.5 seconds (all motors at 55%)
brake(4);                 // Set all motors to 0% power immediately
goFor(0.1);               // Run last command for 0.1 seconds (brake all motors)
motorSpeed(4, 55);        // Set all motors to 55% power
goFor(0.5);               // Run last command for 0.5 seconds (all motors at 25%)
brake(4);                 // Set all motors to 0% power immediately
goFor(0.1)                // Run last command for 0.1 seconds (brake all motors)
motorSpeed(4, 55);        // Set all motors to 55% power
goFor(0.5);             // Run last command for 0.5 seconds (all motors at 25%)
brake(4);                 // Set all motors to 0% power immediately
goFor(0.1)                // Run last command for 0.1 seconds (brake all motors)
motorSpeed(4, 65);        // Set all motors to 65% power
goFor(0.05);              // Run last command for 0.05 seconds (all motors at 25%)
brake(4);                 // Set all motors to 0% power immediately
goFor(0.05);              // Run last command for 0.05 seconds (all motors at 25%)
motorSpeed(4, 40);        // Set all motors to 40% power
goFor(0.3);               // Run last command for 0.3 seconds (all motors at 40%)
motorSpeed(4, 20);        // Set all motors to 20% power
goFor(0.5);               // Run last command for 0.5 seconds (all motors at 20%)
motorSpeed(4, 15);        // Set all motors to 15% power
goFor(0.3);               // Run last command for 0.3 seconds (all motors at 15%)
brake(4);                // Set all motors to 0% power immediately
goFor(0.05);              // Run last command for 0.05 seconds (brake all motors)
motorSpeed(4, 40);        // Set all motors to 40% power
goFor(0.3);               // Run last command for 0.3 seconds (all motors at 40%)
motorSpeed(4, 25);        // Set all motors to 25% power
goFor(0.5);               // Run last command for 0.5 seconds (all motors at 25%)
brake(4);                 // Set all motors to 0% power immediately

Arduino Programming Basics


Team Meeting Notes:
Date: 26–January–2016
Time: 10:30am-12:30pm
Members Present: Kailee Gulbin (KG), Ben Reed (BR), Paul Conway (PC), Grant Miller (GM)
Topics Discussed: Lab 2 Post-Lab


Objectives:
Today’s main focuses were meeting as a team to discuss how to prepare an Executive Summary for Lab 2, update the u.osu.edu website.


To do:
-u.osu.edu (KG)
-Executive Summary (PC, KG, GM, BR)


Reflections:
-The u.osu page was not finished completely, need to finish the description.
-The executive summary was not proof read, and the introduction section was not finished.