Product Evaluation (Sensors)
3D Modeling and CAD Video
General Engineering has created a video that covers the fundamental concepts of 3D modeling for the semester-long design project: 3D Modeling and CAD Video. This video provides the fundamental principles behind the engineering design process and will help determine what solutions justify creating a 3D model. Material covered in the video will be on the lab 3 quiz. Viewing the video is a mandatory pre-lab assignment.
A specified robot to evaluate has already been created for this lab using an EV3 robotics kit. The design will be evaluated for accuracy and precision by utilizing two different sets of code, the first without the use of sensors and the second with. The robot will be tested on one of the two provided mini-courses. The data from the product evaluation of both sets of code will be used to determine if the robot should or shouldn’t use sensors.
Product evaluation is a common task for an engineer and for companies. Sometimes the product evaluated will be a company's product, and sometimes companies will be evaluating a competitor's design. In either case, this evaluation will use a standard (an accepted value), determine an average, and calculate accuracy and precision.
Professional engineers must be sure of standards. For the purpose of this lab, the EG1003 Standard will be 80% precision and accuracy. This means that the product has to achieve a percent accuracy and percent precision of 80 percent and it has to pass 80 percent of the tests that it undergoes.
When taking measurements, the first step is to determine an average.
In this equation, Ap is the average, P1, P2, P3, ..., Pn are the results of the tests and N is the total number of tests performed.
The average is compared to the standard. Accuracy is a variable the must always be considered. The degree of accuracy required will allow the results to be verified. Engineers often work on projects that affect people's safety; it is critical that the solutions to the problems solved by technical professionals are accurate.
The comparison of the average to the standard is called accuracy, defined as Acc in the following equation:
In this equation, Ps is the standard value, and Ap is the value measured. Accuracy is always a positive number, so use the absolute value in case Ps is less than Ap.
Precision is the repeatability of a result, or how close the results are to each other, defined as Prec in the following equation:
In this equation, Prec is precision, Phigh is the highest data value and Plow is the lowest data value. Like accuracy, precision is always a positive number, so use an absolute value here as well.
A product test can be accurate but imprecise, or precise but inaccurate (Figure 1). The goal is always the combination of accuracy and precision. In order for engineers to make a recommendation based on experimental test data, it is important to determine how a product compares to a standard. Engineers need these benchmarks to determine the quality of a product.
By determining the percent accuracy of an experiment, and comparing this percentage to a standard, it can be determined, based on experimental evidence, if the product has passed or failed. The equation for percent accuracy is:
In this equation, %Acc is the percent accuracy, Ps is the standard value, and Ap is the value measured.
Percent accuracy shows how precise a product is compared to the standard. The equation for percent precision is:
In this equation, %Prec is the percent precision, B is the exponential decay factor, and P is the precision measured. Each individual test requires the use of a different exponential decay factor (B):
- Distance Test: B = 0.0972
- Angle of Deviation Test: B = 0.0323
Calculating percent accuracy and percent precision and then comparing those results to a standard determines the quality of the product.
Quality improvement is a process of analyzing a design and testing it either through physical modeling, computer simulation, or mathematical modeling. Quality improvement ensures that a product will perform as expected and allows improvements to be made to the design.
When deciding how to improve the design in this lab, keep these questions in mind:
- Does the robot perform to standard?
- If no, what can be done to improve its functionality?
- If yes, what can be done to improve its performance beyond the standard?
Changes will be implemented after testing the initial code.
Reverse engineering software involves reversing a program's machine code to obtain the original source code or determine the file structures the program uses. This needs to be done when source code is lost or is not available. For example, when a project is reactivated after being dormant for years to add new features to a product, the original design documentation may have disappeared. Also, when companies are writing a program that must interface to a second company's software, the second company may not have any incentive to cooperate by describing how the data in the files they use are organized, forcing the first company to deduce it on their own. Sometimes, this process is also undertaken as a way to improve the performance of a program, to fix a bug, or to find a virus. When the source code is obtained in this way for any of these reasons it is legal and necessary. Reverse engineering software in order to copy it constitutes a copyright violation and is illegal.
Hardware reverse engineering involves taking apart a device to see how it works. If a processor manufacturer wants to see how a competitor's processor works, the company can purchase the processor, disassemble it, and then make a new processor similar to it. In some countries, this process is illegal. Hardware reverse engineering is quite expensive and requires an expert in the field.
Carefully consider the desired results and what needs to be done to achieve it:
- What made or will make the results inconsistent?
- If the robot failed a test, why did it fail?
A sensor is something that measures some specific value and is used as an input. Different features can be measured by the EV3 sensors, such as light intensity, angle, or distance. The three sensors used in this lab are the light sensor, gyro sensor, and ultrasonic sensor.
The light sensor (or “color sensor”) can measure reflected light intensity, color, and ambient light, and is useful for when the robot has the option to follow a line or use differences in color to perform different actions (such as stopping when reaching a different color). If measuring color, the sensor outputs a value (0-7) that corresponds to a specific color. Measuring reflected light outputs a value (0-100) depending on the intensity of the light that is reflected. The ambient light works the same way as the reflected light, except it just measures the surrounding light. The light sensor, as well as all other sensors, can be found in the yellow category of MINDSTORMS:
The type of value the sensor can measure can be changed by clicking the small box on the bottom left of the block:
The gyro sensor can measure the exact degree it turns or the rate at which it is turning. For example, if the robot is set to turn 90 degrees using the gyro, the robot will keep trying to turn until 90 degrees is reached, regardless of any bumps in its way:
The ultrasonic sensor measures the distance between the robot and the closest object to it. It can measure distance in both centimeters and inches; the recommended range is 1 cm to 250 cm:
Switches and Loops
Switches and loops are used to tell the robot what actions to perform depending on the inputs taken from its surroundings, measured by the sensors.
A switch serves as an “if-else” statement: if the initial condition is true, the top action will occur, if false, the bottom action will occur. This block is used when the robot has to perform different actions depending on the situation it is in:
A switch will only run the code once, so if repeated action is desired, a loop must be used to repeat the switch’s statement. A loop continuously runs the code inside of it until the end statement occurs. The end statement can be determined with a sensor, or hard-coded to a specific amount of time or rotations; the figure below shows an infinite loop:
Materials and Equipment
- Mindstorms kit with pre-made robot
- Computer with Mindstorms software
- MIni-course with accuracy markings
<Insert diagram of course here>
Evaluate two types of code for a robot by creating a line of code without the use of sensors and then a separate line of code using sensors. Test the first code by running four trials per section of the mini-course as marked on the physical course, giving you a total of eight trials for the first code. Create a second code using switches and loops to incorporate the types of sensors found on the robot and features on the mini-course. Test again with four trials per section. The total amount of trials for the whole procedure is 16.
The mini-course is divided into two sections: one flat straight section of four tiles and a second section consisting of a right turn and ramp. Both sections have a wall at the end. In the following schematic, Section 1 is marked in red and Section 2 is marked in blue:
Part 1: Hardcoding
- Start the Mindstorms EV3 software
- Click on the ‘’’+’’’ in the top left corner to open up a blank program.
- The screen should look like this. Your program begins with the Start block.
- Place a Large Motor block from the Action palette next to the Start block. Along the bottom of the Large Motor block, there are four options. On the left, there is a Mode Selector button, followed by three values for the input parameters picture above the value: from left to right, Power, Rotations, and Brake at End.
- Click on the Mode Selector and change the mode of the Large Motor block to On for Seconds. This will change the Rotations input parameter to Seconds.
- Test different values of Power and Seconds to find the best settings to travel the first four tiles of the course.
- Assign the port that the motor is connected to at the top right corner of the block.
- Run the program. The program should run the motor connected to Port A for however many seconds set earlier. Repeat this process for a total of 4 trials.
- Create the second half of the program to turn the robot and continue up the ramp. This can be accomplished by using either the “steering” block or “tank” block:
- Test different values of Power and Seconds/Rotations to find the best settings to travel the last 5 tiles of the course. Set the ports to reflect the motors plugged into the brick; both ports have to be correct. A sample turning code is provided below:
- Run the program and make adjustments to the program. Once the accurate settings are found, perform 4 trials for this section, to bring the total count to 8 trials.
Part 2: Sensors
The first section of the course requires following a straight line. The following steps outline how to build a line-following code for the robot to stay on track.
- Click on the ‘’’+’’’ in the top left corner to open up a blank program.
- Insert a blank loop. Insert a switch within the loop.
- Set the input of the switch to a light sensor and the type to Reflected Light Intensity. Set the comparison to the “greater than” symbol and use Port View on the EV3 brick to measure the light intensity of the line. Set the value of the light intensity to the value displayed by Port View.
- In the top half of the switch, insert two Move Motor blocks. Set one to stop and one to continuously moving. Duplicate this in the bottom half but switch the ports. This way one wheel will move while the other stays stationary, which will make the robot wiggle along the line:
- Use the ultrasonic sensor to make the robot stop 5 cm away from the first wall. Set the end statement of the loop to be controlled by the ultrasonic sensor
The second section of the course requires turning to the right 90 degrees, advancing forward one tile, and turning another 90 degrees to prepare for going up the ramp. Each time the gyro is used, it has to be reset in order to set the direction the robot is facing before turning as zero.
- Insert a gyro block and set it to reset:
- Insert a wait block right after the gyro reset. Set it to 2 seconds.
- In order for the robot to continue turning until 90 degrees is reached, a loop must be used to constantly run the robot until the gyro sensor reads 90 degrees. Insert a loop after the wait block
- Insert a motor block into the loop. Select the motor that when activated will turn the robot to the right.
- After the loop, insert a motor block for the robot to travel straight one tile. Use either rotations or time to move the robot and duplicate the first part of the program after the motor block.
- Recreate the line following code to allow the robot to travel up the ramp. Test different values of power to overcome the ramp. The end statement should be the same as the first section where the ultrasonic sensor stops the robot 5 cm away from the last wall.
Tabulation of Results
Individual Lab Report
Follow the lab report guidelines laid out in the page called Specifications for Writing Your Lab Reports in the Technical Communication section of this manual. The following discussion points should be addressed in the appropriate section of the lab report:
- Discuss product evaluation and the need for it.
- Discuss quality improvement and its importance.
- Explain why reverse engineering is important.
- Discuss a standard, an average, accuracy, and precision.
- Discuss the EV3 kit and software used.
- Assess the techniques used in the testing process.
- Discuss better testing methods for the robot design.
- Describe loops and switches and how they are useful in coding.
- Describe the light sensor, gyro sensor, and ultrasonic sensor used in the lab
- Compare the code with sensors and code without sensors and determine which is better. Substantiate the decision with data, observations, and other facts collected.
- Make a final evaluation of the product: should it go into production? Describe its accuracy and precision.
- Discuss the importance of %Prec and %Acc in determining product quality.
- Recommend if any design improvements should be made.
Remember: Lab notes must be taken. Experimental details are easily forgotten unless written down. EG1003 Lab Notes Paper can be downloaded and printed from the EG1003 Website. Use the lab notes to write the Procedure section of the lab report. At the end of each lab, a TA will scan the lab notes and upload them to the Lab Documents section of the EG1003 Website. One point of extra credit is awarded if the lab notes are attached at the end of the lab report. Keeping careful notes is an essential component of all scientific practice.