This example demonstrates to users how to create a CapSense proximity sensor. This example will use the proximity sensor value to mix a color on an RGB LED. The user will also be able to read the data out using the UART and Bridge Control Panel.
Forum Post Attachments:
At the bottom of this post we are including the following items:
- Example Project Zip File
- Zip File of Images
- Project Schematic
- Component Configurations
The user can download the example project at the bottom of this post. The project uses the following list of Creator Components:
The components are configured by right clicking on the component in your Top Design schematic view and selecting Configure. Please enable the following selections in the Configuration windows for the listed components above.
The main.c firmware is included in the example project. Please review the commented sections for more details.
The example project firmware implements a proximity sensor, which is available in the CapSense component under the configuration GUI.
The example project endlessly reads the proximity values from the sensor and calibrates a proximity maximum range. This value is used to calculate the LED color using the LED RGB driver module.You will remember that we used this LED Driver module in example #014.
The hue for the LED is calculated using the proximity value and then passed to the APIs defined in the LED RGB driver file. The value of the hue is then also passed to the UART as two 8 bit values to be displayed in the Bridge Control Panel.
To monitory the values from the UART the user will need to launch the Bridge Control Panel and select the COM port from the port list. This will automatically select the RX8 (UART) radio button. In my example the COM port is COM13. Enter in the following UART command into the Bridge Control Panel and then hit the repeat button.
RX8 [h=43] @1prox @0prox
You will see the UART data displayed in the output window. Navigate to the Chart tab to see the proximity values displayed in the chart window. Move your hand around the proximity wire and see the values change in the chart. In the below image you see a plot of the values from the UART. The peaks are when my hand is close to the proximity sensor.
A key point when using the Bridge Control Panel. The PWM value is a 16 bit value in your application but it is broken into two 8 bit values when transmitted. Here the Bridge Control Panel reads those values and reassembles the two 8 bit values into a single 16 bit value. It accomplishes this by using the '0' and '1' leading values on the read variables.
RX8 [h=43] @1prox @0prox
In the above command we have a variable named 'prox'. We add a leading 1 and 0 to the variable to indicate that these two values should be stitched together to create a single value and assign that value to 'prox'. If the '0' and '1' values are placed after 'prox', for example prox1 or prox0 then this indicates two separate variables. For more information on this please take a look at the Bridge Control Panel user guide.
The user will need to connect a single wire to the P1 pin on the Pioneer Kit. The P1 is on the J2 header. This wire should be long and be pointed vertically away from the board. This help to reduce noise on the proximity detection.
Also connect a single wire to the PSoC 4 pin P4 and the Pin 9 on the header J11. This will connect the UART of the PSoC 4 to the UART Bridge on the PSoC 5LP. This wire will enable the Bridge Control Panel UART data collection. In this example we only need the TX connection from the PSoC 4 as we are not sending values to the PSoC 4.
Test Your Project:
Once the kit is programmed wait until the LED transitions from White to Red. The proximity detector is finding the minimum and maximum values. Once it transitions to Red move your hand close to the wire and see that the LED changes color as you get closer to the wire. Use the Bridge Control Panel to read the proximity value.
I hope this example can help you out in your design.