Skip to content

Commit e82d044

Browse files
MPAE-14443: added code examples, updated readme file and metadata.
1 parent 92266ad commit e82d044

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+6200
-37
lines changed

.main-meta/main.json

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"content": {
55
"metaDataVersion": "1.3.0",
66
"name": "com.microchip.mcu8.mplabx.project.avr64dd32-quadrature-decoder-mplab-mcc",
7-
"version": " ",
8-
"displayName": "",
7+
"version": "1.0.0",
8+
"displayName": "Core Independent Quadrature Decoder using the AVR64DD32 Microcontroller with MCC Melody",
99
"projectName": "avr64dd32-quadrature-decoder-mplab-mcc",
1010
"shortDescription": "Guide for using Core Independent Quadrature Decoder with AVR64DD32 Microcontroller using MCC Melody",
1111
"ide": {
@@ -19,12 +19,12 @@
1919
}
2020
],
2121
"dfp": {
22-
"name": "",
23-
"semverRange": ""
22+
"name": "AVR-Dx_DFP",
23+
"semverRange": "^2.1.152"
2424
},
2525
"configurator": {
26-
"name": "",
27-
"semverRange": ""
26+
"name": "MCC",
27+
"semverRange": ">=5.1.4"
2828
},
2929
"device": {
3030
"metaDataVersion": "1.0.0",
@@ -36,9 +36,20 @@
3636
"versionRange": "*"
3737
}
3838
},
39-
"author": "Marinel-Cosmin Stanciu",
40-
"peripherals": [],
41-
"keywords": [],
39+
"author": "Bogdan-Alexadru Mariniuc",
40+
"peripherals": [
41+
"CCL",
42+
"UART",
43+
"TCB"
44+
],
45+
"keywords": [
46+
"Getting Started",
47+
"Quadrature Encoder",
48+
"EVSYS",
49+
"UART",
50+
"TCB",
51+
"CCL"
52+
],
4253
"additionalData": {
4354
"longDescription": {
4455
"metaDataVersion": "1.0.0",

README.md

Lines changed: 126 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,143 @@
1-
<!-- Please do not change this logo with link -->
1+
[![MCHP](images/Microchip.png)](https://www.microchip.com)
22

3-
[![MCHP](images/microchip.png)](https://www.microchip.com)
3+
# Core Independent Quadrature Decoder using the AVR64DD32 Microcontroller with MCC Melody
44

5-
# Update the title for avr64dd32-quadrature-decoder-mplab-mcc here
5+
<br>
66

7-
<!-- This is where the introduction to the example goes, including mentioning the peripherals used -->
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.
88

9-
## Related Documentation
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.
10+
This application will use a rotary incremental encoder to show how to decode quadrature signals.
1011

11-
<!-- Any information about an application note or tech brief can be linked here. Use unbreakable links!
12-
In addition a link to the device family landing page and relevant peripheral pages as well:
13-
- [AN3381 - Brushless DC Fan Speed Control Using Temperature Input and Tachometer Feedback](https://microchip.com/00003381/)
14-
- [PIC18F-Q10 Family Product Page](https://www.microchip.com/design-centers/8-bit/pic-mcus/device-selection/pic18f-q10-product-family) -->
12+
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.
1513

16-
## Software Used
14+
<br><img src="images/cw_ccw.png">
1715

18-
<!-- All software used in this example must be listed here. Use unbreakable links!
19-
- MPLAB® X IDE 5.30 or newer [(microchip.com/mplab/mplab-x-ide)](http://www.microchip.com/mplab/mplab-x-ide)
20-
- MPLAB® XC8 2.10 or a newer compiler [(microchip.com/mplab/compilers)](http://www.microchip.com/mplab/compilers)
21-
- MPLAB® Code Configurator (MCC) 3.95.0 or newer [(microchip.com/mplab/mplab-code-configurator)](https://www.microchip.com/mplab/mplab-code-configurator)
22-
- MPLAB® Code Configurator (MCC) Device Libraries PIC10 / PIC12 / PIC16 / PIC18 MCUs [(microchip.com/mplab/mplab-code-configurator)](https://www.microchip.com/mplab/mplab-code-configurator)
23-
- Microchip PIC18F-Q Series Device Support (1.4.109) or newer [(packs.download.microchip.com/)](https://packs.download.microchip.com/) -->
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.
2417

25-
- MPLAB® X IDE 6.0.0 or newer [(MPLAB® X IDE 6.0)](https://www.microchip.com/en-us/development-tools-tools-and-software/mplab-x-ide?utm_source=GitHub&utm_medium=TextLink&utm_campaign=MCU8_MMTCha_MPAE_Examples&utm_content=avr64dd32-quadrature-decoder-mplab-mcc-github)
26-
- MPLAB® XC8 2.36.0 or newer compiler [(MPLAB® XC8 2.36)](https://www.microchip.com/en-us/development-tools-tools-and-software/mplab-xc-compilers?utm_source=GitHub&utm_medium=TextLink&utm_campaign=MCU8_MMTCha_MPAE_Examples&utm_content=avr64dd32-quadrature-decoder-mplab-mcc-github)
18+
<br><img src="images/wavedrom.png">
2719

28-
## Hardware Used
20+
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.
2921

30-
<!-- All hardware used in this example must be listed here. Use unbreakable links!
31-
- PIC18F47Q10 Curiosity Nano [(DM182029)](https://www.microchip.com/Developmenttools/ProductDetails/DM182029)
32-
- Curiosity Nano Base for Click boards™ [(AC164162)](https://www.microchip.com/Developmenttools/ProductDetails/AC164162)
33-
- POT Click board™ [(MIKROE-3402)](https://www.mikroe.com/pot-click) -->
22+
<br>
23+
24+
## Related Documentation
25+
26+
More details and code examples on the AVR64DD32 can be found at the following links:
27+
- [Interfacing Quadrature Encoder using CCL with TCA and TCB](http://ww1.microchip.com/downloads/en/AppNotes/00002434A.pdf)
28+
- [Getting Started with CCL](http://ww1.microchip.com/downloads/en/AppNotes/TB3218-Getting-Started-with-CCL-90003218A.pdf)
29+
- [AVR64DD32 Product Page](https://www.microchip.com/wwwproducts/en/AVR64DD32)
30+
- [AVR64DD32 Code Examples on GitHub](https://github.com/microchip-pic-avr-examples?q=AVR64DD32)
31+
- [AVR64DD32 Project Examples in START](https://start.atmel.com/#examples/AVR64DD32CuriosityNano)
32+
33+
## Software Used
34+
35+
- [MPLAB® X IDE 6.00 or newer](http://www.microchip.com/mplab/mplab-x-ide)
36+
- [MPLAB® XC8 2.36 or a newer compiler](http://www.microchip.com/mplab/compilers)
37+
- [AVR-Dx Series Device Pack v2.1.152 or newer](https://packs.download.microchip.com)
38+
- [MPLAB® Code Configurator Melody core 2.1.13 or newer](https://www.microchip.com/en-us/tools-resources/configure/mplab-code-configurator/melody)
39+
- [MPLAB® Code Configurator Melody Drivers](https://www.microchip.com/en-us/tools-resources/configure/mplab-code-configurator/melody)
40+
</br>
41+
TCB: 5.0.5
42+
</br>
43+
UART: 1.6.0
44+
</br>
45+
CCL: 3.1.2
46+
47+
- Saleae Logic
48+
- Terminal software – Tera term, Real term, PuTTY, etc vXXX
49+
50+
51+
## Hardware Used
52+
53+
- The AVR64DD32 Curiosity Nano Development Board is used as a test platform.
54+
<br><img src="images/AVR64DD32.PNG" width="640"><br>
55+
- Oscilloscope/Logic Analyzer
56+
- Motor with encoder
57+
58+
<img src="images/motor.jpg" width="300"><br>
59+
- Rotary encoder <br>
60+
<img src="images/rotor.jpg" width="300"><br>
3461

35-
## Setup
3662

37-
<!-- Explain how to connect hardware and set up software. Depending on complexity, step-by-step instructions and/or tables and/or images can be used -->
3863

3964
## Operation
4065

41-
<!-- Explain how to operate the example. Depending on complexity, step-by-step instructions and/or tables and/or images can be used -->
66+
To program the Curiosity Nano board with this MPLAB® X project, follow the steps provided in the [How to Program the Curiosity Nano Board](#how-to-program-the-curiosity-nano-board) chapter.<br><br>
67+
68+
69+
## 1. Setup
70+
71+
The AVR64DD32 Curiosity Nano Development Board is used as test platform.
72+
73+
<br><img src="images/AVR64DD32.PNG" width="500">
74+
75+
**PA0** and **PA1** are not connected by default on the AVR64DD32 board. **The user must connect them through soldering on the back of the board where it is written PA0 and PA1**.
76+
77+
<br><img src="images/weld.png" width="500">
78+
79+
The following configurations must be made for this project:
80+
81+
82+
| Pin | Configuration | Semnification |
83+
| :---: | :-----------------: | :-----------------: |
84+
| PA0 | Input | Phase A |
85+
| PA1 | Input | Phase B |
86+
| PC0 | Output | USART TX |
87+
| PC1 | Input | USART RX |
88+
| PA6 | Output | CW detection |
89+
| PD3 | Output | CCW detection |
90+
91+
<br><img src="images/portconn.jpg" width="500">
92+
<br><br>
93+
94+
## 2. Demo
95+
96+
In this demo, the function `QEI_GetVelocity` is called every second and the return is printed on serial communication.
97+
98+
<br><img src="images/demo.png">
99+
<br><br>
100+
101+
## 3. Summary
102+
103+
The quadrature decoder can detect and count clockwise and counterclockwise pulses on rising and falling edges of the quadrature signals.
104+
105+
- [Back to Top](#core-independent-quadrature-decoder-using-the-avr64dd32-microcontroller-with-mcc-melody)<br><br>
106+
107+
108+
## How to Program the Curiosity Nano board
109+
110+
This chapter shows how to use the MPLAB® X IDE to program an AVR® device with an Example_Project.X. This can be applied for any other projects.
111+
112+
- Connect the board to the PC.
113+
114+
- Open the Example_Project.X project in MPLAB X IDE.
115+
116+
- Set the Example_Project.X project as main project.
117+
118+
- Right click on the project in the **Projects** tab and click **Set as Main Project**.
119+
<br><img src="images/Program_Set_as_Main_Project.PNG" width="600">
120+
121+
- Clean and build the Example_Project.X project.
122+
123+
- Right click on the **Example_Project.X** project and select **Clean and Build**.
124+
<br><img src="images/Program_Clean_and_Build.PNG" width="600">
125+
126+
- Select the **AVRxxxxx Curiosity Nano** in the Connected Hardware Tool section of the project settings:
127+
128+
- Right click on the project and click **Properties**
129+
- Click on the arrow under the Connected Hardware Tool
130+
- Select the **AVRxxxxx Curiosity Nano** (click on the **SN**), click **Apply** and then click **OK**:
131+
<br><img src="images/Program_Tool_Selection.PNG" width="600">
132+
133+
- Program the project to the board.
134+
- Right click on the project and click **Make and Program Device**.
135+
<br><img src="images/Program_Make_and_Program_Device.PNG" width="600">
136+
137+
<br>
42138

43-
## Summary
139+
- [Back to Setup](#1-setup)
140+
- [Back to Demo](#2-demo)
141+
- [Back to Summary](#3-summary)
142+
- [Back to Top](#core-independent-quadrature-decoder-using-the-avr64dd32-microcontroller-with-mcc-melody)
44143

45-
<!-- Summarize what the example has shown -->
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
#
2+
# There exist several targets which are by default empty and which can be
3+
# used for execution of your targets. These targets are usually executed
4+
# before and after some main targets. They are:
5+
#
6+
# .build-pre: called before 'build' target
7+
# .build-post: called after 'build' target
8+
# .clean-pre: called before 'clean' target
9+
# .clean-post: called after 'clean' target
10+
# .clobber-pre: called before 'clobber' target
11+
# .clobber-post: called after 'clobber' target
12+
# .all-pre: called before 'all' target
13+
# .all-post: called after 'all' target
14+
# .help-pre: called before 'help' target
15+
# .help-post: called after 'help' target
16+
#
17+
# Targets beginning with '.' are not intended to be called on their own.
18+
#
19+
# Main targets can be executed directly, and they are:
20+
#
21+
# build build a specific configuration
22+
# clean remove built files from a configuration
23+
# clobber remove all built files
24+
# all build all configurations
25+
# help print help mesage
26+
#
27+
# Targets .build-impl, .clean-impl, .clobber-impl, .all-impl, and
28+
# .help-impl are implemented in nbproject/makefile-impl.mk.
29+
#
30+
# Available make variables:
31+
#
32+
# CND_BASEDIR base directory for relative paths
33+
# CND_DISTDIR default top distribution directory (build artifacts)
34+
# CND_BUILDDIR default top build directory (object files, ...)
35+
# CONF name of current configuration
36+
# CND_ARTIFACT_DIR_${CONF} directory of build artifact (current configuration)
37+
# CND_ARTIFACT_NAME_${CONF} name of build artifact (current configuration)
38+
# CND_ARTIFACT_PATH_${CONF} path to build artifact (current configuration)
39+
# CND_PACKAGE_DIR_${CONF} directory of package (current configuration)
40+
# CND_PACKAGE_NAME_${CONF} name of package (current configuration)
41+
# CND_PACKAGE_PATH_${CONF} path to package (current configuration)
42+
#
43+
# NOCDDL
44+
45+
46+
# Environment
47+
MKDIR=mkdir
48+
CP=cp
49+
CCADMIN=CCadmin
50+
RANLIB=ranlib
51+
52+
53+
# build
54+
build: .build-post
55+
56+
.build-pre:
57+
# Add your pre 'build' code here...
58+
59+
.build-post: .build-impl
60+
# Add your post 'build' code here...
61+
62+
63+
# clean
64+
clean: .clean-post
65+
66+
.clean-pre:
67+
# Add your pre 'clean' code here...
68+
# WARNING: the IDE does not call this target since it takes a long time to
69+
# simply run make. Instead, the IDE removes the configuration directories
70+
# under build and dist directly without calling make.
71+
# This target is left here so people can do a clean when running a clean
72+
# outside the IDE.
73+
74+
.clean-post: .clean-impl
75+
# Add your post 'clean' code here...
76+
77+
78+
# clobber
79+
clobber: .clobber-post
80+
81+
.clobber-pre:
82+
# Add your pre 'clobber' code here...
83+
84+
.clobber-post: .clobber-impl
85+
# Add your post 'clobber' code here...
86+
87+
88+
# all
89+
all: .all-post
90+
91+
.all-pre:
92+
# Add your pre 'all' code here...
93+
94+
.all-post: .all-impl
95+
# Add your post 'all' code here...
96+
97+
98+
# help
99+
help: .help-post
100+
101+
.help-pre:
102+
# Add your pre 'help' code here...
103+
104+
.help-post: .help-impl
105+
# Add your post 'help' code here...
106+
107+
108+
109+
# include project implementation makefile
110+
include nbproject/Makefile-impl.mk
111+
112+
# include project make variables
113+
include nbproject/Makefile-variables.mk

0 commit comments

Comments
 (0)