Send a command string through Bluetooth to control a QN908X three-phase PWM.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Send a command string through Bluetooth to control a QN908X three-phase PWM.

Send a command string through Bluetooth to control a QN908X three-phase PWM.

About this demo

This demo is based on the Wireless UART example from the SDK available on Welcome | MCUXpresso SDK Builder selecting the QN908X board. 

The main idea of this demo is to be able to send commands from one device to another, it could be from a QN9080DK, a phone using our NXP application: IoT Toolbox or even an FRDM-KW41Z, this is possible because of the BLE protocol used in all our devices.

The end-device used is a QN9080DK, this board receives the message, does parsing and triggers a PWM function using the values sent from another device. This signal can be used in different applications, typically controlling smart lighting brightness and color, speed of motor controls and audio or video amplifiers. The goal of this demo is to implement a task for our FreeRTOS scheduler in order to be able to control a PWM while the BLE connection is still running and receive new incoming messages.

 

Video

Limitations

  1. We only interpret ON, OFF and a string of values for our 3 signal outputs.
  2. The string of values has to be in the following syntax: rXXX,gXXX,bXXX. An example of this could be r255,g130,b200.
  3. The max value should be 255 in order to achieve 100% of the duty cycle, for this example, we are using is at 100 Hz.
  4. The connection is not using pairing or bonding modes, so no device information is saved on the non-volatile memory due to this if the connection is lost we need to follow the initial connection procedure.
  5. The amount of bytes that can be sent is limited by the macro: #define gAttMaxMtu_c in the ble_constants.h file from the project, we recommend to leave it as it is.

 

Useful Links

Useful documentation is available in the SDK previously downloaded: <SDK Installation folder>...\SDK_2.2.1_QN908XCDK\docs

 

Link Description
https://www.nxp.com/webapp/Download?colCode=QN908x-DK  QN908xDK User’s Guide
Welcome | MCUXpresso SDK Builder  SDK Builder site
Wireless Connectivity  NXP Wireless Community
Connectivity Software: Implement tickless mode in FreeRTOS  Document for implementing a new task using OSA Abstraction layer of FreeRTOS
https://www.nxp.com/docs/en/nxp/data-sheets/QN908x.pdf QN908x Datasheet for pins functions

 

Required Items

Link Description
QN908x: Ultra-Low-Power Bluetooth Low Energy System on Chip (SoC) Solution | NXP  It is required at least one as an end-point.
Oscilloscope  An Oscilloscope to visualize the PWM.

Hardware Diagram

pastedImage_2.png

Step-by-Step Guide

  1. Download de QN908x SDK
  2. Download the attached .zip file.
  3. Import it into MCUXpresso, for the end node you should only use the qn908xcdk_wireless_uart_peripheral project.
  4. If you want to use a second QN board to send the commands it is required to also import the qn908xcdk_wireless_uart_central project.
  5. Once the projects are imported, we need to flash each board with a project and connect the PA9, PA10, and PA18 pins to our oscilloscope in order to visualize the signal.
  6. Connect the USB cables to the computer and open Teraterm with the following values: 115200, 8 bits, none,1 bit, none.
  7. Press the RESET Button (SW3) of the Peripheral board
  8. Press the Button1 (SW1) after the message: "Wireless UART starting as GAP Peripheral, press the role switch to change it.", an "Advertising" should appear.
  9. If a second QN board is used (central), we need to open a second Teraterm session and set it to the same Serial configurations from point 5.
    1. If an Android phone is used we need to have the IoT Toolbox application installed and select the Wireless UART example and connect to the Peripheral board using the interface.
  10. To pair the Central board to the Peripheral it is required to press the RESET Button (SW3) of the Central board while the Peripheral board is advertising and then Push the Button1 (SW1).
  11. Once the boards are connected, we need to paste the message to our terminal in order to be sent as one message.
  12. The message should be seen in the other board terminal.
  13. Send "ON" to activate the PWM functionality.
  14. Send "r255,g128,b64" to set the PWM pins to 100%, 50%, 25%.
  15. This signal must be displayed at 100Hz on the oscilloscope.
  16. Send "OFF" to deactivate the PWM functionality.

 

Further Information

  • The Demo is based on the Wireless UART example, The BleApp_ReceivedUartStream function is modified to compare de received strings.
  • The getValuesRGB converts the string into integer values to be assigned to the global variables red, green, blue.
  • Inside getValuesRGB we use the OSA abstraction layer for FreeRTOS to create the task using: OSA_TaskCreate and creating the task named: vfnTaskPWM.
  • vfnTaskPWM configures the timer and initializes the PWM values using the CTimer driver functions and starts the CTimers.

 

 

Results

1. After the QN9080 is flashed and in Advertising mode, we have to connect our Central device, Which in this case is an Android phone. In or Teraterm we should be able to see this message:

pastedImage_2.pngpastedImage_4.png

2. Then, we get the Connected status from our devices and we should be able to send the ON command and the RGB values, Teraterm indicates the integer values and the string received.

 

 

 

pastedImage_7.pngpastedImage_8.png

 

pastedImage_9.png

3. When we send the OFF command the PWM signals should be 0 V.

pastedImage_10.png

 

4. Here is another example:

 

pastedImage_3.png pastedImage_11.png

pastedImage_12.png

Labels (1)
Attachments
Comments

Dear Adrian Puga Candelario‌,

This document has superbly written, and I have a client who looking for exactly the same solution (only based on QN9090).
I would be glad if you could please re-upload the project file again. ("qn908xcdk_wireless_uart_peripheral2.zip 2.9 MB")
The file has been deleted from the NXP server, since this file may contain a virus or malware. 

Thanks in advance 

Kind regards,

Shai

100% helpful (2/2)
Version history
Last update:
‎05-03-2021 10:08 AM
Updated by: