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
+17-17Lines changed: 17 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
5
5
# User Interface Co-Processor with PIC16F18146
6
6
7
-
This example uses the PIC16F18146 to act as a user-interface co-processor, where the MCU debounces a pushbutton, performs quadrature decoding, and generates 4 programmable PWM channels. As the functionality of this example is developed in software, it can be customized to the design.
7
+
This example uses the PIC16F18146 to work as a user-interface co-processor, where the MCU debounces a push button, performs quadrature decoding, and generates 4 programmable PWM channels. As the functionality of this example is developed in software, it can be customized to the design.
8
8
9
9
## Related Documentation
10
10
@@ -30,7 +30,7 @@ This example uses the PIC16F18146 to act as a user-interface co-processor, where
30
30
31
31
## Setup
32
32
33
-
With the power off, install the PIC16F18146 into the socket of the Curiosity LPC board, while matching the pin 1 marker on the DIP and PCB (marked as 1).
33
+
Disconnect power to the LPC board. Install the PIC16F18146 into the socket of the Curiosity LPC board, while matching pin 1 on the DIP and PCB (indicated by the 1 in the image below).
34
34
35
35

36
36
@@ -42,9 +42,9 @@ With the power off, install the PIC16F18146 into the socket of the Curiosity LPC
42
42
| RB6 | SDA, I<sup>2</sup>C Data Line
43
43
| GND | Connect the ground of the MCP2221A to the LPC board.
44
44
45
-
*Important: Match the voltage of the MCP2221A breakout to the setting on the Curiosity LPC (marked as 2). Either +5V or 3.3V can be used, depending on the circuit requirements. Do NOT connect power from the MCP2221A to the LPC.*
45
+
*Important: Match the voltage of the MCP2221A breakout to the setting on the Curiosity LPC, marked as 2. Either +5V or 3.3V can be used, depending on the circuit requirements. Do NOT connect power from the MCP2221A to the LPC.*
46
46
47
-
Next, follow the application circuit of the encoder (if provided), and connect the encoder as follows.
47
+
If provided, follow the application circuit of the encoder, and connect the encoder as follows.
48
48
49
49
| IO Pin | Description
50
50
| ------ | ----------
@@ -57,11 +57,11 @@ Next, follow the application circuit of the encoder (if provided), and connect t
57
57
58
58
### Built-In (Pre-wired) Features
59
59
60
-
For the pushbutton, the button built-in to the LPC is used (S1). No wiring is required. Pin RC6 is the debounced output, which is viewable on an oscilloscope.
60
+
No wiring is required for the push button built-in to the LPC (S1). Pin RC6 is a debounced output that can be viewed on an oscilloscope.
61
61
62
62
| IO Pin | Description
63
63
| ------ | ----------
64
-
| RC4 | Pushbutton Input (S1)
64
+
| RC4 | Push button Input (S1)
65
65
| RC6 | Debounced Output (*Optional, Connect to oscilloscope with ground for testing*)
66
66
67
67
*Note: It was difficult to generate any bounces from S1. Bounces can be easily generated by connecting a piece of wire to RC4 and tapping it on a grounded pin or connection.*
@@ -83,7 +83,7 @@ To demonstrate the PWM controls, the LEDs on the LPC are connected to the output
83
83
| RB6 | SDA, I<sup>2</sup>C Data Line
84
84
| RC0 | Quadrature Decoder "A" Input
85
85
| RC1 | Quadrature Decoder "B" Input
86
-
| RC4 | Pushbutton Input (S1)
86
+
| RC4 | Push button Input (S1)
87
87
| RC6 | Debounced Output (*Optional, Connect to oscilloscope with ground for testing*)
88
88
| RC5 | PWM_CH1 (PWM1, Phase 1)
89
89
| RA2 | PWM_CH2 (PWM1, Phase 2)
@@ -97,7 +97,7 @@ This application implements a simple user-interface co-processor for an embedded
97
97
This proof-of-concept project implements 3 key functions for the main processor:
98
98
- Decoding quadrature signals from rotary encoders
99
99
- Generating 4 PWM waveforms
100
-
- Debouncing a pushbutton
100
+
- Debouncing a push button
101
101
102
102
As this application is software defined, the exact functionality can be customized to meet the requirements of the system.
103
103
@@ -123,7 +123,7 @@ The PWM waveforms are generated by Core Independent Peripherals (CIP), which ope
123
123
124
124
### Debouncing a Button
125
125
126
-
Pushbuttons and switches exhibit a temporary "bounce" when pressed or released. These bounces create brief periods of instability that would confuse the system if not filtered out.
126
+
Push buttons and switches exhibit a temporary "bounce" when pressed or released. These bounces create brief periods of instability that would confuse the system if not filtered out.
127
127
128
128
In this example, a hardware-level button debouncer is implemented using hardware peripherals. To implement this functionality, 2 CLCs and the Numerically Controlled Oscillator (NCO) CIPs are used. The NCO generates a low-frequency clock (200 Hz) for the CLCs, while the CLCs perform basic digital filtering, as shown below.
129
129
@@ -135,13 +135,13 @@ In this example, a hardware-level button debouncer is implemented using hardware
135
135
136
136
### I<sup>2</sup>C Interface
137
137
138
-
To communicate with the device, I<sup>2</sup>C is used. This device is setup as an I<sup>2</sup>C client with an address of 0x40. (The address can be changed in software).
138
+
This device is setup as an I<sup>2</sup>C Client with an address of 0x40. (The address can be changed in software).
139
139
140
-
When I<sup>2</sup>C is not active, the device is in sleep to save power.
140
+
When the I<sup>2</sup>C is not active, the device goes into Sleep mode to save power.
141
141
142
142
#### Writing Data
143
143
144
-
To configure the device, perform an I<sup>2</sup>C write to the device. Writes take the form as:
144
+
Perform an I<sup>2</sup>C write for the device to configure it, as shown in the example below:
145
145
146
146

