![]() |
AVR1600 Using the XMEGA Quadrature Decoder
|
Test signal generation, generates a Quadrature signal. More...

Go to the source code of this file.
Functions | |
| void | generate_qdec_signal (PORT_t *qPort, uint8_t lineCount, uint8_t freq, bool dir) |
| Initializes TCE0 to create Qadrature signal. More... | |
| ISR (TCE0_CCA_vect) | |
| Creates a Quadrature signal, up or down counting depending on the configured direction(dir = 1 -> CW/forward, dir = 0 -> CCW/backward). More... | |
| ISR (TCE0_CCB_vect) | |
| Creates a Quadrature signal, up or down counting depending on the configured direction(dir = 1 -> CW/forward, dir = 0 -> CCW/backward). More... | |
| ISR (TCE0_CCC_vect) | |
| Creates a Quadrature signal, up or down counting depending on the configured direction(dir = 1 -> CW/forward, dir = 0 -> CCW/backward). More... | |
| ISR (TCE0_CCD_vect) | |
| Creates a Quadrature signal, up or down counting depending on the configured direction(dir = 1 -> CW/forward, dir = 0 -> CCW/backward). More... | |
| ISR (TCC0_ERR_vect) | |
| Error interrupt routine for when index signal is used. More... | |
Variables | |
| PORT_t * | q_test_sig_Port |
| The port to set the signal out on. More... | |
| uint8_t | test_lineCount |
| Number of lines in the Quadrature encoder. More... | |
Test signal generation, generates a Quadrature signal.
This file contains code to generate a Quadrature signal for testing of the system. The signal generated goes either direction given by the argument "dir" passed to generate_qdec_signal(). (1->CW/forward, 0->CCW/backward)
To use the test signal the GENERATE_TEST_SIGNAL has to be uncommented in the qdec_example.c file. The generate_qdec_signal will then be included and a signal generated. The signal output pins then has to be connected with the input pins to the Quadrature decoder.
When the signal is connected and the output portC is connected to the led’s the frequency value will be displayed in hex, pin0 LSB.
To test that the index signal is correct, when enabled, one can set a breakpoint in the timer counter C0 error interrupt routine. If the interrupt routine is run more than 1 time (first time resets the count) the index setting is wrong. If it is correct the execution should not break when the index signal is connected, but if the signal is disconnected (remove cable) the code should break.
If a scope is used the frequency measurement can be controlled, the measured frequency should be equal to the frequency on the scope given by the time between the index signal.
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_signal_generator.c.
| void generate_qdec_signal | ( | PORT_t * | qPort, |
| uint8_t | lineCount, | ||
| uint8_t | freq, | ||
| bool | dir | ||
| ) |
Initializes TCE0 to create Qadrature signal.
Calculates the values to create a Quadrature signal that has a frequency given from the freq parameter.
| qPort | The port to set the signal out on. |
| lineCount | The number of lines in the Quadrature encoder. |
| freq | The frequency that is put out, (time between index signal/one rotation). |
| dir | The direction of the signal to be generated, clockwise or counterclockwise signal. |
Definition at line 94 of file qdec_signal_generator.c.
References F_CPU, lineCount, q_test_sig_Port, and test_lineCount.
Referenced by main().
| ISR | ( | TCE0_CCA_vect | ) |
Creates a Quadrature signal, up or down counting depending on the configured direction(dir = 1 -> CW/forward, dir = 0 -> CCW/backward).
Definition at line 145 of file qdec_signal_generator.c.
References q_test_sig_Port, and test_lineCount.
| ISR | ( | TCE0_CCB_vect | ) |
Creates a Quadrature signal, up or down counting depending on the configured direction(dir = 1 -> CW/forward, dir = 0 -> CCW/backward).
Definition at line 172 of file qdec_signal_generator.c.
References q_test_sig_Port.
| ISR | ( | TCE0_CCC_vect | ) |
Creates a Quadrature signal, up or down counting depending on the configured direction(dir = 1 -> CW/forward, dir = 0 -> CCW/backward).
Definition at line 182 of file qdec_signal_generator.c.
References q_test_sig_Port.
| ISR | ( | TCE0_CCD_vect | ) |
Creates a Quadrature signal, up or down counting depending on the configured direction(dir = 1 -> CW/forward, dir = 0 -> CCW/backward).
Definition at line 192 of file qdec_signal_generator.c.
References q_test_sig_Port.
| ISR | ( | TCC0_ERR_vect | ) |
Error interrupt routine for when index signal is used.
This interrupt happens if the count value is not at BOTTOM when the index signal comes. The interrupt also happens if the count value passes the BOTTOM value.
Definition at line 205 of file qdec_signal_generator.c.
References q_test_sig_Port.
| PORT_t* q_test_sig_Port |
The port to set the signal out on.
Definition at line 75 of file qdec_signal_generator.c.
Referenced by generate_qdec_signal(), and ISR().
| uint8_t test_lineCount |
Number of lines in the Quadrature encoder.
Definition at line 79 of file qdec_signal_generator.c.
Referenced by generate_qdec_signal(), and ISR().
Generated on Thu Oct 26 2017 13:33:37 for AVR1600 Using the XMEGA Quadrature Decoder by 1.8.13
|