Introduction
This firmware acts as proxy in between host and accelerometer. It fetches sampled acceleration data from ADXL345 in a real-time manner by using a Blackpill board (ARM STM32F401). The proxy asserts no sample is lost and each measurement is sampled equidistant. To operate the proxy refer to the py3dpaxxel API.
+------------+ +------------+ +------------+
| | | | | |
| HOST |--USB--| Controller |--SPI--| Sensor |
| | | (proxy) | | |
+------------+ +------------+ +------------+
This project is realized by
PlatformIO(compile, flash),CubeMxcode generator (for resource planing and device initialization) and thestm32piotool as glue in-between CubeMX code generator and PlatformIO.
The host to controller communication takes place by Virtual Com port in CDC mode. For more details refer to the host-api repository py3dpaxxel. It provides the python API to communicate with this firmware which can work as standalone command line script as well. The CLI interface allows to manipulate the controller as follows:
start/stop sampling (in streaming mode or up to specific limit of samples)
configure/reset device (output data rate, range, scale)
decode samples from controller
print samples or store in tabular separated values file
See also:
Python Host-API py3dpaxxel
OctoPrint plugin Octoprint Accelerometer
Read the Docs at 3dp-accelerometer.github.io
Prerequisites
The following steps use Poetry to install required tools and set up the environment. This is not a must but for convenience rather. All steps can be achieved manually without Poetry: develop, build, flash, generate documentation.
Workflow
Setup environment
Poetry
cd utils poetry shell poetry install
Manually: ensure
platformioandstm32pioare visible in the environment.
optional: initialize project for your desired IDE; i.e.
pio init --ide clionoptional: modify user code in the marked sections of the auto generated CubeMX code
optional: edit
cubemx.iocwith CubeMx, safe filegenerate code and patch existing code:
stm32pio generateoptional: run native unit tests with `pio test –environment native
optional: iterate development by returning to step 3
compile and flash controller:
pio run --target upload
If only flashing the latest firmware is your desire follow first and last step which essentially boils down to:
git clone https://github.com/3dp-accelerometer/controller.git
cd controller/utils
poetry shell
poetry install
cd ..
# attach stlink and controller to host as described in the subsequent section "Connecting Modules"
pio run --target upload
Connecting Modules
The controller (BlackPill) is attached to the HOST (i.e. your PC, OctoPrint server, …). It acts as proxy that shovels the data from the accelerometer so that each sample that is reported to the host, is sampled in an equidistant manner. A constant time separation in between samples is a key aspect for later Fourier transformation.
+------------+ +-----------------+ +------------+
| HOST | | BlackPill | | Accelero |
| | | STM32F401 | | meter |
| | +-----+ | | ADXL345 |
| post pro- |--USB-| PA12| USB_OTG_FS_DP | | |
| cessing | | PA11| USB_OTG_FS_DM | | |
| | +-----| | | |
| | | watermark EXTI2 |--PA2-----INT1--| |
| | | overrun EXTI3 |--PA3-----INT2--| |
+-----+------+ | |--PA4------!CS--| |
| | |--PA5------SCL--| |
U | |--PA6------SDO--| |
S | |--5V0------VCC--| |
B | |--GND------GND--| |
| optional | | +------------+
| for debugging | |
| | | +------------+
| | |--3V3------3V3--| STLink +---+
| | |--GND------GND--| programmer |USB|--+
| | SWDIO |--PA13---SWDIO--| +---+ |
| | SWCLK |--PA14---SWCLK--| | |
| | | +------------+ |
| | USER_KEY0 |--PA0--+ |
| | USER_LED0 |--PC13-+ |
| | RCC_OSC32_IN |--PC14-+ |
| | RCC_OSC32_OUT |--PC15-+ |
| | | |
| | USER_DEBUG0 |--PA1-- optional for debugging |
| | USER_DEBUG1 |--PB0-- optional for debugging |
| | MCO |--PA8-- optional for debugging |
| +-----------------+ |
+--------------------------------------------------------------------------+
References
Datasheets ./datasheets
PlatformIO BlackPill
PlatformIO stm32cube framework
Platformio with CubeMX
https://community.platformio.org/t/board-genericstm32h750vb-not-found/36441