Full text
Final Project Report Universitat Politecnica de Catalunya Departament d'Enginyeria Electronica in cooperation with Technical University of Lodz Faculty of Electrical, Electronic, Computer and Control Engineering Design of a charge injection compensation system for MEMS electrostatic actuators by Kamil Karliński index nr. 131180 Supervisors: Daniel Fernández, Ph.D. Jordi Madrenas, Asoc. Prof. Barcelona 2010
Yesterday is history. Tomorrow is a mystery. And today? Today is a gift. That's why we call it the present.
To my dear parents, Moriola and Jan Karlińscy and my crazy siblings Mateusz and Kasia
Acknowledgements Unconditional thanks goes to my supervisors Jordi Madrenas and Daniel Fernández. First of all for accepting me as their student. Then for all the highly intelligent conversations along the way through this project. For every heavy step in the creative process of this project. And for patience in answering my question and explaining the basic of electronics sometimes. My courage was always increased after a discussion with my supervisors. These conversations are, without any doubt, the main reason that this project is now completed.
Abstract The main goal of this project is to implement and experimentally verify various control algorithms for MEMS electrostatic actuators. Those algorithms include a charge injection compensation subsystem. The hardware platform consists of some MEMS electrostatic actuators, a front-end sensing system (comprising a full-custom mixed-signal integrated circuit designed at UPC and a highspeed A/D converter) and a Xilinx FPGA for algorithm coding. The work involves the following: o Understanding the working principle of the hardware platform and the issues related to MEMS electrostatic actuators. o Improve the hardware platform, if required by the control algorithm. This might involve some simple PCB design and test with laboratory instrumentation. o Algorithm implementation in VHDL. This includes the signal-processing algorithms and also the ancillary routines for I/O data extraction and signal visualization. Capacitance of MEMS electrostatic actuators were measured under different voltages conditions. It was found that positive voltage stress caused negative charging of the dielectric whereas negative voltage stress caused positive charging of the dielectric. This is consistent with the nature of traps in the silicon oxynitride dielectric used for the switches. Report is divided into three parts, the first chapter is devoted to the description to the MEMS word. The chapter is devoted a small multiplexing board design description. And finally chapter 3 introduce a development of a VHDL code to control all system.
4 standard processes as part of the MUMPs program: PolyMUMPs, a three-layer polysilicon surface micromachining process: MetalMUMPs, an electroplated nickel process; and SOIMUMPS, a silicon-on insulator micromachining process. The PolyMUMPs process is a three-layer polysilicon surface micromachining process derived from work performed at the Berkeley Sensors and Actuators Center (BSAC) at the University of California in the late 80’s and early 90’s. Several modifications and enhancements have been made to increase the flexibility and versatility of the process for the multi-user environment. Figure 1.3: PolyMUMPs process cross section Figure 1.3 is a cross section of the three-layer polysilicon surface micromachining PolyMUMPs process. This process has the general features of a standard surface micromachining process: (1) polysilicon is used as the structural material, (2) deposited oxide (PSG) is used as the sacrificial layer, and silicon nitride is used as electrical isolation between the polysilicon and the substrate [9]. The MEMS board was manufactured in PolyMUMPs technological process. Knowing basic of manufactures process it is time to explain how the MEMS actuators are built. 1.5 Characterization of dielectric charging in MEMS Figure 1.4 shows a schematic representation of an MEMS. The switch consists of two electrodes, of which the top electrode is suspended by tiny springs. The top electrode can be pulled down by applying a voltage across the air gap between the two electrodes. Above a certain voltage, the balance between the attracting electrostatic force and restoring spring force becomes unstable and the switch closes.
5 Figure 1.4: Schematic representation of an MEMS The top electrode of a parallel plate capacitor can be pulled down by applying a voltage greater than the pull-in voltage, which is pulled up again by the springs if the voltage is lowered beneath the pull-out voltage.[10] Figure 1.5 shows how charges are trapped into the MEMS structure. Figure 1.5: E-field in a parallel plate capacitor. a) No fixed charges in the dielectric. b) Fixed surface charge at height z = d. The traps are amphoteric [10] so they can be either positively or negatively charged. During switch operation, the electric field across the dielectric can be of the order of 106 V/cm causing electrons or holes to be injected into the dielectric and become trapped. With repeated operation, charge gradually builds up in the dielectric resulting in control-voltage drift or stiction. 1.6 Controlling the charge A graph in Figure 1.6 presents how charge is controlled by external source. At the beginning, after turn ON a power supply, there is no any loads inside. Loads pass through the electrode and nested in the space between the plates during the time. This process is very slow and depends on MEMS actuator. Some of them doesn’t have such a strong injection. After changing a sequence, which means reverse a divider supply polarity, charge from previous mode is compensated at
6 first. When actuator is totally discharge, the reverse polarity charging process begin. The list below and figures describe this process more clear from the beginning. 1. after power supply turn ON (t = 0). 2. after short while working in sequence I. 3. while after changing a sequence 4. 5. 6. while after changing a sequence again to I Presented train of thoughts in this section (power supply changes - as charge compensation) was carried out by multiplexers - as part of a executive hardware and state machine as system controlling part. The following chapter describe the first one. Figure 1.6: The charge injection effect 15V 2. 15V 3. 15V 5. 15V 6. 15V NO CHARGE 1. 15V 4. NO CHARGE presently reside in the sequence II
2 Hardware 2.1 Overview This chapter presents a hardware part of project. Here will be description of boards which were used to test a MEMS chip, and explanation how they were designed. In this chapter there will be shown how to get started with each boards and how to properly configure them. Whole project consist of three printed circuit boards and one Xilinx Spartan-3 Starter Kit [19]. 2.2 Delirium-I-feael The board was designed by Sergi Gorreta under Daniel Fernandez supervision. It contain a main integrated circuit responsible for generate appropriate signals for measuring the actuator capacitance. The board provides three voltage regulators separated for each power supply, analog to digital converter with differential driver and a big amount of jumpers and potentiometers for tuning and mode selection. Figure 2.1 shows a simple functional block diagram, but the Figure 2.2 their schematic. Figure 2.1: Simple functional block diagram
8 Figure 2.2 Delirium-I-FEAEL schematic Briefly explaining the operation of this board, it should be noted that its heart is the Delirium-I chip, responsible for generating a H, D, and R control signals. The functional diagram of this chip is depictured in the Figure 2.3. Figure 2.3 Simplified schematic of Delirium-I chip. The circuit is better understood by analyzing the running sequence of the digital control signals D, R and H. This sequence can be summarized as follows [7]: o In normal operation, signals D, R and H are equal to 0. In this mode, a high voltage is applied to theupper node of the actuator though the U1 inverter, the switch M2 is turned off and the transmission gateM1 is turned on. Thereby, the output voltage VOUT tracks VCS by means of the PMOS voltage followerM3.
9 o When a reset is required, the signal H is set to logic 1 (and H to 0). This disconnects the transmission gate M1 so the output voltage VOUT is hold constant regardless of VCS. o Then, signal R is set to 1, discharging the serial capacitor CS. o Next, signal D is set to 1, discharging the electrostatic actuator. o After both capacitances have been discharged, R is set back to 0 and the capacitances can be charged again. o Finally signal D is set back to 0, charging the capacitive divider and, after a short time, signal H is set also to zero, enabling the transmission gate, so the output voltage tracks again VCS and the sequence is repeated. Figure 2.3 shows VOUT voltage which provide the current MEMS actuator capacitance. This information is pass through to fully differential amplifier, where it is filtrated and a little bit gained. Then it land in high speed analog to digital converter, and in digital way goes to FPGA circuit, where it is subjected final signal processing. There is also feedback in this circuit, after analyzing it, the FPGA could impact on system operation. This device have control of main chip, and divide supply duty cycle. Figure 2.4 shows the layout of main board and next few section describe their proper configuration, started with jumper. Figure 2.4: DELIRIUM-I-FEAEL board.
10 2.2.1 Jumpers The most important jumper in this circuit is J17, the main objective of it is to prevent the burning of chip. It connects 3.6V Zener diode to a middle node of MEMS system, as depicted in Figure 2.5. That jumper should always be in place during making changes in the fixed capacitor or actuator. Single glitches or short overvoltages, can occur and cause chip damage. WARNING Before making ANY changes with capacitance divider make sure that jumper is closed and power supply is off. After work, also leave the jumper in that position. Figure 2.5: Jumper J17 application Jumper J13 and J14 are used for voltage selection for supply a capacitive divider made up of fixed capacitor and MEMS actuator. All possibilities that can be chosen with the help of this jumper are shown in Table 2.1.
11 Option Jumper J13 Setting Jumper J14 Setting Description High voltage Dependent on selected mode: MODE_I (positive) HI_MEMS LO_MEMS always grounded. MODE_II (negative) HI_MEMS LO_MEMS Low voltage Irrespective of selected mode: HI_MEMS LO_MEMS always grounded. DAMAGE This configuration may cause a damage to Delirium-I chip in mode_II. The chip is able to work only from 0 to 3.3V voltage range. In mode_II middle point of capacitive divider provide a negative voltage. 0V_out In this configuration a capacitive divider out is always equal to ground. Table 2.1: Capacitive divider voltage configuration In the Table 2.1 there is one configuration with can cause a damage to circuit. It is because Delirium-I chip was designed to work only with positive voltage. In this case there is a possibility when HI_MEMS is active with -11.7V, LO_MEMS is grounded and middle point of divider goes into negative voltage. Another jumper in that circuit is marked as J6. It can be used to disconnect Delirium chip’s main clock. It is also possible to connect an external clock as showed in the picture.
12 Figure 2.6: Jumper J18 application. J8 is a jumper which allow you to chose a correct path output signal from capacitive divider as explained in the Figure 2.7 and Table 2.2. Figure 2.7: Jumper J8 application. Option Jumper J8 Setting Description MEMS_direct This position is used to connect the middle point of divider directly to ADC driver for further processing. MUX_board The middle point of divider is led to multiplexing board where a few simple operations are performed depending on the mode Table 2.2: J8 configuration At the beginning of the work the jumper was set only in MEMS_direct position. On the right side of this board there are still other jumpers available. By the means of them one can disconnect some potentiometers or measure appropriate current. When the board stops working without no reason it is a good idea to check the currents in the jumpers. Ranges of an allowed currents are gathered in the end of the next section.
13 2.2.2 Potentiometers The board provide a several potentiometer to set appropriate value e.g. in the power section there are a possibilities to adjust a power supply voltage. Figure 2.8 shows which power voltage can be set by each potentiometer. Figure 2.8: Power section description. a part of board scheme PIN no. 1 2 3 4 On board description AUX GND 15V 60V Recommend voltage supply -11.7V ground 15V NC1 Table 2.3: Main power connection/socket pin configuration. In power supply section a simple National Semiconductor positive voltage regulators are used. Leading feature is a low dropout voltage, a maximum of 1.5V at 1.5A of load current. The circuit marked as LM1086 is available in an adjustable version, which can set the output voltage with only two external resistors included by described potentiometer. A simple application circuit can be founded in datasheet. A good habit is to separate analog and digital power supply. For that reason the board provide two different voltage regulators, moreover there is another one. This one is used to supply halfbridge PWN generator depicted in Figure 2.9. The signal VACT_EXT is led to HI_MEMS pin while – Low voltage – configuration is selected, look in Table 2.1. Figure 2.10 depicts a general purpose of the right side potentiometers. The most important of them are located at the 1 NC = NO CONNECT Figure 2.9: PWM half-bridge
20 The next step is to determined from equation 2.2 a S Ct C C t component and insert it to 2.3. Finally desired relationship amount to. ( ) ( ) 3.3 out II out I V V V (2.4) As equation 2.4 shows after changing between mode it is necessary to invert a output voltage and add a little offset. This task is performed by Texas Instrument’s amplifier, and a scheme is presented in Figure 2.17. Figure 2.17: A inverting amplifier configuration This is a simplified version of this amplifier, in original scheme there are also power supply filtering capacitors and many jumpers to select a mode configuration. The next paragraph describe all of them. In the past there have been a lot of groups of op-amp circuits, but all of them have split power supply. While designing a single supply amplifier it is necessary to remember about specific conversion. It is not possible to change a supply from slip to single without doing modification in circuit. The next paragraph will explain this conversion. Figure 2.16 present split and single supply amplifier. Figure 2.18: A split and single supply circuit
21 The power supply depicture on the left draws consist of positive and equal opposite negative pole. In this case input and output voltage are changed to the ground and swing to a limit of VOM, the maximum peak-output voltage swing. In single supply mode a new concept should be introduced. Virtual ground is a half of positive supply and ground. That is why it is necessary to add this voltage to a input signal. In fact only single supply configuration is used, and this error is compensating by adding a little less offset voltage. To clarify, the slope of input signal is controlling by a gain, and it isn’t depend on power supply mode. To make a board more useful and flexible the variable gain was designed. The gain range is 0.5 to 1.5, and the calculation is presented below. Figure 2.19: A adjustable gain on the Left G=0.5 and Right G=1.5. Simultaneous equations presented below allow to derive all unknowns. 0.5 1.5 f in p fp in R RR RR R (2.5) There are three unknown, for that reason the assignment one of them is necessary. This value should be available in resistance series of types. For the potentiometer’s resistance equal Rp = 500Ω other values are Rin = 750Ω and Rf = 625Ω. The 625Ω value doesn’t exists in E24 series of types and the nearest is 620Ω. So finally the gain range for values arrangement presented below is from 0.49 to 1.5. 620 500 750 f P in R R R (2.6)
22 After explanation of all calculation in amplifier section it is time to present works in graphical way. Figure 2.20 presents only a shape without scales and any values. The dashed line present a system work with operational amplifier, but a continuous line without. Bold black line shows the course of the signal directly from the divider. In the sequence I, dashed lines show the possibilities, that may occur after changing the polarity. If stored charge is large enough, the measured capacitance is overstated after switching – this is represented by lower line, but the dashed line above present a behavioral if charge is not sufficient. It is true that inverting and offset adding could be make by software, but much faster and easier is to do it by analog way. Now the question arises why, after calibrating the device at the beginning of the work may appear there not enough charge. Answer is that, after the change of polarization, the capacitor is loaded opposite charge which in the next sequence should be re-charged. This situation was better describe in 1.6 Controlling the charge section. 2.4.3 Multiplexers In this part describe a multiplexers choice to change a voltage polarity. Section takes to consider only two signals: PWM HI_MEMS supply a capacitance divider and PWM D which is controlled by Delirium-I. The high-voltage logic (+15V) inverter was implemented using the discrete commercial device ICL7667, which allows continuous operation at voltages up to 15 V. This scheme was presented in Figure 2.21. too much charge cause stay in next sequence charge is not sufficient, system stay in previous sequence polarity change dashed and continuous line overlap offset invert this slope Figure 2.20: A charge injection shape with amplifier correction
23 Figure 2.21: Divider’s supply wave generator by inverter This approach is good for only one mode, just for positive voltage +15V and GND wave. In design -11.7V and 3.3V voltage wave is also needful, so there was a problem to find a negative supply inverters or that circuit was very expensive. The new idea was proposed. Inserted there a symmetrical supply multiplexer solved that problem. More over this multiplexers could be order for free from Analog Device research center. Everything will be perfect but new circuit has a longer turning ON and OFF times. The solution for that problem also was founded by placed parallel two of them. The scheme of new approach was presented below in Figure 2.22. For limpidity a second multiplexer was omitted. Figure 2.22: Divider’s supply wave generator by multiplexer To calculate the time constants of divider supply circuit, equivalent capacitance should be estimated at first. Substitute capacitance connected in series could be calculated by the formula 2.7, and for CMEMS ≈ 20pF and CS = 68pF, a Ceq = 15pF. 1 1 1 eq MEMS S MEMS S eq MEMS S C C C CC CCC (2.7)
24 A switching time calculation for both approaches was presented below. Inverter At VCC = 15V, the output impedance of the inverter is typically Rout = 7Ω. The time constant is derived in formula below. 7 15 105 out eq R C pF ns (2.8) Multiplexer The output impedance of this multiplexer with dual power supply is typically Rout = 130Ω, and time constant is derived below. 130 15 1.95 out eq R C pF us (2.9) This time has been reduced twice by connected two MUX in parallel. More over there are introduced several modifications in the code to slightly delay the start of sampling, it will be thoroughly explained in the chapter devote to the program. To choose a right multiplexer a logic level capability is important. The Delirium-I chip was designed to work with TTL level, for that reason the ADG1309 device with 3V, logic-compatible digital input where: VIH = 2.0 V and VIL = 0.8 V was selected. The selected multiplexer has a active high digital input to disconnect all switches. When this signal is low, the device is disabled and all switches are off. When high, Ax logic inputs determine on switches. In project there are no needs to disconnect them so the EN input is shorted to 3.3V. The controlling signals A0 and A1 allow to select a appropriate input. As it is depicture in documentation block diagram this multiplexer has a 1-of-4 decoder and in fact consists with two identical 4 inputs and 1 outputs multiplexers and at the same time the control Ax signals connect both switches. This is useful to generate a both LO and HI_MEMS signals concurrently. One of this outputs goes to high point of actuator and another to low of fixed capacitor. This situations is depicture in figure 2.20. Another useful combination was that D signal is connected directly to A0. This makes the PWM generation independent from FPGA, because D is generated by Delirium-I
25 chip, and only changing between sequence is controlled by FPGA program. This situation is also presented in the Figure 2.22. 2.4.4 Negative voltage calculation To generate a negative supply voltage the UCC384-adj Texas Instrument’s linear regulator was used. In this projects it is no necessary to choose high efficiency regulators just to supply one amplifier which can consume less then 20mA current. The adjustable version was placed because of major functionality. The output voltage is defined by equation 2.10. 1 2 1.25 1 out R VR (2.10) Experience shows that in prototype version it is better to use potentiometer, which allows voltage adjustment in wide range. This solution entails some danger. It is necessary to tune voltage before lead it to circuit. 2.4.5 Printed circuit boards This section describe a board layout design. There will be presented two version of multiplexing board, and a rules which was kept during designing process. Board were made using a free 30-day trial version of Altium Designer. Despite the fact that this program provides a appreciable library items, sometimes it is needed to add a new one, and the standards are becoming very useful in this. That is why this section shall begin by introduce to the most important of them. a) The CAD Library standard Standard component package outlines come from industry standard organizations that specialize in component packaging data and standardization of documents and publications. One of the most well known organization is IPC – Association Connecting Electronics Industries. IPC is the trade association that brings together all of the company in this industry: PCB designers, PCB manufacturers, PCB assembly companies, suppliers, and original equipment manufacturers. These standards define all aspects of facing the engineer. Collection of materials created for this project does not meet all of them, since these standards are developed for large companies where the production takes place in series. Although the multiplexing board is not complicated design, and will not be mass produced, it is worth to follow the standards for each project.
26 Since 1987, when an engineer needed information about the dimensions and ranges footprint tolerance, reached the standard IPC-SM-782. This standard defines the appearance of PCB components for a huge number of standard SMD components, but does not define specifically their names. In 2005 appeared the standard IPC-7351. All libraries included in Altium Designer is made in complying with this standard. At the points below there are listed the most useful standards. IPC-2221A: Generic Standard on Printed Board Design IPC-2222: Sectional Design Standard for Rigid Organic Printed Boards IPC-7351A: Generic Requirements for Surface Mount Design and Land Pattern Standard IPC-7251 (draft): Generic Requirements for Through-Hole Design and Land Pattern Standard. All boards in this project were manufactured in milling process without metallization. That has imposed the following requirements, all tracks, pads, and vias was enlarged. b) A first version This version of the board had a few bugs. The first was its size 52 x 27 mm too small. It was very difficult to make any modification or measurements on the tracks or pins. In addition, in the second mode (negative divider supply), HI_MEMS and LO_MEMS signals looked the same as control D signal. Capacitors are not discharged during the reset, however, during the measurement. The layout of the first version is presented below in the figure 2.21. Figure 2.23: A first version of multiplexing board c) A second version Advantages of this board were introduced a numerous descriptions in the cooper. All elements are logically arranged and work with it is more intuitive and requiring no schema. Board is double layer with components of only one side, with the majority of surface mount elements. A vias were hand made with silver steel. All polygon plane were connected to analog ground, provide efficient shielding.
27 The dimension of new board are: 100 x 27 mm, and rounding in top left corner R = 10 mm. All tracks were placed according to the principle – horizontal on top, vertical at the bottom, then circuit became more clear. The maximum absorbed current is 20 mA so there is no need to increase the thickness of power paths. TOP LAYER BOTTOM LAYER Figure 2.24: A two layers of second version of multiplexing board. 2.4.6 Jumpers This section as before, includes a paragraph about the jumpers and their proper configuration. The majority of them comes from amplifier. Jumper JP1 is used to select on offset voltage. In equation 2.4 this value amount to 3.3V. Therefore, this level could be achieve from power supply or LO_MEMS signal in the second mode. Assuming that the PWM voltage may be modified equation 2.4 may take the form, and offset could depend on VLO_MEMS voltage. ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) HI II LO II out II out I LO II LO I HI I LO I out II out I LO VV V V V V VV V gain V V (2.11) Jumpers JP2 and JP3 are used to choose a amplifier’s supply voltage, split or single. Difference between these modes of supply was discussed in 2.4.2 section.
28 Option Jumper JP2 Settings Jumper JP3 Settings Description Single supply This position it is necessary to remember about virtual ground during a measurements. Slit supply This is basic and very useful configuration, amplifier operates in the manner described in every manuals Single supply without ground shifted This configuration was used during testing circuit, as it was describe before, gain was adjust separately and offset error was corrected by PR1 potentiometers. Table 2.4: Amplifier power supply configuration. The JP4 jumper is useful to test only amplifier operation without reordered circuit. Output of amplifier is available on gold pin marked as out on PCB cooper. Option Jumper JP2 Settings Description Normal mode In this position the out from capacitance divider are connected to inverting input of amplifier, this is normal operational mode. Test mode This position is used to test a amplifier correct operation. There is possible to connect an external signal source – through this jumper and tune a gain and offset. Table 2.5: The jumper’s JP4 purpose The JP5 jumper is used to disconnect a amplifier. Signal DIG(4) set a sequence mode, when the jumper is in place the multiplexer switch between first and second input depends on current sequence. In sequence II the output from divider is led thought amplifier circuit. If JP5 jumper is removed, the R7 resistor pull off the A0 control input to ground, assuring S1 terminal connect to the output drain D. Which means output from capacitance divider is permanently connected to ADC circuit, and do not depend on current sequence, the amplifier is bypassed. Board provide 3 probe pins to observe a several control signals. All of them are depictured in the Figure 2.25. Figure 2.25: Pin signal in probe terminals. P1 1 R 2 D 3 H 4 GND P2 1 Vaux 2 GND P3 1 DIG4 2 DIG3
3 Algorithm implementation 3.1 Overview This chapter presents a hardware description and synthesis with VHDL. At the begging the block diagram will be shown with a description of each state. Then, will be description of all important pieces of code that will be included in the Appendix. 3.2 Codes description 3.2.1 ASM chart This section present a flow chart of designed algorithm and also describe the most important part. An FSM (finite state machine) is used to model a system that transits among a finite number of internal states. The transitions depend on the current state and external input. Unlike a regular sequential circuit, the state transitions of an FSM do not exhibit a simple, repetitive pattern.[3] An FSM is usually specified by an abstract state diagram or ASM chart (algorithmic state machine chart), both capturing the FSM's input, output, states, and transitions in a graphical representation. The two representations provide the same information. The FSM representation is more compact and better for simple applications. The ASM chart representation is somewhat like a flowchart and is more descriptive for applications with complex transition conditions and actions. The ASM chart of the project is depictured in Figure 3.1.
36 Listing 3.6 Avarage implementation in VHDL – dsp.vhd 213 214 215 221 222 224 225 226 227 228 229 231 232 233 234 236 237 238 239 240 241 242 243 244 245 246 247 249 250 251 252 253 254 255 256 257 ---------------------------------------------------------------------------------- -- Averaging device ---------------------------------------------------------------------------------- entity averaging is generic ( avgs : integer; n : integer); port ( clk : in std_logic; din : in STD_LOGIC_VECTOR(n-1 downto 0); dout : out STD_LOGIC_VECTOR(n-1 downto 0) ); end averaging; architecture Behavioral of averaging is type samples IS ARRAY ((2**avgs)-1 DOWNTO 0) OF STD_LOGIC_VECTOR(n-1 downto 0); signal dataSamples : samples; begin process (clk) variable accumulator : STD_LOGIC_VECTOR(n+avgs-1 downto 0) := (OTHERS => '0'); begin if rising_edge(clk) then -- add new sample and detele the last one (Shift right) -- first LSB is deleted, then array is shifted right -- and the new sample is put in MSB place for index in 0 to (2**avgs)-2 loop dataSamples(index) <= dataSamples(index+1); end loop; dataSamples((2**avgs)-1)<=din; -- average all data in array accumulator := (others=>'0'); for index in dataSamples'range loop accumulator := accumulator + ext(dataSamples(index),n+avgs); end loop; dout <= accumulator(n+avgs-1 downto avgs); end if; end process; end Behavioral; Listing 3.6 presets software implementation of averaging module. Number of samples averaging in one cycle is determine by avgs generic, and amount to 2avgs samples. All of them are accumulated in a array at first (line 247). During the time, when new sample arise, array is shifted to the right and new value goes to the MSB (Most Significant Bit) place. After that all data in the array are summed into accumulator (lines: 251-253). Division by the number of samples was carried by the logical right shift accumulator register, whose bits are simply moved a number determine by the avgs generic. The n predefined variable specify a data sample’s number of bits. As it was illustrated in the Figure 3.3, to obtain one average sample it is necessary to collect min 2avgs data. That figure 3.2 shows more clearly the principal of progressive averaging. A average from rectangles marked with a cross will not be further subjected to process because of incomplete set of samples.
37 The system have to wait to collect all samples, the special counter was designed for doing that task and it is presented in the listing 3.3, but before discussing this part a short explanation is necessary. Counter is synchronize with CLK_LF clock, and it could be asynchronous reset by RST signal, or synchronous by assert a slide button high. A DIGS_int(4) is a signal flag to indicate and control a sequence mode. The different settings of the DIGS_int(4) bit have the following effects: DIGS_int(4) = '0': HI_MEMS: LO_MEMS: permanently grounded DIGS_int(4) = '1': HI_MEMS: LO_MEMS: Due to the possible changes in the number of averaging samples up-down counter was proposed. Collect all samples is indicated by setting a overflow bit in the same counter. Counter declaration is shown in the Listing 3.7. Listing 3.7 Averaging counter declaration – MEMS_ChargeInReduction.vhd 93 signal avgCount : STD_LOGIC_VECTOR (AVGS DOWNTO 0) := (others=>'0'); Figure 3.5 An N-point progressive average with prohibited cases
38 The maximum value amount 2AVGS+1 not 2AVGS, as should be normally. The new concept was introduced. The MSB(Most Significant Bit) is used to indicate, that 2AVGS value was counted, when it happen in the next iteration counter just overload, assert meanwhile the avgCount(AVGS) bit. Listing 3.8: Averaging counter implementation – MEMS_ChargeInReduction.vhd 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 -- ------------------------ avgCount ------------------------ process (CLK_LF, RST) begin if RST = '1' then avgCount <= (others=>'0'); elsif rising_edge(CLK_LF) then if SLIDE_FILT(3) = '0' then if DIGS_int(4) = '0' then if avgCount(AVGS) = '1' then avgCount <= (others=>'1'); else avgCount <= avgCount + 1; end if; elsif DIGS_int(4) = '1' then if avgCount(AVGS) = '0' then avgCount <= (others=>'0'); else avgCount <= avgCount - 1; end if; end if; else avgCount <= (others=>'0'); end if; end if; end process; During sequence II, avgCount is counting up, but in sequence I down. For that reason counter have to be loaded to one of limits value. When the avgCount(AVGS)bit is set, it is loaded to maximum (line 473), and when avgCount(AVGS) = 0 counter is cleared (line 476). After presented all the most important instantiates in the module it is time to show how the state machine was implemented. 3.2.5 State machine description Several approaches can be conceived to design a FSM (Finite State Machine) which consist of lower and upper section. The lower one contains the sequential logic (flip-flops), while the upper section contains the combinational logic. The sequential section in this design has three inputs (CLK_LF, RST and state_next), and one output (state_reg). The Listing 3.9 shows this part. Listing 3.9: Lower (Sequential) section of state machine – MEMS_ChargeInReduction.vhd 429 430 431 432 433 434 435 436 437 438 439 -- #################### Lower section (registers) #################### -- ------------------------ STATE_REG ------------------------ process (CLK_LF, RST) begin if RST = '1' then state_reg <= seqI; elsif rising_edge(CLK_LF) then if D_DACEA = '1' then state_reg <= state_next; end if; end if; end process;
39 To encode the states of a state machine, there are several available styles. The default style is binary. Its advantage is that it requires the least number of flip-flops. In this case, with n flip-flops (n bits), up to 2n states can be encoded. The disadvantage of this encoding scheme is that it requires more logic and is slower than the others. At the other extreme is the onehot encoding style, which uses one flip-flop per state. Therefore, it demands the largest number of flip-flops. In this case, with n flip-flops (n bits), only n states can be encoded. On the other hand, this approach requires the least amount of extra logic and is the fastest. In this design the binary encode style was used, and a number of flip-flops could be calculated from the following equation: log2n where n is the number of states. Figure 3.6 confirm that. This is a part of RTL (Register Transfer Level) schematic [4] representation, generated by Xilinx Synthesis Technology (XST) [18]. There are 3 flip-flop marked as D1..D3, to store one of five state possibilities (pre_seqI, seqI, pre_seqII, seqII and manual). Figure 3.6: A part of RTL scheme shows state encoding. Upper section will be discussed separately for each state, start with seqI state which is presented in the Listing 3.10. Listing 3.10: A seqI state – MEMS_ChargeInReduce.vhd 502 503 504 505 506 507 508 509 510 511 512 513 ----------------------- SEQUENCE I ----------------------- when seqI => DIGS_int(4) <= '0'; LEDS(1) <= '1'; if SLIDE_FILT(3) = '0' then if secCount(26 downto 23) = secTime then state_next <= pre_seqII; else state_next <= seqI; end if; else state_next <= manual; end if;
40 After power ON or reset signal program begin from this state. Here there is also possibility to go to manual mode after set a fourth slide button to high which is represent as SLIDE_FILT(3) in the program. When a counter secCount which will be presented in next section reach predefined value secTime,the program goes to pre_seqII state to do comparison. This part is presented in the Listing 3.11. Listing 3.11: A pre_seqII state – MEMS_ChargeInReduce.vhd 515 516 517 518 519 520 521 522 523 524 525 ---------------------- PRE-SEQUENCE II -------------------------- when pre_seqII => DIGS_int(4) <= '1'; LEDS(1) <= '0'; if avgCount(AVGS) = '0' then if (AVGS_OUT < capSeqI - dataInterval) then state_next <= seqII; else state_next <= seqI; end if; else state_next <= pre_seqII; end if; In this state at the beginning the polarization of voltage supply capacitance divider was changed. Next there are collecting a samples to average them, if a sufficient amount was accumulated and permission to average was given program pass to comparison. The state with the lowest ADC data which mean with the lowest MEMS capacitance is chosen. Remaining states (pre_seqI, and seqII) operate in the same manner and they are shown in the Listing 3.12. Listing 3.12: A remaining state: pre_seqI and seqII – MEMS_ChargeInReduce.vhd 490 491 492 493 494 495 496 497 498 499 500 527 528 529 530 531 532 533 534 535 536 537 538 ---------------------- PRE-SEQUENCE I ----------------------- when pre_seqI => DIGS_int(4) <= '0'; LEDS(1) <= '0'; if avgCount(AVGS) = '1' then if (AVGS_OUT < capSeqII - dataInterval) then state_next <= seqI; else state_next <= seqII; end if; else state_next <= pre_seqI; end if; ----------------------- SEQUENCE II ----------------------- when seqII => DIGS_int(4) <= '1'; LEDS(1) <= '1'; if SLIDE_FILT(3) = '0' then if secCount(26 downto 23) = secTime then state_next <= pre_seqI; else state_next <= seqII; end if; else state_next <= manual; end if;
41 Listing 3.13 presents a last state in which user can chance supply manually. Listing 3.13: A manual mode state – MEMS_ChargeInReduce.vhd 540 541 542 543 544 545 546 547 548 549 ----------------------- MANUAL MODE ----------------------- when manual => if CLK_DIV(20) = '1' then LEDS(1) <= '1'; else LEDS(1) <= '0'; end if; if PUSH_FILT(2) = '1' then DIGS_int(4) <= '1'; else DIGS_int(4) <= '0'; end if; if SLIDE_FILT(3) = '0' then state_next <= seqI; else state_next <= manual; end if; As it was shown in the Figure 3.1 it is possible to reach this state only form sequence I or II with putting a fourth slide button to high. A throbbing second led LEDS(1) inform about operations in this state. A third push button can be used to change voltage polarity. Connected with lower section there is another one register which should be described. It is presented in the Listing 3.14. Listing 3.14: A sequence timer – MEMS_ChargeInReduction.vhd 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 -- ------------------------ secCount ------------------------ process (CLK_LF, RST) begin if RST = '1' then secCount <= (others=>'0'); elsif rising_edge(CLK_LF) then if SLIDE_FILT(3) = '0' then -- comment that instead next line put this for sim. if secCount(26 downto 23) = secTime then secCount <= secCount; if D_DACEA = '1' then secCount <= (others=>'0'); end if; -- elsif secCount = (secTime & B"000" & X"0_0000") - 1 then -- if (SLIDE_FILT(4) = '0') then -- secCount <= secCount + 1; -- stopStoraging <= '0'; -- else -- stopStoraging <= '1'; -- end if; else secCount <= secCount + 1; end if; else secCount <= (others=>'0'); end if; end if; end process; When secCount reach secTime value counter is stopped and reset only after asserted a control D signal. When it happened in the same time a state_next register will be updated. The secCount could be stopped just before achieving a secTime value by set a fifth slide button high. This opportunity was introduced for changing a capacitance just before switching and
42 interfere thereby in normal mode. Finally this option was removed due to easier way to force a sequence charge in normal mode. Difference between capacitance in two mode could be changed by the offset. As it was describe in the Figure 2.17 in 2.4.2 section, in sequence II output from capacitance divider pass through amplifier before goes to converter. By changing a offset in this amplifier user can manipulate a capacitance values in seqII, and force staying in different modes. Before sequence changing storage a previous capacitance value is necessary. It was implemented with two D-type flip-flops as shown in the figure and listening below. Figure 3.7: Capacitance storage section Listing 3.15: A VHDL implementation of capacitance storage – MEMS_ChargeInReduce.vhd 553 554 555 556 557 558 559 560 561 -- to storage a ADC data before switch process (CLK_LF) begin if rising_edge(CLK_LF) then if (state_reg = seqI) or (state_reg = manual and DIGS_int(4) = '0') then capSeqI <= AVGS_OUT; elsif (state_reg = seqII) or (state_reg = manual and DIGS_int(4) = '1') then capSeqII <= AVGS_OUT; end if; end if; end process; 3.2.6 Do files In situations where there are repetitive tasks to complete, it is possible to increase productivity with DO files. DO files are scripts that allow to execute many commands at once. The scripts can be as simple as a series of ModelSim commands with associated arguments, or they can be fullblown TCL(Tool Command Language) programs with variables, conditional execution, and so forth. Appendix D – Source codes presents all do file used in this project. 3.2.7 Program – user communication This section describe program collaboration with users. There will be depicture, what diodes and 7-segment LED display shown, and for what are push and slide buttons responsible.
43 The main control is executed by slides buttons. Below in the graph form there will be presented a proper configuration. SW0 SW1 SW2 SW3 SW4 SW5 SW6 SW7 chip clock (CLK_DACEA) selector (SW7,SW6)=00=> : Daniel’s pattern (SW7,SW6)=01=> : L_DUTY (SW7,SW6)=10=> : H_DUTY (SW7,SW6)=11=> : basic pattern ADC clock (CLK_ADC) selector (SW5,SW4)=00=> : ground (clk_off) (SW5,SW4)=01=> : CLK_LF (12,5MHz) (SW5,SW4)=10=> : CLK_50MHz (SW5,SW4)=11=> : CLK_100MHz presented data to 4-digit LED display: (SW2,SW1,SW0)=000 => : average data [*] (SW2,SW1,SW0)=001 => : secTime (SW2,SW1,SW0)=010 => : dataInterval (SW2,SW1,SW0)=011 => : HALFPERIOD (SW2,SW1,SW0)=100 => : dutyCycle (SW2,SW1,SW0)=000 => : patternPeriod (SW2,SW1,SW0)=100 => : dutyCycle (SW2,SW1,SW0)=101 => : patternPeriod (SW2,SW1,SW0)=others : E00E transition to manual mode SW3 = 0: normal mode SW3 = 1: manual mode connecting with manual mode, the polarization could be changed by push button 2. for: BTN2 = 0: positive pol. DIG(4) = 0 BTN2 = 1: negative pol. DIG(4) = 1 BTN2 BTN3 BTN1 BTN0 Figure 3.8: Slide switches configuration
44 3.3 Simulation This section shows correctness the algorithm operation, and also demonstrate work principle in graphical way. A changing a sequence is allow only when H (Hold) signal is active high. For that reason a capacitance divider is disconnected from measurement part and prevent a glitches occurrence. This behavior is depicture on Figure 3.9. Figure 3.9 Sequence changes when H is high. The MEMS capacitance could be changed in several ways. The most obvious is by destruction, but unfortunately in this thesis there is no description of this method. Other important way is designed by Daniel Fernandez. A distance between plates is changed with a PWM duty cycle width. By increasing a time of high level PWM the capacitance increase too [8]. The third method to change it, is by charge injection. Because user can tune a MEMS capacitance, a charge injection phenomena could be see only after changing a power supply, as it was explained in 1.5 section. For that reason we have to capture a ADC data just before and after switch and decide which mode should be selected next. When ADC data are equal or not exceed a interval value in both sequence the program change a voltage polarity every defined period of time(defined by secTime register). The Figure 3.10 presented that situation. The time is set by user because injection speed is different for each MEMS.
45 Figure 3.10: Sequence changes every secTime period. In the Figure 3.12 the data from the ADC are not constant, but increasing due to injected charge. There are register named charge which indicate how large load is injected to MEMS structure. This register does not include charge’s sign. The digs(4) flag which indicate a current sequence, helps to determinate to which pole a capacitor is loaded. This is better explain in the Figure 3.11, and the Figure 1.6 in 1.6 section will also be useful. During each sequence there are discharging from previous pole and charging to opposite one. Returning to Figure 3.12 there are two artificial addition of load, marked as discharging A and B. This stimulation was performed to show that system is able to stabilize, and also that algorithm reduce a charge to the minimum. In this figure there are another signal – leds(1) to indicate what is current state. When leds(1) = 0 the program is in one of two pre-sequence, in pre_seq_I when digs(4)=0 and in pre_seq_II when digs(4)=1. discharging from positive pole/ see draw nr. 3 in Figure 1.6 charging to negative pole/ see draw nr. 4 in Figure 1.6 charging to positive pole/ see draw nr. 6 in Figure 1.6 discharging from negative pole/ see draw nr. 6 in figure 1.2 Figure 3.11: Charging sign explanation
5 Bibliography [1] Allen, J. J. (2005). Micro Electro Mechanical System Design . Broken Sound Parkway NW, USA: Taylor & Francis Group. [2] Ashenden, P. J. (2008). The designer's guide to VHDL. Burlington: Morgan Kaufman Publishers. [3] Chu, P. P. (2008). FPGA prototyping by VHDL examples. Hobokon: Wiley-Interscience. [4] Chu, P. P. (2006). RTL hardware designe using VHDL. Hoboken: Wiley-Interscience. [5] D. Fernández, Jordi Madrenas. Pulse-Drive and Capacitive Measurement Circuit For MEMS Electrostatic Actuators, Analog Integrated Circuits and Signal Processing. Accepted for publication. [6] D. Molinero, R. C. (2006). Dielectric charge measurements in capacitive microelectromechanical switches. Barcelona, Spain. [7] Daniel Fernándeza, Jordi Madrenas. (2008). A Self-Test and Dynamics Characterization Circuit for MEMS Electrostatic Actuators., (pp. 3-4). Barcelona. [8] Horsley, D. (2004). Patent nr US 6,674,383 B2. Berkeley, CA (US). [9] Carter J., Cowen A., MEMSCAP Inc. (2005). PolyMUMPs Design Handbook. Rev. 11.0. [10] Goldsmith C., Ehmke J., (2001). Lifetime characterization of capacitive RF MEMS switches., Dig. IEEE Int. Microwave Symp., (pp. 227-230). [11] Krick D. T., P. Lenahan, (Oct. 1988.) Electrically active point defects in amorphous silicon nitride: An illumination and charge injection study, (pp. 3558-3563). [12] Korvink, J. G., & Korvink, J. G. (2006). MEMS: A Practical Guide to Design, Analysis, and Applications. Freiburg, Germany: Springer-Verlag GmbH & Co. KG. [13] Lyons, R. G. (2007). Streamlining Digital Signal Processing A Tricks of the Trade Guidebook. Piscataway, New Jearsy : IEEE Press .
53 [14] Lyons, R. G. (2004). Understanding Digital Signal Processing, Second Edition. Upper Saddle River, New Jersey: Bernard Goodwin. [15] M.-C. Lu, G. F. (2004). Position Control of Parallel-Plate Microactuators for Probe- Based Data Storage, Microelectromechanical Systems. pp 759–769. Journal of 13 (5). [16] Pedroni, V. A. (2004). Circuit Design with VHDL. Cambridge, Massachusetts: MIT Press. [17] Senturia, S. D. (2002). Microsystem Design. New York: Kluwer Academic Publishers. [18] Xilinx. (2009). PlanAhead User Guide. [19] Xilinx. (2005). Spartan-3 Starter Kit Board User Guide. [20] Xilinx. (2006). Using Digital Clock Managers (DCMs) in Spartan-3 FPGAs. Application Note: Spartan-3 and Spartan-3L FPGA Families.
Appendixes A – DELIRIUM-I-FEAEL documentation. Schematic
55 Reference Design Assembly Drawing
56 B – Multiplexing board documentation Schematic
57 Reference Design Assembly Drawing Top Layer Copper Top Layer Assembly Bottom Layer Copper Bottom Layer Assembly There is no components on that layer.
58 Bills of materials
59 C – A MEMS actuators floor-plan.
60 D – Source codes MEMS_ChargeInReduce.vhd – top level ---------------------------------------------------------------------------------- -- ###################################### JUNE VERSION ###################################### -- Company: Politechnical University of Catalonia (UPC) -- Engineer: Kamil Karliński / Daniel Fernández ([email protected]) -- -- Create Date: 17:59:21 03/23/2010 -- Design Name: -- Module Name: MEMS_ChargeInReduce - Behavioral -- Project Name: -- Target Devices: DACEA platform -- Tool versions: -- Description: Algorithm to reduce the failure mechanizm in elektrostatic actuators like CHARGE INJECTION -- -- Dependencies: -- -- Revision: -- Revision 0.01 - File Created -- Additional Comments: -- ---------------------------------------------------------------------------------- library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; use ieee.numeric_std.all; ---- Uncomment the following library declaration if instantiating ---- any Xilinx primitives in this code. library UNISIM; use UNISIM.VComponents.all; entity MEMS_ChargeInReduce is Port ( CLK_IN : in STD_LOGIC; CLK_ADC : out STD_LOGIC; DATA_ADC : in STD_LOGIC_VECTOR (9 downto 0); CLK_DACEA : out STD_LOGIC; BCD_OUT : out STD_LOGIC_VECTOR (7 downto 0); BCD_SEL : out STD_LOGIC_VECTOR (3 downto 0); FILTER_OUT : out STD_LOGIC_VECTOR (10 downto 0); CAPTURE : out STD_LOGIC; RST : in STD_LOGIC; H_DACEA : in STD_LOGIC; D_DACEA : in STD_LOGIC; R_DACEA : in STD_LOGIC; CMPOUT : out STD_LOGIC; SLIDE_SWITCH : in STD_LOGIC_VECTOR (7 downto 0); PUSH_SWITCH : in STD_LOGIC_VECTOR (2 downto 0); -- TxD : out STD_LOGIC; LEDS : out STD_LOGIC_VECTOR (7 downto 0); -- VGA_HS, VGA_VS, VGA_RED, VGA_GRN, VGA_BLU : out STD_LOGIC; OR_ADC : in STD_LOGIC; MAN : out STD_LOGIC; H0 : out STD_LOGIC; D0_C : out STD_LOGIC; DIGS : out STD_LOGIC_VECTOR (4 downto 1) ); end MEMS_ChargeInReduce; architecture Behavioral of MEMS_ChargeInReduce is type state_type is (pre_seqI, seqI, pre_seqII, seqII, manual); signal state_reg, state_next : state_type := seqI; signal CLK_50MHz : STD_LOGIC; signal CLK_100MHz : STD_LOGIC; signal CLK_100MHzI : STD_LOGIC; signal CLK_LF : STD_LOGIC; signal CLK_DIV : STD_LOGIC_VECTOR(23 downto 0) := (OTHERS => '0'); signal CLK_DACEAI : STD_LOGIC; signal H_POS : STD_LOGIC; -- it's a delayed HOLD signal signal DATA_ADC_SIGNED, SAHP_OUT, SUBS_OUT, AVGS_OUT, SUBS2_OUT, MAX, MIN : STD_LOGIC_VECTOR (10 downto 0) := (others=>'0'); signal capSeqI, capSeqII : STD_LOGIC_VECTOR (10 downto 0) := (others=>'0'); signal AVGS_OUT_disp : STD_LOGIC_VECTOR (10 downto 0) := (others=>'0'); signal AVGS_OUT_dispII : STD_LOGIC_VECTOR (15 downto 0) := (others=>'0'); signal BEGINCAP_MAX, BEGINCAP_MAX_DLY : STD_LOGIC; signal DISPLAY_DATA_SSD : std_logic_VECTOR(15 downto 0); signal DOTS : STD_LOGIC_VECTOR (3 downto 0); signal SLIDE_FILT : STD_LOGIC_VECTOR (7 DOWNTO 0) := (OTHERS => '0'); signal PUSH_FILT : STD_LOGIC_VECTOR (3 DOWNTO 0) := (OTHERS => '0'); signal SELECTOR : std_logic_vector(1 downto 0) := (OTHERS => '0'); signal COMP : STD_LOGIC; signal L_DUTY : STD_LOGIC; signal H_DUTY : STD_LOGIC; signal PRE_CLK_DACEA : STD_LOGIC; signal LOCK, nLOCK, nLOCK_DLY : STD_LOGIC; signal secCount : STD_LOGIC_VECTOR (26 DOWNTO 0) := (others=>'0');
61 signal secTime : STD_LOGIC_VECTOR (3 DOWNTO 0) := "0001"; -- variable, indicate a each sequence period, -- approximate in 1 second unit constant AVGS : NATURAL RANGE 0 to 8 := 5; --it is a power of 2, --indicate how many samlpes was taken to avarage process (in this case 2^2=4) signal avgCount : STD_LOGIC_VECTOR (AVGS DOWNTO 0) := (others=>'0'); --not (AVGS-1 DOWNTO 0) because last bit (MSB) avgCout(AVGS) - can indicate when -- averaging module collect all 2^avgs samples to process signal stopStoraging : STD_LOGIC := '0'; signal dataInterval : NATURAL RANGE 0 to 512 := 10; signal DIGS_int : STD_LOGIC_VECTOR (4 DOWNTO 1) := (others=>'0'); signal dutyCycle : NATURAL range 1 to 1023 := 10; -- signal patternPeriod : NATURAL range 1 to 1023 := 250; -- 125 => period = 10us with CLK_IF = 12.5MHz signal MY_CLK_DACEA : STD_LOGIC; constant PREHOLD_TIME : NATURAL RANGE 0 TO 255 := 2; --the time which we add at the beginig of H_DACEA to delay constant HPOS_TIME : NATURAL RANGE 0 TO 255 := 70; --the time which we add at the end of H_DACEA to delay constant SSFACTOR : NATURAL RANGE 2 to 5 := 3; constant MAXLOCK : NATURAL RANGE 1 to 131000 := 15000; constant GRACE : NATURAL RANGE 1 to 8191 := 200/(2**SSFACTOR); signal HALFPERIOD : NATURAL RANGE 1 to 8191 := 216/(2**SSFACTOR); signal HPadjSpeedUp : NATURAL RANGE 1 to 2047 := 1; signal adjSpeedUp : NATURAL RANGE 1 to 63 := 1; constant LOW_DCP : STD_LOGIC_VECTOR(1023 downto 0) := (0=>'1', 1=>'1', 2=>'1', OTHERS=>'0'); constant HIGH_DCP : STD_LOGIC_VECTOR(255 downto 0) := (0=>'0', 1=>'0', 2=>'0', 3=>'0', 4=>'0', 5=>'0', 6=>'0', 7=>'0', 8=>'0', 9=>'0', 10=>'0', 11=>'0', 12=>'0', 13=>'0', 14=>'0', 15=>'0', 16=>'0', 17=>'0', 18=>'0', 19=>'0', 20=>'0', 21=>'0', 22=>'0', 23=>'0', OTHERS=>'1'); begin --================================================== -- DCM instantiate --================================================== DCM1 : DCM generic map ( CLKDV_DIVIDE => 10.0, -- Divide by: 1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5 -- 7.0,7.5,8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0 or 16.0 CLKFX_DIVIDE => 2**(SSFACTOR), -- Can be any integer from 1 to 32 CLKFX_MULTIPLY => 2, -- Can be any integer from 1 to 32 CLKIN_DIVIDE_BY_2 => FALSE, -- TRUE/FALSE to enable CLKIN divide by two feature CLKIN_PERIOD => 20.0, -- Specify period of input clock CLKOUT_PHASE_SHIFT => "NONE", -- Specify phase shift of NONE, FIXED or VARIABLE CLK_FEEDBACK => "2X", -- Specify clock feedback of NONE, 1X or 2X DESKEW_ADJUST => "SYSTEM_SYNCHRONOUS", -- SOURCE_SYNCHRONOUS, SYSTEM_SYNCHRONOUS or -- an integer from 0 to 15 DFS_FREQUENCY_MODE => "LOW", -- HIGH or LOW frequency mode for frequency synthesis DLL_FREQUENCY_MODE => "LOW", -- HIGH or LOW frequency mode for DLL DUTY_CYCLE_CORRECTION => TRUE, -- Duty cycle correction, TRUE or FALSE FACTORY_JF => X"C080", -- FACTORY JF Values PHASE_SHIFT => 0, -- Amount of fixed phase shift from -255 to 255 STARTUP_WAIT => FALSE) -- Delay configuration DONE until DCM LOCK, TRUE/FALSE port map ( CLK0 => CLK_50MHz, -- 0 degree DCM CLK ouptput CLK2X => CLK_100MHzI, -- 2X DCM CLK output CLKFX => CLK_LF, -- DCM CLK synthesis out (M/D) CLKFB => CLK_100MHz, -- DCM clock feedback CLKIN => CLK_IN -- Clock input (from IBUFG, BUFG or DCM) ); BUF1: BUFG port map (I => CLK_100MHzI, O => CLK_100MHz); --================================================== -- Digital_Signal_Procesing components instantion --================================================== --------------- Delayed of the HOLD (H_DACEA) signal ------------- HLDP : entity work.delayed_stim(Behavioral) generic map (predelay=>PREHOLD_TIME, postdelay=>HPOS_TIME, preventive=>'1') port map ( clk => CLK_100MHz, inp => H_DACEA, outp => H_POS ); ------------------- Sample and Hold for ADC data -------------------- SAHP : entity work.sampleandhold(Behavioral) generic map (n=>11) port map ( clk => CLK_100MHz, hold => H_POS, din => DATA_ADC_SIGNED, dout => SAHP_OUT ); ------------------- Generic subsampler v2 -------------------- SUBS : entity work.subsampler_v2(Behavioral) generic map (n=>11, s=>SSFACTOR) port map ( clk => CLK_100MHz, clk_out => CLK_LF, din => SAHP_OUT, dout => SUBS_OUT ); --------------- Averaging the SUBS_OUT samples ----------------- AVG : entity work.averaging(Behavioral) generic map ( avgs=>AVGS, n=>11) port map ( clk => CLK_LF, din => SUBS_OUT, dout => AVGS_OUT ); --==================================================================
68 ---------------------------------------------------------------------------------- -- Sample and Hold ---------------------------------------------------------------------------------- library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity sampleandhold is generic (n : integer); Port ( clk, hold : in STD_LOGIC; din : in STD_LOGIC_VECTOR(n-1 downto 0); dout : out STD_LOGIC_VECTOR(n-1 downto 0)); end sampleandhold; architecture Behavioral of sampleandhold is begin process (clk) begin if rising_edge(clk) then if hold='0' then dout<=din; end if; end if; end process; end Behavioral; ---------------------------------------------------------------------------------- -- Simple sequence generator ---------------------------------------------------------------------------------- library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity cyclicpattern is generic (n : integer); port (clk, reset: in std_logic; dada : std_logic_vector(n-1 downto 0); b:out std_logic); end cyclicpattern; architecture structural of cyclicpattern is begin process(clk) variable i: integer range 0 to dada'length-1 := 0; begin if rising_edge(clk) then if reset='1' then i := dada'length-1; else if i=0 then i:=dada'length-1; else i := i-1; end if; end if; b <= dada(i); end if; end process; end structural; ---------------------------------------------------------------------------------- -- Averaging module ---------------------------------------------------------------------------------- library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity averaging is generic ( avgs : integer; n : integer); port ( clk : in std_logic; din : in STD_LOGIC_VECTOR(n-1 downto 0); dout : out STD_LOGIC_VECTOR(n-1 downto 0) ); end averaging; architecture Behavioral of averaging is type samples IS ARRAY ((2**avgs)-1 DOWNTO 0) OF STD_LOGIC_VECTOR(n-1 downto 0); signal dataSamples : samples; begin process (clk) variable accumulator : STD_LOGIC_VECTOR(n+avgs-1 downto 0) := (OTHERS => '0'); begin if rising_edge(clk) then -- add new sample and detele the last one (shift right) -- first LSB is deleted, then array is shifted right -- and the new sample is put in MSB place for index in 0 to (2**avgs)-2 loop dataSamples(index) <= dataSamples(index+1); end loop; dataSamples((2**avgs)-1)<=din; -- average all data in array accumulator := (others=>'0'); for index in dataSamples'range loop accumulator := accumulator + ext(dataSamples(index),n+avgs); end loop; dout <= accumulator(n+avgs-1 downto avgs); end if; end process; end Behavioral;
69 misc.vhd ---------------------------------------------------------------------------------- -- Company: Advanced Hardware Architectures (AHA) / Politechnical University of Catalonia (UPC) -- Engineer: Daniel Fernández ([email protected]) -- -- Create Date: 11:30:44 05/29/2008 -- Design Name: -- Module Name: output pattern generators - Behavioral -- Project Name: -- Target Devices: -- Tool versions: -- Description: -- -- Dependencies: -- -- Revision: -- Revision 0.01 - File Created -- 0.1 - RAM_STOPCONT added -- Additional Comments: -- ---------------------------------------------------------------------------------- library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity OUT_PATTERN is generic (maxlock : integer; grace : integer); Port ( clk : in STD_LOGIC; comp : in STD_LOGIC; halfperiod : NATURAL RANGE 1 to 8191; lock : out STD_LOGIC; out_pattern : out STD_LOGIC); end OUT_PATTERN; architecture Behavioral of OUT_PATTERN is type STATE is (dist_decreasing, dist_increasing, not_locked); signal PAT_PRSTATE, PAT_NXSTATE : STATE := not_locked; signal countlock, countdist : NATURAL RANGE 0 to 131000; begin process (clk) begin if (rising_edge(clk)) then if(PAT_PRSTATE = dist_decreasing) then countlock<=countlock-1; else countlock<=maxlock; end if; if(PAT_PRSTATE = dist_increasing) then countdist<=countdist-1; else countdist<=halfperiod; end if; PAT_PRSTATE<=PAT_NXSTATE; end if; end process; process(PAT_PRSTATE, comp, countlock, countdist) begin case PAT_PRSTATE is when dist_decreasing => out_pattern<='0'; lock<='1'; if countlock<(maxlock-grace) then if(comp='1') then PAT_NXSTATE<=dist_increasing; elsif countlock=1 then PAT_NXSTATE<=not_locked; else PAT_NXSTATE<=dist_decreasing; end if; else PAT_NXSTATE<=dist_decreasing; end if; when dist_increasing => out_pattern<='1'; lock<='1'; if(countdist=1) then PAT_NXSTATE<=dist_decreasing; else PAT_NXSTATE<=dist_increasing; end if; when others => out_pattern<='1'; lock<='0'; PAT_NXSTATE<=dist_increasing; end case; end process; end Behavioral; -- --------------------------- MY OUT PATTERN GENERATOR --------------------------- library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity MY_PATTERN is Port ( clk : in std_logic; -- 12,5 MHz clock what means 80ns period dutyCycle : in NATURAL range 1 to 1023; patternPeriod : in natural range 1 to 1023; out_pattern : out std_logic ); end MY_PATTERN; architecture Behavioral of MY_PATTERN is signal Counter : natural range 0 to 1023 := 0; begin process (clk) begin if rising_edge(clk) then if (Counter < patternPeriod) then Counter <= Counter + 1;
70 else Counter <= 0; end if; end if; end process; out_pattern <= '1' when Counter < dutyCycle else '0'; end Behavioral; Display.vhd ---------------------------------------------------------------------------------- -- Company: Advanced Hardware Architectures (AHA) / Politechnical University of Catalonia (UPC) -- Engineer: Daniel Fernández ([email protected]) / Jose Luis Casas -- -- Create Date: 10:57:12 05/27/2008 -- Design Name: -- Module Name: Display - Behavioral -- Project Name: -- Target Devices: DACEA platform -- Tool versions: -- Description: BCD display basic handlers -- -- Dependencies: -- -- Revision: -- Revision 0.01 - File Created -- Additional Comments: -- ---------------------------------------------------------------------------------- library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity Display is Port ( value : in STD_LOGIC_VECTOR (15 downto 0); dots : in STD_LOGIC_VECTOR (3 downto 0); en : in STD_LOGIC_VECTOR (3 downto 0); clkin : in STD_LOGIC; bcd_out : out STD_LOGIC_VECTOR (7 downto 0); bcd_sel : out STD_LOGIC_VECTOR (3 downto 0)); end Display; architecture Behavioral of Display is component BCDto7seg is port (a : in std_logic_vector(4 downto 0); b:out std_logic_vector(7 downto 0)); end component; component muxBCD is port (a3,a2,a1,a0:in std_logic_vector(4 downto 0); s:in std_logic_vector(1 downto 0); b:out std_logic_vector(4 downto 0)); end component; component decBCD is port (a : in std_logic_vector(1 downto 0); en : in std_logic_vector(3 downto 0); b : out std_logic_vector(3 downto 0)); end component; signal bcd_in : std_logic_vector (4 downto 0); signal bcd_in3, bcd_in2, bcd_in1, bcd_in0 : std_logic_vector (4 downto 0); signal sel : std_logic_vector (1 downto 0) := (OTHERS=>'0'); begin BCD : component BCDto7seg port map (bcd_in, bcd_out); MUX : component muxBCD port map (bcd_in3, bcd_in2, bcd_in1, bcd_in0, sel, bcd_in); DEC : component decBCD port map (sel, en, bcd_sel); bcd_in3<=(dots (3) & value(15 downto 12)); bcd_in2<=(dots (2) & value(11 downto 8)); bcd_in1<=(dots (1) & value(7 downto 4)); bcd_in0<=(dots (0) & value(3 downto 0)); process (clkin) begin if (clkin='1' and clkin'event) then sel<=sel+1; end if; end process; end Behavioral; ---------------------------------------------------------------------------------- -- Create Date: 10/11/2007 -- Module Name: decBCD -- Project Name: display -- Tool versions: -- Author: Daniel Fernández ([email protected]) -- Description: Decodificador 2:4. -- ---------------------------------------------------------------------------------- library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; entity decBCD is
71 port (a : in std_logic_vector(1 downto 0); en : in std_logic_vector(3 downto 0); b : out std_logic_vector(3 downto 0)); end decBCD; architecture arhmux of decBCD is begin process(en, a) begin if (a="00" and en(0)='1') then b<="1110"; elsif (a="01" and en(1)='1') then b<="1101"; elsif (a="10" and en(2)='1') then b<="1011"; elsif (a="11" and en(3)='1') then b<="0111"; else b<="1111"; end if; end process; end arhmux; ---------------------------------------------------------------------------------- -- Create Date: 10/11/2007 -- Module Name: -- Project Name: display -- Tool versions: -- Author: Jose Luis Casas / Daniel Fernández (dfern[email protected]) -- Description: Decodificador BCD a 7 segmentos -- ---------------------------------------------------------------------------------- library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; entity BCDto7seg is port (a:in std_logic_vector(4 downto 0); b:out std_logic_vector(7 downto 0)); end BCDto7seg; architecture Arch_BCDto7seg of BCDto7seg is begin process(a) begin if (a(3 downto 0)="0000") then b<=NOT a(4) & "1000000";--displays 0 elsif (a(3 downto 0)="0001") then b<=NOT a(4) & "1111001";--displays 1 elsif (a(3 downto 0)="0010") then b<=NOT a(4) & "0100100";--displays 2 elsif (a(3 downto 0)="0011") then b<=NOT a(4) & "0110000";--displays 3 elsif (a(3 downto 0)="0100") then b<=NOT a(4) & "0011001";--displays 4 elsif (a(3 downto 0)="0101") then b<=NOT a(4) & "0010010";--displays 5 elsif (a(3 downto 0)="0110") then b<=NOT a(4) & "0000010";--displays 6 elsif (a(3 downto 0)="0111") then b<=NOT a(4) & "1011000";--displays 7 elsif (a(3 downto 0)="1000") then b<=NOT a(4) & "0000000";--displays 8 elsif (a(3 downto 0)="1001") then b<=NOT a(4) & "0010000";--displays 9 elsif (a(3 downto 0)="1010") then b<=NOT a(4) & "0001000";--displays A elsif (a(3 downto 0)="1011") then b<=NOT a(4) & "0000011";--displays B elsif (a(3 downto 0)="1100") then b<=NOT a(4) & "1000110";--displays C elsif (a(3 downto 0)="1101") then b<=NOT a(4) & "0100001";--displays D elsif (a(3 downto 0)="1110") then b<=NOT a(4) & "0000110";--displays E elsif (a(3 downto 0)="1111") then b<=NOT a(4) & "0001110";--displays F -- elsif () end if; end process; end Arch_BCDto7seg; ---------------------------------------------------------------------------------- -- Create Date: 10/11/2007 -- Module Name: mux - arhmux -- Project Name: display -- Tool versions: -- Author: Jose Luis Casas / Daniel Fernández ([email protected]) -- Description: Este modulo es un multiplexor de 4:1. Tiene 2 bits de seleccion -- de canal y 4 buses de 5 bits. -- ---------------------------------------------------------------------------------- library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; entity muxBCD is port (a3,a2,a1,a0:in std_logic_vector(4 downto 0); s:in std_logic_vector(1 downto 0); b:out std_logic_vector(4 downto 0)); end muxBCD; architecture arhmux of muxBCD is begin process(a3,a2,a1,a0,s) begin if (s="00") then b<=a0; elsif (s="01") then b<=a1; elsif (s="10") then b<=a2; elsif (s="11") then b<=a3; end if; end process; end arhmux;
72 TB_MEMS_ChargeInReduce.vhd ---------------------------------------------------------------------------------- -- Company: DMCS -- Engineer: Kamil Karlinski -- -- Create Date: 22/04/2010 -- Design Name: -- Module Name: TB_MEMS_ChargeInReduce - testbench -- Description: the same as filename -- -- Dependencies: -- -- Revision: -- Revision 0.01 - File Created -- Additional Comments: -- ---------------------------------------------------------------------------------- library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity TB_MEMS_ChargeInReduce is end entity; architecture testbench of TB_MEMS_ChargeInReduce is -- clocks section signal clk_in, ckl_100mhz, clk_lf, clk_dacea : STD_LOGIC := '0'; signal clk_div : STD_LOGIC_VECTOR(23 downto 0); signal clk_ADC_data, clk_charge : STD_LOGIC := '0'; signal or_adc : STD_LOGIC := '0'; signal h_duty : STD_LOGIC; signal selector : STD_LOGIC_VECTOR (1 downto 0); signal rst,h,d,r : STD_LOGIC := '0'; signal slide, leds : STD_LOGIC_VECTOR (7 downto 0) := (others=>'0'); signal push : STD_LOGIC_VECTOR (2 downto 0) := (others=>'0'); signal digs : STD_LOGIC_VECTOR (4 downto 1) := (others=>'0'); signal secCount : STD_LOGIC_VECTOR (26 DOWNTO 0) := (others=>'0'); signal clearSecCounter : STD_LOGIC; signal upSecCountEnter : STD_LOGIC_VECTOR (27 DOWNTO 0) := (others=>'1'); signal data_adc : STD_LOGIC_VECTOR (9 downto 0) := B"10_0000_0000"; -- = 512 in decimal signal capSeqI, capSeqII : STD_LOGIC_VECTOR (10 downto 0); signal charge : NATURAL range 0 to 512 := 0; signal Charging : STD_LOGIC := '1'; signal AVGS_OUT : STD_LOGIC_VECTOR (10 downto 0) := (others=>'0'); signal secTime : STD_LOGIC_VECTOR (3 DOWNTO 0) := B"0001"; signal avgCount : STD_LOGIC_VECTOR (5 DOWNTO 0) := B"00_0000"; signal A,B : STD_LOGIC_VECTOR (10 downto 0); signal A_higher_B, A_equal_B, A_lesser_B : STD_LOGIC; constant hysteresis : NATURAL range 0 to 15 := 5; signal intCLK_2ms : STD_LOGIC := '0'; signal ADC_increase : STD_LOGIC := '0'; -- signal HI_mems, LO_mems : STD_LOGIC := '0'; signal HI_mems, LO_mems : unsigned (1 downto 0) := "00"; begin SIM_MEMS_unit: entity work.SIM_MEMS port map ( CLK_IN => clk_in, CLK_ADC => open, DATA_ADC => data_adc, CLK_DACEA => clk_dacea, BCD_OUT => open, BCD_SEL => open, FILTER_OUT => open, CAPTURE => open, RST => rst, H_DACEA => h, D_DACEA => d, R_DACEA => r, CMPOUT => open, SLIDE_SWITCH => slide, PUSH_SWITCH => push, -- TxD => , LEDS => leds, -- VGA_HS, VGA_VS, VGA_RED, VGA_GRN, VGA_BLU : out STD_LOGIC; OR_ADC => or_adc, MAN => open, H0 => open, D0_C => open, DIGS => digs, CLK_100MHz_sim => ckl_100mhz, CLK_LF_sim => clk_lf, H_DUTY_out => h_duty, SELECTOR_out => selector, CLK_DIV_out => clk_div, AVGS_OUT_out => AVGS_OUT, secCount_out => secCount, secTime_out => secTime, avgCount_out => avgCount, upSecCountEnter_out => upSecCountEnter, capSeqI_out => capSeqI, capSeqII_out => capSeqII
73 ); -- clocks definition section clk_in <= not clk_in after 10 ns; -- frequency = 50MHz -> period = 20ns ckl_100mhz <= not ckl_100mhz after 5 ns; -- frequency = 100MHz -> period = 10ns clk_lf <= not clk_lf after 40 ns; -- frequency = 1/4 * 50Mhz = 12,5MHz -> period = 80ns intCLK_2ms <= not intCLK_2ms after 3200 us; -- frequency = ??? -> period 4 ms clk_ADC_data <= not clk_ADC_data after 5 us; clk_charge <= not clk_charge after 5 us; slide(7 downto 6) <= "11"; slide(5 downto 4) <= "11"; slide(3) <= '0'; -- manual mode stimulation -- slide(2) <= '0', '1' after 1.8 ms, '0' after 4.7 ms; -- push(2) <= '0', '1' after 2.5 ms, '0' after 3 ms, '1' after 3.5 ms, '0' after 4 ms; -- for HI_mems and LO_mens I do a simulation with the following level: -- logic "01" -> GND -- logic "11" -> +15V -- logic "10" -> +3.3V -- logic "00" -> -11.7V HI_mems <= "01" when d='1' else "11" when d='0' and digs(4)='0' else --sec. I "00" when d='0' and digs(4)='1'; --sec. II LO_mems <= "01" when d='1' or (d='0' and digs(4)='0') else "10" when d='0' and digs(4)='1'; chipSignalGenerator : process begin wait until clk_dacea='1'; wait for 10 ns; h <= '1'; d <= '1'; wait for 30 ns; r <= '1'; wait until clk_dacea='0'; wait for 10 ns; r <= '0'; wait for 30 ns; h <= '0'; d <= '0'; end process chipSignalGenerator; -- -------------------- ADC data -------------------- ADC_data_Stimulator : process (clk_ADC_data, digs(4)) begin if digs(4)'event then if Charging = '1' then data_adc <= data_adc - 2*charge; else data_adc <= data_adc + 2*charge; end if; elsif rising_edge(clk_ADC_data) then data_adc <= data_adc + 1; end if; end process; -- -------------------- CHARGE -------------------- Charge_Stimulator : process(clk_charge) begin -- if rising_edge(intCLK_2ms) then -- charge <= 127; -- els if rising_edge(clk_charge) then if Charging = '1' then charge <= charge + 1; else charge <= charge - 1; end if; end if; end process; -- -------------------- chargingFlag -------------------- charging_flag_Stimulator : process(digs(4), charge) begin if charge = 0 then Charging <= '1'; elsif digs(4)'event then Charging <= not Charging; -- nie może byc = 0 że po zmianie robimy zawsze rozłodowywanie, bo jak na chwilę else -- wejdziemy w drugi tryb - żeby tylko zobaczyć to po powrocie musi być ładowanie Charging <= Charging; end if; end process; -- adcDataSimulator : process(d, intCLK_2ms) begin -- if d'event then -- if ADC_increase = '1' then data_adc <= data_adc + 5; -- else data_adc <= data_adc - 5; end if; -- elsif intCLK_2ms'event then -- if ADC_increase = '1' then data_adc <= data_adc + 20; -- else data_adc <= data_adc - 20; end if; -- end if; -- end process adcDataSimulator; -- ADC_increase <= not ADC_increase after 2.2 ms; -- data_adc <= B"01_0010_1100"; -- 300 in decimal -- -------------------------------------- part to check how comparison works ------------------ -- A <= B"000"&X"00", B"000"&X"03" after 0.3 us, B"000"&X"0F" after 0.65 us, B"000"&X"A0" after 0.9 us, -- B"000"&X"01" after 1 us, B"000"&X"03" after 1.2 us, B"000"&X"0D" after 1.5 us; -- B <= B"000"&X"00", B"000"&X"09" after 0.35 us, B"000"&X"01" after 0.6 us, B"000"&X"A0" after 0.95 us, -- B"000"&X"06" after 1.05 us, B"000"&X"0A" after 1.25 us, B"000"&X"08" after 1.56 us;
74 -- -- histereza daje nam to, że przełączanie nie następuja tak często. -- temporaryCheckingProcess : process(clk_lf) begin -- if rising_edge(clk_lf) then -- if (A > B + hysteresis) then A_higher_B <= '1'; A_lesser_B <= '0'; A_equal_B <= '0'; -- elsif (A < B - hysteresis) then A_higher_B <= '0'; A_lesser_B <= '1'; A_equal_B <= '0'; -- else A_higher_B <= '0'; A_lesser_B <= '0'; A_equal_B <= '1'; -- end if; -- end if; -- end process; end architecture; sim.do quit -sim vdel -all -lib work vlib work vcom Display.vhd vcom dsp.vhd vcom misc.vhd vcom SIM_MEMS.vhd vcom TB_MEMS_ChargeInReduce.vhd #simulate without optimization vsim -novopt work.TB_MEMS_ChargeInReduce onerror {resume} quietly WaveActivateNextPane {} 0 #open the window to time analize a wave view wave # add all items in region to wave # add wave -noupdate -format Logic /tb_mems_chargeinreduce/clk_in # add wave -noupdate -format Logic /tb_mems_chargeinreduce/ckl_100mhz add wave -noupdate -format Logic /tb_mems_chargeinreduce/clk_lf # add wave -noupdate -format Logic /tb_mems_chargeinreduce/clk_dacea # add wave -noupdate -format Logic /tb_mems_chargeinreduce/or_adc add wave -noupdate -format Logic /tb_mems_chargeinreduce/h_duty # add wave -noupdate -format Logic -radix decimal /tb_mems_chargeinreduce/clk_div # add wave -noupdate -format Logic /tb_mems_chargeinreduce/rst add wave -noupdate -format Logic /tb_mems_chargeinreduce/h # add wave -noupdate -format Logic /tb_mems_chargeinreduce/d # add wave -noupdate -format Logic /tb_mems_chargeinreduce/r # add wave -noupdate -format Logic /tb_mems_chargeinreduce/slide # add wave -noupdate -format Logic /tb_mems_chargeinreduce/push # add wave -noupdate -format Logic /tb_mems_chargeinreduce/selector # add wave -noupdate -format Logic /tb_mems_chargeinreduce/leds # add wave -noupdate -format Logic /tb_mems_chargeinreduce/ADC_increase add wave -noupdate -format Analog -min 400 -max 700 -radix unsigned -height 80 /tb_mems_chargeinreduce/data_adc add wave -noupdate -format Analog -min 0 -max 150 -radix unsigned -height 80 /tb_mems_chargeinreduce/charge # add wave -noupdate -format Logic -radix unsigned /tb_mems_chargeinreduce/AVGS_OUT add wave -noupdate -format Analog -min 0 -max 3 -radix unsigned -height 40 /tb_mems_chargeinreduce/hi_mems add wave -noupdate -format Analog -min 0 -max 3 -radix unsigned -height 40 /tb_mems_chargeinreduce/lo_mems # add wave -noupdate -format Logic /tb_mems_chargeinreduce/digs add wave -noupdate -format Logic /tb_mems_chargeinreduce/digs(4) add wave -noupdate -format Logic /tb_mems_chargeinreduce/leds(1) add wave -noupdate -format Logic /tb_mems_chargeinreduce/Charging # add wave -noupdate -format Logic -radix unsigned /tb_mems_chargeinreduce/capSeqI # add wave -noupdate -format Logic -radix unsigned /tb_mems_chargeinreduce/capSeqII # add wave -noupdate -format Logic -radix unsigned /tb_mems_chargeinreduce/secCount # add wave -noupdate -format Logic -radix unsigned /tb_mems_chargeinreduce/clearSecCounter # add wave -noupdate -format Logic -radix decimal /tb_mems_chargeinreduce/secTime add wave -noupdate -format Logic -radix unsigned /tb_mems_chargeinreduce/avgCount
75 # add wave -noupdate -format Logic -radix unsigned /tb_mems_chargeinreduce/upSecCountEnter #add wave -noupdate -format Logic -radix hexadecimal /tb_mems_chargeinreduce/A #add wave -noupdate -format Logic -radix hexadecimal /tb_mems_chargeinreduce/B #add wave -noupdate -format Logic /tb_mems_chargeinreduce/A_higher_B #add wave -noupdate -format Logic /tb_mems_chargeinreduce/A_lesser_B #add wave -noupdate -format Logic /tb_mems_chargeinreduce/A_equal_B TreeUpdate [SetDefaultTree] configure wave -namecolwidth 120 configure wave -valuecolwidth 100 configure wave -justifyvalue left configure wave -signalnamewidth 1 configure wave -snapdistance 10 configure wave -datasetprefix 0 configure wave -rowmargin 4 configure wave -childrowmargin 2 configure wave -gridoffset 0 configure wave -gridperiod 1 configure wave -griddelta 40 configure wave -timeline 0 configure wave -timelineunits us update #run simulation for 1ms # for simulate in normal mode with long D_DACEA pattern set 3ms sim. time #for low/high duty cycle in CLK_DACEA signal (test mode) #run 1ms #for long CLK_DACEA pattern (normal mode) run 10ms