GENERAL POLICIES

The labs are to be conducted in a professional manner. The steps you are expected to follow are listed below. In essence the calculations and design work are to be completed before the laboratory. When you arrive at the laboratory you will be expected to build lab equipment, conduct tests and collect data to verify the system performance. After the lab you will compare the theoretical and experimental data.

In many cases most of the work will be before the laboratory. In general the division of work will be 50-80% of the work before the lab, 20-40% during the laboratory, 10% after the lab.

If any of the required components in a laboratory experiment is missing, 50% of the final grade will be automatically deducted. If two or more required sections are missing, the lab will not be graded and returned with a grade of zero.

2.1.1 Before the Lab

[an error occurred while processing this directive]

- Do all required prelab calculations in the lab book.

- Normally calculations will be done by hand, unless otherwise noted in the laboratory descriptions. However, it is useful to verify hand-calculations with software.

- Students are expected to write a planned procedure to be followed during the lab. When there are questions about the work to be done during the lab, reasonable assumptions should be made. This will require you to read and understand the ’Experiment’ section of the experiment.

2.1.2 During the Lab

[an error occurred while processing this directive]

- Arrive on time, or early. Ariving late is unfair to everybody; it diminishes your educational experience, it places extra demands on your teammates and the lab instructor.

- Have the prelab work in the lab book checked and signed at the beginning of the lab. If work has not been done before the lab marks will be deducted accordingly. However, the pre-lab work must still be completed. Failure to do so may result in a grade of zero for the lab.

- Collect a detailed equipment list, including unique ID numbers.

- Write the procedure and results in the lab book.

- Make note of expected and unexpected observations.

- Before dissassembling equipment and leaving the lab students should compare the theoretical and experimental values. If they don’t match, the work must be repeated.

- If the laboratory work is done early, students are expected to remain in the laboratory.

2.1.3 After the Lab

[an error occurred while processing this directive]

- The theoretical and experimental data values must be compared using tables, graphs, or another appropriate method. Failure to analyze the data numerically will result in severe penalties.

- Discrepancies between the theoretical and experimental data must be discussed.

- The comparison between the experimental and theoretical values must be discussed within the context of the purpose of the laboratory.

- Students are encouraged to not include informal statements such as "This lab was valuable and I learned alot.".

- Students are encouraged to make brief statments about the results based on numerical values.

2.1.4 Notebooks

[an error occurred while processing this directive]

Weekly laboratory checklist

__ use past tense AND passive voice

__ after data is collected, extract characteristic numbers

__ put comments on source code

__ figures should have numbers and titles below the figure

__ tables should have numbers and titles above the table

__ extra sheets (such as printouts) should be attached in the book so that they do not extend beyond the edges. They should be attached with tape, staples, or glue

__ point form must still use full sentences

__ when using ’counts’ convert the numbers to real units

__ consider that I/O is limited and values can be clipped

__ don’t copy the procedure and background from the lab guide

__ the conclusion should address the purpose, using numerical values derived from the experimental data.

__ used numbered steps for procedures

__ when working with integer values recall 2’s compliments rules for negative numbers and the lack of negative numbers for unsigned integers.

__ when using software to draw graphs do not use smooth curve fits for experimental data

__ collect more data in regions where change is occuring

__ when unexpected or notable events occur during the lab they should be noted in the lab book

__ additional data points should be collected in areas of change

 

3.0.1 Lab 1 - Programming the Atmel Atmega32 Thumb Board

[an error occurred while processing this directive]
3.0.1.1 - Purpose

To use the Atmel Mega32 microcontroller boards to input and output digital, analog, serial, and wireless data.

3.0.1.2 - Background/Theory

A method for generating variable analog outputs, called Pulse Width Modulation (PWM), is shown in Figure 3.1 Pulse Width Modulation (PWM). If the output is on all the time, the effective output voltage is the maximum voltage of the output. If the output is only on half the time, the effective output voltage is only half. By varying the ratio of on-time to off-time, the effective voltage is varied. The percentage of time that the signal is on is called the duty cycle. So, if the voltage is only on half the time, the effective voltage is half the maximum voltage, and the duty cycle is 50%. This method is popular because it can produce a variable effective voltage efficiently. (Aside: The frequency of these waves is normally above 20KHz, above the range of human hearing.)

 

Figure 3.1 Pulse Width Modulation (PWM)

An analog to digital (A/D or ADC) converter converts an analog input voltage to a digital value. A successive approximation A/D converter is shown in Figure 3.2 Analog to digital converter. This device is like the one in the AtMega. The main operation concept is based on the successive approximation logic. Once the reset is toggled the converter will start by setting the most significant bit of the 8 bit number. This will be converted to a voltage Ve that is a function of the +/-Vref values. The value of Ve is compared to Vin and a simple logic check determines which is larger. If the value of Ve is larger the bit is turned off. The logic then repeats similar steps from the most to least significant bits. Once the last bit has been set on/off and checked the conversion will be complete, and a done bit can be set to indicate a valid conversion value.

 

Figure 3.2 Analog to digital converter

In the ATMega 32, the A/D converter is 10 bit, and there are up to eight 0-5V inputs available on port A. To operate the A/D converter the following steps must be used. Once the analog input value has been read it can be converted back into a voltage using equation (2).

 

Microcontrollers are often used in real-time applications. Real-time systems must respond to events with time constraints. In other words they must always respond to inputs and cannot ’go to sleep’ as normal desktop computers do. To achieve this responsiveness interrupts are used. An interrupt can be generated by an external event, such as input change, or by an internal timer. When an interrupt occurs the computer will stop whatever it is doing and store its current state. It then runs a designated interrupt subroutine. The interrupt subroutine should run briefly and then allow the computer to restore its previous state and return to normal operations. In a realtime controller the interrupt routine typically runs 100 to 1000 times per second to check motor positions and update outputs to control the motors.

Serial communication typically involves sending bytes between devices. These bytes are often ASCII encoded characters. Multiple bytes make up a string. For our purposes we will use serial communication to send commands to the microcontrollers, and to get responses (including data) back. Serial communications can be done multiple ways. The simplest method will be over the USB port, using a virtual serial port under windows. We may then use a program such as Hyperterminal to interact with the microcontroller.

Communications may also occur without wires. Many wireless communication standards are already in use, however the boards we are using include hardware for a new wireless networking method called Zigbee. This is meant for consumer products with low power consumption and slower data rates. One interesting difference between simple communication and networking is that there may be multiple clients able to talk at one time. And, each client on the network will have a unique identifier, known as a network address. For Zigbee this will be a value between 0 and 255.

3.0.1.3 - Prelab

1. Review C programming using previous course materials.

2. Review the EGR 226 course materials from EGR 261 and 226..

3. Review the analog I/O chapter in the textbook.

4. Skim the Atmel Mega32 manual (www.atmel.com) to become familiar with the processor.

5. Review the fundamentals of ASCII strings, including end-of-line and carriage-return characters.

6. Investigate Zigbee networks on the internet.

3.0.1.4 - Equipment

Computer with an Internet connection

Assembled controller thumb board

10K potentiometer

Multimeter

Oscilloscope

3.0.1.5 - Experimental Procedure

1. Boot your PC and login to the network. (Note: don’t forget to use a browser first to login to the campus network first.) Plug the board into a USB port. At this point windows (XP) should recognize that new hardware has been inserted and look for a driver. If not already installed you will need to do the following --> A message "Welcome to the Found New Hardware Wizard" should appear. For the prompt "Can Windows Connect to Windows Update to search for software?" use "Yes". Select "Install the Software Automatically". You should see something that says "USB->Serial". This process will be repeated for "USB Serial Port". An LED on the PCB may flash indicating that the board has power - if this does not occur don’t worry.

 

2. Open "Start/Control Panel" then "System/Hardware/Device Manager". Open the "ports" item and find the com port number.

 

