Automatic Fan Cooler is device which controls USB Fan. It turns it on when somebody enter room and turn it off when no movement is detected in the room for some time. It is designed for lazy users (for me) who do not want to manually press switch on fan when leaving room. While most use cases are in hot summer days, it is still usable for example as DIY solder flume fanout. For activating device in this case, you need just move hands and do not need to touch anything which is helpful when having full hands of soldering tools, boards and so on.
Device use 61 GHz Radar which rely on Doppler effect. Device is fully digitally adjustable. Sensitivity of detection is configurable using provided web application which utilizes modern Web Bluetooth API for communicating with the device. For switching load PROFET™+2 12V Arduino Shield is used. While it is designed for working on 12V, it works with 5V power as well.
For connection fan to the shield, I use my own DIY board which I designed few years ago for monitoring power consumption of USB devices. Now I connected switch instead of amper meter to the board. Schematic of this board in PDF project and KiCad project are available to download at the end of this article.
Following image show schematic, which also can work as block diagram because circuit consist of development kits and modules. Full (zoomable) schematic you can download in PDF format at the end of this article.
Shield is not directly inserted to the board. The problem was that Shield use the same signals which are on Arduino Header used for SPI bus. I checked all other exposed pins and did not find any group of pins exposing full SPI signals (from the same SCB peripheral). For this reason, I did not inserted shield directly, but rather routed only required pins.
For powering fan, I use external 5V USB Charger, but if you are sure, that your fan is within current specs allowed for sourcing directly from PSoC 6 Board, you can go this way and reduce need of two 5V power supplies.
Radar module must be configured to SPI mode instead of default autonomous mode. Set R_QS1 to SPI. More details about configuration will be provided later in this article.
In real connection of circuit looks as follows:
As mentioned above, sensitivity of device is fully digitally configurable. There is no need to adjust trimmers on the device and it is possible to tune device more precisely. For such configuration, Bluetooth Low Energy (BLE) is used as an interface. This time I made configuration utility as web application. It uses very modern JavaScript Web Bluetooth API for communication with BLE GATT server and use exposed characteristics directly from the web browser. No mobile app is needed. It works in all browsers which supports this API. Currently Microsoft Edge, Google Chrome and some Android browsers supports it. Web application is also available online at my website at: https://misaz.cz/Public/CoolerConf. Application look as follows:
When clicking “+ Connect to device”, the browser will start scanning for Bluetooth Low Energy devices and shows suitable devices for selection.
Device do not transmit advertisements for all time. It sends them 2 minutes after power up and 2 minutes after last Bluetooth disconnect. If you want to reconfigure device and device is not searchable, press USER BTN 1 on the board. It became visible for 2 minutes. Visibility is indicated by alternating blue and yellow color on indication LED. When connected LED is GREEN.
After connecting, you can adjust parameters and then click save for transmitting them to the device. It is not needed to reconfigure device on every power up. Device remembers parameters. Device saves parameters in FRAM memory and loads them at power up (reset).
FirmwareFirmware for the device was developed using ModusToolbox. It uses 3 Infineon Libraries:
- retarget-io for outputting debugging information (using printf function) on UART
- btstack (alias WICED) is used for managing Bluetooth communication and communication with onboard CYW43012 Low-Power Wi-Fi module. GATT Database and other Bluetooth parameters are configured using Bluetooth Configurator 2.80.
- serial-flash is used for controlling QSPI interface which is used for connecting Serial FLASH and FRAM memories to the MCU. FRAM type and parameters are set using QSPI Configurator 4.10.
And of course it relies on Infineon PSoC PDL and HAL.
Firmware is based on FreeRTOS. It runs 4 application tasks and some tasks related to Bluetooth stack. Application tasks are following:
- RadarTask handles reconfiguration of the BGT60LTR11 Radar Module at power up and when parameter change is requested.
- LedTask handles LED for indicating Bluetooth status. It is off, green or blink blue/yellow as described in section above. It also handles green/red balancing when showing yellow color.
- ButtonTask handles switch which is used for making device visible over Bluetooth. It is mainly used for debouncing implementation.
- DetectionTask process inputs from Radar module and drives fan switch.
Configuration and handling of Bluetooth stack was merged to separate file BLE.c. Remaining parts of application are implemented directly in main.c file.
BGT60LTR11 Radar LibraryThe most important part of project is library for configuring BGT60LTR11 Radar chip. This chip can work in two modes:
- Autonomous mode configured using 4 quad state inputs
- SPI Mode which does nothing by default and everything has to be configured over SPI first.
Using sensor in the first mentioned (autonomous) mode is simple. There are several tutorials and there is also Arduino Library directly from Infineon which can handle related stuff. But in opposition, for using sensor in the more advanced SPI mode there is almost nothing. There is C, Python and Matlab SDK available on Infineon website, but it do not configure sensor directly. Instead, it is used for gathering data from microcontroller which interface the sensor. But firmware for microcontroller is closed source. I searched for library capable of SPI communication with BGT60LTR11 Radar on the Google and I found nothing. I tried GitHub and found one lightweight library directly integrated to some STM32 project. After these attempts I decided to develop my own library.
I like developing comprehensive libraries which allows developer to use all features of chip. In opposition they are often not very easy to use by beginners because my libraries require knowledge of the target device. As part of library, I exposed all 54 configurable parameters which I found in user guide and some other related documents. User can configure almost everything. For making it easier it is possible to use function for loading default recommended parameters and adjust only few parameters. Mostly, you will adjust the same parameters which you can adjust by switches and trimmers when using autonomous mode (Radio Signal Frequency, Detection threshold and Hold Time). But with SPI mode and my library you can configure much more like polarity of output signals, idle state of output signal, all PLL, Timing, Baseband and Bite parameters, SPI Mode, change behaviour of SPI output pin and QS4 signals for exposing debugging information from sensor, read RAW ADC data and much more.
While I spend over two months with developing and testing this library, in project it is utilized quite basically. I think most projects will use it very basically and just work in mode of adjusting few parameters rather than comprehensively tune all 54 parameters. As part of development, I did lot of experiments with the sensor and some features of sensor are very interesting. I am not very RF expert so many parameters looks that they do nothing or have minimal impact on output, but I still exposed them to the library for users who can utilize them. Lack of description was the most limiting factor when developing library. Many parameters have no description except their names.
Library is designed as multiplatform and easily portable to new platforms. Currently it is implemented for PSoC 6 platform and expects Modus Toolbox configuration of SPI driver. Driver instance you can select by modifying BGT60LTR11_PlatformSpecific.h file.
More details about library and example code you can find on GitHub: https://github.com/misaz/BGT60LTR11-Library
Similarly, I made library for other digitally configurable device as part of kit which I received for free as part Connect things with code! with Infineon. This sensor and library I do not used in this project, but I still played with this sensor (and especially it’s very special I2C slave controller supporting two modes). Library is designed in a very similar way, and it is also very comprehensive. Support using sensor in all modes, including very interesting low-power interrupts mode which adaptable changes thresholds and generates interrupt every time the value change which allows running MCU in low power mode as long as value measured by magnetic sensor do not change. There is example showing how to use it in this way as well as many other examples. Library you can download from my GitHub which also contains instruction how to integrate it to (not only Modus Toolbox) project. For development of this library, I used different microcontroller (XMC1300) for gathering experiences with this interesting MCU which I never used before.
Link to library: https://github.com/misaz/TLI493D-Library
ClosingThank you all who read my article as far. In this article I described my automatic fan controller and basically described libraries which I created in recent months. In the section below you can download resources which you can use if you decide to make your own Automatic Fan Cooler or if you decide to use my libraries for BGT60LTR11 Radar sensor or TLI493D 3D Magnetic sensor in your own projects.
Resources- Automatic Fan Cooler Schematics (PDF)
- USB Power Measurement/Switch Board Schematics (PDF)
- USB Power Measurement/Switch Board Gerbers (ZIP)
- USB Power Measurement/Switch Board KiCad Project (ZIP)
- Firmware Source Codes (ZIP) (You need to restore Modus Toolbox libraries by clicking Update in Library Manager)
- Firmware Prebuilt Binary (ELF)
- Sensitivity Configuration Web Application Sources (ZIP)
- Sensitivity Configuration Web Application (Online)
- My BGT60LTR11 Library (GitHub)
- My TLI493D Library (GitHub)
Comments