STM32F1xx micro-controller C firmware template
Go to file
King Kévin 18f541adbb README: document HBMBSG02 2020-12-10 20:08:52 +01:00
lib oled_text: add library to show text on SSD1306 OLED display 2020-12-07 19:12:41 +01:00
libopencm3@cb0661f81d update libopencm3 2020-02-17 11:43:47 +01:00
.gitignore cherry-pick from busvoodoo branch, part 2 2018-02-18 15:20:01 +01:00
.gitmodules remove STM32duino-bootloader 2016-08-14 19:03:17 +02:00
Doxyfile doc: fix documentation 2020-01-03 00:16:59 +01:00
LICENSE.txt add GPLv3 license file 2018-02-13 15:14:10 +01:00
README.md README: document HBMBSG02 2020-12-10 20:08:52 +01:00
Rakefile Rakefile: allow to specify CPUTADIP to use SWD with CKS32 2020-06-24 11:57:45 +02:00
application.c application: add segment selector 2020-12-10 18:19:51 +01:00
application.ld ld: use a MCU with 128 KB of flash (e.g. original STM32) 2020-12-07 18:56:33 +01:00
bootloader.c bootloader: disable clocks after domains used 2020-06-24 11:57:22 +02:00
bootloader.ld ld: use a MCU with 128 KB of flash (e.g. original STM32) 2020-12-07 18:56:33 +01:00
global.c global: fix ADD_SAFE macro and add function returning sum 2020-12-07 19:10:04 +01:00
global.h global: fix ADD_SAFE macro and add function returning sum 2020-12-07 19:10:04 +01:00

README.md

This is the firmware for the ThermoHybaid MBS 0.2G MBLK001 issue 2 (short HBMBSG02) thermo-cycler replacement controller board.

This is the firmware for the thermo-cycler This firmware template is designed for development boards based around STM32 F1 series micro-controller.

project

summary

I bought a HBMBSG02 thermo-cycler, with unknown defect, and wanted to use to make PCR tests.

technology

I replaced the controller board with custom electronics to be able to operate it again.

HBMBSG02

The device did power up. After a couple of seconds it shut down the fan and probably waits for further instructions. No defect was visible. I did not get any software to operate it, or check for errors. This is a rather old device, from 2003. The manufacturer did not reply to my request for any software or further documentation.

There are two RJ11 ports, for RS-485 communication. No traffic has been seen during boot up (this probably uses a master slave protocol since the devices can be chained). I did not get any reply after sending random bytes.

The device is made out of the following parts.

MBLK002

The heating (and cooling) bed for 8x12 PCR tubes. Made of black anodized aluminium.

lid

there is a heated lid with two connectors.

temperature sensor, 12 kOhm NTC thermistor, 3-pin (pin 1 has notch):

  1. thermistor lead 1
  2. thermistor lead 2
  3. chassis connected to MBLK005.

heating element, 150 Ohm resistor, 2-pin connector. connected to MBLK078. this is power by AC 220V, controller by main board. I don't recommend to have is on at full power for too long. The heating mat gets hot very fast. I even blew to inline fuse (196 °C) although I only tried to heat it up to 94 °C. I replaced the fuse.

MBLK005

this board provides power to the controller board and lid.

power + heater, 2x2 connector:

  1. red, 12V (13-77 V)
  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

1x2 connector to lid heater, controller by BTA06 triac.

it also allows to select between 110 V and 220 V, and provides AC power to the TEC power supply.

MBLK041

RS485 adapter board. it provides 2 interconnected RJ11 ports. this allows to chain thermocyclers.

1x4 connector, to main board:

  1. yellow, RS-485-2 A (9/Y on MAX489)
  2. green, RS-485-2 B (10/Z on MAX489)
  3. brown, RS-485-1 A (12/A on MAX489)
  4. orange, RS-485-1 B (11/B on MAX489)

A4-246

power supply for the TECs (e.g. peltier elements) though yellow/orange cables. I think this provides a programmable constant current to operate the TECs efficiently.

2x5 IDC connector to main board:

  1. IC2 anode
  2. IC2 cathode with R23
  3. IC4 anode through R24
  4. IC4 anode
  5. IC6 collector
  6. IC6 emitter
  7. IC3 anode
  8. IC3 cathode through R15
  9. IC5 anode through R25
  10. IC5 cathode

by applying any combination on ID2-5 I was not able to have it output power. IC6 is active when IC5 gets power, but that's the only reaction I got.

test points:

  • T3-8 -- TP9 -- TR4 -- TP8
  • TP8: 38 kHz @ 1V
  • TP9: 38 kHz @ 60V
  • TP10: ground
  • TP11: PWM 38 kHz @ 13V
  • TP12: 6V
  • TP13: 16.6V

A4-250

H-bridge module mounted on A4-246

PL2 connection:

  1. ground
  2. orange wire (H-bridge output)
  3. yellow wire (H-bridge output)
  4. VCC (6V)

PL5: 5. IC3 collector 7. VCC 8. ground 9. ground 10. IC6 anode 12. IC5 collector 13. IC2 emitter (pulled down) 14. IC4 emmiter (pulled down)

front panel

1x5 connector, to main board:

  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

1x2 connector, to main board:

  1. red: 12V
  2. black: ground

MBLK019/MBLK020

controls which TECs get power, and how.

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

1x6 conenctor, to TEC and power supply.

MBLK009

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

2x7 IDC connector:

  1. NC
  2. VCC
  3. LN393 OUTPUT-A
  4. MAX1247 DIN
  5. MAX1247 DOUT
  6. MAX1247 SCLK
  7. MAX1247 nCS
  8. ST339 OUTPUT-3
  9. 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)

1x6 conenctor to TECs:

  • 1 -- free standing 93 °C fuse -- fuse in heat sink -- 2x top TECs in series -- 2
  • 2 -- 2x middle-top TECs in series -- 3
  • 4 -- 2x middle-bottom TECs in series -- 5
  • 5 -- 2x bottom TECs in series -- 6

when 3 is + and 1 is -, the top half bed heats up. when 6 is + and 4 is -, the bottom half bed heats up.

MBLK005

this is the main controller board. it is connected to all other parts through individual connectors, or the card edge connector.

the 2.4V rechargeable battery was empty and leaking, with spades corroded. changing the battery did not change anything: the thermo-cycle goes to sleep after power up. I don't know it it hold the calibration data in SRAM and the reason why the device has been sold as defective.

This is replaced by a custom controller board for which this firmware is.

board

The MBLK005-replacement board uses a blue pill, based on a STM32F103C8T6.

peripherals

additional peripherals to operate the thermo cycler:

SSD1306 OLED screen to show the detailed state:

  1. GND
  2. VDD
  3. SCK
  4. SDA

24V 12A power supply replacing the A4-246. 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. 12V is not enough to heat the TECs rapidly up to 94 °C.

connections

All pins are configured using defines in the corresponding source code. Connect the peripherals the following way.

heating block MBLK-008 CO IDC 7x2:

  1. NC
  2. 3.3V
  3. PB3
  4. PB15 SPI2_MOSI
  5. PB14 SPI2_MISO
  6. PB13 SPI2_SCK
  7. PB12 SPI2_NSS
  8. PB4
  9. PB5
  10. PC14
  11. PC15
  12. PB1
  13. ground

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

DS18B20 1-Wire temperature sensor, 1x3:

  1. OWD, PB8
  2. ground
  3. 3.3V

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).