3. Install the following software packages in the order shown. These packages are available on the course home page (http://claymore.engineer.gvsu.edu/~jackh/eod/egr345.html), or on the C2D2 web page. Note: Be careful to install the packages in the order shown below.

WinAVR 3.5 or newer - a basic set of tools and the C compiler.

Megaload 5.0 or newer - a tool for downloading programs.

Gvim 6.1 - (on C2D2) an editor for modifying programs.

AVR C Compiler Update - (on C2D2) to provide a shell for compiling

GVim Editor Update Installation - (on C2D2) adds some shortcuts

test.hex - a test program for the thumb board

 

4. Run megaload and select the com port found in step 2. In Megaload set the "File to be program in the flash" to be "test.hex", and set the baud rate to 38,400. You should then be able to push the reset button on the board and load the program. If all was successful you will see a few lines of text in the "messages" window and the last line will be "Flash Prog Done!".

 

5. Run ’AVR Studio 4’ and do the following steps. Note: If the software crashes look on-line for help. This seems to be a particular problem with Windows Vista.

a) Select ’New Project’ - Note: This is also the point where you can open older projects later.

b) Select ’GNU GCC’ - This is the free compiler that you used in EGR 226. If you do not see it make sure ’Win AVR’ is installed.

c) Enter a ’Project Name’ of ’lab1_a’. - Notice that the project directory is shown below. If this directory is not acceptablen. Write down the location. Select ’Next’.

d) Under ’Debug Platform’ select ’AVR Simulator’ - Many of the other choices require hardware for incircuit debugging. Under ’Device’ select ’ATMEGA 324P’ - If this choice is not present you will need to install a newer version of the software.

e) Select ’finish’ and the programming IDE (Interactive Development Environment) will show up. On the left are project files. By default the main c program editing window is already open.

f) Enter the program in Figure 3.3 Test program (simple.c).

g) Open ’Project/Configure Options’ and Enter a ’Frequency’ of 8000000 (8 million) - this tells the compiler what default CPU frequency is so that it may calculate delays properly. Verify that the ’Create Hex File’ option is selected - this will create the ’hex’ file that we can download. Select ’OK’ to close the window.

h) Select ’Build/Build All’ to compile the program. If any compiler errors occur they will appear on the bottom of the screen. Double click on any errors to go to that line in the program. Once the program is compiled correctly go to the next step.

 

Figure 3.3 Test program (simple.c)

 

6. Use the simulator to test the program. Select ’Build/Build and Run’, then ’Debug/Run’. The program simulation should now be running. Go to the right hand side of the screen and expand ’PORTC’.

 

7. Start the Megaload program and make sure that the ’File to be programmed in the flash’ is pointing to the ’lab1_a.hex’ file in the project directory. Press the reset button on the board to download the program. A message will appear if the download was completed successfully. The program will now be running.

 

8. The program toggles the output on Pin 6C. This is slowed by the ’delay’ function. Connect the positive side of a multimeter to the PC6 output. Connect the negative side of the multimeter to a common/ground terminal. Change the delay and download the program again.

 

9. Enter, compile, and download the program in Figure 3.4 Digital inputs. Test it by changing inputs on port A and verifying that the same output changes on port B. Note: if an input is not connected, it will tend to assume a random value.

Figure 3.4 Digital inputs

10. Enter, compile, and download the program in Figure 3.5 Analog inputs. Test the program by setting an analog input with a variable power supply connected to PA0. The 5 most significant bits of the outputs will be on port B. Set the input voltage to different voltages and measure the digital outputs. Convert the binary values to a decimal value and plot the results.

 

Figure 3.5 Analog inputs

11. Enter, compile, and download the program in Figure 3.6 Analog Outputs with Pulse Width Modulation (PWM). The program will accept the input voltage on PA0 and output a corresponding voltage on PD7. Use a DMM to verify that the input and output voltages match. Use an oscilloscope to verify that the output wave is PWM and trace a few examples at different duty cycles.

 

Figure 3.6 Analog Outputs with Pulse Width Modulation (PWM)

 

12. Enter, compile and download the program in Figure 3.7 A system clock using interrupts. The outputs on port B will change in a binary pattern.

 

Figure 3.7 A system clock using interrupts

 

13. Download the files sio.c and sio.h to your working directory. Enter, compile and download the program in Figure 3.8 ASCII Communications. You will then need to close ’megaload’ and start hyperterm. Choose ’com1’ with 9600baud, 8 data, 1 stop, no parity and Xon/Xoff handshaking. You should see text messages on the screen.

 

Figure 3.8 ASCII Communications

14. Put a Zigbee program to exchange bytes ---------------------------

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx

 

4.0.1 Lab 2 - Numerical Methods

[an error occurred while processing this directive]
4.0.1.1 - Purpose

To be able to use Scilab and C programs to model systems.

4.0.1.2 - Background/Theory

In order to analyze dynamic systems on computers we will need to use programs to perform the calculations. In this case we will use Scilab and C as our preferred tools.

 

Programs written in C can be very efficient and fast. Moreover, when we develop a complete system, we can incorporate C programs into a finished product.

 

Scilab is a clone of the Matlab software package. Both are designed to do matrix oriented mathematics with simple commands.

 

4.0.1.3 - Prelab

