Comments (17)
Hello, I have started a PR for this topic #141
Feel free to comment and propose solution and idea.
from makair.
The data snapshot (sent each 1/100s)
Data is composed with 9 fields, each field is written in binary to compress the data flow (as these exchange will not be used to be human readable).
-
D:
to start the line -
The MCU serial ID, to identify the machine (96bits)
it can be retrieved at*(uint32_t*)(UID_BASE)
:
Serial.println("UID [HEX] : "+String(*(uint32_t*)(UID_BASE), HEX)+" "+String(*(uint32_t*)(UID_BASE+0x04), HEX)+" "+String(*(uint32_t*)(UID_BASE+0x08), HEX));
-
the Systick of the STM32 (64bits)
-
centile number (16bits)
-
current pressure (16bits)
-
phase and sub-phase number encoded as it :
- Inspiration - inspi = 17
- Inspiration - hold = 18
- Expiration - expi = 68
- Expiration - hold = 72
So the phase is coded on the 4 high bits, and the subphase is coded on least 4 bits
-
blower valve position (8 bits)
-
patient valva position (8 bits)
-
blower rpm (8 bits)
-
battery level (8 bits)
all theses fields are separed by a tab char.
from makair.
The machine state snapshot, sent at the beginning of a cycle.
This message summarize the machine state and the respiration metric of the last cycle (called previous cycle)
-
S:
to start the line -
The MCU serial ID, to identify the machine (96bits)
-
the cycle number (32 bits)
-
consigne plateau (8 bits)
-
consigne Peep (8 bits)
-
consigne Breath Rate per minute (8 bits)
-
consigne Patient weight (or volume) (8 bits)
-
previous peak pressure (8 bits)
-
previous plateau pressure (8 bits)
-
previous peep pressure (8 bits)
-
current alarms (the list of the alarms triggered during the previous cycle)
-
previous alarms (the list of the alarms wich were existing at the beginning of the previous cycle)
-
EOL mark (since the alarms list can be empty, this mark is used to define the real end of the message)
from makair.
alarm Trap
-
T:
to start the line -
The MCU serial ID, to identify the machine (96bits)
-
the Systick of the STM32 (64bits)
-
centile number (16bits)
-
current pressure (16bits)
-
phase and sub-phase number
-
the cycle number (32 bits)
-
the alarm code
-
the alarm level
-
triggered / untriggered toggle encoded as it :
if triggered => the 4 high bits are HIGH and the 4 least are LOW (11110000)
if suppression msg => the 4 high bits are LOW and the 4 least are HIGH (00001111)
-
wanted value
-
measured value
-
duration of the alarm in cycle count (0 for trigger message)
from makair.
- The MCU serial ID, to identify the machine (96bits)
it can be retrieved at*(uint32_t*)(UID_BASE)
:
Serial.println("UID [HEX] : "+String(*(uint32_t*)(UID_BASE), HEX)+" "+String(*(uint32_t*)(UID_BASE+0x04), HEX)+" "+String(*(uint32_t*)(UID_BASE+0x08), HEX));
FYI, one other way could be to use LL:
#include "stm32yyxx_ll_utils.h"
...
Serial.printf("%x%x%x\n", LL_GetUID_Word0(), LL_GetUID_Word1(), LL_GetUID_Word2());
from makair.
all the pressure values are in mmH2O, so the typical plateau is around 300, and the peep around 80
from makair.
A quick look at UART performance, with HardwareSerial lib :
- There is no DMA implemented
- There is no hardware FIFO (because the CPU is DMA capable...)
- There is a 64 bytes software FIFO. It means an interrupt is triggered after each byte confirmed sent to push the next byte into TX register. Todo : look at this interrupt priority...
At 115200 baud:
- Transmission of 1 to 62 bytes take 50µs CPU time when calling Serial6.print (constant time)
- If you want to send X bytes with X greater than 62 bytes, calling Serial6.print takes 50µs+(X-62)*95µs (mean, see measures)
Measures at 115200 bauds:
byte count | blocking time | time on tx line |
---|---|---|
1 | 50 µs | |
62 | 50µs | |
128 | 6.1ms | 12.1 ms |
256 | 18.2ms | 24.2ms |
Effective max bandwith with the interrupt overhead is 10.5 ko/s (without any other preemptive interrupts)
from makair.
Buffer size can be increased:
https://github.com/stm32duino/Arduino_Core_STM32/blob/61b14ecb4ce640bbb37b733791b51aa28d906e56/cores/arduino/HardwareSerial.h#L43-L48
IRQ prio is 1 so not advised to increase to 0 as 0 is used for the systick :
https://github.com/stm32duino/Arduino_Core_STM32/blob/61b14ecb4ce640bbb37b733791b51aa28d906e56/cores/arduino/stm32/uart.h#L53
from makair.
Not easily... I tried #define SERIAL_TX_BUFFER_SIZE 200
before including anything else, but no way to compile in the order I want.
from makair.
Use this:
https://github.com/stm32duino/wiki/wiki/Customize-build-options-using-build_opt.h
from makair.
@fpistm How does it work with Arduino CLI?
It seems I already have build.xSerial=-DHAL_UART_MODULE_ENABLED
in my Arduino15/packages/STM32/hardware/stm32/1.8.0/platform.txt
file. If I want to add another option like -DSERIAL_RX_BUFFER_SIZE
, where should I put it?
from makair.
Add a file named build_opt.h
in your 'sketch' folder, which is (if I'm not wrong) : src/software/firmware/srcs
Then in this file add -DSERIAL_TX_BUFFER_SIZE=256
Note that I used a "power of 2" buffer size which is recommended for ease modulo operation.
from makair.
I've tested and redefinition works as expected.
I've made a mistake in my previous post to the content, I've forgot an '=', I've edited my comment.
If you need more support I'm on slack, do not hesitate 😉
from makair.
Tested, it works. Nice.
That's kind of weird to have a header file in the srcs directory... But it is working. Don't forget to rm -rf /tmp/arduino-*
before compiling again.
from makair.
I know .h is not a good extension but Arduino IDE could only create file with .h, .hpp, .c, .cpp and .ino extension. That's why .h is used.
For the clean you could use arduino-cli cache clean before the first build with a build_opt.h file
from makair.
As a note discussed w/ @dsferruzza this morning: we should go for a pure-binary protocol, where the receiver parses the packets by simple binary array dereferencing. The first 8 bits should contain the protocol version (eg. V1 as 00000000, V2 as 00000001, etc.). This way the receiver can handle version changes smoothly and support multiple firmware / board versions.
from makair.
Hi, we are a team that needs your feedback to complete our idea.
Please visit our pages and comment on it.
github
gitlab
from makair.
Related Issues (20)
- State management - reset & initialize HOT 1
- Buzzer code review
- Bill of materials HOT 3
- ESD protection
- Where I can find SCH and PCB files ?
- Feronyl - Spécialiste en injection de pièces plastiques techniques / Specialist in injection moulding of technical parts in plastic
- Makair MotherBoard
- Use of pneumatic air line to replace the blower. HOT 11
- Initial contribution of a system design HOT 4
- Motherboard of makers for life ventilator
- Move the sonarcloud directory in a sub directory, or hide it?
- PCB ?
- Control: Graph rendering issues HOT 2
- Question about UI design HOT 2
- BLDC for Blower
- Request to join "Makers For Life"
- MassFlow using DP and Venturi
- medical standard compliance for alarms (60601-1-8)
- Create a CODE_OF_COUNDUCT.md and a CONTRIBUTING.md HOT 2
- Blower motor details HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from makair.