147
147
@@ -164,27 +164,27 @@ A list of the virtual registers is shown below.
164
164
165
165
#### Reading Data
166
166
167
-
To get the net change from the quadrature decider, perform an I<sup>2</sup>C read. The bytes read from the device are in int16_t format, with the 1st byte being the high byte, and the 2nd byte being the low byte. An example is shown below, with 2 back-to-back reads:
167
+
To get the net change from the quadrature decoder, perform an I<sup>2</sup>C read. The bytes read from the device are in int16_t format, with the 1st byte being the high byte and the 2nd byte being the low byte. An example is shown below, with 2 back-to-back reads:
168
168
169
169

170
170
171
171
*Note: The application automatically zeros the net change after each read.*
172
172
173
-
When the high-byte is read, the microcontroller computes the net rotation. This ensures the value doesn't rollover while a read is happening. After the low-byte, the system will repeat the operation above, but with the net rotation since the last read.
173
+
When the highbyte is read, the microcontroller computes the net rotation. This ensures the value doesn't rollover while a read is performed. After the lowbyte, the system will repeat the operation above, but with the net rotation since the last read.
174
174
175
-
*Note: Very long byte read sequences with the MCP2221A seem to fail, likely due to insufficent clock stretching time for the client. Be sure to give the device time to respond.*
175
+
*Note: Very long byte read sequences with the MCP2221A seem to fail, likely due to insufficent clock stretching time for the Client. Time must be given for the device to respond.*
176
176
177
177
#### Setting Up PWM
178
178
179
179
For each channel of PWM, there is an associated period and duty cycle register. These settings can be set independently of each other, or at the same time. The PWM is internally loaded and started at the same time to keep the channels as synchronized as possible.
180
180
181
181
**Note: Setting the channels to differing frequencies is likely to break synchronization.**
182
182
183
-
Consult the PWM chapter of the datasheet for more information about the PWM.
183
+
Consult the PWM chapter of the data sheet for more information about the PWM.
184
184
185
185
##### Frequency Setup
186
186
187
-
The PWM Core Independent Peripheral (CIP) generate 2 outputs for each instance of the peripheral. These instances share the same frequency, but different duty cycles. The period register determines the max count in the PWM timer. For instance, setting a period of 10, would limit the count to 10 or less. Each time the clock source (LFINTOSC, 31 kHz) goes high, the counter increments.
187
+
The PWM CIP generates 2 outputs for each peripheral. These outputs share the same frequency, but can have differing duty cycles. The period register determines the max count in the PWM timer. For instance, setting a period of 10 would limit the count to 10 or less. Each time the clock source (LFINTOSC, 31 kHz) goes high, the counter increments.
188
188
189
189
To determine the value to write for a given frequency, divide the clock source frequency by the desired target. As an example, if the desired output was 100 Hz, then write 310 (0x01, 0x36) to the register.
0 commit comments