1. Write a C Program to integrate the area beneath the function below. The program should ask the user for the start and end points, as well as the number of steps. (you can download compilers from http://claymore.engineer.gvsu.edu/~blaucha/c2d2/c2d2.html)

 

2. Review the Scilab tutorial (see the course home page for a link). Download and install the Scilab software (www.scilab.org).

 

3. Write a Scilab program that does the same numerical integration used in step 1 (there is a similar example in the numerical methods chapter of the textbook).

 

4. Write differential equations for the following system. Convert the equations to state form and write C and Scilab programs to solve the state equations.

 

4.0.1.4 - Equipment

Computer with internet access.

4.0.1.5 - Experimental

1. (If necessary, download and install a C compiler.) Enter the C program written for numerical integration and verify the operation.

 

2. Enter and test the numerical integration Scilab program written for the prelab. Change the step size and determine what step size results on ’convergence’ of the results. Show a graph of the results.

 

3. Enter the C and Scilab programs for the mechanical system and verify their operation.

 

4. Change the step size for the C program and determine what step size results on ’convergence’ of the results. Show a graph of the results.

 

5. Follow the tutorial for creating web pages.

 

6. Post all of the programs written during the lab to your web page.

 

 

5.0.1 Tutorial - Creating Web Pages

[an error occurred while processing this directive]

• The general steps are:

1. Get a computer account on ‘claymore.engineer.gvsu.edu’ from Prof. Jack. This account will have a prototype web page that you can edit.

 

2. Go to http://www.mozilla.org/editor and download the web page editing tool. In the editor go to ‘claymore.engineer.gvsu.edu’ and look for your account under ‘students’. You should be able to find a page that starts with ‘YOUR_NAME_GOES_HERE’.

 

3. First, save the page using ’save’. If one doesn’t exist, create a ‘temp’ directory on the computer. This directory will be used to temporarily hold your web page files. Make sure that the files will be saved in the ‘temp’ directory, and then ‘save’ the file as ’index.html’, all in lower case. An editor will start on the screen.

 

4. The editor behaves much like Microsoft Word, with some subtle differences. At this point add your name, and change your email address to your university account. You can change your email address by clicking on the email link, and then clicking on the ’chain link’ near the top of the screen.

 

5. To upload the changes use FTP. Many computers have ’WSFTP’ installed, although other FTP tools are available and may be used. You will need to connect to ’claymore.engineer.gvsu.edu’ and login with you user ID and password. (NOTE: Don’t save these on the computer you are using because somebody else could use your account.) Change to the ’public_html’ directory and copy the files there. As a minimum you will need to copy the ’index.html’ file, but any other files you need should also be in this directory, or in a subdirectory.

 

6. Use Firefox, not the editor, to see if the changes have occurred. Your changes may not show up on the browser. This is because Firefox does not reload pages every time to look at them. Pages are often stored for up to 1 month on the PCs hard drive, and reused when you look at them. One way to update the screen before this time limit is to click on the ’reload’ or ’refresh’ button.

 

7. Next we will add links to your home page. Identify the file you would like to link to, and move it to the temp directory with the ’index.html’ file. Use a file name that is all lower case such as ‘test.mcd’ - any upper case letters cause problems in Windows. Open your homepage in the editor, if it is not open already. Write a simple description for the file, and highlight it with the mouse. Use the ’link’ button at the top of the editor screen, and enter the file name for the link. If it is in the same directory nothing else is needed beyond the file name. Pay attention to the case of the file name, upper and lower case are significant. Upload the page (using FTP) and the file to claymore and verify that the link works.

 

8. Get your home page back in the editor. Someplace on the page add a line that says ’GVSU’. Use the mouse to select what you just typed, and then click on the link button. For the link name enter ‘http://www.gvsu.edu’, and apply the change. This will now be a link to the Grand Valley home page. Upload and test the link.

 

9. Explore the editor to see what other features are available.

• Some tips when creating web pages are,

- Windows will not allow multiple applications to open the same file at the same time. If you seem to be having trouble opening a file, make sure it is not open in another application.

 

- As you add other files to your homepage, put them in the ‘temp’ directory. This will make all of the procedures simpler.

 

- Try to make your web pages small, and link them together. This will decrease download time and make browsers happier.

 

- Avoid using excessive images. Anything over 100K will make it slow downloading. Anything over 1M makes modem downloading very slow.

 

- When putting images on the web page use ‘jpg’ for photographic images, and ‘gif’ for line images. ‘jpg’ images can be compressed more than ‘gif’, but lines will become blurred.

 

- To link to other files or web pages there will be a ‘link’ command. If you want to add a file that is in your ‘temp’ directory, just put the name of the file in the ‘URL’ field.

 

- Watch upper/lower case. This is a major cause of web page problems. It is best to keep to lower case for all file names.

6.0.1 Lab 3 - A Feedback Controller

[an error occurred while processing this directive]
6.0.1.1 - Purpose

To use the Atmega32 microcontroller for velocity feedback control of a motor.

6.0.1.2 - Background/Theory

A basic feedback control system is shown in Figure 6.1 Atmega32 based velocity feedback controller. In this system the atmega32 will output a control voltage as a PWM signal. When the output is 0V, the transistor will be off, and act like an open switch. However, when the output is 5V, it will turn the transistor on, and allow current to flow to the motor. (Note: There will be a voltage drop across the transistor, in this case approximately 0.8V.) The motor shaft is connected to a tachometer to measure the motor speed. (Note: In this lab we will use another motor as the tachometer.) The tachometer will produce a voltage proportional to the motor speed.

 

Figure 6.1 Atmega32 based velocity feedback controller

To complete the control system, a program is required. The program reads the motor speed input, Ct, from the analog voltage, Vt, and use it to adjust the output, Cc, to adjust the voltage, Vs, to control the motor speed. Normally a user may supply a setpoint, Cd. This setpoint indicates the desired speed. In this program care is required to ensure that the Cc value remains in the range from 0 to 255 because of the limitation of the PWM functions.

 

Figure 6.2 The complete feedback loop

The PWM output to the motor is a square wave with a variable duty cycle. Equation (1) below shows how to convert the PWM value to an effective output voltage. It is worth noting that part of the voltage from the power supply is lost across the transistor, thus reducing the effective voltage to the motor.

 

 

To implement this controller we need a better program structure than was used before. This is shown in the following program listing. The IO_update() function will be called many times per second by an interrupt subroutine. The CLK_setup function initializes the interrupt routines in the processor so that the ’SIGNAL(SIG_OVERFLOW1)’function will be called once evey 10ms. This in turn will call the IO_update() function. The main program sets up the various input output devices and then begins a loop where it deals with keyboard IO. Notice that the subroutines to update the inputs and outputs do not appear in the main program loop. It communicates with those routines by changing the value of the global variable ’count’.

 

 

 

One major challenge when constructing a system is debugging. The flowchart in Figure 6.3 The Traditional Debugging Approach shows the tradition approach to debugging.

Figure 6.3 The Traditional Debugging Approach

While this debugging approach is easy to understand it takes much longer to solve problems and can become very frustrating. The debugging approach shown in Figure 6.4 Enlightened Debugging Approach is much more mature. Although it involves a few more steps, it will often take substantially less time. The essence of this method is that the program is not changed until the source of the problem in known. Common methods are to use print statements, or other debugging tools to see what the program is doing.

 

Figure 6.4 Enlightened Debugging Approach

 

6.0.1.3 - Prelab

1. Review the programs from the previous lab.

2. Write a program that will allow keyboard commands to change the PWM, and output the analog input to the screen once a second. Please note that this may be noisy and using the average of multiple readings may be required to reduce the noise.

3. Write a program that implements the feedback controller described in the background section. Put the feedback loop in an interrupt subroutine, and use the main program for keyboard IO. Don’t forget to consider the number limitation of the chosen datatypes. (i.e., 2’s compliment integers)

6.0.1.4 - Equipment

computer with an atmega32 compiler

atmega32 board

2 motors

2 multimeters

strobe tachometer

TIP 120/122 Darlington NPN transistor

heatsink for TIP 120/122 transistor

external power supply

capacitor (1-100uF)

6.0.1.5 - Experimental

1. Build the motor speed controller pictured in Figure 6.5 PWM control of motor speed. Use Figure 6.6 TIP 120/122 NPN Darlington pair transistor when connecting the transistor. (Note: if the transistor gets hot during operation use a heat sink on the transistor to help dissipate heat). Use the PWM program from the previous lab to control the PWM output and test the motor speed control.

 

Figure 6.5 PWM control of motor speed

 

Figure 6.6 TIP 120/122 NPN Darlington pair transistor

2. Use a second motor as the tachometer (not to be confused with the strobe tachometer, used for calibration). This is done by connecting the motor shafts using a light colored piece of tape. It is also advisable to fix both motors to a common base to reduce vibrations. DO NOT CONNECT THE TACHOMETER LEADS TO THE ANALOG INPUT YET.

 

3. Label both leads of the motor V+ and V-. Connect these leads to a DMM. Connect the V+ lead to the positive input on the DMM, and V- to the common/ground on the DMM.

 

4. Use the program developed for the prelab to vary the PWM output to control the motor speed. Take the following readings in a tabular form. The motor RPM can be measured using the strobe tachometer as a reference. Vt is measured from the motor tachometer using the DMM, and a second DMM is used to measure Vs. The table should have at least 5 points spanning the range. (Note: if there is excessive vibration correct it before taking readings.)

5. If the voltages for Vt were negative swap the V+ and V- labels on the motor tachometer. FAILURE TO DO THIS MAY DAMAGE YOUR EQUIPMENT. Connect the motor tachometer to the analog input as shown in Figure 6.7 Motor tachometer analog input. You may also change the signs for Vt in the table.

 

Figure 6.7 Motor tachometer analog input

6. Use the prelab program to vary the PWM output and read the resulting analog input. Add the values to the previous table.

 

7. Enter and test the feedback control program developed in the prelab with a gain of P=2. Change the setpoint, Cd, to different values and measure the resulting speed, Ct. Record these values in a new table.

 

8. Repeat the previous step twice for gains of P=1 and P=4.

 

9. Graph the results from the three tests on a single graph.

 

7.0.1 Lab 4 - Deadband Compensation for Bidirectional Motion

[an error occurred while processing this directive]
7.0.1.1 - Purpose

To compensate for ’stiction’ in a bidirectional open loop controller.

7.0.1.2 - Background

Friction in motors will prevent them from turning when small voltages are applied. This effect is normally known as ’stiction’, a combination of the words static and friction. Friction is present in all motors, however this effect is greater in lower cost motors. When a motor is connected to a mechanical system the friction may increase greatly. In most cases we can reduce the cost of a new design by using less expensive motors and compensating for larger friction effects in software.

7.0.1.3 - Theory

In motors there are two types of friction that must be considered. The static friction, ’stiction’, will prevent initial motion. If the motor supplies enough torque to break free and start turning, the kinetic friction will provide a roughly constant friction torque.

Figure 7.1 Motor deadband for a bidirectional motor shows an example of how this friction affects the relationship between the voltage applied to a motor, and the resulting velocity. At very low voltages the torque is too low to overcome the stiction. The region where the applied voltage has no effect is called the deadband. Once the applied voltage exceeds the deadband limits the motor will start to turn. While turning, the motor experiences kinetic friction, damping and other effects. If the voltage supplied to the motor is slowly decreased it will eventually ’stick’. However, the sticking force will be lower than the static friction force. This alternate path is shown in the figure as a heavy dashed line.

 

Figure 7.1 Motor deadband for a bidirectional motor

There are a number of methods for compensating for a non-linear deadband in a system. A simple method is shown in Figure 7.2 Deadband approximation for a bidirectional motor. This method involves finding the voltages where the motor breaks free in the positive and negative directions. These are used in a program to change the wanted output voltage, to an adjusted output voltage.

 

Figure 7.2 Deadband approximation for a bidirectional motor

The equations to implement a deadband compensator are shown in Figure 7.3 Deadband approximation for a bidirectional motor. These adjust the wanted voltage to exclude the deadband. In this case the equations also adjust the relationship to allow the full use of the PWM output scale.

 

Figure 7.3 Deadband approximation for a bidirectional motor

The equations from the previous example are implemented in the subroutine given in Figure 7.4 Deadband compensation for an ATMega32 controlled output. This subroutine actually allows the positive and negative deadband limits to be different, as would be expected in an actual motor. The subroutine also verifies that the corrected values are within the limits of the PWM output. In the example the equations have been rearranged to prevent roundoff errors during the integer calculations. The moving variable must be set so that when the velocity of the system is approaximately zero, it will have a value of 1. The algorithm includes an option to apply a higher (static) torque when not moving (moving == 0) to ’break away’. Normally this would be used for a short period of time to allow the motor to start moving, and then be reduced (moving = 1) so that the kinetic friction torque is used. If a system has feedback the detection of motion can be used to change the coefficient used.

 

Figure 7.4 Deadband compensation for an ATMega32 controlled output

Limiting function are used when the requested output exceeds the available output range. An example is shown in Figure 7.5 An output limiter.

 

Figure 7.5 An output limiter

In previous labs we used a transistor to control motor movement in one direction. The H-bridge circuit shown in Figure 7.6 H-bridge circuit for motor control can be used to drive a motor in two directions. As before, the transistors are used to switch current flow. In this case applying a voltage to the A1 and A2 terminals would allow voltage to flow left-to-right through the motor. Turning on inputs B1 and B2 would cause current to flow right-to-left through the motor. When the inputs are controlled using a PWM signal the effective motor voltage can be varied.

 

Figure 7.6 H-bridge circuit for motor control

When controlling an H-bridge some extra logic circuitry is commonly used, such as that in Figure 7.7 H-bridge control logic. The main purpose for this circuitry is to protect the H-bridge. For example, if A1 and B1 were both on at the same time, current would bypass the motor, on the left side. The current would be high, similar to a short circuit, eventually destroying the devices. The logic in the figure prevents this. In the logic the PWM output is connected to the E (enable) input. The direction is then used to determine which pair of transistors is turned on.

 

 

Figure 7.7 H-bridge control logic

In this lab we will use an integrated circuit that already contains protection circuitry. For our purposes we can approximate the control logic in that chip with that in Figure 7.8 H-bridge control logic. In this logic we will apply the PWM signal to the E (enable) input. We will then turn on the CW (clockwise) or CCW (counter clockwise) output to determine direction. Care is required to avoid turning both the CW and CCW outputs at the same time.

 

Figure 7.8 H-bridge control logic

As you will recall from previous labs the PWM output range is from 0 to 255. However for bidirectional motion we will have both positive and negative motor outputs. The program in Figure 7.9 Subroutines for PWM outputs and reversing the motor direction is designed to compensate for this by checking the sign of the requested output value. Depending upon the sign the CW and CCW outputs will be switched, and the negative values made positive. This routine also checks to make sure that the values don’t exceed the maximum limit of 255. This subroutine also changes the direction of rotation by reversing two of the output bits on port C.

 

Figure 7.9 Subroutines for PWM outputs and reversing the motor direction

 

The subroutines in Figure 7.10 The output update subroutines deal with general IO updates, as well as a simple delay routine. It allows the deadband compensation to be disabled to simplify the identification of deadband limits.

 

Figure 7.10 The output update subroutines

The main program is shown in Figure 7.11 The main test program. It includes numerous keystroke commands to allow the modification of settings.

 

Figure 7.11 The main test program

7.0.1.4 - Prelab

1. Develop a program for open loop velocity control using the subroutines given in the theory section. The program should compensate for the deadband of the motor, as described in the prelab. The main program should initialize the PWM routines and other outputs and allow keyboard inputs to change the setpoint. The routines that correct for the deadband stiction and update the PWM output are not part of an interrupt driven subroutine. This is because we are using feedforward control and there is no feedback value available to update the system.

 

Figure 7.12 The open-loop controller

2. Develop a plan for measuring the deadband limits for multiple motors.

7.0.1.5 - Equipment

computer with the winavr compiler and megaload

ATMega32 board including an L293D Push-pull four channel driver

3 motors

1 multimeter

strobe tachometer

external power supply

7.0.1.6 - Experimental

1. Set up the motor controller as shown in Figure 7.13 Using an ATMega32 motor controller with a L293Ddriver, the pins for the device are shown in Figure 7.13 Using an ATMega32 motor controller with a L293Ddriver and Figure 7.14 L293D pinout diagram (top view). The L293D actually contains four drivers, or the equivalent of two H-bridges. In this case we will use two of these that can supply a peak current of 600mA.

 

Figure 7.13 Using an ATMega32 motor controller with a L293Ddriver

 

Figure 7.14 L293D pinout diagram (top view)

2. Enter the program developed for the prelab and test the motor controller.

3. Run the program with the deadband correction disabled. Vary the voltages for the motor to fall between -255 and 255 and record the desired motor speed, the output voltage and the actual motor speed in a table. Note: that the negative values are probably shown as 2’s compliment negative value and must be converted to positive values.

 

4. Use the data collected in the previous step to determine the deadband limits, and enable the deadband compensation in the program.

 

5. Repeat the readings taken in step 3 with the deadband values enabled.

 

6. Compare the results with and without deadband compensation on a graph. Plot the values using voltages instead of the PWM values.

 

7. Repeat the process for at least two other types of DC motors.

 

8. By now you will have observed that even with deadband compensation the motors may still ’sick’ at very low speeds. One trick to overcome this issue is to add a brief ’kick’ at the start of a speed increase. Do this by adding some code similar to that shown in Figure 7.15 ’Kick’ code - please note you will need to modify this somewhat.

 

Figure 7.15 ’Kick’ code

8.0.1 Lab 5 - Position Control with an Encoder

[an error occurred while processing this directive]
8.0.1.1 - Purpose

To use proportional and integral gain control to position a motor using an encoder.

8.0.1.2 - Background

Rotational position is often measured with potentiometers. The devices typically are low cost and provide reasonable accuracy (typ. 1%) but they have limited ranges of rotation. Encoders are more expensive devices that allow unlimited ranges of motion. An optical encoder is shown in Figure 8.1 An optical encoder. In this device two pairs of optical emitters and detectors are directed through a disk with openings. By counting the number of times the light beam is broken the distance of rotation is measured. Two light beams are used to detect the direction of rotation.

 

Figure 8.1 An optical encoder

 

8.0.1.3 - Theory

A very low resolution encoder disk is shown in Figure 8.2 Encoder disk. The dashed line indicates the position where the light beams cut across the disk. As the disk rotates the beams are broken at staggered intervals.

Figure 8.2 Encoder disk

Optical encoders can operate at high speeds with a longer life because there is no mechanical contact. Mechanical encoders use a rotating disk with metal rings in patterns similar to those in optical encoders. As the disk rotates mechanical contacts are opened and closed. These mechanical contacts are prone to ’bouncing’ as they make and break contact, and hence they do not work well for higher rotational speeds. Typically the contacts bounce time is less that 10ms. Although limited in speed, mechanical encoders are popular because they generally cost less than similar optical encoders.

 

An quadrature input pattern from an encoder is shown in greater detail in Figure 8.3 Quadrature Encoders. If we were to simply count the rising edges on one of the inputs we would be able to measure a total distance covered. However we must also use the second phase to determine the direction of motion. This method still uses one of the phases for the count. When a positive edge is encountered the counter is incremented if the other phase is true. However, if the other phase is false then the counter is decremented.

Figure 8.3 Quadrature Encoders

The previous method is simple to implement, but less accurate. A more accurate method looks at the current and previous state of both quadrature inputs. Consider the example in Figure 8.4 Quadrature Encoders as binary inputs where the two phases are binary inputs. If the last input value was 00 and an updated value is 10 then the motion is clockwise, if the updated value is 01 then the motion is counterclockwise.

 

Figure 8.4 Quadrature Encoders as binary inputs

A program to read position and velocity input from an encoder is given in Figure 8.5 Subroutines for reading position using an encoder. The program uses pins 0 and 1 on port B as encoder inputs. In this case the program counts upon both the positive and negative edges of both phases. This is done by comparing the current encoder position to the previous encoder position. When the inputs change the encoder value is either incremented or decremented, depending upon the preious values.

 

Figure 8.5 Subroutines for reading position using an encoder

A position control system is shown in Figure 8.6 Position control system. This system uses the H-bridge from the previous laboratory to drive a motor, which in turn drives an encoder used for position feedback.

 

Figure 8.6 Position control system

The block diagram for the control system is shown in Figure 8.7 Position control feedback loop. This control system will use a desired position for the system, in terms of the encoder position. An interrupt driven subroutine will be used to implement the feedback controller. It will calculate the system error by subtracting the encoder counter from the desired position. This will then be passed through a proportional and integral function. The result will be corrected for the deadband and output to control the motor as a PWM signal.

 

Figure 8.7 Position control feedback loop

All of the functions in the control system have been implemented in previous laboratories, except for the integration term. To integrate in a program we will need to add new values to previous values, using a known time step, as shown in Figure 8.8 Numerical integration. A subroutine to implement the proportional-integral controller is shown in Figure 8.9 Proportional integral controller. The integration subroutine also includes a crude limiting function to prevent the integral value from becoming excessively large.

 

Figure 8.8 Numerical integration

 

Figure 8.9 Proportional integral controller

Please note that the interrupt subroutines given in a previous lab use the same timer (1) as the PWM output. As a result new version using counter 0 is given in Figure 8.10 Interrupt subroutine using counter 0.

 

Figure 8.10 Interrupt subroutine using counter 0

8.0.1.4 - Prelab

1. Write a list of steps describing the procedure you are going to follow to carry out the experiment.

2. Provide a description (table) of the data (information) you are going to collect during the experiment.

3. Draw the block diagram of the test setup and sequence of flow.

4. Write a program to implement a control loop with encoder feedback for position control. The program should have the following:

a) A proportional and an integral gain value for the controller.

