Part I. High Level Design
1 Rationale and Problem Overview
As regular grapefruit consumers, both of us could appreciate the value in automating the cutting procedure. We saw the problem as suitable for a final project because it is [very] challenging while requiring a combination of software, analog electrical hardware, and physical components. The device has further appeal as something that can even be commercialized if it works well enough.
But challenges abound. For most humans, the task of cutting out segments in a grapefruit is simple. We have a substantial amount of dexterity along with direct feedback that enables us to cut around the pulp of a grapefruit with relative ease. However, an automated machine is much less capable, especially one which is constructed under a limited budget. The main challenge is trying to account for the large variability present from one grapefruit to another. We hoped to be able to cut many different types of grapefruit, including ruby red, white, and dark red varieties, as shown in Fig. 2↓
; including multiple varieties causes more problems in variability. Furthermore, no physical dimension of a grapefruit is guaranteed: the widths of the segments typically vary by a factor of at least two; the radial length of segments can be different, even within a fruit, and not perfectly straight; the strength of the pulp and edges depends specifically on the fruit; the rind has variable width; the height and width of a grapefruit varies, especially between species; there are usually seeds that knives must avoid, and so on. We tried to address all these problems and construct as robust a machine as we could, though obviously there will be cases where automatic segmenting is either inefficient or, at worst, impractical.
2 Background Math
Formal analysis of the geometry of the problem is intractable due to the large variation in grapefruit physical characteristics and lack of standardized studies on such quantities. Thus, we were unable to base our design on any sort of idealized grapefruit model, and most of our dimensions and quantities resulted from trial and error, including all the dimensions of the apparatus, the motor drive voltage, and the position of the knives on the CD tray.
It can be reasoned that the optimal solution to the problem of finding edges in the fruit would reduce to a Kalman Filter applied to either flex sensor or image data, that combined a model of grapefruit segment placement as well as the response of the sensor to the fruit. This would be an extremely complicated approach, and its behavior would depend on how well the process and measurement noises could be characterized. Dismissing this tool, the algorithms we implemented achieved, in some cases, impressive results.
Other math needed in the project is trivial, such as precalculating the gain of the amplifier in Sec. 6.3.2↓
3 Logical Structure
The overall software flow diagram is shown in Fig. 3↓
. The software had a few specific tasks at a given time, depending on what part of the process the machine was executing. Its main responsibilities were handling user input, controlling the stepper motor during the data collection phase, logging and processing sensor data, and controlling the stepper and DC motors when cutting. Since the design only requires a few steps to be done sequentially, the software was straightforward compared to that of previous labs (e.g. the video game
). For more detail on the specific implementation of each task, see Sec. 7↓
There are independent circuits for the flex sensor, stepper motor control, DC motor control, and user interface. See Sec. 6↓
for more detail on each of these.
During typical operation of the machine, the user must hit the “Start/Stop” button to initiate the cutting sequence after power up. The MCU begins rotating the grapefruit around its center axis by commanding the internal electromagnetic components of the stepper motor, which is driven by the MCU via a Darlington array. As the fruit is rotating, the carefully-supported piezoelectric flex sensor deflects off the edges of the grapefruit. The sensor transduces the small mechanical deflections into measurable electrical signals,[C] [C]For the principles of piezoelectric sensor operation, consult Wikipedia
which are amplified by a non-inverting op-amp amplifier, then fed into the ATMega644’s analog to digital converters (ADC) with an adjustable threshold, producing a time history of how the sensor position changed as it was dragged across the fruit. Because we need to know the angular displacement of the fruit at all times, and because we need to start and stop rotation instantaneously, the stepper motor, with its discrete driveshaft positions, was the obvious choice for the task of rotating the fruit.
Once the sensor has traversed the fruit, the MCU halts the stepper motor and calculates the best estimate for all the edge locations. Then the MCU controls the DC motor on the CD-ROM tray and the stepper motor simultaneously to rotate to the next estimated edge location, drop the cutting knives, and raise the cutting knives, until all found edges are accounted for. An H-bridge controls the DC motor, allowing the MCU to drive the CD tray up and
down (as well as at much higher voltage and current than the MCU can supply). At any point in the operation, the user can hit the “Stop/Start” button to pause the machine. Status LEDs indicate the current step in the process that is executing, including when safety checks have failed. The basic flow of the hardware is illustrated in Fig. 4↓
4 Hardware/Software Tradeoffs
Our design allows for computationally cheap operation by doing much of the necessary work in hardware. Our original design involved using a camera to detect edges, as described in Sec. 8.1↓
. This would have been extremely intensive in terms of both computation power and memory requirements, because each (possibly color) frame would have to be read in to the MCU and digitally processed before letting the stepper advance the fruit position. Instead, using a force sensor mounted on a cantilever is an elegant solution to finding the edges of the fruit: not only does it reduce the amount of information to process per edge, but it also allows us to process the signal partially in hardware. Initially, we didn’t even use the ADC, opting to tradeoff software complexity for very slight hardware complexity, namely a comparator. The stepper motor positions (hereafter referred to simply as “steps”) where the comparator transitioned from logic low to logic high were saved in an array, and we ran it through our own simple edge finding algorithm to deduce the most likely edge locations from a sparse set of data (see Sec. 7.4↓
). Ultimately, we redesigned the edge detection algorithm to use the ADC, undoing this tradeoff.
Another design consideration was to use as few motors as possible without losing accuracy or robustness in operation. We tried to implement as many things as possible in mechanical hardware, so that we could forgo extra control logic on the MCU. In this spirit, we chose not to have separate motors drive the exact radial position of the knives, the rotation of the “back” or “rind” knives, or the sensor height. The minimum number of motors we found could was two: one for rotating the fruit and one for raising and lowering the knives. We decided that the accuracy possible using a fixed radial position would be sufficient, given that the variation in grapefruit diameter is not too extreme. The fact that stepper motors can be run without any extra sensors or control (open-loop) simplifies software substantially, as we won’t need to implement any sort of closed-loop rotation measurement and PID control as in the tachometer and motor control lab (Lab 4
To control the DC motor that powers the cutting knives, we could either use pulse-width modulation (PWM) of a fixed voltage to vary the supply power, or we could simply use a constant voltage. The former approach is very flexible, allowing effective motor speed to be adjusted via software. However, it also requires non-trivial closed-loop control for best operation. Since we have access to a variable power supply in lab, and various diodes to perform any crude voltage regulation if needed, we decided to only use a constant drive signal, relying on empirically derived timings to change the motor state. In addition, we had to come up with mechanical ways to control the parallel edge-cutting knives with the circumferential rind-cutting knives with the same motor. For a full description of the physical design, see Sec. 6.4↓
Lastly, having a simple user interface is important because it means having less complicated hardware and software. Because our device is built to perform one function only, we could reduce the user interface to a two-button panel. Instead of a more expensive and inefficient LCD readout, we installed four LEDs for status indication. The extra work was worth the improvement in the user experience.
5 Existing Patents, Copyrights, and Trademarks
As far as we can tell, there are currently no automated grapefruit cutters commercially available, though several hand-operated gadgets exist. A portion of our design idea did come from the Chef’n Grapefruiter(tm)
, a manually operated grapefruit sectioning tool pictured in Fig. 5↓
. However, on top of being fully automated, our design seeks to cut out segments that are of variable width instead of having a set distance between blades as in the Grapefruiter and all solutions we found on the market.
Figure 5 Grapefruiter with back knife fully retracted. From Amazon.com product listing.
Part II. Program and Hardware Design
6 Hardware Details
DC Motor Circuit
As put forth in Lab 4
, it is always a good idea to isolate logic power from motor power to avoid excessive noise induced from a DC fan (especially one with brushes) or current dips as the motor(s) strain. The main slicing knives are mounted onto a heavily modified CD tray scavenged from an old desktop PC. Fortunately, after stripping it down to the bare essential components needed for this design, we saw that the tray was powered by a simple DC motor with a complex, but robust mesh of gears. Pre-assembly testing revealed that the motor+tray apparatus can handle well over 5V, and provides a very strong push at 9-12V without noticeable strain in any of the components. In fact, testing revealed that the 5V the motor typically runs off of is insufficient cut the grapefruit, so we had to up the motor power to a full 12V, drawn from a regulated 12 V rail from the power supply unit (PSU) scavenged from an old computer (for more see Sec. 6.4↓
In order to move the tray from software, we needed to connect a high-voltage, relatively high-current power supply in one of two polarizations across the motor leads to get it to extend or retract. An H-bridge circuit, shown as a simplified set of switches in Fig. 7↓
does just this. It is a simple set of four switches–usually transistors–that engage in one of two patterns to apply a voltage in either direction across a DC motor, thereby turning the driveshaft in both directions. The circuit can also attempt to brake the motor by shorting the two terminals to VM
or ground. One must also be careful when controlling these switches from software, since it is easy to cause a short circuit by turning on either a top and bottom switch on either side.
The implementation of the H bridge can prevent this. While we can build an H-bridge with components commonly available in lab, H-bridge ICs offer a more robust solution with short-circuit protection, level shifting (in case motor and logic voltages are different, as they are in ours), a high range of voltage operation, and high current output. Based on I/O and package requirements, we opted for a Freescale MPC17510, in a small-but-solderable 24-pin TSSOP package. The IC takes as input three signals from the MCU: an enable toggle EN
, and two pins IN1
to determine polarity applied to the motor. Setting these latter two pins to (HI, LO) biases the motor one way, while (LO, HI) biases it the other. The circuit handles all other combinations of EN
, and IN2
without short circuiting. Two outputs of the IC go to the motor leads, and several other pins are connected with capacitors to act as charge pumps for the level shifters (not related to actual operation of the H-bridge; used for going from logic level to transistor-driving levels). We have discussed here only the crucial operational components of the particular chip; see the datasheet, available in Sec. 17↓
, for much more detail and explanation for all the extra pins that seem to complicate a simple circuit.
6.2 Stepper Motor Circuit
Other steppers, namely bipolar motors, have only four leads, while higher phase-count motors have even more. Six-lead is a common arrangement, and allows for simpler, unipolar drive circuitry by having a center tap on each coil to make reversing current direction easy. A stepper motor can’t be driven with a simple constant DC or PWM signal — it has six input wires (see sidebar) that all need to be set appropriately in order to energize electromagnets that cause a central permanent magnet to spin. The magnet is the shaft, and by pulsing current down the coils of the electromagnets in the proper sequence, we can pull the magnet around in discrete steps. Fig. 8↓
shows an animated mock stepper motor as its internal magnets turn on sequentially to attract different teeth and cause the shaft to spin.
Figure 8 Physical Operation of Stepper Motor. (By Wapcaplet; Teravolt.Teravolt at en.wikipedia [GFDL
], via Wikimedia Commons)
There are many different types of stepper motor, as well as different winding arrangements, which determine how the magnets shown above are controlled. The motor used in our design, an Aratron AB model PF35T-48, is unipolar, two coil model.
Figure 9 2-phase unipolar stepper motor internal coils and wiring.
(By Yegorius (Own work) [GFDL
], via Wikimedia Commons.)
The internal wiring corresponds to the idealized model shown in Fig. 9↑.
The two common wires are shorted and go to motor power, while the other four go to the outputs of a Darlington array. The Darlington array chip (ULN2003AN) contains seven pairs of transistors arranged in a Darlington configuration (Fig. 10↓
Figure 10 Transistors in Darlington pair.
(By Jacek FH (Own work) [Public domain], via Wikimedia Commons).
, which act as input current amplifiers, in this case of the four control signals from the MCU going to the four different coil taps. By alternating which of the coil-end wires is ground, the direction of current and thus orientation of magnet poles can be changed.
There are also several stepper drive patterns that result in different motor torques and angular resolution. Since our stepper motor is mating to a large-diameter gear, a relatively large step on a small motor shaft radius maps to a much smaller angular step on the gear that holds the grapefruit. Thus we chose to use a high-torque full step
drive pattern that has two phases energized at a time, as opposed to the one-at-a-time example of Fig. 8↑
. The step sequence is stored in software as a 2D array look-up table; the MCU sets the output ports to the appropriate value based on what the integer step index is. For smoother operation, the ideal drive patterns are sines and cosines, phased appropriately. This would require a look-up table and D to A converter, complicating our design unnecessarily. The vibration from the motor is significant, but it does not affect the quality of measurements or cuts, and we significantly reduced the noise by adding padding around the edges of the platform to dampen the vibrations.
Figure 11 Full Step drive pattern, where A
are the two coil-ends of one phase, and B
are the ends of the other. (By Misan2010 (Own work) [CC-BY-3.0
], via Wikimedia Commons)
6.3 Sensor Circuit
Our sensor circuit can be divided into two main, sequential parts: the piezoelectric sensor that’s attached to the fruit probe and an analog amplifier.
6.3.1 Piezoelectric sensor
The sensor we used was an extremely sensitive, LDT0-028K laminated piezoelectric film vibration sensor. We mounted it on a cantilever apparatus, as shown in Fig. 12↓
, which was constructed out of LEGO® bricks. A dulled X-Acto© blade is attached to the end of the cantilever, so that when the device is positioned above a rotating grapefruit half, with the point of the blade submerged in the flesh by about 4 mm, the blade point would be able to ride along the surface, transferring the up and down motion down to the axis of the cantilever, on which the sensor is placed.
Figure 12 Piezoelectric sensor mount. A cantilever vibrates when a fruit is rotated under the tip of the knife.
6.3.2 Amplifier and Analog to Digital Converter
When testing with real grapefruit, we found that our sensor was able to produce voltage spikes on the order of 20-200 mV after hitting an edge. In order for the MCU to interpret these reliably, we chose to amplify the signal substantially. We used an operational amplifier on the LM358 chip to create a single stage non-inverting amplifier (with topology shown in the schematic of Fig.25↓
, as well as this
thorough Wikipedia page). The gain of the amplifier was
VoutVin = (1 + R2R1) = 101,
Moreover, we felt more comfortable operating the ADC with a much larger amplitude range, especially since our bit depth is “only” 8 and we aren’t bothering with ADC noise cancellation.
which increased the sensor output to a maximum of 5 V, at which it has been clipped. This amplified signal is then fed into a single channel of the MCU’s on-board analog to digital converter (ADC). The configuration of the ADC is discussed more in the relevant software section, but in order for the physical ADC to assign discrete values to input voltages, it needs a reference voltage. This can be the 2.5V band-gap reference voltage available internally, a 1.1V internal reference, or whatever value is supplied on the AREF pin of the MCU. We ran VCC through a 10K pot back to MCU ground, put a large cap on the wiper of the pot to smooth potential voltage fluctuations for a maximally stable reference, and set the AREF value manually after measuring a few runs of the sensor output on an oscilloscope. This lets us change the levels easily as we change other parts of the design.
Why did we bother to amplify the signal instead of just setting a suitably low VREF for the ADC? In order to get more accurate quantization, it’s important to set VREF to retain as much dynamic range as possible while clipping only the inputs that add no extra information. Simply put, it’s hard to tune a reference voltage down to a few tens of millivolts with accuracy using only a pot–multimeters can only offer so much accuracy.
In the final implementation, this parameter is fixed; were this a commercial product, the user would not be expected to tweak such a parameter with no a priori knowledge of the machinations of the device and how it reacts to different types of grapefruit.
We also found through extensive testing that it’s best to amplify a certain lead of the sensor over another. The flicks that occur when the probe drops from an edge back down to the flesh are much sharper in time and higher in amplitude than the comparatively smaller magnitude “humps” of output when the sensor knife first rides up an edge. Before attempting an ADC solution, we checked the duration of these flicks. Since we’re only sampling at a relatively slow 390 Hz (Ts = 2.56 ms), these pulses must be large enough to ensure that we capture them. Fortunately, they are on the order of 5-10 ms wide so such a low rate is acceptable.
6.4 Physical Construction
Most of the parts for the physical structure were purchased from Lowe’s or created from various parts that we already owned. The main aspects of the physical construction are the base and supports, the rotating platform, the force sensor mount, the CD tray actuator, and the safety enclosure.
The overall physical design is shown in Fig. 13↓
. We constructed the base of the apparatus out of two parallel sheets of Masonite pegboard with 1/4” holes, between which we sandwiched the stepper motor so that the gear of the motor was protruding from the top piece. We attached a vertical piece of pegboard to the base as a support for the CD tray. A long 1/4” diameter bolt through the base acts as a variable height stand for the sensor, which could be adjusted easily by moving the wing nuts holding the sensor in place up or down. We also extended two thin dowels from the base to the unsupported side of the CD tray to act as further support and stabilize the motion of the knives, with further wire and dowels to provide rigidity to the system, shown in Fig. 14↓
. Last, we mounted a torsion spring on a 1/4” bolt between the CD tray pegboard support and the fruit to keep the fruit from shifting while knives were cutting, shown in Fig. 15↓
The rotating platform shown in Fig. 16↓
consisted of a 2.25” diameter gear rotating on a 1/4” bolt positioned so that it meshed with the gear of the stepper motor. The relatively large gear size compared to the stepper motor gear allowed us to control the position of the plate in much smaller increments than a single step size for a motor could provide, resulting in much more precise positioning; See Sec. 7.2↓
for the full details. On this we fastened a hard plastic plate so that the plate and gear would rotate together about the bolt. Four small nails near the center of the plate, anchor the grapefruit to the plate.
The force sensor mount that we constructed is mentioned in Sec. 6.3↑
We mounted the CD tray vertically and used its DC motor as a linear actuator to propel the knives up and down into the fruit. The motor was already equipped with a gear system, meshed to a toothed tray riding on plastic rails. In order to implement the rotating knives that cut around the rind, two rectangular grooved plastic pieces made of LEGO® bricks were mounted to an axis at the base of the CD tray; these are shown in detail in Fig. 17↓
. A bolt extending on both sides of the CD tray rides in grooves cutout in the knife arms. When the tray moves up and down, this bolt slides in the groove, causing a rotational motion about the pivot point on the corner of the CD tray. Both the parallel knives and the rind knives are detachable so that they can be easily cleaned.
Because safety was a large concern for the project, we constructed an enclosure out of a plastic bin to shield the user from the dangerous parts of the device. The device is built on top of the underside of the lid, and the user has to place the bin over the lid to seal it, actuating a switch to ensure the cover is on tight before beginning operation, as shown in Fig. 18↓
. We enforced this safety feature by connecting two separate leads to the underside of the lid, stripping off a large portion at the endpoints, and running it through the handle. A separate wire runs from one edge of the bin, around the outer lip, and to the other edge of the bin such that having the bin placed on the device short the two exposed lead ends attached to the lid (see Fig. 19↓
). Safety is discussed in more detail in Sec. 11↓
|Custom PCB Breakout Board
||Hosts MCU, power, and connections to rest of project
|Wires, resistors, and capacitors
||Connectivity, motor control circuitry, filtering, detection, etc.
||Free in lab
|1N3024 15V Zener diode
||Back-EMF Snubbing for DC motor circuit
||Free in lab
|ULN2003AN Darlington Array
||Stepper motor control
||Free in lab
||Analog motor control hardware
||For knife arm
||Free in lab
|PF35T-48 Stepper motor
||Free in lab
||Knife mounting and rotation
|Plastic enclosure box
|Hardware – 1/4”-20 nuts, bolts, screws
||Connections through the fiberboard
||Lowe’s & Free in lab
||Custom board connections
|Freescale MPC17510 H-bridge
||DC motor control
|Generic TSSOP Breakout Board
||To host H bridge
||Free in lab
|Measurement Specialties LDT0-028K
||Piezo flex sensor for flick detection
||Cannibalized for knives
||18 total , 6 each of 3 varieties
||Power and reset
||Free in lab
|100W Power Supply
||Mains to +12V, 2A regulated DC for MCU and motors
||For holding sensor onto mount
||Free in lab
|LM358 Dual Op Amp
||Piezo Sensor output amplification
||Free in lab
|Alligator clips (x2)
||Connecting the DC motor
Low cost PCB on PCBWay - only $5 for 10 PCBs and FREE first order for new members
PCB Assembly service starts from $88 with Free shipping all around world + Free stencil
PCBWay 2nd PCB Design Contest