Download as pdf or txt
Download as pdf or txt
You are on page 1of 34

Week 4 Report

July 5, 2023

Week 4 Report July 5, 2023 1 / 34


Outline

1 MAXREFDES70 reference kit Initialization Details


Interrupt Details
Introduction
Calculation performed by MCUs
Comparison with Ti’s offering
3 Calibration
MAX35101 Analog frontend
MAX35101 SPI Command Interface 4 Accuracy
MAX35101 Measurement cycle 5 Kalman filters diffculties and some
2 Analyzing reference implementation alternatives
Hardware Design Kalman filter modeling
Software Implementation Alternatives

Week 4 Report July 5, 2023 2 / 34


MAXREFDES70 reference kit

MAXREFDES70 reference kit

Week 4 Report July 5, 2023 3 / 34


MAXREFDES70 reference kit Introduction

Introduction to MAXREFDES70 refrence kit

High-Precision, Long-Battery Life


Heat/Flow Meter refrence design
Using ultrasonic technology
Include a MAX35101 analog frontend,
MAX4701 analog switch, a Silicon Labs
EFM32ZG110F32-QFN24 Host
microcontroller and a 16x3 LED LCD
Include a refrence firmware for the host
microcontroller.

Week 4 Report July 5, 2023 4 / 34


MAXREFDES70 reference kit Comparison with Ti’s offering

Comparison with Ti’s offering

EVM430-FR6047 MAXREFDES70
Manufacture Ti Maxim Intergrated
Host MCU MSP430FR6xxx Silicon Labs EFM32ZG110F32
Analog frontend Built in MAX35101
Design All in one SOC Separated component connected via SPI
Expansion Easily accessible header Header protected in case, fewer pins
Noise reduction No Yes
Specialies real time clock Tamper resistance, RTC, scheduling
Toolchain support Ti-CGT and GCC GCC
Documents Available Available

Week 4 Report July 5, 2023 5 / 34


MAXREFDES70 reference kit MAX35101 Analog frontend

MAX35101 Analog frontend

Analog frontend used to interface with


transducer and process measured data
Have built in flash, register,RTC and
tamper resistance
Can be setup to measure with predefined
cycle an signal MCU when done
Connected to host micro controller via SPI
Controlled by sending specialized
command

Week 4 Report July 5, 2023 6 / 34


MAXREFDES70 reference kit MAX35101 Analog frontend

MAX35101 SPI Command Interface

Have 2 field, Opcode and Address


Depending on the command, each field will hold different command
Command type Opcode field Address field Effects
Execution Command’s opcode None Command executed
Register read 0xB0 to 0xFF None Value of register sent
Register write 0x30 to 0x43 None Write to register
Flash memory read 0x90 0x0000 to 0xFFFF Read from flash memory
Flash memory write 0x10 0x0000 to 0xFFFF Write to flash memory
Block Erase 0x13 0x0000 to 0xFFFF Erase region of flash

Week 4 Report July 5, 2023 7 / 34


MAXREFDES70 reference kit MAX35101 Analog frontend

MAX35101 Measurement cycle

Week 4 Report July 5, 2023 8 / 34


Analyzing reference implementation

Analyzing reference kit in details

Week 4 Report July 5, 2023 9 / 34


Analyzing reference implementation Hardware Design

Hardware Design

Separated chip connected together via SPI bus


Most of the heavy measurement and calculation works is done by MAX35101 chip
Beside standard SPI connection, the MAX35101 also connect with host microcontroller
with INT pin in order to signal event completionas well as WDT pin to communicate
watchdog status to MCU
Allow MCU to enter low power mode unless an event is triggerd

Week 4 Report July 5, 2023 10 / 34


Analyzing reference implementation Hardware Design

Hardware connection diagram between chips

Week 4 Report July 5, 2023 11 / 34


Analyzing reference implementation Software Implementation

Software Implementation

main() begins with initializing the host and send configuration info to MAX35101
while(1) section only execute a state machine to control a screen
Most of calculation only happens when the MCU sees the INT pin got asserted by
MAX35101
This action trigger an interrupt, which is where the important bit resides