b) A method to collect the instantaneous output of the motor (feedback signal) and store it for use in monitoring motor performance vs. time.

c) A part that ensures compensation of the motor dead-band.

8.0.1.5 - Equipment

computer with an WinAVR compiler

ATMega32 board with an L293D (or L298) Push-pull four channel driver

1 motor

1 encoder (Grayhill series 61B 16 position)

1 multimeter

external power supply

8.0.1.6 - Experimental

1. Connect the control system and the motor using an L293D to drive the motor and an encoder as shown in Figure 8.11 Connecting the Encoder to the ATMega or Figure 8.12 Connecting a mechanical encoder to the ATMega32. Note the motor used in this lab may be a 3V motor, so the power supply voltage may differ from previous labs.

 

Figure 8.11 Connecting the Encoder to the ATMega

 

Figure 8.12 Connecting a mechanical encoder to the ATMega32

 

2. Test the program developed for the prelab. (Note: Remember to build and test in pieces whenever possible.) Determine all necessary parameters, such as the deadband limits. Note: if the motor positive and encoder positive directions are opposite, then the motor will rotate forever. This problem can be solved by reversing the motor leads.

 

3. For the proportional and integral gains use values of Kp = 1, Ki = 1.

 

4. Produce a calibration curve relating motor output position (degrees) to commanded position.

 

