Skip to content

abstract-333/Tissue-Processor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

174 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

workflow status

Tissue Processor Controller

Arduino-based automation controller for a laboratory / medical tissue processor.

The system manages:

  • Automated movement between processing tanks
  • Vibration control during immersion
  • Wax heater management
  • Tank identification and sequencing
  • Safety interlocks and fault detection
  • LCD status display and operator controls

The firmware is implemented as a deterministic Finite State Machine (FSM) using the MicroBeaut Finite-State library for predictable and maintainable behavior.

πŸ› Legacy Machine Restoration

This project was created to restore a heavily damaged:

Histokinette E7326 tissue processor.

The original machine was fully mechanical and its control system was no longer reliable.
An Arduino-based controller was added to replace the damaged control hardware while preserving the original mechanical system.

The goal of this project is to give the machine a second life using modern, maintainable, and open-source electronics.

Modern Improvements

This implementation adds:

  • Deterministic FSM-based control logic
  • Motor timeout protection
  • Sensor validation and debouncing
  • Wax temperature verification
  • Watchdog-based recovery
  • LCD diagnostics and runtime information
  • Structured development workflow
  • Automated builds and testing support

This project demonstrates how older laboratory and industrial equipment can be restored, documented, and maintained using modern embedded development practices while keeping the original machine functional and operational.

✨ Features

Process Automation

  • Sequential processing across 12 tanks
  • Configurable dwell times per tank
  • Automatic tank transition detection
  • Multi-cycle support for wax tanks
  • Inspection / manual intervention mode

Robust FSM Architecture

The controller is structured entirely around explicit FSM states:

  • Startup verification
  • Recovery modes
  • Lowering / raising
  • Tank dwell timing
  • Transition handling
  • Error shutdown

This improves:

  • Reliability
  • Debugging
  • Safety validation
  • Long-term maintainability

Safety Systems

Built-in protection mechanisms include:

  • Motor runtime timeout protection
  • Sensor sanity validation
  • Wax readiness verification
  • Invalid tank detection
  • Watchdog recovery (avr/wdt)
  • Debounced sensors and buttons
  • Controlled motor switching delays

Operator Interface

  • 16x2 I2C LCD status display
  • Remaining process time display
  • Start / pause / inspection controls
  • Real-time tank information

🧩 Hardware Configuration

Pin Mapping

Power Outputs

Function Pin Description
Movement Motor D8 Vertical movement motor
Vibration Motor D7 Tank vibration motor
Heater 1 D6 Wax heater 1
Heater 2 D5 Wax heater 2

Sensors (Active LOW)

Sensor Pin Description
Bottom Sensor A0 Lower limit switch
Top Sensor A1 Upper limit switch
Wax Sensor 1 D3 Wax ready thermostat 1
Wax Sensor 2 D4 Wax ready thermostat 2

Tank Selector

Pins Description
D9–D12 4-bit binary tank identifier

User Controls

Control Pin Description
Start / Stop Button D2 Start or pause process
Skip Tank Button D1 Skip current tank
Raise / Continue Button D0 Raise sample for inspection

LCD

Interface Pins
I2C LCD A4 (SDA), A5 (SCL)

LCD address:

0x27

βš™οΈ Process Workflow

Startup Sequence

On boot:

  1. Hardware initializes
  2. Sensors are validated
  3. Tank position is synchronized
  4. FSM enters verification mode
  5. System transitions to IDLE

πŸ”„ FSM State Flow

Core States

State Purpose
S_VERIFYING Initial startup verification
S_IDLE Waiting for operator input
S_STARTING_NEW_TANK Tank initialization
S_LOWERING Moving sample downward
S_PRE_DOWN Motor safety delay
S_DOWN Active tank dwell period
S_CHECKING Wax and cycle verification
S_PRE_RAISING Motor switching delay
S_RAISING Raising sample upward
S_UP Inspection / top position
S_TRANSITIONING Waiting for next tank
S_ERROR Emergency shutdown

πŸ›‘ Safety Features

