document forumslader-logger project

This commit is contained in:
King Kévin 2017-07-22 01:11:53 +02:00
parent c54a4af550
commit 6add61fd1e
1 changed files with 103 additions and 13 deletions

116
README.md
View File

@ -1,4 +1,4 @@
This firmware template is designed for development boards based around [STM32 F1 series micro-controller](http://www.st.com/web/en/catalog/mmc/FM141/SC1169/SS1031).
The forumslogger (or forumslader-logger) is a small man-in-the-middle board for logging [forumslader automatiklader](http://www.forumslader.de/automatiklader/) data.
project
=======
@ -6,24 +6,108 @@ project
summary
-------
*describe project purpose*
The [forumslader](http://www.forumslader.de/) [automatiklader](http://www.forumslader.de/automatiklader/) is a power manager for bicycles.
It used the power generated by a dynamo to charge Li-Ion battery and can also provide 12V (for lights) and 5V (to charge phones over USB).
The automatiklader can also be enhanced with a [bluetooth module](http://www.forumslader.de/automatiklader/erweiterungen/bluetooth/), allowing a phone to log precise speed (using the dynamo activity), battery charge, and other values using the [forumslader Andoird app](https://play.google.com/store/apps/details?id=com.duringsoft.forumslader).
Sometimes you don't have your phone around to log the data though, but you still want the data to be recorded.
This project covers this case, always logging the forumslader data no matter if a phone is present or not.
technology
----------
*described electronic details*
The phone connects to the forumslader using Bluetooth.
The app uses the Bluetooth Serial Port Profile (SPP) to transfer data (see protocol section for an example of data sent by the forumslader).
The forumslader board uses an off-the-shelf bluetooth module.
Thus instead of using Bluetooth to get the forumslader data (like the phone would do), we will remove the forumlader Bluetooth module, connect our logger board directly to the underlying serial port, and our board will have a Bluetooth module so to forward the data again to the phone.
Since our board sits between the forumslader and phone it can log the data all the time.
The logged data is saved onto a micro-SD card for virtually unlimited storage space.
Each time the forumslader wakes up and starts sending data a new file containing the logged data is created.
The internal Real Time Clock (RTC) is used to provide date and time, which is used in the file name of the logged data.
In addition to the forumslader a GPS module is added.
This allows to automatically set the correct time in the RTC (once the GPS has a fix).
The GPS data is also logged (into the same file).
This allows to add a timestamp to the forumslader data (every second the GPS sends the UTC time) and log the actual route cycled.
While GPS also provides speed, the forumslader data based on the dynamo is much more precise (similar applies to the distance).
On top of the forumslader commands, the logger provides additional commands to list, retrieve, and delete the logged data files.
state
-----
working:
- SD card read and write
- file read and write (using fatfs)
- GPS data parsing
- RTC date and time synchronisation to GPS time
TODO:
- log forumslader data
- log GPS data
- provide Bluetooth commands to list, retrieve, and delete files
The forumslader data does not include timestamps.
The data is just sent periodically.
This periodicity is used to calculated the current speed, also using the provided number of dynamo steps recorded.
Thus providing the logged data all at once to the forumslader app will lead to erroneous speed data.
The other information will remain consistent (e.g. distance, battery status, ...) since only the last values are used (this information is not dependent on the periodicity).
protocol
--------
The forumslader data is NMEA-0183 formatted (without checksum).
The app sends
$FLT,5;
TODO check what device responds
The device sends periodically data (every 50-100 ms?):
$FL5,00c000,0,0,4130,4133,4135,-26,0,305,1,219,200,6750,14077;
$FLB,850,101652,219,0;
$FL5,00c000,0,0,4130,4133,4133,-15,0,305,1,218,200,6750,14077;
$FLC,4,258,269,8,9,0;
$FL5,00c000,0,0,4131,4133,4135,-18,0,305,1,217,200,6750,14077;
$FLB,850,101651,219,0;
$FL5,00c000,0,0,4130,4133,4135,-26,0,305,1,216,200,6750,14077;
$FLC,5,66086,100,718,28,31897091;
$FL5,00c000,1,3,4130,4133,4135,-25,0,305,1,240,211,6750,14077;
$FLB,850,101649,221,0;
$FL5,00c000,1,17,4130,4133,4133,-28,0,306,1,240,228,6750,14077;
$FLC,0,16198,49,200,2146,76;
$FL5,00c000,1,17,4130,4131,4133,-29,0,307,1,240,245,6750,14077;
$FLB,850,101652,219,0;
850 is ???
101652 is the pressure in centi-hectopascal
219 is the altitude in dm
0 is the gradient in decidegree
$FLC,4,258,269,8,9,0;
???
$FL5,00c000,0,0,4130,4133,4135,-24,0,305,1,232,260,6750,14077;
00c000 is the status (hex, seperate tab)
the 1st 0 is the switching step in steps
the 2nd 0 is the speed in 0.6 km/h steps
4130 is the cell 1 voltage in mV
4133 is the cell 2 voltage in mV
4135 is the cell 3 voltage in mV
-24 is the accu current in mA
the 3rd 0 is the consumer power in 0.0124 Watt steps (dependant on another parameter)
1 is the cinsumer current in mA
232 is the temperature in F
260 is the micropulsecounter
6750 is the pulsecounter
board
=====
The current implementation uses a [core board](https://wiki.cuvoodoo.info/doku.php?id=stm32f1xx#core_board).
The underlying template also supports following board:
- [Maple Mini](http://leaflabs.com/docs/hardware/maple-mini.html), based on a STM32F103CBT6
- [System Board](https://wiki.cuvoodoo.info/doku.php?id=stm32f1xx#system_board), based on a STM32F103C8T6
- [blue pill](ihttps://wiki.cuvoodoo.info/doku.php?id=stm32f1xx#blue_pill), based on a STM32F103C8T6
- [core board](https://wiki.cuvoodoo.info/doku.php?id=stm32f1xx#core_board), based on a STM32F103C8T6
The firmware is for a [STM32 F1 series micro-controller](http://www.st.com/web/en/catalog/mmc/FM141/SC1169/SS1031) (i.e. STM32F103C8T6).
Currently a [core board](https://wiki.cuvoodoo.info/doku.php?id=stm32f1xx#core_board) is used for development since it provides a micro-SD card slot.
In the end a [blue pill](ihttps://wiki.cuvoodoo.info/doku.php?id=stm32f1xx#blue_pill) will be used so it can fit in the bicycle frame.
**Which board is used is defined in the Makefile**.
This is required to map the user LED and button provided on the board
@ -33,7 +117,10 @@ connections
Connect the peripherals the following way (STM32F10X signal; STM32F10X pin; peripheral pin; peripheral signal; comment):
- *list board to preipheral pin connections*
- USART1: forumslader (remove the Bluetooth module)
- USART2: Bluetooth module (i.e. HC-05)
- USART3: GPS module (i.e. u.blox NEO-6M with small patch antenna)
- SPI1: micro-SD card slot
All pins are configured using `define`s in the corresponding source code.
@ -47,6 +134,9 @@ The source code uses the [libopencm3](http://libopencm3.org/) library.
The projects is already a git submodules.
To initialize and it you just need to run once: `git submodule init` and `git submodule update`.
To read and write files on the FAT formatted micro-SD card the [FatFs](http://elm-chan.org/fsw/ff/00index_e.html) library is used,
The files are already included in the project.
firmware
--------
@ -66,7 +156,7 @@ The `bootloader` is started first and immediately jumps to the `application` if
The main application should be implemented in `application.c`.
It is up to the application to advertise USB DFU support (i.e. as does the provided USB CDC ACM example).
The `bootlaoder` image will be flashed using SWD (Serial Wire Debug).
The `bootloader` image will be flashed using SWD (Serial Wire Debug).
For that you need an SWD adapter.
The `Makefile` uses a Black Magic Probe (per default), or a ST-Link V2 along OpenOCD software.
To flash the `booltoader` using SWD run `make flash_booloader`.