1 I. Title and Abstract SHELF ASSIST! EECS Senior Project Group 5 2013 Spring/Fall Team Bitshifters Members : Jeffrey McDonald, Mamunur Rahman, Andrew Rankin, Ibrahim Al Mustaneer. Introduction: When people are confined to a wheelchair, they suffer from not being able to reach high cabinets and shelves. Manual pull-down shelves already exist, but people confined to a wheelchair would still not be able to reach these shelves in high cabinets. This project would solve that issue by supplying a high cabinet with an automated lowering shelf which can be installed in the kitchen, pantry, closet, laundry room, etc. For this project, we have worked with a few residents from Cerebral Palsy Research Foundation (CPRF) over the period of two semesters. Primarily, their apartments provide shelves and cabinets that are not easily accessible to many of the residents, who are confined to wheelchairs. A device is needed to lower the items in these cabinets and shelves to a reachable distance for wheelchair occupants. With the existing pull-down shelves in the market, the residents would still have to reach and pull down the shelf from their cabinets. Since many of the residents have limited use of their hands, an automated pull-down shelf is needed. We started with a manual pull down shelf from a hardware store. Our goal was to turn the shelf into an automated shelf controlled by a remote while keeping it economically accessible, environmentally green, socially accepted, as well as meeting health and safety standards. Here are some pictures of the shelf including the control box, frontal view, sensors on the bottom and the left side view. 2 3 Here is a video of the Automated Shelf in its working environment: SHELF ASSIST! II. Specifications Shelving Unit: Base unit is a pre-manufactured two tier stainless steel manual pull down shelf made by Rev-A-Shelf Dimensions: 21.75″ W x 18.87″ H x 10.25″ D Weight: 23lbs. Additional weight limit: 40lbs. Requires a cabinet with a minimum 20-1/4″ wide opening Pulls out 14-3/4″ and lowers 10″ from fully stowed position Shelf can be bottom or side mounted in cabinet Gas assist pistons stabilize movement of shelf Modified with a 6″ stroke linear actuator recycled from a power wheel chair to automate the lowering and raising of the shelf from the cabinet 4 Automation Unit: 24VDC, 6″ stroke linear actuator 4.6A max current 100lb. weight capacity Weight: 1.3lbs. Control Unit: Arduino Uno R3 prototyping platform utilizing the ATMega328 8-bit microcontroller Operating voltage: 5VDC Recommended input voltage: 7-12 VDC Input voltage limits: 6-20 VDC 14 Digital I/O pins, 6 Analog input pins 40mA max current per I/O pin 3.3V, 5V, Vin pins for accessing input voltage Wireless Control: 4-button key fob style RF transmitter utilizing a PT2262 encoder RF receiver utilizing a PT2272 decoder Receiver has 4 toggle type data outputs, coinciding with the 4 button transmitter, for easy interface with the Arduino Frequency: 315MHz Collision Detection Control: Array of 3 HC-SR04 ultrasonic sensors Operating voltage: 5VDC Quiescent current: 2mA Working current: 15mA Frequency: 40kHz Ranging distance: 2cm-400cm/1in-13ft Angle of detection: <15degs Resolution: 0.3cm Power Supply: Input: 120VAC Output: 12VDC, 3A Total Weight: Approximately 25lbs. 5 III. User Manual Installation: The automated shelf can be installed in a cabinet, on a pantry shelf, etc. using existing installation instructions for the manual pull down shelf. These instructions can be found online here Instructions. Additional instructions: Access to 120VAC will need to be provided. It is recommended to have a licensed electrician for installation of new outlets, additional wiring, etc. While the shelf is designed so moving parts do not affect the wiring, ensure pinch points are not introduced during shelf installation. Setup: After plugging a 12-16VDC power supply into the Arduino the shelf is ready for operation. If for some reason the shelf is not in the fully up/stowed position, it will return to that position upon first supplying power. Note: While this unit is designed to control only a single shelf, a simple software upgrade can be installed to operate up to 4 shelves independently with no additional hardware required, with the exception of additional wiring for each shelf. Operation: The shelf is designed to move through a full range of motion to either fully extended or fully stowed, it cannot be controlled to a stop in mid-range. For proper operation, do not load shelf with more than 20lbs. of additional weight. Single shelf operation: A single push and release of the “A” button on the wireless key fob is all that is needed to lower or raise the shelf. The shelf direction can be reversed at anytime with another press of the “A” button. If an object is detected below the shelf at anytime during it’s operation, the shelf will halt all motion and remain stopped until the detected object is removed from the shelf’s path. Multi shelf operation: Operation is the same as for single shelf operation, except that each shelf is set up to individually correspond to one of the 4 buttons of the wireless key fob. 6 Maintenance: Degradation of shelf movement may occur if more than 20lbs. of additional weight is added to shelf. Take care to keep objects clear of the shelf’s full range of motion, especially items that may have fallen behind shelf in cabinet as shelf does not have the ability detect these objects. During normal use, check that the wiring does not become susceptible to pinch points or stress. Troubleshooting: If shelf is not moving: Ensure unit is getting power 1. Check that the power supply is plugged in to both the wall outlet and the control unit. 2. Check that the outlet breaker in service panel is not tripped or off. 3. Plug power supply into another outlet, ideally on a separate breaker than normal outlet used for shelf. Ensure wireless key fob transmitter is operational 1. Replace battery in key fob If it has been determined that outlet power and the key fob transmitter are not the cause, further inspection by a qualified technician will be needed to determine the cause and a replacement of the power supply, control unit, wiring or motor may be warranted. IV. Theory of Operation Operation: The Auto Shelf uses a commercially available manual pull down shelf, modified by installing a linear actuator to automate the raising and lowering travel of the shelf. The position of the shelf is monitored by a control unit(CU) consisting of an Arduino Uno R3 microcontroller utilizing input from a set of switches that relay whether the shelf is fully retracted in cabinet, fully extended, or neither indicating that it is in motion. User input is communicated to the CU from a 315MHz wireless push button keyfob RF transmitter and corresponding receiver. The CU uses the input signals from the position switches, RF receiver, and last known direction of the shelf to logically determine which direction to next operate the shelf. 7 The Arduino can only provide a maximum of 40mA at any of it’s I/O connections, so to provide power to the actuator, which typically draws .5 to 1.5 amps, the CU uses an external 12VDC power supply passed directly through the Arduino which it switches on and off by biasing a NPN power transistor through a predetermined I/O connection. Once direction is determined by the CU, a 5VDC relay is used to change the polarity of the power supplied to the actuator to either raise or lower the shelf. Positive polarity will retract the actuator effectively raising the shelf and negative polarity will extend the actuator effectively lowering the shelf. Due to the relay’s operating current of 80 to 100 mA, the current limitations of the Arduino’s I/O connections mentioned above require that the 5VDC relay supply is directly passed through the Arduino, which is again switched on and off by biasing a NPN power transistor through a predetermined I/O connection. The ability to detect obstacles below the shelf before a collision occurred was determined to be an important safety feature to implement in the design of the shelf. This is achieved through the use of an array of ultrasonic sensors mounted under the bottom shelf to determine the distance to any objects underneath it. The sensors have a minimum detection range of 2cm(1in) and a maximum detection range of 400cm(13ft) and a resolution of .3cm. To avoid interference from it’s own or other sensor “pings”, the first sensor in the array will ping every 250ms, the second 35ms after the first, and third 35ms after the second. This results in a complete array distance sampling rate of approximately 3 per second( 1000ms/[250ms+35ms+35ms] = 3.125). To avoid a collision any object detected less than an upper threshold of 6″ from the base of shelf will halt the shelf’s motion until the object is removed. Since the base of the containing cabinet will likely be within the 6″ threshold of the sensors, a lower threshold has been established allowing the sensors to ignore anything detected less than 5″ from shelf base. This will eliminate the “false detection” of the cabinet itself. We feel this is acceptable as it is highly unlikely that an object, other than the cabinet base itself, will suddenly appear under the 5″ threshold. Potential Consumers: The Auto Shelf was conceived after receiving feedback from a number of residents at the Cerebral Palsy Research Foundation pertaining to the difficulty of accessing upper kitchen cabinets and pantry shelves, thus it was initially designed with the disabled community, especially those who are wheelchair bound, in mind. Conceivably, though, anyone could benefit from installing these units in tall kitchen cabinets, pantries, closets, garage, workshop, etc. Presumably the exact design could be used in any of these situations without modification from the original. 8 Comparison to Alternatives: Benefits: While manual pull down shelves are commercially available, automated versions are extremely limited and none were found to be mass produced. Has the advantage of using a pre-manufactured manual shelf as the basis of the unit. Simple modifications make it fully automated economically, while still retaining the easy installation procedures of the manual shelf in pre-existing cabinets. Of the few alternatives found, all were custom designed shelves, and in some cases the entire cabinet had to be custom built, dramatically increasing the up front cost and difficulty of installation. Easily and economically mass produced control unit. Wireless user interface. No others have this feature. Collision detection. Others do not appear to have this capability. Much more useful to disabled individuals than a manual pull down, which for some may be no better than just a standard cabinet. Disadvantages: Use of a premanufactured shelf might introduce patent infringement issues with the shelf manufacturer. This would need to be further explored and remedied before the Auto Shelf is made commercially available. Added complication of mechanical and electrical components over a manual shelf. Loss of wireless transmitter or power would leave shelf inoperable and possibly stuck in a position outside of cabinet, although by resetting the power to the control unit it will return to a fully up position in cabinet. Manual shelves would not suffer from this limitation. 9 Flow Chart: 10 V. Technical Description Control Unit Schematic: Code: The code executed on the Arduino was written, compiled, and uploaded from within the 1.5.4 release of the Arduino IDE. The Arduino’s bootloader will then execute the program. The code, Auto_Shelf.ino, can be downloaded here Auto_Shelf.ino. A copy of the NewPing library will need to be copied into the Arduino IDE’s libraries folder. A copy of v1.5 can be downloaded here NewPing. A plain text version of the operating code is provided in the Appendix at end of report. 11 Instructions: Unzip NewPing.zip and copy the NewPing folder into …\Arduino\libraries\ folder. Open Auto_Shelf.ino into the Arduino IDE. A USB cable must be connected to the Arduino before uploading. Select the Upload button. This will verify/compile the code and upload to Arduino. Parts List: Qnty Part Description Mfg Part Num Supplier Price/Unit 1 24″ Pull Down Shelf Rev-A-Shelf 5PC-24CR Menards 183.99 *1 12VDC 6″ Stroke Linear Actuator MPC LA-6 (0726) Amazon $66.95 1 Arduino Uno R3 Smart Projects N/A Adafruit $29.95 1 315MHz 4 Button Keyfob RF Transmitter Adafruit N/A Adafruit $6.95 1 315MHz RF Receiver – Toggle Type Adafruit N/A Adafruit $4.95 3 Ultrasonic Distance Measuring Czb Electronic Sensor HC-SR04 Czb (thru Ebay) Lot of 5 – $7.40 2 Diode, 1A, 400V NTE Electronics 1N4004 RadioShack $0.10 2 NPN Transistor Farnell TIP-31A RadioShack $1.05 1 Relay, 5V, 2A Omron Electronic G5V-2 RadioShack $2.95 4 Cable Organizer Clips Command 17301CLR WalMart Package of 4 $3.95 Total: $309.39 * The actuator used for project was recycled from a power wheelchair from CPRF. The actuator listed above would be a better fit as the power supply is 12VDC and the Arduino is not recommended to use a supply over 16VDC. This one also seemed to have a better load capacity which would allow for more weight on shelf. 12 VI. Usability Study Introduction Our project is a modification to a manual pull-down shelf. The shelf is now motorized and can be controlled via the single push of a single button on a key-fob remote. It also includes sensors on the bottom to detect any obstructions in its path. Our intention was to make the cabinets at the CPRF more accessible to those of limited mobility. For a successful project, our shelf needed to be easily usable by the CPRF residents. So feedback from the CPRF residents was necessary. We conducted a usability study with two CPRF residents, Sheridan and Jerri, on December 3, 2013. Both residents have difficulty reaching the cabinets, although Jerri can occasionally stand up out of her wheelchair to reach them. The study involved having both residents successfully lower and raise the shelf and then answering questions from our survey. Results After we explained to them that the shelf operates by pressing the “A” button on the remote, both Sheridan and Jerri successfully lowered and raised the shelf on their own. Next, we conducted the following survey: Do you think this shelf would be useful if installed in your cabinets? Sheridan: “Yes, most definitely. For me, I can’t stand at all. It would work in any shelf.” Jerri: “Yes.” Is the speed ok? Sheridan: “Yeah, the speed is great. We have china and we don’t want it to go flying out.” What do you like about the shelf? Sheridan: “I just like how convenient it is. I could install it anywhere.” What would you improve about the shelf? Sheridan: “Nothing comes to mind.” 13 On a scale of 1 – 10, 10 being perfect and 1 being pour, how would you rate the usability of the shelf? Sheridan: “10″ Jerri: “10″ Do you like the single-push key-fob remote, or would you prefer a different method for controlling the shelf? Sheridan: “I like it. I’m fine with the small remote, but some other residents might need a larger button.” Reflection Overall, the feedback provided by Sheridan and Jerri was overwhelmingly positive. Not only were they able to operate the shelf easily, but they showed enthusiasm towards the features of the shelf giving it perfect 10′s. They like the speed of the shelf, the convenience of the remote, and the fact that it can be installed anywhere. Although Sheridan likes the remote, he mentioned that the buttons may be too small for other residents. To resolve this, we would recommend obtaining and testing alternative remotes with buttons of different sizes. The perfect rating and absence of critique is likely due to the fact that the study was conducted quickly after the residents only operated the shelf once. With more time, one could conduct a study that involves a resident keeping multiple shelves in his/her cabinets for an extended period. This would allow the resident to provide better feedback and address possible liability concerns. VII. Historical Perspective Motivation: Through our initial meeting with the residents of the Cerebral Palsy Research Foundation we gained a perspective of the desire for disabled individuals to be independent in their day to day lives. Simple tasks like holding a camera steady, getting into and out of bed, and reaching items in upper cabinets were everyday struggles without help for most of the residents we met with. 14 Our decision to design an automated shelf was agreed upon due to a reoccurring desire of most of the wheelchair bound individuals we spoke with to be able to access the upper cabinets in their kitchen. This idea also seemed to resonate with many others that suffered motor control issues in their arms. It was an idea presented to previous classes so we felt it was an important idea to pursue. First Semester Work: With three electrical engineering and one computer science majors, we felt pretty confident with the circuitry and microcontroller programming aspect of the project. The mechanical requirements, though, were not well anticipated. That being the case, most of our work at this stage revolved around determining how to build the shelving unit itself, what type of motor to use, and how to mount it. It became clear pretty quickly that with our limited knowledge, building the actual shelf would be too error prone and require too much time. The alternative we decided upon was to purchase a premanufactured shelf with the capability to be manually lowered from and raised into the cabinet. None of the team were aware of these type of shelves and, after finding them commercially available, wondered if this solution would work and automating it would be overkill and cost prohibitive. After a second meeting with some of the CPRF residents, we learned that for most this shelf would offer no or little benefit as they cannot even reach the base of the cabinet to retrieve items, so we pressed on. A linear actuator was chosen to control the shelf’s movement due to it’s ease of use, strength, and the lack of requiring external gears and linkage. Even with the simpler solution the actuator provided, mounting it to the shelf took most of our efforts in the first semester. We felt retaining the shelf’s full range of motion was a must, but mounting the actuator so that it would not reach it’s maximum or minimum stroke before the shelf was in it’s down or up position proved problematic. To provide the arcing motion the shelf required the actuator also needed to be a few degrees outside of perpendicular when up and outside of parallel when down or the actuator would simply pull straight in against the shelf providing no motion. This process was largely trial and error and produced a number of misplaced bolt holes. As the semester came to a close, we finally got a working design by installing a piece of sheet metal to the shelf arm to extend where the desired pivot point was located and a piece of an inch thick aluminum rod was used to reinforce the attaching bolt as the torque would cause it to bend over time. While the gas piston and spring were removed from the actuator side, we decided to leave them in place on other side to provide added stability. Pressed for time, the control unit was simply made from a dual rocker switch to swap the polarity of the 12VDC power supplied by an Arduino and motor shield to the actuator. 15 Images of shelf at end of first semester: Second Semester Work: With the automation of the shelf working, we began developing ideas on how to improve the shelf’s usability, and safety: Provide cheaper more robust solution than an Arduino motor shield to supply the actuator power Operate with a single click of a button, so as to not require a button to be held down through it’s range of motion User interface is wireless and simple Clean up wiring Provide collision detection for objects under shelf within it’s range of motion The Arduino’s 40mA max current I/O pin limitation would not be enough to drive the actuator or the relay used for polarity swapping either. While a motor shield would provide this capability, it is relatively expensive and still proved somewhat problematic with higher current draws when the shelf was under additional load. This was easily solved by using two of the Arduino’s digital I/O pins to turn on and off separate transistors that act as a switch to allow current to flow from either the 12VDC for the actuator or 5VDC for the relay. One click operation would require the Arduino to be able to monitor the shelf’s position. This was achieved by using a set of push button switches installed so as to be depressed by the shelf’s arm when either up or down. This input was used by the Arduino to switch the 12VDC transistor switch off. We were excited to find a simple and inexpensive 315MHz 4 button keyfob transmitter and receiver to utilize for the user interface. It not only met our needs of wireless and simple, but it can also be used to control up to four shelves independently. The Arduino monitors the 16 receivers output to track the current/last direction of the shelf and to reverse the direction when desired. An external transistor switch is used by the Arduino to turn on and off a 5VDC supply to a relay used for polarity swapping of the 12VDC actuator power. For collision detection we decided on using ultrasonic distance sensors instead of a mechanical switch mechanism so as to alleviate the need for the shelf to come into contact with an object. Originally we wanted to use five of these sensors but were limited to three because there was not enough I/O pins left on the Arduino Uno to install two more. While the sensors will halt motion of the shelf when objects come within 6″ of the shelf base, a workaround was needed so the shelf would ignore the base of the cabinet. This situation was remedied by setting a threshold between 6″ and 5″ as to where the shelf would logically detect and halt the shelf. We felt this would not compromise safety as there would be little chance an object other than the cabinet would suddenly be detected less than 5″. The final unit had quite a bit of wiring to clean up for both aesthetic purposes and to avoid pinch points. Some simple wire wraps and adhesive backed cable hooks were used to loop the wiring on one side and down an arm to the control unit along the back of the shelf. The actuator and switch wiring were fairly simple to contain as they were close to the control unit and were immobile so the wires did not have to track with the shelf as it moved. 17 We were pleased with the successful accomplishment of our goals in the final product but the positive reception from the CPRF residents, whom we demoed the shelf with in their apartments, was especially rewarding as they were the original motivation behind this project. VIII. Business Viability Patent Research US 3415586 A: A cabinet structure provided with an outer shell and shelf structure slidably supported in the shell by webs which are adapted to be wound on a motor driven roller. The motor and an electromagnetic brake are both adapted to be energized when the shelf structure is being raised. Only the electromagnetic brake is adapted to be energized when the shelf structure is being lowered by gravity. Although this patent is meant for a similar purpose, it’s basic dynamics is similar to an elevator which would be problematic above counters. Our design differs from this one in that ours extends outward and doesn’t necessarily require modifications to the cabinets which is more ideal for the CPRF. US 8303053 B2: A basket apparatus which includes a basket positioned in a cabinet, a motor to drive the basket from a rearward lowered position in the cabinet to a forward directed raised position outside of the cabinet, and a driver connecting the basket to the motor. Like our shelf, this basket apparatus extends outward from a cabinet. However, this apparatus is vertically confined to the level of its cabinet which wouldn’t be useful for user who can’t reach their cabinets. US 8414093 B2: A robust, motorized moveable shelf assembly having a shelf carriage, a stationary support structure, and a motorized drive assembly that can be retrofitted into an existing cabinet structure or be combined with a cabinet structure in which the shelf carriage can rotationally-move outside and either downward or upward of the stationary support structure and back again so that the shelf carriage is more readily accessible to a person of limited mobility. This patent is similar to our design (Both are based off the Rev-A-Shelf Pull Down Shelving System). However, ours uses a linear actuator, whereas this patent utilizes a pulley-system. Also, our shelf includes obstruction sensors and wireless control. US 8424983 B1: A storage VBS with opposing side walls, a top, a bottom, a back with an open or openable front, houses movable upper and lower adjustable shelving boxes. This patent may make a good replacement for standard cabinets for those confined to a wheelchair. Since the CPRF already has cabinets our shelf is designed to be retrofitted into an already existing cabinet. 18 Industry Standards Our shelf is a modification to the manual pull-down shelf manufactured by Rev-A-Shelf. This shelf is intended to fit in cabinets that meet the standards set by KCMA 161.1 (Performance and Construction Standard for Kitchen and Vanity Cabinets). The wireless key-fob utilizes 315MHz RF. This complies with the FCC’s standard for frequency spectrum in the US and Canada (260-470 MHz). The Arduino that controls the shelf includes a USB port for communication and power. This port meets the standards for USB 1.0. Liability Concerns Liability concerns may exist depending on the structural integrity of the cabinets in which the shelves would be installed. Before installing, the user should make sure cabinets meet the standards set by KCMA. Required Certification There are no required certifications for building, installing, or operating this shelf. However, the cabinets, in which the shelf will be installed, should meet KCMA’s testing and certification standards. IX. Future Work Looking Ahead: If this product were to continue to be developed, what would the next steps be? Increase load capacity of automated shelf to meet that of the manual shelf’s rated load. Continue to improve on safe operation of the shelf. Further develop a multi-shelf design. Increase accessibility of shelf by automating the opening and closing of cabinet doors. What parts might be redesigned in your product? Eliminating the Arduino prototype board to streamline the control unit into one circuit board. The ATMega328 8-bit microcontroller itself could still be used and integrated into the single board unit. Increasing the number of accessible I/O connections by using a ATMega2560 microcontroller. Other microcontroller’s could be used but the operating code would 19 need to be completely rewritten and specs would have to be checked for any differentiation in power requirements and limitations. The current design requires the wiring to the control unit to be directly hardwired to the circuit and Arduino. An interface to the control unit utilizing a simple plug in from sensor and motor wiring would greatly enhance the usability and ease the installation process. Further research different linear actuators, specifically focusing on their load capacity. While the current actuator is rated for 100lbs., it struggled to provide the torque needed to lift the shelf from it’s down position and to control the descent speed as weight was added. Improve how the actuator is mounted on the shelf, as it is currently necessary to mount the actuator somewhat loosely on the bolts to allow for rotation. While the empty shelf would move smoothly through it’s range of motion, jerking was introduced at certain points, especially going through parallel, of it’s descent and ascent as weight was added. Using a solid ball bearing mount could possibly remedy this. Researching other, possibly mechanical, collision sensing methods is somewhat warranted. What functionality might be added? A secondary hardwired/wireless push button control, installed at the counter top for example, could be used as a backup to the keyfob in case it is lost or until a replacement for a dead battery is available. Some users may prefer this as the primary control. Control of additional shelves from a single interface would be the ideal upgrade for this project but also the largest difficulty. While the current wireless solution can control up to 4 shelves independently, more than 4 would not work even with multiple keyfobs as the receivers are not addressable. This would result in multiple shelves operating from a push of the A,B,C,orD buttons from any remote. Initially we had thought to use a smartphone app, scalable to the number of shelves, and communicate with the control unit over Bluetooth. This may be the way to proceed in the future. Another limiting factor to operating multiple shelves from a single control unit is the added wiring and I/O requirements. Some sort of wireless unit at each satellite shelf communicating with the base control unit should be explored, but this introduces separate power requirements at each shelf. An additional actuator can be installed on the other side of longer shelves if needed to keep it from twisting. What functionality seems unnecessary or is adding unneeded complexity? While some form of collision sensing method is necessary for safety purposes, other avenues should be explored. While the ultrasonic sensors worked well, the additional wiring, circuitry, and coding might be unnecessarily complex for it’s purpose. The ultrasonic sensors were chosen for their ease of mounting, and the ability to detect objects without actually coming into contact with them. A mechanical alternative with high sensitivity to contact would conceivably be acceptable. One option we thought about was a thin aluminum or plastic plate installed under the shelf with push button type switches at each corner that when the plate contacted an object it would push up against the switch depressing it and stopping the shelf. Although this would probably increase the mounting 20 complexity, a single I/O could be used to monitor all four switches reducing the wiring and coding requirements. X. Contract and Schedule Project Contract At the beginning of the second semester, we created a project contract between our team members, Dr. Skinner, and Tom McGuire. This contract promised that we would deliver a final working product at the end of the semester and that all members would participate. The contract also lists the specifications of the final product. A hard copy of this contract was signed by Dr. Skinner, Tom McGuire, and all team members. Gantt Chart Along with the project contract, we provided a Gantt chart for our instructors. This chart includes a tentative schedule and deadline for specific portions of our project. We used this as a timeline in order to stay on track throughout the semester. Appendix References: 1. Arduino o Main website can be found here Arduino homepage o Software for compiling and uploading to Arduino can be found here software o The NewPing library download and instructions can be found here NewPing 2. Suppliers o Adafruit o Rev-A-Shelf 21 Operating Code: #include <NewPing.h> //Ultrasonic sensors distance/collision setup const int maxDistance = 20; const int pingSpeed = 250; unsigned long pingTimer1, pingTimer2, pingTimer3; long distance1, distance2, distance3; //sonar NewPing NewPing NewPing object constructors (trigger_pin, echo_pin, max_scan_distance) sonar1(13, 12, maxDistance); sonar2(11, 10, maxDistance); sonar3(8, 9, maxDistance); //Power cutoff switches for when shelf is fully up or down const int upShutOff = 5; const int dwnShutOff = 6; //Pins to drive transistors to supply power to relay and motor const int rlyDrive = 3; const int mtrDrive = 4; //direction control switch (input from wireless keyfob) const int dirSw = 2; void setup() { Serial.begin(9600); pingTimer1 = millis() + pingSpeed; //SENSOR1 fires after 50ms pingTimer2 = pingTimer1 + 35; //SENSOR2 fires 35ms after sensor1 pingTimer3 = pingTimer2 + 35; //SENSOR3 fires 35ms after sensor2 //setup cutoff switches using internal pullup resistors pinMode(upShutOff, INPUT); pinMode(dwnShutOff, INPUT); digitalWrite(upShutOff, HIGH); digitalWrite(dwnShutOff, HIGH); pinMode(rlyDrive, OUTPUT); pinMode(mtrDrive, OUTPUT); pinMode(dirSw, INPUT); } /* Function to determine requested direction and the current position of shelf */ void shelfDirection(int dirSwState, int upShutOffState, int dwnShutOffState){ if(upShutOffState == LOW){ /* This overrides the switch that is activated when the shelf is in the fully up position: 22 When remote input goes HIGH and shelf is in fully up position the relay picks, delivering rev polarity to lower shelf. */ if(dirSwState == LOW){ MtrRlyDrive(LOW, LOW); //digitalWrite(rlyDrive, HIGH); //relay delivers reverse polarity //digitalWrite(mtrDrive, HIGH); //motor power is turned on } //Else shelf power is cut off and shelf remains in up position else{ MtrRlyDrive(HIGH, HIGH); //digitalWrite(rlyDrive, HIGH); //relay delivers reverse polarity //digitalWrite(mtrDrive, LOW); //cut motor power } } else if(dwnShutOffState == LOW){ /* This overrides the switch that is activated when the shelf is in the fully down position: When remote input goes LOW and shelf is in fully down position the relay drops, delivering pos polarity to raise shelf. */ if(dirSwState == LOW){ MtrRlyDrive(LOW, HIGH); //digitalWrite(rlyDrive, LOW); //relay delivers positive polarity //digitalWrite(mtrDrive, HIGH); //motor power is turned on } //Else shelf power is cut off and shelf remains down else{ MtrRlyDrive(HIGH, LOW); //digitalWrite(rlyDrive, LOW); // relay delivers positive polarity //digitalWrite(mtrDrive, LOW); // cut motor power } } /* These last two statements4 are when shelf is in transition. If switch is low, the shelf lowers. If switch is high, the shelf raises. */ else if(dirSwState == HIGH){ MtrRlyDrive(HIGH, HIGH); //digitalWrite(rlyDrive, HIGH); //digitalWrite(mtrDrive, HIGH); } else if(dirSwState == LOW){ MtrRlyDrive(LOW, HIGH); //digitalWrite(rlyDrive, LOW); ///digitalWrite(mtrDrive, HIGH); } else; } 23 /* Function to drive transistor switches for the motor and relay when the direction and position of shelf has been determined. */ void MtrRlyDrive(int rlyCntrl, int mtrCntrl){ digitalWrite(rlyDrive, rlyCntrl); digitalWrite(mtrDrive, mtrCntrl); } void loop() { /* Shelf direction: dirSwState = LOW ---> shelf raises dirSwState = HIGH ---> shelf lowers */ int dirSwState = digitalRead(dirSw); int upShutOffState = digitalRead(upShutOff); int dwnShutOffState = digitalRead(dwnShutOff); /* If 250ms has passed from last array scan sensor 1 pings Then updates to fire again 250ms later */ if(millis() >= pingTimer1){ pingTimer1 += pingSpeed; distance1 = sonar1.ping_in(); } /* Sensor 2 pings 35ms after sensor 1 Then updates to fire 35ms after sensor 1's new ping time */ if(millis() >= pingTimer2){ pingTimer2 = pingTimer1 + 35; distance2 = sonar2.ping_in(); } /* Sensor 3 pings 35ms after sensor 2 Then updates to fire 35ms after sensor 2's new ping time */ if(millis() >= pingTimer3){ pingTimer3 = pingTimer2 + 35; distance3 = sonar3.ping_in(); } if((distance1 <= 6 && distance1 >= 5) || (distance2 <= 6 && distance2 >= 5) || (distance3 <= 6 && distance3 >= 5)){ //Obstruction is detected and all power to shelf is turned off MtrRlyDrive(LOW, LOW); } else{ shelfDirection(dirSwState, upShutOffState, dwnShutOffState); } } 24 I have read the entire report and it meets my personal quality standards. Jeff McDonald Andrew Rankin Mamunur Rahman Ibrahim Al Mustaneer