Motor Timeout Protection

If the movement motor runs longer than:

60 seconds

without reaching the target sensor, the system enters:

S_ERROR

Sensor Validation

The controller immediately halts if:

  • Top and bottom sensors activate simultaneously
  • Tank ID becomes invalid
  • Wax conditions fail unexpectedly
  • Mechanical motion becomes inconsistent

Watchdog Protection

The AVR watchdog timer automatically resets the controller if the firmware hangs.

wdt_enable(WDTO_2S);

Debouncing

All sensors and buttons are software debounced:

20 ms

to eliminate false triggers caused by electrical noise.


🧠 Tank Profiles

Tank behavior is configured through a compact PROGMEM table:

struct TankProfile
{
    uint8_t dwellMinutes;
    uint8_t requiredHeater;
    WaxRequirement requiredWax;
    uint8_t cycles;
};

Example Configuration

Tank Duration Heaters Wax Check Cycles
1–9 60 min None None 1
10 60 min Heater 1 None 1
11 120 min Both Wax 1 2
12 120 min Both Wax 1 + 2 2

πŸ–₯ LCD Interface

Example Screens

Idle

Status: Idle
Press Start

Active Tank

Tank: 05
Time: 00:42:11

Error

ERROR
MOTOR OVER TIME

πŸ§ͺ Development Modes

The firmware supports optional compile-time development modes.

Enable Debug Output

#define DEBUG

Enables verbose serial logging for:

  • FSM transitions
  • Sensor events
  • Timing diagnostics
  • Safety faults

Enable Fast Simulation

#define TEST

Changes timing behavior for rapid testing:

Normal TEST Mode
1 minute 1 second
1 hour dwell 60 seconds
60s timeout 10s timeout

Useful for validating full process cycles quickly.


πŸ›  Dependencies

Required Arduino libraries:

Library Version
Finite-State 1.6.0
LiquidCrystal_I2C 1.1.2
Wire Built-in

πŸš€ Build & Upload

Arduino IDE

  1. Open the sketch
  2. Install required libraries
  3. Select target board
  4. Upload firmware

πŸ”§ Makefile Workflow

The repository includes a development workflow using make.

Build

make build

or

make compile

Upload

make upload PORT=/dev/ttyACM0

Windows example:

make upload PORT=COM3

Serial Monitor

make monitor PORT=/dev/ttyACM0

Format Source Code

make format

Uses:

clang-format

Lint

make lint

Uses:

cpplint

Run Tests

make test

Display Binary Size

make size

Clean Build Files

make clean

πŸ“‚ Project Structure

.
β”œβ”€β”€ TissueProcessor.ino
β”œβ”€β”€ Makefile
β”œβ”€β”€ README.md
β”œβ”€β”€ LICENSE
β”œβ”€β”€ build/
└── tests/

πŸ” Usage

Starting the Process

  1. Power on the controller
  2. Ensure tank selector is correct
  3. Hold the Start button
  4. System begins automatic processing

Inspection Mode

During processing:

  • Press the raise button
  • Sample rises to top position
  • Inspection can be performed safely
  • Resume process afterward

Skip Tank

Operator can manually skip the current tank using the skip button.


🧰 Debugging

Recommended workflow:

#define DEBUG
#define TEST

This enables:

  • Fast simulation cycles
  • Full serial diagnostics
  • Easier FSM validation

🌐 Simulation

Wokwi Online Simulation

Wokwi Simulation


⚠ Disclaimer

This project is intended for:

  • Research
  • Prototyping
  • Educational purposes

Before use in a real laboratory or medical environment:

  • Validate all timings
  • Verify thermal safety systems
  • Test all limit switches
  • Confirm relay and power-stage isolation
  • Perform independent safety certification

πŸ“„ License

Licensed under the MIT License.

Copyright Β© 2026 Basher Hasan (abstract-333)

See:

LICENSE

About

Arduino/C++ sketch for tissue processor machine.

Resources

License

Stars

Watchers

Forks

Contributors