DETAILED DESIGN REVIEW: Wireless Assistive Control System Project 08027 Todd Bentley, ISE Vianna Muller, EE Benjamin Danziger, EE Peter “PJ” Drexel, EE Jay Radharkrishnan, EE James Corcoran, CE Dr. Edward Brown, Advisor November 2nd, 2007 RIT Multidisciplinary Senior Design 1 Page 1 of 46 Design Review: Table of Contents Function Diagram Front End Customer Needs for the Front End Strap Design BOM: Strap Controlling Hand Movements BOM: Electrodes Test for Deciding Electrodes Filter, Controller Customer Needs for the Filter and DSP Unfiltered EMG data Filter types Exploration of Crosstalk DSP 537 Architecture Control System Operation Processing Requirements and Specifications Audio System Audio Interface Audio Amplifier Design BOM: Speaker Amplifier Wireless System RC Car The QFD as it relates to the RC Car. Microcontroller Development Board Programmer RC Car Pseudo Code Visual Feedback BOM: RC Car Bill of Materials Page 2 of 46 3 4 5 7 9 10 10 10 11 11 13 14 15 21 26 28 30 30 31 31 32 34 34 35 36 38 40 42 45 46 Design Review: Functional Diagram Right Thumb Left Thumb Left Fingers Right Fingers Amplifier Grass Tech. BF511 DSP Development Board (for BlackFinn 533) DSP: Filter and Controller BlackFinn 533 RF TX Sound Transmitted Commands RF RX Micro Controller Motor ATtiny2313 Motor Figure 1: Overall System Functional Diagram Page 3 of 46 Speaker Left Right Forward Reverse Design Review: Front End Right Thumb Left Thumb Left Fingers Right Fingers Amplifier Grass Tech. BF511 DSP Development Board (for BlackFinn 533) DSP: Filter and Controller BlackFinn 533 RF TX Sound Transmitted Commands RF RX Micro Controller Motor ATtiny2313 Motor Figure 2: Front End Functional Diagram Page 4 of 46 Speaker Left Right Forward Reverse Category Front End Nu. Specification Units Ideal Marginal A Directs/Protects EMG wires A2 Ergonomic Design, size ft 4 ±1 Universal Fitment of glove A3 Ergonomic Design, size ft 2 ±0.5 1 Universal Fitment EMG wires A4 Ergonomic Design, size in 8 ±5 1 Aesthetic value ("coolness") A5 The "Fonze" Factor N/A N/A N/A Secures EMG pads in place Durable A6 A7 Location of pads Material N/A N/A N/A N/A Comfortable to wear A8 Ergonomic Design, size in Safe Electrodes and Wires A9 Current into the body A Electrode Size A10 Radius Page 5 of 46 N/A N/A Cm 8 ±5 3 1 1 Documentation Wires must be easily able to connect to electrodes Wires should be thin and insulated Electrodes must be grounded consistently Amplifier no more than 5 lbs Guaranteed safety by manufacturer High strength thread used for construction Rating of the appeal of the glove to the customer. Easily stored for extended periods of time 3 1 1 3 3 1 1 3 1 1 3 3 1 None None 2 Wear resistant straps Velcro strong enough to hold without loosening Strap length sufficient to wrap arm of most operators Length of wires sufficient for most operators Puts EMG wires and electrodes close to desired location Customer Needs for the Front End 9 3 3 1 33 3 3 1 1 3 1 3 Anthropometric Summary(cm) Wrist Breath Female Elbow Breadth Male Female Wrist to Elbow Male Male 5th 95th 5th 95th 5th 95th 5th 95th 5th 95th 4.6 5.9 5.3 6.6 5.7 7.7 6.4 8.2 31.9 41.1 The wrist to elbow dimension requires a maximum only since anyone with arms shorter than 41.1 centimeters will simply have a bit of slack between the wrist and elbow points. Summary of Specs and Anthropometric Basis Desired Spec Strap Anthropometric Data Measure Converted Circumference around elbow Elbow Strap Elbow Breadth is the diameter of the elbow 8.2 10.1 Circumference around wrist Wrist Strap Wrist Breadth is the diameter of the wrist 6.6 8.2 Length of wrist to elbow Connecting Tube Relates to the Wrist to Elbow Distance 41.1 16.2 Height from wrist to thumb Thumb Strap No anthropometric data exists for such a measure, convenient since it is not necessary to know. N/A N/A The final column represents a conversion of the anthropometric data from a diameter to a circumference and converting the measure from centimeters to inches. The final lengths of each strap will need to overlap so an additional 3 inches was added for the Velcro overlaps. --For the length of the wires from the electrodes to the pack anthropometric data was used combining the 95th percentile for the reach of the human male and the waist to shoulder height for the same male. The length of the thenar-to-pack wire was found to be 4.5 feet and the length of the finger flexors-to-pack wire was determined to be 3.5 feet. This would allow the operator to control the vehicle with his or her arms over their head. **All Data Collected from NHANES/NCHS databases and Bodyspace by Stephen Pheasant.** Page 6 of 46 Figure 3: Three-Dimensional View of the Strap Page 7 of 46 Figure 4: Strap Components with Measurements Page 8 of 46 BOM: Strap Primary Sources Item 1" Nylon Webbing Quantity (Roll) 1 - 50 ft Roll Total Price $22.90 1" Nylon Web Tubing 1 - 50 ft Roll $20.50 2" Nylon Webbing 1 - 50 ft Roll $30.50 1.0" Duragrip ™ Black Hook Std 1.0" Duragrip™ Black Loop SewOn 1 - 25 ft Roll $12.50 1 - 25 ft Roll $12.50 1" Ladder Locks 10 @ $1.17 $11.70 500 Denier Cordura Plus® Page 9 of 46 1 yd Sub-total Est. Shipping Total $13.40 $124.00 $20.00 $144.00 Controlling Hand Movements One potential problem is the differences in a person’s movements were that they produce varying signals. A solution to the problem is to have a hand controller that would limit the variation of movements from operator to operator. This hand controller would consist of something that will require the user to push inward using all four of their fingers, thus maximizing the potential created by their flexors. Also, this hand controller will be spring loaded, but testing purposes we would simply grip the controller we have now with reasonable force. On top of the hand controller, there will be an analog stick much like the current video game controller we are currently using. Ultimately, the analog stick would have to move in only one direction but for out tests we will only move it medially. This will control the contraction of the thenar muscle group in the thumb by forcing the user flex their thumb inward. BOM: Electrodes Item Source 1025 passive electrode DDN 20 passive electrode Part # 243 (with GND) Part # 242 The Electrode Store The Electrode Store Noraxon, USA, Inc Noraxon, USA, Inc Amount Cost Status 3 boxes $165 arrived 20 packages $110 arrived 1 TBD getting quote 1 TBD getting quote This BOM pertains to the needs of the IRB and will depend on the following test. Test for Deciding Electrodes In order to decide which electrodes will work best, first we have to decide which type of electrode is preferred: active or passive. Active electrodes have a preamplifier closer to the muscle, thus improving the signal. Passive do not have this feature and depends on the amplification provided by the Grass Technologies QP511. To compare, the Meditrace passive electrodes will be used in a series of movements with the electrodes places on the appropriate locations on their arm. Then, placing the active electrodes in the same locations and performing the same movements. Finally, the signals will be compared, after taking into account numerically for the pre-amplification by normalizing the gains, which makes a visual determination of the noise possible. Whichever produces the least noise will be the better choice. Our prediction is that the active electrodes will prevail. However in the case where there is no significant difference between the two signals concerning noise, the passive electrodes would be preferred since they are less expensive. Page 10 of 46 Design Review: Signal Processing Right Thumb Left Thumb Left Fingers Right Fingers DSP Development Board (for Amplifier Grass Tech. BF511 DSP: Filter and Controller BlackFinn 533 BlackFinn 533) RF TX Speaker Sound Transmitted Commands RF RX Micro Controller Motor ATtiny2313 Motor Left Right Forward Reverse Figure 5: Data Processing Functional Diagram Category Filter/DSP Sampling Rate Acquisition Lines Line to Transmitter Line to Speaker Page 11 of 46 Number B B1 B2 B3 B4 Specification Units Ideal Marginal Range Input Output Output second 10,000 ±250 N/A 4 >4 1 N/A 1 9 9 9 Documentation Transfer Rate Number of inputs for each command and clarity After A/D conversion, there is a large number samples Customer Needs for the Filter and DSP 1 1 1 1 9 Implementation of Filter in the system The 4 lines of on analog data enter DAQ and leave digitized and enter MATLAB. From here the filtration process will start. As of right now, a sampling frequency of 500Hz is being used, the thumb uses 5k amplification and the forearm muscle uses 50K amplification. After the data is obtained, the RMS is taken and then it will be filtered. The movements used to obtain data will be categorized as A, B, C and D. The A and B movements are on the right arm and the C and D movements are on the left arm. The A and C movement uses the forearm muscles and the B and D movements use the thumb muscle. In senior design II, the filtration process ADC will happen inside of the DSP along with the filtering. After the data is filtered, it is sent the control system to figure out how to handle the data further. Some unfiltered data can be seen on the following page. Note that the period of activity is a rough estimate. Page 12 of 46 Unfiltered EMG data after RMS Figure 6: an example of the A movement (50K amplification) Figure 7: another example of the A movement (50K amplification) Figure 8: example of the B movement (5K amplification) Figure 9: another example of the A movement (5K amplification) Page 13 of 46 Filter types From the International Encyclopedia of Ergonomics and Human Text, it is seen that the three main filters to look at are a Low pass, a High pass and Notch filter. The low pass will be used with a 600hz cutoff frequency when working with surface EMG and 1000Hz when working with fine wire EMG to prevent aliasing. It is suggested to use an analog filter for this. The High pass filter would be used with a 15 cutoff, due to the rapid hand movements to remove movement artifacts. It is suggested to use a 4th order Butterworth filter. The notch filter is used at 60Hz to get rid of noise from power lines. From Muscles Alive by J.V. Basmajian, the limits of the EMG frequencies were observed to be 20Hz to 1000Hz Working with RMS data When working with the EMG signal, we want to work with the RMS data (root mean squared). In order to replicate this on the grass QP511, the RMS function will have to be performed on the DSP. An equation similar to this will have to be used. Xrms ( X 12 X 22 X 32 ... X n2 ) n Page 14 of 46 Exploration of Crosstalk Shown in the following graph is data obtained of a person doing the A movement with electrodes on both the arm and thumb. 50K amplification was used was the forearm while 5k was used on the thumb. Cross talk with movement A 4.5 4 3.5 voltage (v) 3 2.5 2 1.5 1 0.5 0 -0.5 0 1 2 3 4 5 time (s) 6 7 8 9 10 Figure 10: Crosstalk on Movement A In the next graph is data obtained of a person doing the B movement with electrodes on both the arm and the thumb muscle group. 50K amplification was used was the forearm while 5k was used on the thumb. Cross talk with movement B 4.5 4 3.5 voltage (v) 3 2.5 2 1.5 1 0.5 0 -0.5 0 1 2 3 4 5 time (s) 6 7 8 Figure 11: Crosstalk on Movement B With these two movements, there is minimal cross talk to be seen. Page 15 of 46 9 10 Smoothing Techniques We looked at a couple of smoothing techniques to handle the data. We tried a moving average technique to make the data more workable. Here is the code for the moving average: y= xlsread('C:\Documents and Settings\tkb1214\Desktop\test a-1'); y=y'; x=linspace(0,5,2500); t=linspace(0,5,2500); %settign up the graph %size of moving average n=50; out=linspace(0,0,2500) %itterate over the lenth of the data starting from n points in for i = n:length(y) %copy the contents of our window into a temp array for j=1:n temp(j) = y(i-n+j); end; out(i) = sum(temp)/n; end; figure(1) plot(t,y, 'b'); hold on plot(t,out,'r') ylim([0 5]) ylabel('Voltage (v)') xlabel('Time (s)') figure(2) plot(t,y) ylabel('Voltage (v)') xlabel('Time (s)') figure(3) plot(t,out, 'r') ylabel('Voltage (v)') xlabel('Time (s)') Figure 12: Moving Average Code Page 16 of 46 5 4.5 4.5 4 4 3.5 3.5 3 3 Voltage (v) Voltage (v) 5 2.5 2 2.5 2 1.5 1.5 1 1 0.5 0.5 0 0 0.5 1 1.5 2 2.5 Time (s) 3 3.5 4 4.5 0 5 0 0.5 1 Figure 13: Both the original and smoothed signal 1.5 2 4.5 4 Voltage (v) 3.5 3 2.5 2 1.5 1 0 0.5 1 1.5 2 2.5 Time (s) 3 3.5 Figure 15: The unsmoothed signal Page 17 of 46 3 3.5 4 Figure 14: The smoothed signal 5 0.5 2.5 Time (s) 4 4.5 5 4.5 5 Control System A proper model of the situation is necessary before designing the control system. This section extensively describes the model and logistics of the control system. How the control system fits into the overall project architecture is shown in the block diagram below. The controller and the digital filter is both implemented in the DSP processor. DIGITAL FILTER CONTROL SYSTEM WIRELESS Tx Figure 16: System architecture under scrutiny The Control system was designed qualitatively by modeling the situation at hand. For instance, the situation is presented where a muscle is flexed from its initial rest position at point (a) in the figure below to the point (b) and returned back to its original rest position. The user’s motion does not have to be like this; however it represents the range of force exerted by any muscle. The EMG data is recorded to process and develop the control system in a similar manner. Figure 17: The range of movement of muscle under scrutiny The figure 3 below shows how this can be represented through a graph. The points (a) and (b) from figure 1 is shown on the figure 2. This graph can be seen as the input to the controller. The only exception is that 4 different muscles excerpt properties in a similar manner. The 4 different muscles exhibit the same range of force. IT SHOULD BE NOTED THAT THESE GRAPHS ONLY MODEL THE SITUATION AND DOES NOT REFLECT ANY EMG DATA. Page 18 of 46 Figure 18: Controller input model For this project we have 4 different muscular inputs that translate to subsequent outputs that go through a wireless transmitter to the RC car. For instance how one input is related to the output is shown in figure 4 below. Figure 19: Relationship of EMG input data to move left to the output on the RC car It can be noted that the EMG data to move right works in a similar way, except the output will be taking into account the range in which the tires of the RC car turn right. However, the input-output relation to move forward and backward is slightly different. This is more clearly shown in figure 5 below. Page 19 of 46 Figure 20: Relationship of EMG input data to move forward to the output of the RC car. Here, it can be seen that the input is tied to the velocity of the RC car to move forward. The same relationship is applied to move the car backward. This whole modeling idea is influenced from fuzzy logic modeling. However, the lack of overlapping membership functions, made full fledged implementation of fuzzy logic unnecessary and impractical. However, concepts from fuzzy logic are used in this digital controller. A much clear representation of this modeling is shown in figure 6 below. Figure 21: The explicit modeling of the control system Everything explained till now is shown in the figure above. How the force excerpted by the muscle should translate to the movement of the RC car is explained in the figure above. A further explanation of how this is done in the DSP processor is explained below. Page 20 of 46 DSP 537 Architecture Figure 22: BF537 Board Architecture It can be seen from the figure above that the processor does not have an in-built ADC or DAC. The ADC and DAC are both peripheral devices on the Development board. General-Purpose IO This section describes general-purpose IO signals that are controlled by means of setting appropriate registers of the flash A or flash B. These registers are mapped into the processor’s address space, as shown below. Page 21 of 46 Table 1: Flash Memory Map on BF533 Flash device IO pins are arranged as 8-bit ports labeled A through G. There is a set of 8-bit registers associated with each port. These registers are Direction, Data In, and Data Out. It could be noted that the Direction and Data Out registers are cleared to all zeros at power-up or hardware reset. The Direction register controls I/O pins direction. When a bit is 0, a corresponding pin functions as an input. When the bit is 1, a corresponding pin is an output. This is an 8-bit read-write register. The Data In register allows reading the status of port’s pins. This is an 8-bit read-only register. The Data Out register allows clearing an output pin to 0 or setting it to 1. This is an 8-bit read-write register. Table 2: Flash A configuration registers for Ports A and B Figure 8: ADC connector jack on the development board Page 22 of 46 The EMG signals need to be hooked up directly the four input pins of J5, these input pins are hooked up to the ADC at pins 16-19, and pins 22-26.This is clearly shown in the figure below. Also, the analog signal is amplified by ADI amplifier that has a 120 dB open loop gain, low noise, low input bias current and low offset voltage. Figure 23: Audio Codec with ADC and DAC pins The figure above also shows the pins for serial communication, these are pins SCK MOSI MISO and PF4 (Pins: 50, 51, 2, and 49). The MOSI signal is for the SPI bus, and MISO is the pin through which data is brought to the board through the 90-pin connector. This is clearly shown in figure 9 and 10. However, the reset for the ADC (AD1836) is controlled by the GPIO pin PA0 in flash A. How it is connected on the 90-pin connector is shown in figure 10 below. Also, the pins of interest are circled in red as seen in the figure. The GPIO’s subsequent connection on the processor is shown in figure 11. The serial peripheral interface (SPI) of the ADSP-BF533 processor connects to the AD1836 audio codec and the expansion interface. The SPI connection to the AD1836 is used to access the control registers of the device. The PF4 flag of the processor is used as the devices select for the SPI port. The SPI signals are available on the expansion interface and on the SPI connector (P6). The inputs are available on the board as two stereo headphone jacks. These inputs are then connected to IN1R+/-, IN1L+/- and IN2R+/-, IN2L+/- respectively on the AD1836 chip. This is clearly shown in figures 8 and 9. Page 23 of 46 Figure 24: J2 connector on the Development board Analog-to-Digital Converter (ADC) The AD1836 is a high-performance, single-chip codec providing three stereo DACs and two stereo ADCs. A SPI port is included, allowing a microcontroller to adjust volume and many other parameters. On the ADC, the analog inputs are multiplexed on a single ADC per channel. As shown in the figure below the left channels are Page 24 of 46 multiplexed on one ADC and both right channels are multiplexed on the other ADC. In the figure below, it can be seen there are four inputs to the ADC. The four EMG signals will be hooked up to these inputs. Therefore, the right arm’s data will be connected the AIN2L1 and AIN2L2, and the left arm’s data will be connected to AIN2R1 and AIN2R2. These inputs are selected because the ADC will be operating in the Time-Division Multiplexed (TDM) mode. Figure 11: Functional Block Diagram of the ADC (AD1836) Page 25 of 46 Control System Operation How the control system functions will be explained in detail in this section. At this point, it is assumed that the digital filter cleans out the raw EMG data. The filtered EMG data is fed to the controller; this is clearly shown in the figure below. LEFT INPUT DIGITAL FILTER FILTERED DATA RIGHT INPUT CONTROL SYSTEM WIRELESS TRANSMITTER FORWARD INPUT BACKWARD INPUT Figure 25: Detailed operations diagram of the control system The controller accepts the inputs and transmits 8 bits of data as the output through the wireless transmitter. The controller logic is pretty important in deciding the output and is briefly explained here. The truth table clearly shows the situations in which a particular output can be high. Left (i) 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 Right (i) Forward(i) 0 0 0 0 0 1 0 1 1 0 1 0 1 1 1 1 0 0 0 0 0 1 0 1 1 0 1 0 1 1 1 1 Reverse(i) 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 Left(o) Right(o) Forward(o) 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 1 0 0 1 1 0 1 0 1 0 0 1 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 Table 1: Truth Table for the input-output relation The truth table can be summarized to the follow assumptions: Left output is high when the Left input is high and when the Right input is low. Right output is high when the Right input is high and when the Left input is Low. Forward input is high when the Forward input is high and when the Reverse input is low. Reverse input is high when the Reverse input is high and when the Forward input is low. Page 26 of 46 Reverse(o) 0 1 0 0 0 1 0 0 0 1 0 0 0 1 0 0 Depending on the inputs, the output that will go through the wireless transmitter is an 8 bit number. How the 8bit data is allocated is shown in the figure below. Figure 26: Bit allocation for the 8-bit output From the above figure, it is apparent that there are 16 positions for forward/Reverse Directions and 16 positions for Left and Right Directions. All of this information is integrated using the following pseudo code: a= 4bits of information for right/left turn b=4bits of information for forward/reverse direction If (left amplitude > right amplitude) Then (resulting left turn= (left – right) of a’s left magnitude) If (right amplitude > left amplitude) Then (resulting right turn = (right-left) of signed a’s magnitude) If (right amplitude = left amplitude) Then (a=0000) If (forward amplitude > reverse amplitude) Then (resulting forward magnitude = (forward – reverse) b magnitude) If (reverse amplitude > forward amplitude) Then (resulting reverse magnitude = (reverse – forward) signed b magnitude) If (forward amplitude = reverse amplitude) Then (b=0000) This clearly means that each direction’s magnitude is divided into 8 divisions. Also, the control system is itself an open loop control system were the only feedback is the user’s eyes. Also it can be seen that the user is the actual control system while the digital controller could be seen as a simple interface, since no major control algorithms are being used there. How the pseudo code works is demonstrated through the figures below. After the entire signal processing work is and a signal as showed in the figure below is obtained to move the car forward. Here, the magnitude is divided into major 8 divisions that represent the 7 different speeds to move forward. The 8-bit output value it translates to is shown in the figure below. Here, it could be assumed that only the data to move the car forward is excited. Page 27 of 46 Figure 27: 8-Bit output relation to filtered signal Processing Requirements and Specifications For this project the Nyquist frequency is fN= 1kHz. Thus: fS ~ 10 fN = 10kHz Therefore: BW = 10kHz Thus the dynamic range for the Analog to Digital converter is from 1 kHz to 15 kHz. This results in a dynamic range of 23.52dB. A total of 1 GPIO is needed; this is the 1 GPIO through which the output from the controller to wireless transmitter. Four inputs to the ADCs for the four EMG signals. Also 1 GPIO is necessary for the audio feedback that was recently added to this project. The 4 EMG input signals needs to be sampled simultaneously than serially. Although multiplexing 2 inputs such as forward and reverse as one along with right and left as another might workout. The Resolution was calculated thus: Range from Highest observed EMG amplitude to Lowest observed EMG amplitude = 5Vto -5V = 10. A resolution of 24 bits is used because this is the highest resolution at which the ADC can operate; also this yields the optimal results. The other major issue is the skew rate: Since the sampling frequency is assumed to be 10 kHz, the Skew rate is calculated as shown in the figure below: Page 28 of 46 Figure 28: Skew rate calculation It is apparent from the figure above that skew rate is 0.3ms. This translates to a frequency of (10/3) kHz, which is quite negligible considering the sampling frequency, is around 10kHz. Should this sampling frequency proves not be sufficient, it can be increased to the desired frequency. The Time frame for the DSP is normally the time taken by the DSP to process the whole process. This is calculated as the sum of the processing times for each of the individual components: Asynchronous Memory Read Cycle Timing = 6ns+6ns+6ns=18ns Asynchronous Memory Write Cycle = 4(6ns) =24ns SDRAM Interface Timing = 2(6ns) +2(4ns) =20ns Parallel Peripheral Interface (PPI) Timing: 9ns+8ns=17ns Serial Ports-External Clock = 4(10ns) =40ns Serial Port-Internal Clock =3ns+3ns =6ns Serial Port-Enable and Three State=10ns+3ns=13ns Serial Peripheral Interface (SPI) Port Master Timing = 4ns+6ns+7.5ns=17.5ns SPI Slave Timing = 10ns+10ns+8ns+8ns=36ns GPIO Port Cycle Timing=2(6ns) =12ns JTAG Port Timing=10ns+12ns+20ns+12ns+5ns+4ns=63ns Approximate Code Processing Time=12ms Total time frame for the DSP is about 15ms. The other memory requirements include about 800kb for Audio storage, 5kb for u-boot and other boot files, and about 20kb for coding. This sums to about 825kbs of memory that needs to be saved on the flash memory. The flash memory has 2MB of memory. Therefore, it might be enough for this project. Other power specs include a 7.5V input voltage for the BF533 Ez Kit Lite, with a regulator of 5V and 3.3V. Page 29 of 46 Design Review: Audio System Right Thumb Left Thumb Left Fingers Right Fingers Amplifier Grass Tech. BF511 DSP Development Board (for BlackFinn 533) DSP: Filter and Controller BlackFinn 533 RF TX Sound Transmitted Commands RF RX Speaker Micro Controller Motor ATtiny2313 Motor Left Right Forward Reverse Figure 29: Audio Capability Functional Diagram Audio Interface The AD1836 audio codec provides three channels of stereo audio output and two channels of multichannel 96 kHz input. The SPORT0 interface of the processor links with the stereo audio data input and output pins of the AD1836 codec. The processor is capable of transferring data to the audio codec in time-division multiplexed (TDM) or two-wire interface (TWI) mode. The TWI mode allows the codec to operate at a 96 kHz sample rate but limits the output channels to two. The TDM mode can operate at a maximum of 48 kHz sample rate but allows simultaneous use of all input and output channels. When using TWI mode, the TSCLK0 and RSCLK0 pins, as well as the TFS0 and RFS0 pins of the processor must be tied together external to the processor. This is done through the SW9 DIP switch. The AD1836 audio codec’s internal configuration registers are configured using the SPI port of the processor. The processor’s PF4 programmable flag pin is used as the select for this device. The general-purpose IO pin PA0 of flash A is a source for the AD1836 codec reset. In this project, TDM mode will be implemented because this is the only mode in which simultaneous EMG inputs can be used. Page 30 of 46 Audio Amplifier Design Figure 30: Basic Amplifier design for the speaker BOM: Speaker Amplifier Part LM358 Amp Cap .01 uF Cap 3.3 uF Cap 100 uF Res 1M Res 3.3k Res 10k Res 6.8k Res 4.7k BJT 2N4403 BJT 2N4401 Bread Board Speaker Quantity 2 2 1 1 3 2 1 1 2 1 1 1 1 Overall Cost Page 31 of 46 Cost (each) $ 0.45 $ 0.17 $ 0.16 $ 0.14 $ 0.26 $ 0.04 $ 0.04 $ 0.04 $ 0.04 $ 0.04 $ 0.04 $ 2.50 $ - Total Cost $ 0.90 $ 0.34 $ 0.16 $ 0.14 $ 0.78 $ 0.08 $ 0.04 $ 0.04 $ 0.08 $ 0.04 $ 0.04 $ 2.50 $ $ 5.14 Design Review: Wireless Communication Right Thumb Left Thumb Left Fingers Right Fingers Amplifier Grass Tech. BF511 DSP Development Board (for BlackFinn 533) DSP: Filter and Controller BlackFinn 533 RF TX Speaker Sound Transmitted Commands RF RX Micro Controller Motor ATtiny2313 Motor Left Right Forward Reverse Figure 31: Wireless Functional Diagram Wireless System The wireless link between the DSP and RC car consists of a paired ASK transmitter module with an output of up to 8mW depending on power supply voltage and a receiver with a sensitivity of 3uV. Frequency: 434 MHz Range: 500 ft Max Data Throughput: 4800bps Transmitter Voltage Range: 2 – 12V (connected to 5V from regulated supply on DSP board) Receiver Voltage Range: 4.5 – 5.5V (connected to 5V supply on vehicle) Optional Antenna: 30-35cm of wire Page 32 of 46 The data communications protocol for the wireless communications system is quite simple. Each transmitted data sample will consist of 3 8-bit bytes. To operate properly, the wireless link must transmit data which has approximately neutral disparity (#0’s:#1’s = 1). The first byte of this sample will consist of a start byte, which will indicate to the receiver that data is being sent to it. To indicate the beginning of a data transmission the transmitter will send a header byte having neutral disparity (eg. 0xAA, 0x55). Subsequently, the transmitter will send the packet described earlier consisting of the sign and magnitude information for the motor controls. Lastly the compliment of the second byte will be transmitted. This will allow for neutral disparity of the data transmission to be preserved, while also allowing for error detection on the receiving end. The design of this communications protocol will limit data transfer to a maximum of 150 samples/sec. Figure 32: Wireless Transmitter/Receiver Hardware Page 33 of 46 Design Review: RC Vehicle Right Thumb Left Thumb Left Fingers Right Fingers DSP Development Board (for Amplifier Grass Tech. BF511 DSP: Filter and Controller BlackFinn 533 BlackFinn 533) RF TX Speaker Sound Transmitted Commands RF RX Micro Controller Motor ATtiny2313 Motor Left Right Forward Reverse Figure 33: Robot Functional Diagram Control µProcessor Power Page 34 of 46 Marginal Length Width Max Weight Transmission range Minimum turning radius Accuracy of Path Sufficient PWMs Minimum battery life Minimum battery supply voltage in in lb m ft in # min V 12 6 < 10 150 2 ±3 2 60 6 20 8 < 20 50 5 ±3 2 45 >6 1 1 1 1 1 1 3 3 3 3 1 9 3 3 Documentation Ideal Must be relatively small chassis Units Vehicle is aesthetically pleasing Specification Efficient control of all drives/servos Number C C1.1 C1.2 C1.3 C2.1 C2.2 C2.3 C3.1 C4.1 C4.2 Vehicle Easily Controlled Category Proof of Concept Chassis Vehicle Must receive RF commands The QFD as it relates to the RC Car. 1 1 1 1 1 1 1 1 1 Microcontroller The microcontroller being used for the task of controlling the vehicle is the ATTiny2313. Up to 20 MHz operating frequency 8bit processor 15 I/O Lines UART compatible pins Data and Non-volatile program and data memories o 2K Bytes In-System Self Programmable Flash o 128 Bytes In-System Programmable EEPROM o 128 Bytes Internal SRAM One 8bit Timer/Counter One 16bit Timer/Counter Four PWM Channels Operating Voltage Range: 2.7 – 5.5V (@10MHz) Typical Power Consumption o Active Mode 1MHz, 1.8V: 230uA o Power-down Mode Page 35 of 46 <0.1uA at 1.8V Figure 34: ATtiny 2313 Microcontroller Microcontroller Development Board: Figure 35: Microcontroller Development Board Schematic Page 36 of 46 Microcontroller Development Board: Description: Prototype board for 20 pin AVR microcontrollers with power supply circuit, crystal oscillator circuit, RS232 port, reset IC, status LED, 10 pin STK ICSP port. ICSP 5x2 pin connector for in-circuit programming with AVR Programmers Voltage regulator +5V or 3.3V, LM317 Quartz crystal oscillator circuit: 10Mhz Reset IC ZM33064 Status LED connected to PB7 via removable jumper AGND-GND AVCC-VCC jumpers DIL28 microcontroller socket RS232 DB9 female connector RS232 MAX232 interface circuit with Tx, Rx, CTS, DTR/RTS signals Extension slot on every uC pin Grid 100 mils GND bus Vcc bus Page 37 of 46 Microcontroller Programmer: Description: AVR-PG1B is programmer based on serial port PonyProg design. It takes the power supply from the target board. The connector is 2x5 pin with 0.1" step and Atmel STKxxx compatible layout. Figure 36: Microcontroller Programmer Page 38 of 46 C9 U1 22p Q 10 MHz C10 22p 0 5 4 1 12 13 14 15 16 17 18 19 U4A 5 6 7 8 4 3 2 VCC VCC Data GND Data GND ANT GND ICSP ICSP ICSP 1 10 MO-RX3400 PA0/XTAL1 PA1/XTAL2 PA2/RESET/DW 20 VCC V1 2 3 6 7 8 9 11 PD0/RXD PD1/TXD PB0/AIN0/PCINT0 PD2/CKOUT/XCK/INT0 PB1/AIN1/PCINT1 PD3/INT1 PB2/OC0A/PCINT2 PD4/T0 PB3/OC1A/PCINT3 PD5/OC0B/T1 PB4/OC1B/PCINT4 PD6/ICP PB5/MOSI/DI/SDA/PCINT5 PB6/MISO/DO/PCINT6 PB7/UCSK/SCK/PCINT7 R3 1k BUT 0 2 0 U6 R4 1 2 3 Wireless receiver A0 A1 A2 Microcontroller THERMAL FLAG OUTPUT 8 CURRENT SENSE OUTPUT 10 2 OUTPUT 2 OUTPUT 1 VS POWER SUPPLY GROUND 9 DIRECTION INPUT PWM INPUT BRAKE INPUT BOOTSTRAP 2 C6 BOOTSTRAP 1 3 Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7 15 14 13 12 11 10 9 7 R5 R6 100 R8 100 R10 100 R7 100 R9 100 R11 100 100 100 5 Left Side 74F138 4 11 1 C7 6 4 11 1 7 U3 LMD18200 C5 10n U5B 18 GND 6 VCC 17 10n 10n DC Motor Steering V2 6Vdc OUTPUT 2 OUTPUT 1 C5 10n Rear 0 U7 R12 1 2 3 10 2 THERMAL FLAG OUTPUT CURRENT SENSE OUTPUT 8 U2 LMD18200 BOOTSTRAP 2 BOOTSTRAP 1 5 PWM INPUT BRAKE INPUT 3 DIRECTION INPUT GROUND VS POWER SUPPLY 9 0 Right Side GND 0 7 3.3Vdc 1 ATTINY 2313 0 C11 100n 18 GND VCC A0 A1 A2 17 DC Motor Acceleration Motor Controls Y0 Y1 Y2 Y3 Y4 Y5 Y6 Y7 15 14 13 12 11 10 9 7 R13 R14 100 100 R15 100 100 R19 100 74F138 R16 100 R18 100 R17 100 0 Visual Feedback Title RC Vehicle Schematic Size B Date: Figure 37: RC Vehicle Circuit Schematic Page 39 of 46 Document Number <Doc> Wednesday , October 31, 2007 Rev 1 Sheet 1 of 1 RC Car Pseudo Code: The RC Car must accept digital control information from a wireless source and translate this information into direction and magnitude information which will control the motors. The RC vehicle will utilize interrupt driven subroutines for both of these tasks. As shown in the Vehicle Circuit Schematic, the wireless transmitter will interface directly to the microprocessor through a digital input on pin 16 (PB4). Upon receiving data an interrupt will be thrown causing the received data to be verified. To indicate the beginning of a data transmission the transmitter will send a header byte having neutral disparity (eg. 0xAA, 0x55). Upon identifying this byte subsequent data will be accepted, otherwise the byte is dropped and further data is not stored. Upon receiving a header successfully two additional bytes will be accepted. The first is the data byte and the second is its compliment. If the addition of these two bytes is equal to zero, the first byte will be stored for later use in the motor control subroutine. The design of this communications protocol will limit data transfer to a maximum of 150 samples/sec. The motor control subroutine references a stored byte to update the motor control parameters. This subroutine is executed at a set interval and in effect will control how frequently the robots motor parameters will be changed. This subroutine will parse the stored data byte for direction and magnitude information for the forward/reverse and left/right motors. It is estimated that code requirements to implement the functions necessary for the operation of the vehicle to be approximately 1K bytes. //Receive wireless data //Enter from receive interrupt wait: Read in a byte from the serial connection Clear Receive Interrupt and Disable interrupts If byte is equal to start byte Get byte1 Get byte2 //We expect byte2 to be the compliment of byte1 If( byte1 + byte2 == 0) store byte1 to MotorByte else Toss bytes else continue to wait for start byte Enable interrupts //Setup Motors //Enter from timed interrupt at least 30 times/sec //Forward/Reverse Motor Controls mask upper four bits of MotorByte Set fwd/rvs direction based on bit 3 Set fwd/rvs PWM based on bits 0-2 Move lower 3 bits to mux to update fwd/rvs LEDs //Right/Left Motor Controls shift MotorByte right 4 mask upper four bits of MotorByte Set left/right direction based on bit 3 Set left/right PWM based on bits 0-2 move lower 3 bits to mux to update left/right LEDs Figure 38: RC Car Circuit Board Placement Mock-U Page 40 of 46 Figure 39: RC Car Circuit Board Placement Mock-Up Page 41 of 46 Visual Feedback: Concern was expressed in the proposed control design in the fact that there will be little feedback to the user to indicate how the vehicle is responding to a user’s actions. One mechanism devised to provide feedback on the actions being received by the vehicle is through lighted indicators on the sides and rear of the vehicle. It is intended that these be composed of individual LEDs aligned linearly on the sides and rear of the vehicle (as shown in the images to follow). These lights would range in color from green yellow red. The different colors will be used to indicate a magnitude of direction. For example, if the user is turning left, the LEDs at the back of the vehicle will light the left half of the LEDs according to the magnitude of the direction. Similarly if a user is driving forward, the lights positioned at the side of the vehicle will light indicating magnitude of direction in the forward or reverse direction. These Lights will be connected to a 3-to-8 multiplexor which in turn will connect to the digital outputs of the ATtiny2313. A total of 8 discrete levels of magnitude will be able to be indicated in the left/right directions and the forward/reverse directions. The lights will be installed behind a plastic cover which lies flush with the truck body. The plastic cover and the packages of the LEDS can be sanded to help diffuse the light and create the appearance of a clean transition between colors. Page 42 of 46 Figure 40: RC Car Side Lighting Mock-Up Page 43 of 46 Figure 41: RC Car Rear Lighting Mockup Page 44 of 46 BOM: RC Car RC Vehicle BOM Component ATtiny2313 AVR Dev board Power Supply Serial Cable Programmer H Bridge DC Motor (Forward/Reverse) DC Motor (Left/Right) Wireless Link 315MHz Wireless Link 434MHz RC Car 5mm Red LED 5mm Green LED 5mm Yellow LED 3-to-8 Multiplexor 10 pin 100Ω Resistor network Total Cost Page 45 of 46 Quantity 3 1 1 1 1 1 1 1 1 1 1 Retail Link Link Link Link Link Link Sampled From RC Car From RC Car Link Link WalMart Cost/Item $2.88 $16.95 $5.95 $3.95 $12.95 $0.00 $0.00 $0.00 $16.95 $16.95 $19.97 Total Component Cost $8.64 $16.95 $5.95 $3.95 $12.95 $0.00 $0.00 $0.00 $16.95 $16.95 $19.97 20 20 20 10 Link (152805) Link (1586197) Link (152792) Link (835315) $0.19 $0.65 $0.17 $0.20 $3.80 $13.00 $3.40 $2.00 10 Link (280671) $0.26 $2.60 $127.11 Design Review: Bill of Materials Comprehensive Bill of Materials System Front End Signal Processing Audio Proof of Concept Comprehensive BOM Number of Parts 16*** Strap 16 Amplifier NA Dev Board 1 Amp 19 93 Wireless System 2 Car with Supplies 91 Total Parts 129*** Subsystem Subsystem Cost Total Cost $ $ $ $ $ 519.00* $ $ 250.00 5.14 $ 33.90 93.21 Total Cost 901.25 $ 127.11 $ $ *The cost of the active electrodes were unknown at this time. **Shipping is unknown for these items ***The electrode equipment is not accounted for Page 46 of 46 144.00 375.00* 250.00 5.14** 901.25