Skip to content

Commit 8eed8c7

Browse files
Diana LolesDiana Loles
authored andcommitted
MPAE-16817: updated readme and code
1 parent 2720e87 commit 8eed8c7

File tree

88 files changed

+55445
-13016
lines changed

Some content is hidden

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

88 files changed

+55445
-13016
lines changed

.main-meta/main.json

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,29 @@
22
"metaDataVersion": "1.0.0",
33
"category": "com.microchip.ide.project",
44
"content": {
5-
"metaDataVersion": "1.1.0",
5+
"metaDataVersion": "1.3.0",
66
"name": "com.microchip.mcu8.mplabx.project.pic16f18446-sensor-board-battery-measurement",
7-
"version": "1.0.1",
8-
"displayName": "PIC16F18446 Sensor Board Battery Measurement",
7+
"version": "2.0.0",
8+
"displayName": "Sensor Board Temperature Measurement Using the PIC16F18446 Microcontroller",
99
"projectName": "pic16f18446-sensor-board-battery-measurement",
1010
"shortDescription": "Battery (Vdd) level measurement is performed while the display is turned on. The percentage level of the remaining charge in the batteries is shown as a battery icon with proportional filling in the top-right corner of the display. Additionally, the battery voltage in Volts and percentage graph are displayed.",
1111
"ide": {
1212
"name": "MPLAB X",
13-
"semverRange": ">=5.30.0"
13+
"semverRange": ">=6.15.0"
1414
},
1515
"compiler": [
1616
{
1717
"name": "XC8",
18-
"semverRange": "^2.10.0"
18+
"semverRange": "^2.45.0"
1919
}
2020
],
2121
"dfp": {
2222
"name": "PIC16F1xxxx_DFP",
23-
"semverRange": "^1.2.99"
23+
"semverRange": "^1.21.368"
2424
},
2525
"configurator": {
2626
"name": "MCC",
27-
"semverRange": ">=3.95.0"
27+
"semverRange": ">=5.3.7"
2828
},
2929
"device": {
3030
"metaDataVersion": "1.0.0",
@@ -37,17 +37,14 @@
3737
}
3838
},
3939
"author": "Microchip",
40-
"subcategories": [
41-
[
42-
"Peripherals",
43-
"ADCC"
44-
]
45-
],
4640
"peripherals": [
47-
"ADCC"
41+
"ADCC",
42+
"MSSP",
43+
"CLC"
4844
],
4945
"keywords": [
50-
"Battery Level"
46+
"LCD",
47+
"Battery Monitoring"
5148
],
5249
"additionalData": {
5350
"longDescription": {

README.md

Lines changed: 118 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,145 @@
11
[![MCHP](images/microchip.png)](https://www.microchip.com)
22

33

4-
# PIC16F18446 Sensor Board Battery Measurement
4+
## Sensor Board Battery Measurement Using the PIC16F18446 Microcontroller
55

6-
The PIC16F184xx family has a new Analog to Digital Converter with Computation (ADCC) with a 12-bit resolution. This project shows how the PIC can internally measure its Vdd using the ADCC and FVR.
6+
The PIC16F184xx family has a new Analog-to-Digital Converter with Computation (ADCC) with a 12-bit resolution. This project shows how the PIC can internally measure its Vdd using the ADCC and FVR.
77

8-
In this example we will be using the PIC16F18446 Sensor Board. Battery (Vdd) level measurement is performed while the display is turned on. The percentage level of the remaining charge in the batteries is shown as a battery icon with proportional filing in the top-right corner of the display. Additionally, the battery voltage in Volts and percentage graph are displayed.
8+
This example showcases the PIC16F18446 Sensor Board. Battery (Vdd) level measurement is performed while the display is turned on. The percentage level of the remaining charge in the batteries is shown as a battery icon with proportional filing in the top-right corner of the display. Additionally, the battery voltage in Volts and percentage graph are displayed.
99

1010
## Related Documentation
1111
- [PIC16F18446 Product Family Page](https://www.microchip.com/design-centers/8-bit/pic-mcus/device-selection/pic16f18446)
1212
- [PIC16F18446 datasheet](http://ww1.microchip.com/downloads/en/DeviceDoc/40001985B.pdf) for more information or specifications.
1313

1414

1515
## Software Used
16-
- MPLAB® X IDE 5.30 or newer [(microchip.com/mplab/mplab-x-ide)](http://www.microchip.com/mplab/mplab-x-ide)
17-
- MPLAB® XC8 2.10 or a newer compiler [(microchip.com/mplab/compilers)](http://www.microchip.com/mplab/compilers)
18-
- MPLAB® Code Configurator (MCC) 3.95.0 or newer [(microchip.com/mplab/mplab-code-configurator)](https://www.microchip.com/mplab/mplab-code-configurator)
19-
- MPLAB® Code Configurator (MCC) Device Libraries 8-bit AVR MCUs 2.3.0 or newer [(microchip.com/mplab/mplab-code-configurator)](https://www.microchip.com/mplab/mplab-code-configurator)
20-
- PIC16F1xxxx DFP 1.2.99 or newer Device Pack
16+
- [MPLAB® X IDE](http://www.microchip.com/mplab/mplab-x-ide) v6.15 or newer
17+
- [MPLAB® XC8](http://www.microchip.com/mplab/compilers) v2.45 or newer
18+
- [PIC16F1xxxx_DFP](https://packs.download.microchip.com/) v1.2.99
2119

2220
## Hardware Used
23-
- [PIC16F18446 Sensor Board Demonstration](https://www.microchip.com/promo/pic16f18446-sensor-board-demonstration)
21+
- [PIC16F18446 Sensor Board Quick Start Guide](http://ww1.microchip.com/downloads/en/DeviceDoc/30010172A.pdf)
22+
<br><img src="images/PIC16F18446_Sensor_board.PNG" width="800">
2423

24+
## Operation
25+
26+
To program the microcontroller with this MPLAB® X project, follow the steps provided in the [How to Program the Microcontroller](#how-to-program-the-microcontroller) chapter.<br><br>
2527

2628
## Setup
2729

28-
To get the Vdd voltage, ADCC is used to measure the FVR (which is configured to 1.024V) with Vdd as positive reference. Then the Vdd is calculated using this formula: Vdd = 1.024V * 4096 / ADC_Reading.
30+
The following configurations must be made for this project:
31+
32+
- Clock Control:
33+
- Clock Source: HFINTOSC
34+
- HF Internal Clock: 32 MHz
35+
- Clock Divider: 1
36+
37+
<br><img src="images/clock_control.PNG" width="600">
38+
39+
- Configuration bits:
40+
- External Oscillator Selection bits: Oscillator disabled
41+
- Reset Oscillator Selection bits: HFINTOSC (1 MHz)
42+
- WDT Operating Mode bits: WDT Disabled, SWDTEN is ignored
43+
44+
<br><img src="images/config_bits.jpg" width="600">
45+
46+
- MSSP1 (SPI):
47+
- Mode: Host
48+
- SPI Mode: SPI Mode 0
49+
- Input data sampled at: Middle
50+
- Clock source selection: F<sub>OSC</sub>/4
51+
52+
<br><img src="images/mssp1(spi).PNG" width="600">
53+
54+
- CLC1:
55+
- Enable CLC: Yes
56+
- Logic Cell mode: AND-OR
57+
58+
<br><img src="images/CLC1.PNG" width="600">
59+
60+
- CLC2:
61+
- Enable CLC: Yes
62+
- Logic Cell mode: AND-OR
63+
64+
<br><img src="images/CLC2.PNG" width="600">
65+
66+
- FVR:
67+
- Enable FVR: Yes
68+
- FVR buffer gain to ADC: 1x
69+
- FVR buffer gain to other peripherals: 1x
70+
71+
<br><img src="images/FVR.PNG" width="600">
72+
73+
- ADCC:
74+
- Enable ADC: Yes
75+
- Operating Mode: Burst Average mode
76+
- Result Alignment: Right
77+
- Positive Input Channel: ANA0
78+
- Positive Reference: V<sub>DD</sub>
79+
- Negative Reference: V<sub>SS</sub>
80+
- Auto-conversion Trigger: Disabled
81+
- Acquisition Count: 0
82+
- Clock Source: F<sub>OSC</sub>
83+
- Clock Divider: F<sub>OSC</sub>/128
84+
- Repeat: 64
85+
86+
<br><img src="images/adc_hardware_settings.PNG" width="600">
87+
<br><img src="images/adc_clock_and_computation_feature.PNG" width="600">
88+
89+
| Pin | Configuration | Description | Custom Name |
90+
| :-: | :------------: | :-----------------------: | :-----------------------: |
91+
| RC1 | SCK1 | Serial Clock | SCK1 |
92+
| RB4 | SDI1 | Serial Data In | SDI1 |
93+
| RC5 | CLC2 | Analog output | IO_RC5 |
94+
| RC6 | CLC1 | Analog output | IO_RC6 |
95+
| RB5 | GPIO | Digital input | S2 |
96+
| RC4 | GPIO | Digital input | S3 |
97+
| RB7 | GPIO | Digital output | LCD_RESET |
98+
| RC2 | GPIO | Digital output | LCD_BACKLIGHT |
99+
| RC7 | GPIO | Digital output | LCD_CS |
100+
101+
<br><img src="images/pin_grid_view.PNG" width="600">
102+
<br><img src="images/pins.PNG" width="600">
103+
104+
## Demo
29105

30-
### MCC Settings
106+
To get the Vdd voltage, ADCC is used to measure the FVR, which is configured to 1.024V, with Vdd as positive reference. Then the Vdd is calculated using this formula: Vdd = 1.024V * 4096 / ADC_Reading.
31107

32-
Here are the settings used for MSSP, CLC, FVR, and ADCC. MSSP + CLC are used for the LCD control.
33-
### MSSP Settings
34-
<br><img src="images/MSSP1.png" width="600">
108+
<br><img src="images/display.png" width="600">
35109

36-
### CCL Settings
37-
<br><img src="images/CLC1.png" width="600">
110+
## Summary
38111

39-
<br><img src="images/CLC2.png" width="600">
112+
This code example shows how to use the Battery level measurement feature on the Sensor Board, using MSSP and CLC for LCD control, FVR and ADCC.
40113

41-
### FVR Settings
42-
<br><img src="images/FVR.png" width="600">
114+
## How to Program the Microcontroller
43115

44-
### ADCC settings
45-
<br><img src="images/ADCC1.png" width="600">
46-
ADRPT register is set to 0x40, to average a burst of 64 samples.
47-
<br><img src="images/ADCC2.png" width="600">
116+
This chapter demonstrates how to use the MPLAB X IDE to program a PIC® device with an `Example_Project.X`. This applies to other projects.
48117

49-
### PIN Grid
50-
<br><img src="images/PIN_Grid.png" width="600">
118+
1. Connect the Sensor board to the PC.
51119

52-
### PIN Module
53-
<br><img src="images/PIN_Module.png" width="600">
120+
2. Open the `Example_Project.X` project in MPLAB X IDE.
54121

55-
## Demo
56-
<br><img src="images/display.png" width="600">
122+
3. Set the `Example_Project.X` project as main project.
123+
<br>Right click the project in the **Projects** tab and then Set as Main Project.
124+
<br><img src="images/Program_Set_as_Main_Project.PNG" width="600">
125+
126+
4. Clean and build the `Example_Project.X` project.
127+
<br>Right click the `Example_Project.X` project and select Clean and Build.
128+
<br><img src="images/Program_Clean_and_Build.PNG" width="600">
129+
130+
5. Select Starter Kits (PKOB) in the Connected Hardware Tool section of the project settings:
131+
<br>Right click the project and **Properties**.
132+
<br>Click the arrow under the Connected Hardware Tool, and from the dropdown, select Starter Kits (PKOB) by clicking the SN.
133+
<br>Click **Apply** and then **OK**.
134+
<br><img src="images/Program_Tool_Selection.PNG" width="600">
135+
136+
6. Program the project to the microcontroller.
137+
<br>Right click the project and then Make and Program Device.
138+
<br><img src="images/Program_Make_and_Program_Device.PNG" width="600">
139+
140+
<br>
141+
142+
- [Back to Top](#sensor-board-battery-measurement-using-the-pic16f18446-microcontroller)
143+
- [Back to Setup](#setup)
144+
- [Back to Demo](#demo)
145+
- [Back to Summary](#summary)

images/ADCC1.png

-48.7 KB
Binary file not shown.

images/ADCC2.png

-40.3 KB
Binary file not shown.

images/CLC1.png

18.5 KB
Loading

images/CLC2.png

22.9 KB
Loading

images/FVR.png

4.24 KB
Loading

images/MSSP1.png

-30.9 KB
Binary file not shown.

images/PIC16F18446_Sensor_board.PNG

209 KB
Loading

images/PIN_Grid.png

-55.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)