5. Supply different set points of motor positions and measure the steady state position. Also observe the response speed. After the motor settles, attempt disturbing the motor position (gently) and record your observations.

 

6. Repeat step 3 for different values of Kp and Ki.

 

7. Plot the results on a single graph. Results should show motor performance in time.

 

9.0.1 Lab 6 - Motion Control

[an error occurred while processing this directive]
9.0.1.1 - Purpose

To use a setpoint table to generate smooth motion profiles.

9.0.1.2 - Background

A simple (e.g., proportional) controller will move faster when further from the setpoint (desired position). This means at the start of motion there is normally a period of fast acceleration, resulting in a ’jerk’ and high acceleration. At the end of motion the controller slows smoothly to a stop. In many cases we prefer motion that starts and stops smoothly. This is achieved by adding motion control.

A block diagram for a motion controller is shown in Figure 9.1 Motion generation. In this system a target position is used to generate a set of points and times along a smooth path in a setpoint schedule table. These points are then used as setpoints for the feedback control loop. Motion starts at the beginning of the table with the first setpoint. At the given times, the setpoint is updated to the new value in the table. In this system the controller is always shooting for the next point on a smooth path.

Figure 9.1 Motion generation

9.0.1.3 - Theory

There are multiple methods for generating a smooth motion path, this section outlines two of these. The first is shown in Figure 9.2 Generating smooth motion paths, it controls motion using a parametric function ’p(u)’. The function value varies from 0 to 1 as the parameter ’u’ varies from 0 to 1. However, the parameters of the function are selected so that the motion starts and stops with a velocity of zero. In this case the final polynomial equation, (3), is fairly simple. This equation can then be used in equation (1) to generate a smooth motion path between any arbitrary start and end point, with arbitrary start and end times.

Figure 9.2 Generating smooth motion paths

The example in Figure 9.3 Generating smooth motion paths shows the use of a trigonometric function, instead of a polynomial. This function was used to generate the points in the following sample program in Figure 9.4 Subroutines for motion profile generation and use.

 

Figure 9.3 Generating smooth motion paths

The program in Figure 9.4 Subroutines for motion profile generation and use generates a motion table that can then be used to update setpoints. The function ’table_init()’ must be called once when the program starts to set up global time and table values. When a new target position has been specified the ’table_generate()’ function is called to generate the setpoint table. The ’table_update()’ function is called once every interrupt scan to check the setpoint table, and update the global setpoint variable, ’point_current’ at scheduled times. This function also includes a simple clock to keep track of the system time.

 

Figure 9.4 Subroutines for motion profile generation and use

9.0.1.4 - Prelab

1. Modify the subroutines in the prelab to use 15 motion points, instead of 11.

 

2. Write a program to use the setpoint generation routines with the position feedback control system developed in previous labs. The user interface should allow the user to increment or decrement a target value using ’i’ or ’d’. The user should be able to set the duration using key ’0’ to ’9’. The target value will not update the motion table until ’g’ is input. ’s’ will stop the motion.

9.0.1.5 - Equipment

computer with a WinAVR compiler

ATMega32 board with an L293D (or L298) Push-pull four channel driver

1 motor

1 encoder

1 multimeter

external power supply

9.0.1.6 - Experimental

1. Connect the control system using an L293D to drive the motor, and an encoder as done in previous labs.

 

2. Test the program developed for the prelab. Determine all necessary parameters, such as the deadband limits.

 

3. For the proportional and integral gain values use Kp=10, Ki = 0. Supply different setpoints and measure the steady state position and record other observations.

 

4. Repeat step 3 for different values of proportional and integral gains.

 

5. Tune the system by varing the PID parameters until the motion is smooth. First vary the P gain, then the I gain, and then finally the D gain.

 

6. Vary the time of the motion and observe the system behavior.

 

7. Vary the motion distance and observe the changes.

 

8. Plot the results on a single graph, be sure to indicate the setpoints.

 

10.0.1 Lab 7 - Characterizing Brushed DC Motors

[an error occurred while processing this directive]
10.0.1.1 - Purpose

To develop a differential equation that models a brushed DC motor

10.0.1.2 - Background

DC motors will generate a torque between the rotor and stator that is related to the applied voltage or current. When a voltage is applied the resulting current will generate a torque causing the rotor to accelerate. For any voltage and load on the motor there will tend to be a final angular velocity due to friction and drag in the motor. And, for a given voltage the ratio between steady-state torque and speed will be a straight line.

 

10.0.1.3 - Theory

The basic equivalent circuit model for the motor is shown below. We can develop equations for this model. This model must also include the rotational inertia of the rotor and any attached loads. On the left hand side is the resistance of the motor and the ’back emf’ dependent voltage source. On the right hand side the inertia components are shown. The rotational inertia J1 is the motor rotor, and the second inertia is an attached disk.

The model can now be considered as a complete system.

Looking at this relationship we see a basic first-order differential equation. We can measure motor properties using some basic measurements.

 

 

Figure 10.1 The torque and inertia in a basic motor model

These basic equations can be manipulated into the first-order differential equation in Figure 10.2 The first-order model of a motor.

 

