Memorandum
To: Bill Cohen
From: Brannon Oiler, Nimit Desai, Josh Kuehn, Ian Stamm
Date: 02/20/15
Re: Introduction to Sensors and Motors
1. Introduction
In order to begin using parts that are essential to the functioning of a robot, it is important to first
thoroughly check the equipment for any malfunctioning that may impede progress later. This is
especially true for the ports on the Proteus. Along with this, a firm knowledge of how the ports
read in data is useful for further progress in the design project. Knowing how the code interacts
with the parts that will be used is an important skill.
Section 2, results and description, will remark on the completion of tasks and present any data
recorded. Section 3, discussion, will interpret any data collected and identify any problems
encountered during the diagnostics and coding. Finally, section 4, summary and conclusions,
will summarize the previous sections in a concise manner.
2. Results and Description
After soldering the CdS cell and microswitch and performing diagnostics, code was written to
manipulate the motor and servo using digital and analog inputs. Figures of the parts and ports
used are attached, as well as code for parts 4 and 5. Parts 2 and 3 were performed successfully
to allow proper running of the motor. For part 4, by receiving an analog input from the
Cadmium Sulfide cell and using colored filters, readings were taken when in contact with red
light, blue light, and no light. Results are shown on the following page:
Table 1: CdS cell readings for light and filter combinations. [1]
CdS Readings
Red Light
Blue Light
No Light
Red Filter
Blue Filter
0.10
0.75
.057
0.355
0.23
0.79
Yellow Filter
0.085
0.25
0.36
Green Filter
0.22
0.33
0.67
No Filter
0.85
0.17
0.34
Using digital and analog inputs from the microswitch and CdS cell, the motor and servo
successfully moved based on calibrations performed and CdS cell readings.
3. Discussion
For part 1, during the diagnostics, a couple of problems were encountered related to the
orientation of the ports. The servo ports above the screen have the ground on top, which is
extremely important to know for proper wiring. This can be seen in Figure 3 in the attachments.
Also, the motor ports on the top of the Proteus are indexed from right to left, so the first motor
must typically be on the right-most port first. This can be viewed in Figure 2.
For part 4, one of the first problems encountered was the declaration of the CdS cell. It is
important to declare it as an analog input in order to receive a range that can be analyzed by the
code. When deciding if a filter should be used, the average distance between the values needs to
be taken into account. Based on the data, it appears that the green or yellow filter would be
beneficial to use. Also, these filters change the ordering of the readings so that the no light
reading is not in the middle of the red and blue light readings. This may prove useful later. It
may be possible that the readings were not accurate based on whether or not the positioning of
the CdS cell on the robot will allow room light to shine on it when not receiving a signal from a
light source on the course.
The method for determining the color would be based on error ranges. After thorough testing,
each color light would have a set minimum and maximum range in which a reading would fall
into. By using some ‘if’, ‘else-if’, and ‘else’ statements, the Proteus would receive the reading
and place it into a category. More code could be written to only allow smoother transitions and
prevent error readings from appearing by requiring multiple confirmations.
Finally, in general, it is important to use #include for all the necessary libraries the Proteus uses.
Also, when declaring an input, motor, or servo, it is important to designate the correct port based
on C’s index starting at 0 and the orientation (such as the motor ports starting from the right on
top of the Proteus.
4. Summary and Conclusions
Overall, by performing diagnostics, our group would be able to recognize problems with the
Proteus and/or the soldering performed. Also, parts 2-4 allowed our group to gain an essential
concept of how the inputs are read into the Proteus, interpreted by the code, and finally sent as a
signal to move the motor or servo if necessary. Also, by using analog CdS cell readings and
testing them against different light sources on the course, it was determined that a green or
yellow filter may prove helpful for receiving more reliable data to determine the current light
colors. Finally, something to consider is that all actions performed with the code involved only 1
motor or servo at a time.
For the robot our group has decided on using, 2 motors will need to act independently at the
same time. This may be possible to do with our current knowledge, but a better method to thread
the code will also be looked into and considered. It would allow our robot to perform all actions
required in a more practical and manageable way.
Attachment: Code, 1.
Attachment: Figures, 1.
Attachment: References, 1.
Code
CODE FOR PART 4.4 (Written by Nimit Desai and Joshua Kuehn)
#include <FEHLCD.h>
#include <FEHIO.h>
#include <FEHUtility.h>
#include <FEHMotor.h>
int main(void){
//Declare buttons and input pins
ButtonBoard buttons( FEHIO::Bank3 );
AnalogInputPin an00 (FEHIO::P0_0);
DigitalInputPin di01 (FEHIO::P0_1);
//Set default LCD
LCD.Clear( FEHLCD::Black );
LCD.SetFontColor( FEHLCD::White );
//Declare Motor
FEHMotor motor0 (FEHMotor::Motor0);
//Use while loop to end program if middle button or microswitch is held
while(!buttons.MiddlePressed() && di01.value() == 1){
motor0.SetPercent(-100 + 200 * (an00.Value()/3.3));
//Sleep to allow for servo to not be overloaded with commands
Sleep(250);
}
}
_____________________________________________________________________________________________________________________________________
CODE FOR PART 5.4 (Written by Joshua Kuehn)
#include <FEHLCD.h>
#include <FEHIO.h>
#include <FEHUtility.h>
#include <FEHServo.h>
int main(void){
//Declare buttons and input pin
ButtonBoard buttons( FEHIO::Bank3 );
AnalogInputPin an00 (FEHIO::P0_0);
//Set default LCD
LCD.Clear( FEHLCD::Black );
LCD.SetFontColor( FEHLCD::White );
//Declare Servo
FEHServo servo0 (FEHServo::Servo0);
//Use while loop to end program if middle button is held
while(!buttons.MiddlePressed()){
//Declare servo min and max
int min = 500;
int max = 2500;
//Use while loop to keep turning servo until power off
while(true) {
//Set servo min and max
servo0.SetMin(min);
servo0.SetMax(max);
//Calculate and Set servo to degree value
int deg = 606*an00.Value()/max*180;
servo0.SetDegree(deg);
//Sleep to allow for servo to not be overloaded with commands
Sleep(250);
}
}
}
Figures
Figure 1: Soldered CdS cell and microswitch attached to port 0 and 1 of the I/O ports
Figure 2: Motor attached to port 0 of the motor ports on top
Figure 3: Servo attached to port 0 of the servo ports, ground is on top.
References
[1]
Lab 01 Writeup. 2015, February 13. www.carmen.osu.edu.
© Copyright 2026 Paperzz