Week 4 Report July 5, 2023 12 / 34


Analyzing reference implementation Software Implementation

Initialization Details

main() begins with initialize the main MCU and setup SPI bus and GPIO for built in
buttons as well as INT pin
Next, it blinds reset the MAX35101 and calls a different init routine which init the
MAX35101
Details of this routine will be explained in next slide
Then it set the MAX35101 to periodically measure data and enter while(1).

Week 4 Report July 5, 2023 13 / 34


Analyzing reference implementation Software Implementation

MAX35101 Configuration details

Name Address Config hex Meaning


TOF1 0x38 0x1311 launch 19 pulses,
freq:1Mhz, stop at rising slope,
bias time 122 us
TOF2 0x39 0xA3F2 6 measured hits
select wave 7 to measure t2
delay between measurements: 19.97ms
512us timeout

Week 4 Report July 5, 2023 14 / 34


Analyzing reference implementation Software Implementation

MAX35101 Configuration details

Name Address Config hex Meaning


TOF3 0x3A 0x0809 Hit 1 Wave Select: Wave 2
Hit 2 Wave Select: Wave 9
TOF4 0x3B 0x0A0B Hit 3 Wave Select: Wave 10
Hit 4 Wave Select: Wave 11
TOF5 0x3C 0x0C0D Hit 5 Wave Select: Wave 12
Hit 6 Wave Select: Wave 13
TOF6 0x3D 0x0048 Upstream offset: 72 LSB
TOF7 0x3E 0x0048 Downstream offset: 72 LSB

Week 4 Report July 5, 2023 15 / 34


Analyzing reference implementation Software Implementation

Interrupt Details

The reference source have 2 interrupt source, GPIO interrupt and timer interrupt
The timer interrupt routine only increment a timer counter.
The GPIO interrupt routine lives in GPIO EVEN IRQHandler()
GPIO EVEN IRQHandler() check the GPIO interrupt flag to see if the interrupt come
from the INT pin assertion or not
If this is the case, it will go to calculation routine to calculate velocity and volumetric flow.

Week 4 Report July 5, 2023 16 / 34


Analyzing reference implementation Software Implementation

GPIO Interruption routine details

The Interrupt routine first check the GPIO interrupt flag


If the GPIO pin trigger the interrupt is wired to button, it will activate a debouncing
routine to see if it is a real press and react accordingly
If the GPIO pin trigger the interrupt is wired to the INT pin of MAX35101, it will query
the interrupt status of MAX35101.
If the interrupt status indicate a successful measure, it will query the ∆t calculated by
MAX35101 and call Calculate Flow Parameters() to calculate flow parameters and
store it.

Week 4 Report July 5, 2023 17 / 34


Analyzing reference implementation Software Implementation

Calculation performed by MCUs


Calculate Flow Parameters() calls 2 functions:Calculate TOF Velocity() and
Calculate Volumetric Flow()
Calculate TOF Velocity() function looks up the speed of sound in water using
temperature measured with linear interpolation and calculate the velocity of water with
this formula
∆tc 2
v= (1)
2L
Calculate Volumetric Flow() then takes the result of Calculate TOF Velocity()
and calculate volumetric flow with this formula
initial volumetric flow = v πr 2 (2)
. After that, Calculate Volumetric Flow() looks up correctional gain value and
compute the actual flow
actual volumetric flow = initial volumetric flow ∗ correctional gain (3)
Week 4 Report July 5, 2023 18 / 34
Calibration

Calibration

Week 4 Report July 5, 2023 19 / 34


Calibration

Calibration
Calibrate the MAX35101 timer can be
done automatically by sent a calibration
command to it
According to documents from Maxim
Integrated, calibration of the meter can be
done by creating volumetric correction
gain table used in formula (3)
This table can be created by measuring
with reference meter 24 time with 24
different, increasing flow rate together and
calculate the offset gain needed
This table can be written to
VOLUMETRIC FLOW CORRECTION TABLE
array in LookUpTable.h
Week 4 Report July 5, 2023 20 / 34
Accuracy

