![]() |
AVR1600 Using the XMEGA Quadrature Decoder
|
The XMEGA Quadrature Decoder example source code. More...

Go to the source code of this file.
Macros | |
| #define | CLOCK_DIV 64 |
| #define | CLOCK_DIV_bm TC_CLKSEL_DIV64_gc |
| Defines the clock division for the timer used. if changed both defines NEED to be changed correspondingly. More... | |
Functions | |
| int | main (void) |
| Quadrature decoding example. More... | |
Variables | |
| uint16_t | calcFreq = 0 |
| uint16_t | calcRPM = 0 |
| uint16_t | captureFreq = 0 |
| Global frequency variable. More... | |
| bool | dir = CW_DIR |
| Direction of the output signal. More... | |
| uint8_t | freq = 60 |
| If GENERATE_TEST_SIGNAL is defined the system generates a test signal with frequency equal to freq (RPM = freq*60). More... | |
| uint8_t | lineCount = 30 |
| Number of lines in the quadrature encoder. More... | |
The XMEGA Quadrature Decoder example source code.
This file contains example code that demonstrate the quadrature decoder. It shows how to set up the event system and the Timer/Counter to decode the angle of rotation from a quadrature encoder.
Copyright (c) 2008, 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 AND FITNESS FOR A PARTICULAR PURPOSE 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.
Definition in file qdec_example.c.
| #define CLOCK_DIV 64 |
Definition at line 69 of file qdec_example.c.
Referenced by main().
| #define CLOCK_DIV_bm TC_CLKSEL_DIV64_gc |
Defines the clock division for the timer used. if changed both defines NEED to be changed correspondingly.
Definition at line 68 of file qdec_example.c.
Referenced by main().
| int main | ( | void | ) |
Quadrature decoding example.
This is the main example code demonstrating the setup and configuration to make the quadrature decoder work. The example use the event system and a Timer/Counter to decode the signals and the counter value in the Timer/Counter will reflect the angle of rotation. The direction bit in the TC reflect the current direction of rotation.
Hardware setup:
Peripherals used:
Definition at line 98 of file qdec_example.c.
References calcFreq, calcRPM, CLOCK_DIV, CLOCK_DIV_bm, dir, F_CPU, freq, generate_qdec_signal(), GetCaptureValue, lineCount, QDEC_TC_Freq_Setup(), and QDEC_Total_Setup().

| uint16_t calcFreq = 0 |
Definition at line 76 of file qdec_example.c.
Referenced by main().
| uint16_t calcRPM = 0 |
Definition at line 77 of file qdec_example.c.
Referenced by main().
| uint16_t captureFreq = 0 |
Global frequency variable.
Definition at line 75 of file qdec_example.c.
| bool dir = CW_DIR |
| uint8_t freq = 60 |
If GENERATE_TEST_SIGNAL is defined the system generates a test signal with frequency equal to freq (RPM = freq*60).
Output frequency when system generates a signal
Definition at line 60 of file qdec_example.c.
Referenced by main().
| uint8_t lineCount = 30 |
Number of lines in the quadrature encoder.
Definition at line 72 of file qdec_example.c.
Referenced by generate_qdec_signal(), and main().
Generated on Thu Oct 26 2017 13:33:37 for AVR1600 Using the XMEGA Quadrature Decoder by 1.8.13
|