DOC PREVIEW
GVSU EGR 345 - Lab 1 - Programming the Atmel Atmega32 Thumb Board

This preview shows page 1-2-3 out of 10 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 10 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

3.0.1 Lab 1 - Programming the Atmel Atmega32 Thumb Board3.0.1.1 - Purpose3.0.1.2 - Background/Theory3.0.1.3 - Prelab3.0.1.4 - Equipment3.0.1.5 - Experimental Procedureegr345 lab guide - 3.13.0.1 Lab 1 - Programming the Atmel Atmega32 Thumb Board3.0.1.1 - PurposeTo use the Atmel Mega32 microcontroller boards to input and output digital, ana-log, serial, and wireless data.3.0.1.2 - Background/TheoryA method for generating variable analog outputs, called Pulse Width Modulation (PWM), is shown in Figure 3.1. 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 volt-age 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 volt-age efficiently. (Aside: The frequency of these waves is normally above 20KHz, above the range of human hearing.)Figure 3.1 Pulse Width Modulation (PWM)Vmax0tVeff50100---------Vmax=50% duty cycleVmax0tVeff20100---------Vmax=20% duty cycleVmax0tVeff100100---------Vmax=100% duty cycleVmax0tVeff0100---------Vmax=0% duty cycleegr345 lab guide - 3.2An 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. This device is like the one in the AtMega. The main operation concept is based on the succes-sive 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 indi-cate a valid conversion value.Figure 3.2 Analog to digital converterIn 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).D to Aconvertersuccessiveapproximationlogic88+-clockresetdata out+Vref-VrefVinVeVin above (+ve) or below (-ve) Vedoneegr345 lab guide - 3.3Microcontrollers 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 typi-cally 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 pur-poses 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 - PrelabR 2N=where,R resolution of A/D converter=VIthe integer value from the A/D conveter=VCVIR 1–------------⎝⎠⎛⎞VmaxVmin–()Vmin+=VCthe voltage calculated from the integer value=(1)(2)N number of bits=egr345 lab guide - 3.41. 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 - EquipmentComputer with an Internet connectionAssembled controller thumb board10K potentiometerMultimeterOscilloscope3.0.1.5 - Experimental Procedure1. 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 soft-ware?" 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 should flash indicating that the board has power.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


View Full Document

GVSU EGR 345 - Lab 1 - Programming the Atmel Atmega32 Thumb Board

Documents in this Course
Y Axis

Y Axis

2 pages

Load more
Download Lab 1 - Programming the Atmel Atmega32 Thumb Board
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lab 1 - Programming the Atmel Atmega32 Thumb Board and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lab 1 - Programming the Atmel Atmega32 Thumb Board 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?