Freshman Year Millipede Project

Page 1

EG11111

Millipede Module

Jim Bradley Oliver Chmell Jennifer DeMarco Emily Gore Charlie Hunter Section 11 Group 2 March 2, 2009


ABSTRACT The cantilever was designed to function in the most efficient manner, with the least unnecessary motion—shaking of the cantilever—and other interference that may have skewed the values for the rotation or touch sensors. The code utilized multiple functions, many of which defined what the RCX was to do to move the scanner in an appropriate manner. The code also contained many loop functions for the purpose of performing repeated actions while using much less space on the RCX. The demonstration, overall, went very well; the RCX performed exactly as expected, as defined by the code. However, the code defined that the cantilever calibration be performed separate from the main function, and omitted the scanner hardware test. The cantilever, as it was required, found each of the sequences on the scanner in the appropriate order and played one tone for each first sequence detected. SECTION 1 The components utilized in the Millipede model module were a 555 timer circuit, a cantilever constructed of Lego Mindstorms components, sensors, and motors, and a Lego RCX used to control the cantilever. The circuit used was designed to provide a duty cycle near fifty percent, and was constructed with a breadboard, an IDL 800 Digital Lab Shift Register, three resistors, one capacitor, an LED, a 555 timer, and a shift register. The circuit also consisted of multiple wires connected to the breadboard in series and parallel with the resistors, capacitor, and LED. The breadboard is connected to a power input of five volts, a ground, an LED, a switch, and 8 data input bits. The resistors and capacitor that were used were selected because they give a dutycycle of fifty percent. The frequency was determined by the equation f 

1.44 , and C1  ( R1  2 R2 )


needed to be lower, with a smaller voltage so as not to burn out the LED. The duty cycle was calculated by the equation DutyCycle(%) 

T1 100 , and needed to be about fifty percent. T1  T2

Using these equations, the appropriate resistors and capacitor chosen can be seen in Table 1. Table 1. Components of the timer circuit Component Value (With Units) R1 2000 ohms R2 1,000,000 ohms R3 100 ohms C 1 Microfarads Table 1 shows the values of the resistors chosen. The value of Resistor 1 is 2000 ohms. This value needed to be smaller than Resistor 2 in order for the frequency to be a small value. The value of Resistor 2 is 1,000,000 ohms, which is significantly greater than Resistor 1. The value of the capacitor is 1 microfarad. The value of Resistor 3 is 100 ohms. This resistor was chosen because it was the recommended value and the previously tried 47 ohm resistor did not supply a bright enough light for the LED. These make up the major components of the circuit. The other major construction of the project was the cantilever arm as shown in Figure 1 below.

Figure 1. Labeled figure of the cantilever and its major components


The constructed cantilever had a simple structure, made of six major components, numbered in Figure 1. It was comprised of a solid base (4), a body (8) which holds the motor (3) and a rotation sensor (2), all of which were stabilized by rubber bands (6). Also included were a joint connecting the cantilever arm to the base by means of a worm gear and three black axles (7), a cantilever arm made of four one by sixteen blocks (5), and a touch sensor device with an axle used to reach down and find pits (1). The base held the entire structure in place and provided extra height for better reach of the arm to the bits on the table. The body of the structure provided the most height, and held the motor and rotation sensor. The rotation sensor spun with the motor (although at a much faster rate because of the gears used), as well as an axle running through the worm gear; this worm gear is what lifted and lowered the arm. The arm was also stabilized by rubber bands which reduced bounce in the arm and kept the rotation sensor values similar. The motor and sensors used in the Millipede model were connected to the cantilever RCX in the input and output ports. The motor was attached to Output A. The sensors used in the model were two light sensors, a touch sensor, and a rotation sensor. One light sensor was connected to Input 1 and the other light sensor was connected to Input 3. The rotation sensor was connected to Input 2. The touch sensor was connected to Input 1 as well. Table 2 shows the connection of each sensor and the motor and a brief description of what each component does.

Component Light Sensor(1)

Light Sensor(2)

Table 2. Sensors and motor connections Description Connection to Connection to the model Cantilever RCX Used to communicate with Input 1 Connected to the optical the IDL. It detects the light fiber on the IDL of the LED through the optical fiber translates it, performing the action. Used to communicate with Input 3 On the scanner table, linked the scanner RCX. It tells the w/ the light sensor


scanner to move. Rotation Sensor Touch Sensor Motor