Figure 10.2 The first-order model of a motor

A method for calculating motors parameters given the motor response to a step input is shown in Figure 10.3 Estimating motor parameters from performance. In this example the motor windings had a measured resistance of 40 ohms. When a 15V step input was applied, the motor ran with a steady state velocity of 2400 RPM. The motor responded to the input with a time constant of 0.5s.

 

Figure 10.3 Estimating motor parameters from performance

10.0.1.4 - Prelab

1. Integrate the differential equation to find an explicit function of speed as a function of time.

 

2. Develop a plan for measuring motor parameters. Also include sample calculations for finding the motor parameters values (with units), K, R, J.

 

3. Write a program for the ATMega32 that will set the PWM output and collect data for tachometer speed. Hitting the ’R’ key will make the process idle, with a PWM output of 0. Hitting a key between ’0’ and ’9’ will set the PWM output value between 0 and 255 in equal divisions. At this point the program should begin to collect analog input values every 10ms and save these in an array for 1 second. After the data collection period, the PWM output should stop and the program should become idle. Hitting the ’D’ key should dump the data to the screen so that it can be saved and plotted in Excel. The program should also include deadband compensation.

10.0.1.5 - Equipment

computer with a WinAVR compiler

ATMega32 board

1 motor

1 tachometer (another motor)

1 multimeter

strobe tachometer

TIP-122 Darlington coupled transistor, L293D, or L298

external power supply

10.0.1.6 - Experimental

1. With the motor disconnected from all other parts of the circuit, measure the resistance across the motor terminals. You may need to rotate the shaft slightly (and slowly) as the resistance will vary as the motor brushes and commutator make/break contact.

 

2. Connect the motor and the ATMega32 board so that the PWM output drives the motor with the TIP 120/122 transistor or L293D. The motor shaft should be connected to the motor being used as the tachometer.

 

3. Enter and test the program, and determine the motor deadband. Enable the deadband before collecting experimental data.

 

4. Use a strobe light to find the relationship between the tachometer voltage and the angular speed.

 

5. Obtain velocity curves for the motor with different voltage step functions. Use these to determine the motor parameters. Note: it is useful to use a range of voltages so that the data includes a wide range of steady state angular velocities.

 

 

11.0.1 Lab 8 - System Modeling and Simulation

[an error occurred while processing this directive]
11.0.1.1 - Purpose

To simulate and then build a motor controller for position control using a potentiometer.

11.0.1.2 - Background

In the previous laboratory we modelled a motor using a differential equation that did not include friction. To compensate for the effects of friction a deadband compensator was used. If we include friction in the model for the motor it is possible to develop a better motor model that is more accurate. It also makes it possible to develop a simulation that accurately models the system as a whole.

11.0.1.3 - Theory

The differential equation is rederived in Figure 11.1 The torque and inertia in a basic motor model and Figure 11.2 The first-order model of a motor experiencing kinetic friction to include a term for friction. In the derivation it is assumed that the motor is turning, and the friction is dynamic. Clearly the motor will not turn if the motor torque is less than the static friction limit.

Figure 11.1 The torque and inertia in a basic motor model

The coefficients for the differential equation in Figure 11.2 The first-order model of a motor experiencing kinetic friction can be found for the motor in a dynamic case using steady state velocities. The static torque value can be found using the deadband limits.

Figure 11.2 The first-order model of a motor experiencing kinetic friction

Potentiometers measure the angular position of a shaft using a variable resistor. A potentiometer is shown in Figure 11.3 A Potentiometer. A potentiometer is based upon a resistor, normally made with a thin film of resistive material. A wiper can be moved along the surface of the resistive film. As the wiper moves toward one end there will be a change in resistance proportional to the distance moved. If a voltage is applied across the resistor, the voltage at the wiper interpolate the voltages at the ends of the resistor.

 

Figure 11.3 A Potentiometer

The potentiometer in Figure 11.4 A Potentiometer as a Voltage Divider is being used as a voltage divider. As the wiper rotates the output voltage will be proportional to the angle of rotation.

Figure 11.4 A Potentiometer as a Voltage Divider

Potentiometers are inexpensive but have limited accuracy, normally in the range of 1%. They measure absolute position, and are calibrated by rotating the shaft to given angles and measuring the resulting output voltage. The range of rotation is normally limited to less than 360. An example of a potentiometer used for position feedback is given in Figure 11.5 Position control system.

Figure 11.5 Position control system

For the laboratory this week we will use a system like that defined in Figure 11.6 Block diagram of a position control system, with a potentiometer for position feedback.

 

Figure 11.6 Block diagram of a position control system

A control system can be evaluated numerically using a program similar to the one shown in Figure 11.7 Scilab program to simulate position feedback control and Figure 11.8 Scilab program to simulate position feedback control. The program uses the simple model of the motor, without friction, and proportional feedback control. The program has also been designed to model the potentiometer input and PWM output.

 

Figure 11.7 Scilab program to simulate position feedback control

 

Figure 11.8 Scilab program to simulate position feedback control

11.0.1.4 - Prelab

1. Develop a Scilab worksheet to simulate the differential equation for the motor model including friction.

 

2. Develop a method for calculating the motor coefficients, including the static and kinetic friction torques.

 

3. Write a C program to control the motor using the potentiometer for position feedback. The program should use deadband compensation (note: this is the static friction torque when the motor is not moving, but the kinetic friction torque while turning). The program should have a user interface similar to the one used for measuring motor parameters. The motor should start at rest, and when a key is pushed it should be given a new setpoint. The data should be collected, and dump when the user hits another key.

11.0.1.5 - Equipment

computer with a WinAVR compiler and Megaload

ATMega32 controller board

1 gearhead motor

1 potentiometer

1 multimeter

L293D H-Bridge driver

external power supply

11.0.1.6 - Experimental

 

1. Connect the motor and the ATMega32 board so that the PWM output drives the motor with the L293. The motor shaft should be connected to the potentiometer

 

2. Measure the potentiometer output voltage versus position and develop a graph. Use the slope later to convert values to angles.

 

3. Measure the motor parameters including friction. Note, if the motor will be used at lower speeds, then determine the motor parameters using the lower speed range.

 

4. Put the appropriate parameters into the C and Scilab programs.

 

5. Provide a step input to the ATMega32 controller and measure the response. Compare the actual motor response to the curve simulated in Scilab with the same system conditions. The comparison should be in terms of first/second order characterizations, such as damped frequency, overshoot or time constant.

 

6. Repeat step 5 for different step sizes in both directions and with different values of Kp.

 

 

12.0.1 Lab 9 - Variable Frequency Drives

[an error occurred while processing this directive]
12.0.1.1 - Purpose

To control the speed of an AC motor using a Variable Frequency Drive.

12.0.1.2 - Background/Theory

AC induction motors are designed with motor winding on the stator (outside) of the motor. The AC current in the stator coils sets up an alternating magnetic field. This field induces currents in the conductors (squirrel cage) in the rotor. This current creates a magnetic field that opposes the field from the stator. As a result a torque is created. In actuality the rotor must rotate somewhat slower than the field changes in the stator, this difference is called slip. For example a 3 phase motor (with two poles) that has a 60Hz power applied will with absolutely no rotational resistance rotate at 60 times per second. But in use it might rotate at 58 or 59Hz. As the number of poles in the motor rises, the speed of rotation decreases. For example a motor with four poles would rotate at half the speed of a two pole motor. The speed of the motor can be controlled by changing the frequency of the AC power supplied to the motor.The motor that we will use in the lab is a 3 phase AC motor made by Marathon Electric. It is a Black Max model number 8VF56H17T2001. The motor drives are Allen Bradley model 161 motor drives.

An induction motor has the windings on the stator. The rotor is normally a squirrel cage design. The squirrel cage is a cast aluminum core that when exposed to a changing magnetic field will set up an opposing field. When an AC voltage is applied to the stator coils an AC magnetic field is created, the squirrel cage sets up an opposing magnetic field and the resulting torque causes the motor to turn.

The motor will turn at a frequency close to that of the applied voltage, but there is always some slip. It is possible to control the speed of the motor by controlling the frequency of the AC voltage. Synchronous motor drives control the speed of the motors by synthesizing a variable frequency AC waveform, as shown in Figure 12.1 AC Motor Speed Control.

 

