SLAAE50A January 2022 – October 2022 MSP430FR2533 , MSP430FR2533
A. Liquid Level Height Calculation
To show level height on the LCD, the application must measure the capacitance value at different liquid level heights. As Equation 6 shows, measure LTA and COUNT, and then calculate the .
By measuring multiple sets of data, Figure 3-6 shows the relationship between the liquid level height and the capacitance value change. According to the fitting result, the relationship between the liquid level height and the is: Y = 341.5X − 34.249.
B. Flow chart
The software design mainly includes three parts: capacitance detection, LCD display liquid level height and I2C communication. Figure 3-7 shows the overall code design flow chart.
When the program starts, the MCU initializes the IO ports, clock, etc. Then the LCD displays “Start” to indicate that the measurement can be performed. After a short delay, the measurement is started through CAPT_appStart(), and the measurement function is called back in APP_init(). The APP_init() function includes continuously scanning each channel, calculating the height in real time according to the scanned data, and displaying it through the LCD.
C. Calibration and Communication
Communication with the host MCU is recommended for development using the provided UART and I2C library functions. First of all, the default code generated by the GUI will complete IO configuration and clock configuration of the UART (eUSCI_A0) and I2C (eUSCI_B0) in the BSP_configureMCU() function. Therefore, it is only necessary to configure the communication module and write the communication protocol. This design uses the I2C to communicate with the host, which can send commands to perform calibration and receive data from the slave. The specific operation steps are as follows:
Master | Host |
---|---|
pBuffer[0]-[3] | Not care |
pBuffer[4] = 01 | Do calibration |
pBuffer[5] = 01 | Save height data to pBuffer[6] |
pBuffer[7] = 01 | Save code version to pBuffer[8] |
pBuffer[9] = 01 | Bootloader, software update |
When the MCU receives the data sent by the host, if the fourth bit of the data is 0x01, the MCU performs calibration. If the fifth bit of the data is 0x01, the height data is stored in pBuffer[6], and the host can read it. If the seventh bit is 0x01, the host can read the version number from pBuffer[8]. If the ninth bit is 0x01, that is for bootloader, the software can be updated.