The values show if the Input 2 cantilever arm touched a land or a pit Tells when the cantilever Input 1 arm touches a surface Moves the cantilever arm up Output A and down

connected to the scanner RCX Cantilever arm

Cantilever arm Cantilever arm

The Table shows what each sensor and motor did in the model. The touch sensor and the light sensor (1) were connected to the same Input on the RCX, Input 1. This was because the touch and light sensor will never be used at the same time; therefore, the Input could be assigned to either the tough or light sensor throughout the code. The motor was assigned to an output. This would allow the motor to only have an output value, meaning that the cantilever RCX controlled the power of the motor and not giving any value back into the RCX that is used in the model. The components attached to the cantilever RCX control the whole system. The motor, the different sensors, the circuit, and the cantilever RCX controlled the functions and interacted with the whole system. These components told the system what to do and when to do it. The power of the motor was set in the program in the cantilever RCX and from this the cantilever arm would move up and down. When the arm hit the surface of the scanner table, the touch sensor began its job in the system; it showed when the arm should stop moving. From this the rotation sensor value would be taken and used to determine if the surface was a pit or a land. The first light sensor, as defined above in Table 2, was used to communicate with the IDL shift register through the LED on the breadboard circuit. The purpose of this light sensor was to turn on the whole system and start the cantilever and the scanner table. The second light sensor was used to communicate with the scanner RCX through another light sensor, as seen in Table 2. This was used to send a code telling the scanner to move the scanner table. The


circuit on the IDL turned the system on. It did this by using resistors, a capacitor, and NE555 chip and a shift register chip. These controlled how bright the LED, the light used to communicate with the cantilever RCX via an optic fiber, how long and when the LED light was on and off. By changing the switches on the IDL, the intermittent flashes of light from the LED communicated with the cantilever RCX and started a program. The cantilever RCX is the “crossroad” of the whole system. It connected everything together and gave each Input and Output a command according to the program it was assigned to execute. SECTION 2 Pits and lands were differentiated by the rotation sensor output value, labeled CalVal (for calibration value). The CalVal detected when the touch sensor hits a pit, was multiplied by 1000 (in order to get a greater range of values and because NQC only saves integers) and then placed in the variable named CalPit for the calibration of a pit value. This same process was used when finding a land. The CalVal was multiplied by 1000 and set equal to the variable CalLand for the calibration land value. These two variables, CalLand and CalPit were then used to calculate an appropriate threshold, or an average between the two values. This threshold value allowed the cantilever to determine the difference between a land and pit. Each successive time the cantilever was lowered on a bit, the rotation output value was multiplied by one thousand and compared to the threshold value to determine if it is a pit or a land. The detection algorithm was contained within a function named “stateFunction” and contained 4 major states. First, an initial variable z was defined and set equal to zero in order to assure the code will run and “break out” as needed. Each successive “if” statement was made true by defining the value of z to be zero as well as defining a second variable a to keep track of the state. The first nested loop was considered state zero. Both of the statements, a equals zero and z equals zero, must have been true in order for this loop to run. Once in state zero, there was


an “if – else” condition. First, if the CalVal found by the cantilever arm was less than the threshold, this means the bit detected was a pit. However, the first desired sequence is Land, Pit, and Pit. Therefore, if the bit detected was a pit, the state needed to remain the same and then break out of the loop. In order to do this, a was again set to zero and z was set to five to make the while loop untrue. The “else” statement considers the condition when the CalVal obtained was greater than the threshold value, which means the bit was a Land, and the first part of the desired sequence. Thus, the state would increase by one, and again the code would break out of the while loop. Now when the “stateFunction” is called again, if a is one, the program would begin at the next state because z would be reinitialized as zero, making the entire “if” statement in the first state true. Following this same procedure of comparing the bits obtained to the threshold value, the first sequence could be found. Since the cantilever was allowed to detect more than one first sequence, a counter variable was used in the second state when the final bit of the first sequence was detected. This was done by defining the global variable n, and making n increase by one each time it reaches this “if” condition in state two. Now that the cantilever has detected the first sequence, n will equal one, and a will equal zero. Starting back at the beginning of the large “while” loop, the cantilever could begin detecting the first sequence or the second sequence. Since the first bit of each sequence was the same, the state zero code remained the same. However, once it reached the first state, if a pit was detected the second bit of the first sequence had been detected, whereas if the bit was a land, the second bit of the second sequence was found. Thus, another nested loop was included in the land detection of the first state. Here, if a was equal to one (meaning it was in the first state and a land had been detected) and n was greater than or equal to one (meaning the first sequence had been detected at least once) then the code should move to the second state of the second sequence; for clarity purposes this state was assigned to state four. After setting a to four and z to five, the “stateFunction” could be called