Accuracy

Week 4 Report July 5, 2023 21 / 34


Accuracy

Accuracy

Accuracy of meter is fluctuated according


to the range of water flow
According to Maxim Integrated, the error
of meter stays around 0.8% with their own
testing

Week 4 Report July 5, 2023 22 / 34


Kalman filters diffculties and some alternatives

Kalman filter model

Week 4 Report July 5, 2023 23 / 34


Kalman filters diffculties and some alternatives Kalman filter modeling

Problem with modeling the initial state

Due to lack of data, the model for the initial state have few problems as stated below:
We only have the velocity of the water flow. This is a difficult to model only the velocity
of the flow as a 1x1 matrix for the filter.
Attempts were made to make the model has the inital state as a 2x1 matrix. But not yet
known what is the derivative of velocity.
Most of the papers we encountered were mostly using a matrix 2x1 to represent the initial
state. And very little information about the model we are working with, which is
ultrasonic water flow.

Week 4 Report July 5, 2023 24 / 34


Kalman filters diffculties and some alternatives Kalman filter modeling

Problem with modeling the initial state

There is a paper about ultrasonic water flow applied with Extended Kalman filter. But:
It use another factor with velocity, which is temperature.
Since our model does not measure temperature, we cannot extend this idea further unless
we know what is the second state variable for the model.
Since there’s currently no data on the second state variable. Our sample code could not
be used.

Week 4 Report July 5, 2023 25 / 34


Kalman filters diffculties and some alternatives Alternatives

Some possible alternatives

MAX35101
Hardware digital filter
Software digital filter

Week 4 Report July 5, 2023 26 / 34


Kalman filters diffculties and some alternatives Alternatives

MAX35101

As stated in the documentation:


the MAX35101 provides noise suppression
to prevent erroneous edge detection using
early edge detection technique while
calculating the ratio tt12
This is what we would recommend using
since it’s already has the noise suppression
which could act as a digital filter.
Also the highest time-to-digital conversion
accuracy (20ps) on the market.

Week 4 Report July 5, 2023 27 / 34


Kalman filters diffculties and some alternatives Alternatives

MAX35101

As stated in the documentation:


the MAX35101 provides noise suppression
to prevent erroneous edge detection using
early edge detection technique while
calculating the ratio tt12
This is what we would recommend using
since it’s already has the noise suppression
which could act as a digital filter.
Also the highest time-to-digital conversion
accuracy (with typical value of 20 ps)

Week 4 Report July 5, 2023 28 / 34


Kalman filters diffculties and some alternatives Alternatives

Hardware filter

We could design a hardware filter or use another filter chip to process data. Some examples
are listed here:
HSP43220: a linear phase low pass decimation filter which is optimized for filtering narrow
band signals in a broad spectrum of a signal processing applications. Use FIR filter.
SM5846AP is a multi-function digital filter that incorporates 4/8 times oversampling
digital audio signal reproduction, digital deemphasis, digital attenuation and soft mute
functions. Use IIR filter.
Further reading about this section is required.

Week 4 Report July 5, 2023 29 / 34


Kalman filters diffculties and some alternatives Alternatives

Software filter

Another approach is using the library CMSIS


for signal processing in embedded applications.

Could be used to implement various filters.


Available only to Cortex-M micro
controller. So EFM32, which is what we
work with, is suitable, but computation
operation could be limited due to its low
performance compared with other M4 or
M7 cores.

Week 4 Report July 5, 2023 30 / 34


Kalman filters diffculties and some alternatives Alternatives

Performance Comparison

Week 4 Report July 5, 2023 31 / 34


Kalman filters diffculties and some alternatives Alternatives

Suggestions

Using a M3 core micro controller, computation speed would be better.

Week 4 Report July 5, 2023 32 / 34


Kalman filters diffculties and some alternatives Alternatives

Flow rate result

Week 4 Report July 5, 2023 33 / 34


Kalman filters diffculties and some alternatives Alternatives

Error result

Week 4 Report July 5, 2023 34 / 34

You might also like