1. Introduction
The LC sensor controller (LCSC) controls DAC, COMP, VCMBUFF power-on/power-off and dedicated GPIOs (PB1, PA14, PB2) for the measurement of LC networks damping times.
In this type of application, the flow of a fluid in a pipe forces the rotation of a wheel, and the number of revolutions permits the quantification of the amount of fluid consumed. This feature is generally used in a metering application, such as water and gas metering.
Three external LC networks, positioned on top of the wheel, count the number of revolutions. These networks must be connected to the identified GPIOs. Two of them (PB1 and PA14) position the rotating wheel (to be determined), whereas the other (PB2) is necessary to avoid tampering.
2. LCSC block diagram description
The figure above is extracted from RM0511. It shows the block diagram of the LCSC, while the figure below shows the connections of LCSC to DAC, COMP, VCMBUFF and PB1, PA14, PB2 and PB4 GPIO.
The LC sensor controller (LCSC) works autonomously by managing the hardware blocks DAC, COMP, VCMBUFF power-on/power-off to continuously measure the number of oscillations of the two LC sensors: LCA and LCB.
PB1 and PA14 are used to determine the position of the rotating wheel, whereas PB2 is used to detect a tampering event.
The LC sensor controller requires an external circuitry:
- Two LC couples (LCA and LCB) exposed to the rotating wheel
- One LC couple (LCT) (optional) placed close to the rotating wheel (but not exposed to it, as its function is to detect an eventual tampering with a metal part) that allows both LCA and LCB to be affected to the same damping factor, thus making it impossible to detect the rotation of the wheel
- Cext capacitor, to be charged at VBAT/2, used to charge sequentially the LC oscillators
The LC sensor metering uses an LC network connected to a VDD/2 bias voltage. This VDD/2 voltage is internally generated by the DAC and is provided by the PB4 pin. PB1, PB2, PA14 pins are used as output GPIO when the LC sensors must be charged, and then in alternate function as positive input of the COMP once the LC starts oscillating. The negative input of the comparator is internally connected to the output of the DAC which generates a threshold voltage above the VDD/2 bias to provide a noise margin.
3. Oversampling recommendation
In order to detect and count the wheel rotations, the LCSC timings must be configured properly. The scan frequency takes into account an oversampling that correctly detects the wheel rotation.
Each of the four position combinations are detected in order to determine a full revolution and increase the rotations counter. To illustrate this, a x8 oversampling is suggested as the minimum to correctly detect, without uncertainties, all of the four quarters.
To discriminate between plastic and metal, a count threshold is set: counts below this threshold indicate that the coil is exposed to the metal, counts above the threshold indicates that the coil is exposed to plastic.
4. Hardware setup on NUCLEO-WL33CC
The evaluation of the LCSC feature using the NUCLEO-WL33CC evaluation kit is possible as long as there is the ability to connect the coils to the NUCLEO-WL33CC board. It is also possible to use test PCBs, prototypes, or hole board during the evaluations.
When evaluating the LCSC feature, it is crucial to maintain a stable setup, as LC detections can be highly susceptible to disturbances. Several parameters must be considered:
- Distance between the wheel and the coils (1 mm to 5 mm according to specifications)
- Distance between the two coils (LCA & LCB)
- Distance between the coils and the ground plane of the PCB
- Quality of the coils (preferably with low DCR and impedance)
Firstly, the requirement is specific coils with low DCR and impedance. Generally, the lower the values, the better. In the reference design Murata 11R474C (470µH) coils are used. The choice of coil is critical as it directly impacts the shape of the signal and the oscillations. Increased oscillations lead to higher accuracy in the application.
5. Software setup on NUCLEO-WL33CC
5.1. LCSC_BasicDemo Application:
Once the coils are connected to the correct STM32WL33 pins, the evaluation of the LCSC can start using the STM32CubeWL3 package.
In this package, under the following path :
\STM32Cube_FW_WL3_V1.0.0\Projects\NUCLEO-WL33CC\Examples_LL\LCSC\LCSC_BasicDemo
This SW example shows how to use an LC sensor controller (LCSC) peripheral to measure rotation of a wheel. It is based on the STM32WL3x LCSC API. In order to make the program work, use the following steps :
- Open the preferred toolchain
- Rebuild all files and load the image into target memory
- Run the example
This example runs on STM32WL33CCVx devices and has been tested with the NUCLEO-WL33CC board and can be easily tailored to any other supported device and development board.
5.2. Example description:
The LCSC controls the COMP, DAC, VCMBUFF and PB1, PA14, PB2 in order to implement the LCSC feature.
This example is configured to count the number of wheel rotations in both clockwise and anticlockwise directions with LCA and LCB.
When the tamper (LCT) detection is activated, it is possible to detect if a metallic surface has interfered with the measurement of the number of revolutions.
This example can be divided in the following parts:
- Initialization of the LCSC IP
- Initial calibration of the LCSC (for this step the coils must not be exposed to the metal part)
- Do not use calibration if not using coils from the reference design. The calibration code uses static values, that might not be relevant for specific LCSC setups.
- Infinite while loop, and the LCSC works independently
The wheel is placed in front of the coils only after the initial calibration and can eventually start rotating. when the wheel performs a number of rotations, clockwise or anticlockwise, equal to the threshold defined in the proper register. A message is printed at the terminal.
5.3. Connection needed:
Hardware used for the LC network in this example :
Inductances: La, Lb and Lt = 470uF (Murata 11R474C)
Capacitors: Ca, Cb and Ct = 560pF Cext_LCSC = 470nF
Note: The configuration of the LCSC must be updated based on the inductors and capacitors used.
5.4. On-the-fly debug configuration
Using a picoscope or oscilloscope, it is possible to check the integrity of the LC signals :
- On line PB2, PA14, or PB1 (depending which coils are connected or not)
It is possible to perform on-the-fly configuration of the LCSC IP when debugging with IDE. Using the "Debug mode" and the "registers" system view, it is possible to modify the register contents on-the-fly and observe the impact on the LCSC application and LC signals using an oscilloscope or any other analog tool.