Figure 12.1 AC Motor Speed Control

These drives should be used for applications that only require a single rotational direction. The torque speed curve for a typical induction motor is shown in Figure 12.2 Torque Speed Curve for an Induction Motor. When the motor is used with a fixed frequency AC source the synchronous speed of the motor will be the frequency of AC voltage divided by the number of poles in the motor. The motor actually has the maximum torque below the synchronous speed. For example a motor 2 pole motor might have a synchronous speed of (2*60*60/2) 3600 RPM, but be rated for 3520 RPM. When a feedback controller is used the issue of slip becomes insignificant.

 

Figure 12.2 Torque Speed Curve for an Induction Motor

The equipment used in this laboratory is designed for industrial use and requires some knowledge of basic electrical concepts. These motors use 3-phase power. Most of the electrical sources you use are single (1) phase Alternating Current (AC). In these systems the power is delivered with three wires, the hot (black), the neutral (white), and the ground (ALWAYS GREEN). Important: The ground is used for safety, it should always be connected first to all major metal pieces in a system. The neutral should normally be a 0V (like a DC common). The hot will be switched on/off and provide a 120Vac 60Hz sine wave voltage to the system. The hot also has a fuse attached for safety. In this arrangement power flows from the hot to the neural, and should not flow through the ground unless there has been a short or some other fault.

Three phase electrical systems deliver power with 3-three lines. Each of the lines (L1, L2, and L3) contains a 60Hz sinusoidal voltage that has a 0, 120, or 240 degree phase shift. A useful mathematical property of these is that the sum of all three voltages is 0V. When 3-phase power is used with balenced loads there is no need for a neutral, although one is often provided for unbalanced loads. Grounds are also required for these systems.

When connecting grouns it is important to do so in a ’tree’ configuration. The grounds in the electrical system are connected to a deep conductor burried beneath the building. These are then run up to each outlet and machine from central points. A problem called a ground loop can occur when connections are made that cross the branches of the tree such that a circle of ground wire is made. Any magnetic fields cutting across these loops induce currents/voltages. These are often the source of randon failures, electrical shocks, etc.

12.0.1.3 - Prelab

1. Visit the Marathon Electric and Allen Bradley web sites and review the manuals for the motor and controllers. Don’t print these, but make a note of the web address so that you can find the manuals easily during the lab.

2. Read the VFD manual and make notes about the important parameters. Typical parameters/readings that must be set/viewed are listed below.

Speed reference (input/memory)

Speed input reference type (voltage/current)

Acceleration/Decelleration times

Enable inputs

Reset to factory settings

PID/Feedback control inputs and settings

Output frequency

Stop mode inputs

3. Develop a wiring plan for the drive that considers

The ’Stop’ input (Normally one input)

Start Inputs

Power/ground inputs

Speed signal inputs - look for a potentiometer

12.0.1.4 - Equipment

Computer with WinAVR programming software and Megaload

ATMega32 controller board

AB model 161 VFD Drive

3 phase AC motor

Tachometer (dc motor)

12.0.1.5 - Experimental

1. Follow the tutorial on the course web page and make notes and observations in your laboratory notebook.

2. Connect the 3 phase motor to a tachometer for a velocity feedback. Before connecting the tachometer to the ATMega32 and check the polarity and maximum voltage when the motor is running at the maximum speed. Do not use the tachometer if the voltage exceeds 5V. Connect the tachometer to the ATMega32 board and use a capacitor to reduce noise from the tachometer.

3. Use the ATMega32 to collect motor speed data for a step input to the VFD. The step input can be obtained by putting the VFD in program mode, setting the potentiometer to e new position and then putting the motor back in run mode. The display should be set to display the motor speed. Repeat the process for different setpoints, and plot the curves on the same graph.

4. Using the manual, determine how to change the PID parameters. Don’t forget to connect the tachometer to the motor drive for velocity feedback. Run a number of tests to see what it does. Record the data and graph it in your lab book.

 

13.0.1 Tutorial - Allen Bradley 161 Variable Frequency Drives

[an error occurred while processing this directive]

1. The motor should be connected the the drive as shown in the figure below. The three phase power lines are T1, T2 and T3. These can be connected to the drive by loosening the screw on the front face of the drive. (WARNING: make sure the power is off before opening the drive, and relseal the drive when done) The two other lines P1 and P2 from the drive are for a thermal overload relay, we will not use these. For general caution the ends of the wires should be covered with electrical tape to prevent accidental contact with other conductors. The wire from P24 (a 24V power source) and input 3 are for an emergency stop and must be connected for the drive to work. These terminals can be found under a flip up panel on the bottom front of the drive that can be opened by pulling on the right side of the face.

2. Notice the display and lights on the front face of the drive. When a program is running the ’RUN’ light is on. The program can be started using the green ’1’ button, and stopped with the red ’0’ button.

3. Program the unit using the buttons on the front panel, following the steps below (from page 17 in the manual). After the steps have been followed press the run button and turn the potentiometer to vary the speed. Try holding the shaft (cover the shaft to avoid cuts) at high and low speeds. What do you notice at very low speeds?

4. Connect a proximity to the controller as shown in the diagram below. Display the input values using ’D05’.The bits on the screen should move up for an active input, and down for an inactive input. Input 3 will always be active because it is being used for the emergency stop (a factory default).

5. Various display parameters are listed below. Try these to see what information they show.

D02 - display the motor current (try holding the shaft while turning slowly)

D01 - display the frequency of rotation

D03 - the direction of rotation

D04 - PID parameters (when in use)

D05 - input status

D06 - output status

D16 - total drive run time in 10 hour blocks

6. Function parameters can be set with the ’F’ locations. Change the acceleration and decelleration times to 1 second using the ’F02’ and ’F03’ locations.

7. Restore the controller to the factory defaults using the sequence below from page 16 of the manual.

 

 

 

14.0.1 Lab 10 - IO Using Labview

[an error occurred while processing this directive]
14.0.1.1 - Purpose

To use Labview for analog digital and analog IO.

14.0.1.2 - Background

Programming languages are essential components of complex systems. Languages such as ’C’ execute one function at a time as the program executes. This is good for program with a clear execution order. However for programs dealing with a continuous system this can be cumbersome.

 

Labview is a dataflow methodology, like a block diagram. This allows the creation of programs that show how inputs flow through functions to create outputs. Labview allows us to write programs for calculation and data collection, but instead of typing instructions we draw function blocks and connect them. How we connect them determines how the data (numbers) flow. The functions are things like data reads and calculations.

 

In general people can learn to write simple Labview programs quickly, however more complicated programming tasks can be more difficult than similar programs written in C. But, Labview has a distinct advantage when developing Graphical User Interfaces.

14.0.1.3 - Theory

The computers we will use all have DAQ (Data AcQuisition) boards - National Instruments PCI-1200 DAQ cards. These cards have capabilities that include:

 

24 I/O bits - TTL 0,5VDC, 20mA max.

8 single ended or 4 double ended analog inputs - 12 bits

3 counters - 16 bits

2 analog outputs - 12 bits

 

The connector for the card, shown in Figure 14.1 PCI-1200 Card edge connector pinout, can be found on the back of the computer. It will have a connector with pinouts like the one shown below. A ribbon cable will be used to make electrical connection to the connector in the back of the computer.

 

Figure 14.1 PCI-1200 Card edge connector pinout

NOTE: LABVIEW MANUALS ARE AVAILABLE ON-LINE, AND CAN BE FOUND ON THE COURSE HOME PAGE.

 

In this lab we will be using Labview to connect to a data acquisition (DAQ) board in the computer. This will allow us to collect data from the world outside the computer, and make changes to the world outside with outputs.

 

When interfacing to the card using a program such as Labview, there must be ways to address or request information for a specific input or output (recall memory addresses in EGR226). The first important piece of information is the board number. There can be multiple DAQ boards installed in the computer. In our case there is only one, and it is designated device ’1’. There are also many inputs and outputs available on the card. For analog outputs there are two channels so we need to specify which one when using the output with 0 or 1. For analog inputs there are 8 channels, and as before, we must specify which one we plan to read from using 0 to 7. For digital I/O there are a total of 24 pin distributed across 3 ports (1 byte each). Therefore when connecting inputs and output we must specify the port (PA=0, PB=1, PC=2) and the channel from 0 to 7. Note is that we can make the ports inputs or outputs, but not mixed - in other words we must pick whether a port will only be used for inputs or for outputs.

 

