![]() |
AVR1600 Using the XMEGA Quadrature Decoder
|
This documents the firmware for the application note. The firmware includes the three following main components:
The application example sets up the device for decoding of quadrature signals received on pins PD0 and PD1, no index pulse. The calculated frequency of the signal is written to the PORTC I/O pins, which can be connected to LEDs etc for visualization.
Note that the ticks in a quadrature signal is represented by a repeating pattern of alternating edges on the PD0 and PD1 lines, such that every fourth tick corresponds to a rising edge on PD0. Since the signal on PD0 initiates the timer capture used for calculating the frequency, the actual tick frequency of a quadrature signal will be four times the frequency calulated by this example application.
The included signal generator can be used to verify the firmware functionality by uncommenting the GENERATE_TEST_SIGNAL definition in qdec_example.c. The signal generator will then output a quadrature signal on PE0 and PE1 (index pulse on PE2) with frequency and direction given by the variables freq and dir also defined in qdec_example.c. The defines CW_DIR and CCW_DIR in qdec_driver.h should be used for setting the direction. By connecting PD0 to PE0 and PD1 to PE1 and starting the application, the calculated frequency should be close to the configured signal generator frequency.
This firmware was compiled with IAR Embedded Workbench for AVR 7.10.1 and Atmel Studio 7.0.
To open the application in Studio, open the Studio solution file AVR1600_XMEGA_Quad_Encoder.sln in the AVR1600_XMEGA_Quad_Encoder folder.
To open the application in IAR EWAVR, open the qdec_example.eww workspace file, or:
All XMEGA devices with the targeted module can be used. The example is written for ATxmega128A1.
For more info about Microchip AVR visit http://www.microchip.com/design-centers/8-bit/microchip-avr-mcus/avr-mcus
Support: http://www.microchip.com/support/
Copyright (c) 2009 Atmel Corporation. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Generated on Thu Oct 26 2017 13:33:37 for AVR1600 Using the XMEGA Quadrature Decoder by 1.8.13
|