Jason Zheng, Joey Mintz, Suzanne Yam, Leobeliz Perdomo Blanco Arduino Programming
Group L-Instr. Professor Jayne Kim, GTA Anusha Mannava February 3rd, 2016
Executive Summary
The Arduino Programming Basics Lab consisted of the team becoming familiar with the automatic control system hardware components and with Arduino by being able to program basic functions and upload programs. All team members were instructed to set up the AEV software, install Arduino and upload the ‘sketchbook’ on their computers during the lab. One team member wrote the commands for the given Scenario 1 with the help of the other team members. In order for the code to work the team had to set the proper Board, Processor and Serial Port. After completing the instructions, the team ran the code to test if the two motors worked properly and followed the commands. This lab also gave the team the chance to practice troubleshooting techniques if the code did not work or if there were any problems with the motors.
Arduino Nano was introduced to the students in Lab 2. Arduino Nano is known as the heart of the AEV controller. Students will be using this software to control motor speeds, time or distance that the motor is going to move and recording system data. Arduino programming language is somewhat similar to C or C++ syntax. This lab allowed students to practice coding some of the basic functions that they are going to use for their AEV (Advanced Energy Vehicle). For examples, celerate(m,p1,p2,dt), motorSpeed(m,p), goFor(dt), brake(m) and reverse(m).
The electric motors performed mostly as expected. Initially there was some resistance when accelerating, but once it reached higher power inputs it spun steadily. The program ran correctly after some small formatting errors. The AEV is limited to what it can be coded as, in that the possible commands given to the AEV can only do a specific number of things. The “brake(m)” command is one command that may be problematic. It may be named “brake”, but all it does is cut the power to the motors, effectively taking the theoretical foot off of the gas pedal, but not actually stopping the AEV. Stopping without coasting for a short period of time is not possible with this command, so something may need to be done to work around this when coding the AEV software.
As an engineer, an individual will be bound to encounter situations where potential errors would arise. In this particular scenario, working with C++, errors could often be unavoidable. One major error that occurred was that the (system) was not running. To troubleshoot this, the group simply switched the USB port it was originally connected in. When the team initially ran the code, it did not run the way it was suppose to. The team looked over the code and corrected it by fixing the script file; using the ‘4’ to symbolize everything rather than writing out 3 codes individually. The team overall did not need need more guidance. However, the team will certainly have a better experience if we were able to get more familiar with the C++ language during class and have a deeper understanding regarding the AEV vehicle.
Appendix
void myCode()
{
//—————————————————————————————-
// myCode();
//
// This is the tab where the programming of your vehicle operation is done.
// Tab _00_AEV_key_words contains a compiled list of functions/subroutines used for vehicle
// operation.
//
// Note:
// (1) After running your AEV do not turn the AEV off, connect the AEV to a computer, or
// push the reset button on the Arduino. There is a 13 second processing period. In
// post processing, data is stored and battery recuperation takes place.
// (2) Time, current, voltage, total marks, position traveled are recorded approximately
// every 60 milliseconds. This may vary depending on the vehicles operational tasks.
// It takes approximately 35-40 milliseconds for each recording. Thus when programming,
// code complexity may not be beneficial.
// (3) Always comment your code. Debugging will be quicker and easier to do and will
// especially aid the instructional team in helping you.
//—————————————————————————————-
// Program between here——————————————————————-
// Accelerate motor one from start to 15% power in 2.5 seconds.
celerate(1,0,15,2.5);
// Run motor one at a constant speed (15% power) for 1 second.
motorSpeed(1,15);
goFor(1);
// Brake motor one.
brake(1);
// Accelerate motor two from start to 27% power in 4 seconds.
celerate(2,0,27,4);
// Run motor two at a constant speed (27% power) for 2.7 seconds.
motorSpeed(2,27);
goFor(2.7);
// Decelerate motor two to 15% power in 1 second.
celerate(2,27,15,1);
// Brake motor two.
brake(2);
// Reverse the direction of only motor 2.
reverse(2);
// Accelerate all motors from start to 31% power in 2 seconds.
celerate(4,0,31,2);
// Run all motors at a constant speed of 35% power for 1 second.
motorSpeed(4,35);
goFor(1);
// Brake motor two but keep motor one running at a constant speed (35% power) for 3 seconds.
brake(2);
goFor(3);
// Brake all motors for 1 second.
brake(4);
goFor(1);
// Reverse the direction of motor one
reverse(1);
// Accelerate motor one from start to 19% power over 2 seconds
celerate(1,0,19,2);
// Run motor two at 35% power while simultaneously running motor one at 19% power for 2 seconds.
motorSpeed(2,35);
motorSpeed(1,19);
goFor(2);
// Run both motors at a constant speed (19% power) for 2 seconds.
motorSpeed(4,19);
goFor(2);
// Decelerate both motors to 0% power in 3 seconds.
celerate(4,19,0,3);
// Brake all motors
brake(4);
// And here——————————————————————————–
} // DO NOT REMOVE. end of void myCode()