King Kévin b8cc7d7591 | ||
---|---|---|
lib | ||
libopencm3@cb0661f81d | ||
.gitignore | ||
.gitmodules | ||
Doxyfile | ||
LICENSE.txt | ||
README.md | ||
Rakefile | ||
application.c | ||
application.ld | ||
bootloader.c | ||
bootloader.ld | ||
global.c | ||
global.h |
README.md
This firmware template is designed for development boards based around STM32 F1 series micro-controller.
project
summary
describe project purpose
technology
described electronic details
board
The current implementation uses a core board.
The underlying template also supports following board:
- Maple Mini, based on a STM32F103CBT6
- System Board, based on a STM32F103C8T6
- blue pill, based on a STM32F103C8T6
- black pill, based on a STM32F103C8T6
- core board, based on a STM32F103C8T6
- ST-LINK V2 mini, a ST-LINK/V2 clone based on a STM32F101C8T6
- USB-Blaster, an Altera USB-Blaster clone based on a STM32F101C8T6
Which board is used is defined in the Makefile. This is required to map the user LED and button provided on the board
The ST-LINK V2 mini clone has SWD test points on the board.
Because read protection is enabled, you will first need to remove the protection to be able to flash the firmware.
To remove the read protection (and erase flash), run rake remove_protection
while a SWD adapter is connected.
The Altera USB-Blaster clone has a pin header for SWD and UART1 on the board.
SWD is disabled in the main firmware, and it has read protection.
To be able to flash using SWD (or the serial port), the BOOT0 pin must be set to 1 to boot the system memory install of the flash memory.
To set BOOT0 to 1, apply 3.3 V on R11, between the resistor and the reference designator, when powering the device.
The red LED should stay off while the green LED is on.
Now you can remove the read protection (and erase flash), run rake remove_protection
while a SWD adapter is connected.
ST 339 is a quad voltage comparator. I don't know what it compares.
LN 393 is a dual comparator. I don't know what it compares.
there is also an external reference (REF1). this is probably for the MAX1247 (only the MAX1246 has an internal voltage reference).
MAX1247 is a 4-channel 12-bit ADC. it is used to measure the temperatures.
there are four 2.2 kOhm thermistors. one side is connected to REF1, the other to a MAX1247 channel.
- TH4: on the sink, connected to CH2 through R8 (2702), and COM through R4
- TH3: in the tube, connected to CH3 through R7 (2702), and COM through R3
- in the top of the tub heating bed, connected to CH0
- in the bottom of the tub heating bed, connected to CH1
heating block MBLK-008:
- NC
- VCC
- LN393 OUTPUT-A
- MAX1247 DIN
- MAX1247 DOUT
- MAX1247 SCLK
- MAX1247 nCS
- ST339 OUTPUT-3
- LK1 jumper (missing), other side connected to ground
- LK2 jumper (missing), other side connected to ground
- LK3 jumper (present), other side connected to ground
- LK4 jumper (present), other side connected to ground
- ground
- LN393 OUTPUT-A through 10 kOhm resistor (not sure what this is used for, probably not just to pull)
heated lid, 12 kOhm NTC thermistor, 3-pin (pin 1 has notch):
- thermistor lead 1
- thermistor lead 2
- chassis
thermocouple (e.g. peltier elements) controller board, MBLK019, 2x3 pin plug (IDC numbering):
- red, VCC
- red/green, sink to control IC/TR 2/6
- red/black, sink to control IC/TR 1/4
- red/blue, connected to pin 6
- red/brown, sink to control IC/TR 3/5
- black, connected to pin 4
front control panel, 1x5 connector:
- ground
- play/pause indicator, green LED anode
- play/pause indicator, orange LED anode
- power indicator, red LED
- play/pause button, connected to ground when pressed
fan:
- red: 12V
- black: ground
MBLK-078, power + heater, 2x2 connector:
- red, 12V
- black, ground
- yellow/red, optocoupler anode for triac controlling the lid heater
- yellow/black, optocoupler cathode for triac controlling the lid heater
SSD1306 OLED screen:
- GND
- VDD
- SCK
- SDA
power for thermocouples
use a 12V xA power supply. ideally it would be an adjustable constant current supply (probably what the original power supply was), but using PWM on constant voltage is good enough for thermocouples, even if less efficient.
I created a custom board with:
- 2 relays to act as h-bridge, allowing to invert the voltage on the thermocouples
- 1 power MOSFET, to PWM the power
- 1 optocoupler, to control the MOSFET
- an IDC 2x5 connector, to re-use to cable
relay 1:
- COM: thermocouple yellow
- NC: OUT
- NO: 12V dedicated power supply
- VCC: 5V
- GND: ground
- IN: IDC pin 3,4
relay 2:
- COM: thermocouple orange
- NC: OUT
- NO: 12V dedicated power supply
- VCC: 5V
- GND: ground
- IN: IDC pin 5,6
power nMOS (FQP30N06L, 60V 32A):
- gate: PC817 optocoupler source, pulled low (100 kOhm to ground)
- drain: OUT from relay
- source: ground
IDC 2x5 connector:
- 1,2: 5V to power the relays and optocoupler
- 3,4: input to relay 1, active low (when sinking)
- 5,6: input to relay 2, active low (when sinking)
- 7,8: input optocoupler controlling MOSFET, active low (when sinking)
- 9,10: ground
PC817 optocoupler:
- source: power nMOS gate
- drain: 12V dedicated power supply
- anode: 5V though 330 Ohm
- cathode: IDC pin 7,8
connections
All pins are configured using define
s in the corresponding source code.
Connect the peripherals the following way.
heating block MBLK-008 CO IDC 7x2:
- NC
- 3.3V
- PB3
- PB15 SPI2_MOSI
- PB14 SPI2_MISO
- PB13 SPI2_SCK
- PB12 SPI2_NSS
- PB4
- PB5
- PC14
- PC15
- PB1
- ground
heated lid, 12 kOhm NTC thermistor, 3-pin (pin 1 has notch):
- PA0/ADC1_CH0, pulled up to 5.0V by 10 kOhm resistor
- ground
- earth
thermocouple controller board, MBLK019, 2x3 IDC connector:
- 3.3 V
- PA1
- PA2
- PA3
- PA4
- ground
front panel:
- ground
- PA5, with 330 Ohm inline resistor
- PA6, with 330 Ohm inline resistor
- PA7, with 330 Ohm inline resistor
- PB0
fan:
- 12V front board power supply
- power nMOS drain power nMOS source. ground power nMOS gate. PA15, pulled up externally to 5V
MBLK-078, power + heater, 2x2 connector:
- LM7805 in
- ground
- 5V though 330 Ohm
- PA10
SSD1306 OLED screen:
- ground
- 3.3 V
- PB6/I2C1_SCL, pulled up to 3.3V by external 10 kOhm resistor
- PB7/I2C1_SDA, pulled up to 3.3V by external 10 kOhm resistor
thermocouple power supply control board. IDC 2x5:
- 1,2: 5V
- 3,4: PB10
- 5,6: PB11
- 7,8: PB9
- 9,10: ground
code
dependencies
The source code uses the libopencm3 library.
The projects is already a git submodules.
It will be initialized when compiling the firmware.
Alternatively you can run once: git submodule init
and git submodule update
.
firmware
To compile the firmware run rake
.
documentation
To generate doxygen documentation run rake doc
.
flash
There are two firmware images: bootloader
and application
.
The bootloader
image allows to flash the application
over USB using the DFU protocol.
The bootloader
is started first and immediately jumps to the application
if it is valid and the DFU mode is not forced (i.e. by pressing the user button on the board or requesting a DFU detach in the application
).
The application
image is the main application and is 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 bootloader
image will be flashed using SWD (Serial Wire Debug).
For that you need an SWD adapter.
The Makefile
uses a ST-Link V2 programmer along OpenOCD software (default), or Black Magic Probe.
To flash the booltoader
using SWD run rake flash_booloader
.
If the development board uses the CKS32 chip STM32 alternative, use CPUTAPID=0x2ba01477 rake flash_booloader
.
Once the bootloader
is flashed it is possible to flash the application
over USB using the DFU protocol by running rake flash
.
To force the bootloader to start the DFU mode press the user button or short a pin, depending on the board.
It is also possible to flash the application
image using SWD by running rake flash_application
.
debug
SWD also allows to debug the code running on the micro-controller using GDB.
To start the debugging session run rake debug
.
USB
The firmware offers serial communication over USART1 and USB (using the CDC ACM device class).