stm32f1/README.md

278 lines
8.6 KiB
Markdown
Raw Normal View History

2017-04-15 13:58:39 +02:00
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).
project
=======
summary
-------
2016-08-14 20:25:55 +02:00
*describe project purpose*
technology
----------
2016-08-14 20:25:55 +02:00
*described electronic details*
2016-01-29 12:12:04 +01:00
board
=====
2017-04-03 13:12:18 +02:00
The current implementation uses a [core board](https://wiki.cuvoodoo.info/doku.php?id=stm32f1xx#core_board).
2016-01-29 12:12:04 +01:00
The underlying template also supports following board:
2016-01-29 12:12:04 +01:00
- [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
2020-02-02 21:18:28 +01:00
- [blue pill](https://wiki.cuvoodoo.info/doku.php?id=stm32f1xx#blue_pill), based on a STM32F103C8T6
2020-02-19 21:10:16 +01:00
- [black pill](https://wiki.cuvoodoo.info/doku.php?id=stm32f1xx#black_pill), based on a STM32F103C8T6
2017-04-03 13:12:18 +02:00
- [core board](https://wiki.cuvoodoo.info/doku.php?id=stm32f1xx#core_board), based on a STM32F103C8T6
2020-01-03 19:40:31 +01:00
- [ST-LINK V2 mini](https://wiki.cuvoodoo.info/doku.php?id=jtag#mini_st-link_v2), a ST-LINK/V2 clone based on a STM32F101C8T6
2020-01-03 19:41:39 +01:00
- [USB-Blaster](https://wiki.cuvoodoo.info/doku.php?id=jtag#armjishu_usb-blaster), an Altera USB-Blaster clone based on a STM32F101C8T6
2016-01-29 12:12:04 +01:00
**Which board is used is defined in the Makefile**.
2017-04-15 13:58:39 +02:00
This is required to map the user LED and button provided on the board
2016-01-29 12:12:04 +01:00
2020-01-03 19:40:31 +01:00
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.
2020-01-03 19:41:39 +01:00
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:
01. NC
02. VCC
03. LN393 OUTPUT-A
04. MAX1247 DIN
05. MAX1247 DOUT
06. MAX1247 SCLK
07. MAX1247 nCS
08. ST339 OUTPUT-3
09. LK1 jumper (missing), other side connected to ground
10. LK2 jumper (missing), other side connected to ground
11. LK3 jumper (present), other side connected to ground
12. LK4 jumper (present), other side connected to ground
13. ground
14. 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):
1. thermistor lead 1
2. thermistor lead 2
3. chassis
thermocouple (e.g. peltier elements) controller board, MBLK019, 2x3 pin plug (IDC numbering):
1. red, VCC
2. red/green, sink to control IC/TR 2/6
3. red/black, sink to control IC/TR 1/4
4. red/blue, connected to pin 6
5. red/brown, sink to control IC/TR 3/5
6. black, connected to pin 4
front control panel, 1x5 connector:
1. ground
2. play/pause indicator, green LED anode
3. play/pause indicator, orange LED anode
4. power indicator, red LED
5. play/pause button, connected to ground when pressed
fan:
1. red: 12V
2. black: ground
MBLK-078, power + heater, 2x2 connector:
1. red, 12V
2. black, ground
3. yellow/red, optocoupler anode for triac controlling the lid heater
4. yellow/black, optocoupler cathode for triac controlling the lid heater
SSD1306 OLED screen:
1. GND
2. VDD
3. SCK
4. 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
===========
2016-01-29 12:12:04 +01:00
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:
01. NC
02. 3.3V
03. PB3
04. PB15 SPI2_MOSI
05. PB14 SPI2_MISO
06. PB13 SPI2_SCK
07. PB12 SPI2_NSS
08. PB4
09. PB5
10. PC14
11. PC15
12. PB1
13. ground
2016-01-29 12:12:04 +01:00
heated lid, 12 kOhm NTC thermistor, 3-pin (pin 1 has notch):
1. PA0/ADC1_CH0, pulled up to 5.0V by 10 kOhm resistor
2. ground
3. earth
thermocouple controller board, MBLK019, 2x3 IDC connector:
1. 3.3 V
2. PA1
3. PA2
4. PA3
5. PA4
6. ground
front panel:
1. ground
2. PA5, with 330 Ohm inline resistor
3. PA6, with 330 Ohm inline resistor
4. PA7, with 330 Ohm inline resistor
5. PB0
fan:
1. 12V front board power supply
2. power nMOS drain
power nMOS source. ground
power nMOS gate. PA15, pulled up externally to 5V
MBLK-078, power + heater, 2x2 connector:
1. LM7805 in
2. ground
3. 5V though 330 Ohm
4. PA10
SSD1306 OLED screen:
1. ground
2. 3.3 V
3. PB6/I2C1_SCL, pulled up to 3.3V by external 10 kOhm resistor
4. 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
2016-01-29 12:12:04 +01:00
code
====
2016-01-29 12:12:04 +01:00
dependencies
------------
2016-01-29 12:12:04 +01:00
The source code uses the [libopencm3](http://libopencm3.org/) library.
The projects is already a git submodules.
2017-08-07 23:13:30 +02:00
It will be initialized when compiling the firmware.
Alternatively you can run once: `git submodule init` and `git submodule update`.
2016-01-29 12:12:04 +01:00
firmware
--------
2016-01-29 12:12:04 +01:00
2017-08-07 23:13:30 +02:00
To compile the firmware run `rake`.
2016-01-29 12:12:04 +01:00
documentation
-------------
2017-08-07 23:13:30 +02:00
To generate doxygen documentation run `rake doc`.
2016-01-29 12:12:04 +01:00
flash
-----
2017-04-15 13:58:39 +02:00
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`).
2017-08-07 23:13:30 +02:00
The `application` image is the main application and is implemented in `application.c`.
2017-04-15 13:58:39 +02:00
It is up to the application to advertise USB DFU support (i.e. as does the provided USB CDC ACM example).
2020-10-11 12:55:04 +02:00
The `bootloader` image will be flashed using SWD (Serial Wire Debug).
For that you need an SWD adapter.
2020-10-11 12:55:04 +02:00
The `Makefile` uses a ST-Link V2 programmer along OpenOCD software (default), or Black Magic Probe.
2017-08-07 23:13:30 +02:00
To flash the `booltoader` using SWD run `rake flash_booloader`.
2020-10-11 12:55:04 +02:00
If the development board uses the CKS32 chip STM32 alternative, use `CPUTAPID=0x2ba01477 rake flash_booloader`.
2017-04-15 13:58:39 +02:00
2017-08-07 23:13:30 +02:00
Once the `bootloader` is flashed it is possible to flash the `application` over USB using the DFU protocol by running `rake flash`.
2017-04-15 13:58:39 +02:00
To force the bootloader to start the DFU mode press the user button or short a pin, depending on the board.
2017-08-07 23:13:30 +02:00
It is also possible to flash the `application` image using SWD by running `rake flash_application`.
2016-01-29 12:12:04 +01:00
debug
2016-01-29 12:12:04 +01:00
-----
SWD also allows to debug the code running on the micro-controller using GDB.
2017-08-07 23:13:30 +02:00
To start the debugging session run `rake debug`.
2016-01-29 12:12:04 +01:00
USB
---
The firmware offers serial communication over USART1 and USB (using the CDC ACM device class).