You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+47-29Lines changed: 47 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,33 +2,28 @@
2
2
3
3
# Core Independent Quadrature Decoder using the AVR64DD32 Microcontroller with MCC Melody
4
4
5
-
<br>
6
-
7
-
Quadrature signals are the standard waveforms used as output for incremental encoders that come with motors. They provide information about motor direction and shaft position. There are two types of encoders - linear and rotary - and each can have two types of measurement: Absolute and incremental. There are also different technologies used for encoders: Magnetic, optical, inductive, capacitive, and laser.
5
+
Quadrature signals are the standard output waveforms of incremental encoders that come with motors. They provide information about motor direction and shaft position. There are two types of encoders - linear and rotary - and each can have two types of measurement: Absolute and incremental. There are also different technologies used for encoders: Magnetic, optical, inductive, capacitive, and laser.
8
6
9
-
The main categories of encoders are absolute and incremental. A rotary absolute encoder outputs a unique code for each position of the motor's shaft. If the power of this encoder is lost and the shaft is rotated, the encoder can return the correct position of the shaft. The rotary incremental encoder generates pulses while the shaft is rotated. If any pulse is missed, then the shaft position cannot be determined correctly anymore.
7
+
The main categories of encoders are absolute and incremental. A **rotary absolute encoder** outputs a unique code for each position of the motor's shaft. If the power of this encoder is lost and the shaft is rotated, the encoder can return the correct position of the shaft. The **rotary incremental encoder** generates pulses while the shaft is rotated. If any pulse is missed, then the shaft position cannot be determined correctly anymore.
10
8
This application will use a rotary incremental encoder to show how to decode quadrature signals.
11
9
12
10
The following image highlights the Clockwise (CW) and Counterclockwise (CCW) conditions on the quadrature signals A and B. When signal A leads signal B (on rising or falling edge), it will be a clockwise detection, otherwise, when signal B leads signal A (on rising or falling edge), it will be a counterclockwise detection.
13
11
14
12
<br><imgsrc="images/cw_ccw.png"width="800">
15
13
16
-
The quadrature decoder uses the Configurable Custom Logic (CCL) to detect CW and CCW pulses. The following picture shows the output signals of the CCL implementation, CW and CCW, based on the quadrature signals A and B.
14
+
The quadrature decoder uses the Configurable Custom Logic (CCL) on the AVR64DD32 to detect CW and CCW pulses. The following picture shows the output signals of the CCL implementation, CW and CCW, based on the quadrature signals A and B.
17
15
18
16
<br><imgsrc="images/wavedrom.png"width="800">
19
17
20
18
Using the Event System (EVSYS) peripheral, the CW and CCW signals are linked to two TCB instances: One counts the CW pulses, the other one counts the CCW pulses.
21
19
22
-
<br>
23
-
24
20
## Related Documentation
25
21
26
22
More details and code examples on the AVR64DD32 can be found at the following links:
27
23
-[Interfacing Quadrature Encoder using CCL with TCA and TCB](http://ww1.microchip.com/downloads/en/AppNotes/00002434A.pdf)
28
24
-[Getting Started with CCL](http://ww1.microchip.com/downloads/en/AppNotes/TB3218-Getting-Started-with-CCL-90003218A.pdf)
In this demo, the function `QEI_GetVelocity` is called every second and the return is printed on serial communication. The setup connections are presented in the following picture:
114
+
In this demo, the function `QEI_GetVelocity` is called every second and the returned value is printed on the serial terminal. The hardware setup is presented in the image below:
115
115
116
-
<br><imgsrc="images/portconn.jpg"width="960">
116
+
<br><imgsrc="images/portconn.jpg"width="1000">
117
117
<br>
118
118
119
-
Every one second, the device sends a message through USART interface together with the counter value:
120
-
<br><imgsrc="images/serial-terminal.jpg">
119
+
Every second, the device prints a message with the counter value through the USART interface:
The signals are presented in the following picture. The values of counter are **8** and **-8**.
123
-
<br><imgsrc="images/Signals_Capture.jpg">
123
+
**Note:** Follow the steps in the **How to use MPLAB® Data Visualizer** section to set up the Data Visualizer so that it can correctly show the text messages through USART0.
124
124
125
+
A snapshot of the different signals from the logic analyzer can be seen below. The CW and CCW pulses correspond to the counter values **8** and **-8**.
The quadrature decoder can detect and count clockwise and counterclockwise pulses on rising and falling edges of the quadrature signals.
132
+
The quadrature decoder can detect and count clockwise and counterclockwise pulses on rising and falling edges of the quadrature signals. Read more about the implementation at https://www.microchip.com/en-us/about/blog/design-corner/quadrature-decoder.
133
+
134
+
135
+
## How to use MPLAB® Data Visualizer
136
+
137
+
This section illustrates how to use the MPLAB® X Data Visualizer to send commands and receive information, but prior to programming the AVR64DD32 Curiosity Nano Board. This can be applied to any other projects.
138
+
139
+
### Operation
140
+
141
+
1. Open the software terminal in MPLAB® X IDE. Left click on the **Data Visualizer** button.
2. Select the **Input Source** corresponding to the AVR64DD32 in the right side.<br>
145
+
146
+
3. Identify the coresponding COMx that is represented by the AVR64DD32 Curiosity Nano Board and select it in the **Connections** tab in the left side.<br>
131
147
132
-
-[Back to Top](#core-independent-quadrature-decoder-using-the-avr64dd32-microcontroller-with-mcc-melody)<br><br>
148
+
4. Set the specific **Baud Rate**, in this case **115200**.<br>
133
149
150
+
5. Press **Start streaming COMx button**. The text messages will appear in the **Terminal** tab.
0 commit comments