again, and enter at state four. Now if the CalVal was less than the threshold, a pit had been detected which was the last bit of the second sequence. Therefore, the code broke out of the function because the overall task to find the first sequence at least once and then the second sequence had been achieved. This was done by setting x equal to ten (so that later the code could break out of the larger loop), and z equal to five. Otherwise, a land had been detected, which meant a Land, Land, Land has been detected so the state could remain at four. Again, a is reset to four, and z was set to five in order to break out of the function. SECTION 3 The Millipede model was controlled by the physical components of the system as well as the computer programming. The software would control when the components would move and it would send the necessary bits through the light sensors. This was done by turning the light on and then off by setting the sensor to a touch sensor. Two very important communication processes needed to move the cantilever arm and the scanner table were the light sensor attached to the optical fiber and the rotation sensor on the cantilever arm. The light sensor would determine if the LED on the IDL was on or off. This was done by means of a threshold. This threshold value was the middle value between the light being on and the light being off. This threshold value was found by attaching the optical fiber to the light sensor and the LED and reading the values the RCX displayed. The other important communication component is the rotation sensor on the cantilever arm. A threshold value was needed to determine if the touched surface is a pit or a land. This value would be the average of the values received for a pit and a land during the calibration at the beginning of the program and used for the rest of the program to determine a pit or a land. This brought the system together by starting and performing the main task of the model, determined if the bit was a pit or a land, and went on to determine a sequence of bits.


The biggest problem encountered during the making of the model was the algorithm for determining the detected sequence. The algorithm was put into a function titled “stateFunction”. In the beginning the function would not detect the second sequence because the program did not have the correct transition from detecting the first sequence to being able to detect either the first sequence again, or begin testing for the second sequence. The first attempt at finding each sequence dealt with a while loop that defined every state of the sequence using a series of letters, such as “a” and “z”. This was a total of six while loops, and was determined to be problematic because it would get stuck looking for the first sequence and never look for the second sequence, never ending the program. This was changed by noticing that the second state was the only different value needed to differentiate between the sequences. So, a variable n was used to show how many times the Land, Pit, and Pit sequence was found. From this, an “if” statement was added to the program to so that if a land was found for the second bit and “n” was greater than one, meaning the Land, Pit, and Pit sequence had already been found, then the program should enter the final state in the detection of the second sequence. In this final state, the “if” statements were used to determine if the next bit was a pit so that the program could terminate. Thus, this problem was solved by integrating the detection loops for second sequence into the first sequence. DEMONSTRATION RESULTS All of the parts of the Millipede Project performed very well during the demonstration, with the exception of the layout of the program. As the scanner changed columns and rows, the cantilever successfully detected each land and pit until the correct sequences were found, played the appropriate tones, and rewound to the beginning. The system did not have to restart at all during the demonstration. There was very little doubt that the cantilever would not perform like this. Only once or twice before it was demonstrated the scanner would sometimes skip a row or


column for no apparent reason. The only flaw in the performance was that the project technical specification document was misinterpreted. The bi-phase code “01� was set to calibrate the threshold for the rotation sensor instead of executing the scanner test routine. This would have been a simple adjustment to the NQC code and it shows that the project should always be read over carefully. CONCLUSION The Millipede model project performed a little less than expected. The hardware in the model did not cause very many problems although there are key areas which could have been improved. The part which gave the most trouble was the integration between the hardware and software. After many long hours of work, demonstration day went very well; we only lost points because the layout of the NQC program did not include the scanner test at the end, and the calibration was not included with the rest of the program. The overall performance of the cantilever arm could have been improved in a couple of ways. It had a very slender base and arm which allowed for too much oscillation and sometimes would double-tap the bit during the execution of the program. The problem was resolved by adjusting the cantilever arm so that it was very close to the top of the land, but it could have just been rebuilt more structurally sound. Another area for improvement in the design would have been to redesign the cantilever without the angular motion. With this angular motion, sometimes the cantilever would touch the bit and force the probe at too much of an angle, missing the touch sensor. Instead, the incorporation an arm which detects the land or pit by moving with an up and down vertical motion may have proven more reliable.


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.