The voltage levels for the inputs and outputs are important, and you will need to be aware of these. For the digital outputs they will only ever be 0V or 5V. But the analog inputs and outputs will vary from -5V to 5V. This is build into the board. If we exceed these voltage limits by a few volts on the inputs, the boards have built in protection and should be undamaged. If we exceed the input voltages significantly, there is a potential to permanently damage the board.

14.0.1.4 - Prelab

1. Go through the LabVIEW QuickStart Guide (on the course homepage). This will also be good review for those who have used LabVIEW before. Please note, the tutorial mentions a video, skip this step.

 

2. Write a Labview program that will count from 1 to 100, square the values, and print the results on a strip chart.

14.0.1.5 - Equipment

PC with LabVIEW software and PCI-1200 DAQ card

Interface cable

Signal generator

Digital multimeter

14.0.1.6 - Experimental

1. Review the LabVIEW QuickStart Guide used before the laboratory. This will also be a good review for those who have used LabVIEW in previous courses.

 

2. Enter the LabVIEW program (layout) schematically shown in Figure 14.2 Analog input using Labview and connect a signal generator to the analog input (ACH0). (Note: there is a pin diagram for the connector in the Labview tutorial section.) Start the signal generator with a low frequency sinusoidal wave. Use the ‘DAQ Configure’ software to test the circuitry and verify that your hardware is operational. Then run your Labview program. Record the observations seen on the screen.

 

Figure 14.2 Analog input using Labview

3. Run additional programs such as browsers, spreadsheets, etc. and see how this affects the data collection speed.

 

4. Connect the multimeter as shown in Figure 14.3 Analog output using Labview. Test the circuit using the ‘DAQ Configure’ utility. Enter the LabVIEW program schematically illustrated below and then run it. You should be able to control the output voltage from the screen using the mouse. Record your observations.

Figure 14.3 Analog output using Labview

5. Connect the digital input and output circuits to the DAQ card, as shown in Figure 14.4 Digital IO using Labview, and use the test panel to test the circuits. To do this, run the ‘DAQ Configure’ utility, double click on the ‘PCI-1200’, run the test panel window and ensure that the inputs and outputs are working correctly. Create the LabVIEW screen schematically illustrated below. This should allow you to scan an input switch and set an output light. When done, quit the program and run your LabVIEW program.

Figure 14.4 Digital IO using Labview

6. Use a counter output for a PWM device. Figure 14.5 PWM output using Labview shows a simple program to control the PWM output on the DAQ board. Enter the program and verify the operation with an Oscilloscope and DMM.

Figure 14.5 PWM output using Labview

15.0.1 Lab 11 - Torsion

[an error occurred while processing this directive]
15.0.1.1 - Purpose

To theoretically predict and experimentally verify the period of oscillation for a torsional pendulum.

15.0.1.2 - Background/Theory

Suppose a large symmetric rotating mass has a rotational inertia J, and a twisting rod has a torsional spring coefficient K. Recall the basic torsional relationships.

Figure 15.1 A torsional mass

15.0.1.3 - Prelab

1. Calculate the explicit equation for the natural frequency for a rotating mass with a torsional spring by solving the differential equation.

 

2. Set up a Scilab program that will include the following elements. Please note that units are very important. You are strongly encouraged to use metric units to minimize calulcation problems.

- use material properties and a diameter of a round shaft and determine the spring coefficient.

- accept geometry for a rectangular mass and calculate the polar moment of inertia.

- use the spring coefficient and polar moment of inertia to estimate the natural frequency.

- plot the function derived using the explicit solution.

- use previous values to estimate the oscillations using Runge-Kutta integration and plot the results.

 

3. Write a Labview program that will read analog input data and save it to a file.

 

4. Review the Experimental Procedure.

15.0.1.4 - Equipment

A computer with Labview and a DAQ card

The machine shop and appropriate equipment

A potentiometer

A power supply

Force Gauge

15.0.1.5 - Experimental Procedure

1. Design and build a large torsional pendulum. The design elements below should be considered.

- The pendulum will normally be suspended from the unistrut on the ceiling of the laboratory. It will need to be firmly clamped.

- Select a round rod for the spring. A longer length, and a diameter from 1/4" to 1/2" will give a reasonable frequency range. Make sure you can identify the material so that you can estimate the spring coefficient.

- Select a mass of 10-20kg. Ideally the mass will have a simple geometry that will simplify the calculation of the moment of inertia. Placing parts of the mass farther from the center of rotation will lower the frequency.

- A potentiometer should be mounted at the center of rotation to measure position.

 

2. Collect values from the physical equipment and use these to calculate the frequency of oscillation.

 

3. Calibrate the potentiometer so that the relationship between the output voltage and angle is known. Plot this on a graph and verify that it is linear before connecting it to the mass. Calculate the relationship between input angle and output voltage. Use this in following steps to convert potentiometer voltages to angles.

 

4. Verify that values displayed in Labview correlate to the position of the potentiometer and the time.

 

5. Connect the potentiometer to the mass. Apply a static torque and measure the deflected position. Use this to calculate a coefficient for the torsional spring.

 

6. Apply a torque to offset the mass, and release it so that it oscillates. Estimate the natural frequency by counting cycles over a long period of time. Compare this to the theoretical value.

 

7. Determine if the initial angle of deflection changes the frequency of oscillation.

 

16.0.1 Lab 12 - System Simulation with Simulink

[an error occurred while processing this directive]
16.0.1.1 - Purpose

To model control systems using Simulink.

16.0.1.2 - Background/Theory

Simulink is a tool in Matlab (like Scilab) that allows users to simulate system behavior using block diagrams.

16.0.1.3 - Prelab

1. Follow the Simulink tutorial linked to the course web page. Note that the ’s’ in the tutorial is equivalent to the ’D’ operator.

2. Use ’Help/Demos’ then select ’Simulink’ and try some of the demos.

16.0.1.4 - Equipment

A computer with Matlab and Simulink installed

16.0.1.5 - Experimental

1. Run Matlab, and enter ’simulink’ on the command line to start Simulink. Create a new simulation file by selecting ’File/New/Model’. You will see a blank programming window.

 

2. Select a ’Sources/Step’ block and drag it to the blank window. This will be a step input to the system. By default it is a unit step that starts at t=0s. This can be changed by right-clicking, or double clicking, on the icon and selecting new parameters.

 

3. Create a summation block, so that we can use negative feedback, using ’Math/Sum’. The default block will sum both inputs. Change this by changing the parameters from ’I++’ to ’I+-’. This will be reflected on the main window as a negative feedback summation block.

 

4. Connect the step input to the positive terminal of the summation block by clicking on one of the small arrows on the summation block and dragging it to the step input.

 

5. Add a proportional gain to the system with ’Math/Gain’. The default gain for this is ’1’, but this can be changed by changing the properties. Connect this to the output of the summation block. (Note: the ’s’ and ’D’ operators are equivalent so 1/(s+1) = 1/(D+1).)

 

6. Add a system model using ’Continuous/Transfer Fcn’. Use the transfer function ’1/(s+1)’ for a first order response. Connect the input of this function to the output of the gain function.

 

7. Create an output display using ’Sinks/Scope’ and connect the output of the transfer function to the scope.

 

8. Connect the output of the transfer function back to the negative input of the summation block. At this point the system diagram should look like Figure 16.1 A simple feedback system in Simulink.

Figure 16.1 A simple feedback system in Simulink

9. Right-click on the scope block and open it. A new window should appear on the screen. Use ’Simulation/Start’ to run the simulation.

 

10. Change the gain from 1 to 20 and run the simulation again. Print and attach the output graph in your lab book.

 

11. Verify the results found in the last step by explicitly integrating the differential equation and plotting the results.

 

12. Enter the simulation for the second order differential equation, as shown in Figure 16.2 Simulation of a differential equation. Enter different values for the coefficients and verify the system behavior. Print and include graphs in your lab book.

Figure 16.2 Simulation of a differential equation

13. Verify the results in the previous section by explicitly integration the differential equation for one set of values used in the previous step. Plot the function and compare it to the response found with Simulink.

 

14. Create a simulation of a position feedback control system with deadband compensation. Include a graph of the response.

 

[an error occurred while processing this directive]