Refactor README.md
This commit is contained in:
		
							parent
							
								
									f755d3775b
								
							
						
					
					
						commit
						fd1189bb2f
					
				
							
								
								
									
										131
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										131
									
								
								README.md
									
									
									
									
									
								
							@ -1,91 +1,110 @@
 | 
				
			|||||||
# Overview
 | 
					# Overview
 | 
				
			||||||
Firmware for a homemade automated electric armchair.  
 | 
					This repository contains the firmware for a custom-built automated electric armchair.  
 | 
				
			||||||
Extensive details about this project can be found on the website:
 | 
					Detailed project information and documentation is available on the website:
 | 
				
			||||||
- ~~V1: [Electric Armchair V1](https://pfusch.zone/electric-armchair)~~
 | 
					- ~~V1: [Electric Armchair V1](https://pfusch.zone/electric-armchair)~~
 | 
				
			||||||
- V2: [Electric Armchair V2](https://pfusch.zone/electric-armchair-v2)
 | 
					- V2: [Electric Armchair V2](https://pfusch.zone/electric-armchair-v2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Note: In the current version V2.2, only the esp-project in the [board_single/](board_single) folder and the custom libraries in [common/](common) are used.  
 | 
					**Note:** In the current version _V2.2_, only the esp-project in the [board_single/](board_single) folder and the custom libraries in [common/](common) are used.  
 | 
				
			||||||
The projects in the folders `board_control/` and `board_motorctl/` are no longer compatible and legacy from V2.1.
 | 
					The projects in the folders `board_control/` and `board_motorctl/` are no longer compatible and are legacy from _V2.1_.
 | 
				
			||||||
 | 
					 | 
				
			||||||
<img src="doc/2023.09.09_armchair-frame.jpg" alt="Photo machine" style="width:60%;">
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					<img src="doc/2023.09.09_armchair-frame.jpg" alt="Photo machine" style="width:60%;"><br>
 | 
				
			||||||
*Photo of the built frame that carries the armchair*
 | 
					*Photo of the built frame that carries the armchair*
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Hardware Setup / Electrical
 | 
					 | 
				
			||||||
### PCB
 | 
					 | 
				
			||||||
The firmware in this repository is designed for an ESP32 microcontroller integrated into a custom PCB developed here: [Project Work 2020](https://pfusch.zone/project-work-2020)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
### Connection Plan
 | 
					 | 
				
			||||||
A detailed diagram illustrating all components and wiring can be found in the file [connection-plan.drawio.pdf](connection-plan.drawio.pdf)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
For more details refer to the documentation on the website.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Overview
 | 
				
			||||||
## Current Features
 | 
					## Current Features
 | 
				
			||||||
- Control Modes:
 | 
					- **Control Modes:**
 | 
				
			||||||
  - Joystick: Control via hardware joystick mounted on the right armrest
 | 
					  - **Joystick:** Control movement via hardware joystick mounted on the right armrest
 | 
				
			||||||
  - HTTP: Control via virtual joystick on a web interface
 | 
					  - **HTTP:** Control movement via virtual joystick on a web interface
 | 
				
			||||||
  - Massage: Armchair shaking depending on stick position
 | 
					  - **Massage:** Armchair shaking depending on stick position
 | 
				
			||||||
  - Auto: Execute stored driving commands sequentially
 | 
					  - **Adjust:** Control leg and backrest position via joystick
 | 
				
			||||||
- Electric Chair Adjustment: Leg and backrest control via joystick
 | 
					  - **Auto:** Execute stored driving commands sequentially
 | 
				
			||||||
- Advanced Motor Control: Configurable motor fading (acceleration, deceleration limit), current limit, braking; compatible with different hardware
 | 
					- **Advanced Motor Control:**
 | 
				
			||||||
- Wi-Fi:
 | 
					  - Deceleration limit
 | 
				
			||||||
 | 
					  - Acceleration limit
 | 
				
			||||||
 | 
					  - Current limit
 | 
				
			||||||
 | 
					  - Braking
 | 
				
			||||||
 | 
					  - Compatible with different motor drivers:
 | 
				
			||||||
 | 
					    - 3 pins: A, B, PWM - e.g. various common H-Bridges
 | 
				
			||||||
 | 
					    - 1 pin: UART/RS232 - e.g. Sabertooth
 | 
				
			||||||
 | 
					- **Input/Sensors:**
 | 
				
			||||||
 | 
					  - **Speed Measurement:** Measures speed and direction of each tire individually using custom built encoders
 | 
				
			||||||
 | 
					  - **Current Measurement:** Monitors current of each motor
 | 
				
			||||||
 | 
					  - **Battery Voltage:** Measures battery voltage and calculates percentage according to discharge curve
 | 
				
			||||||
 | 
					  - **Analog Joystick:** 
 | 
				
			||||||
 | 
					    - Evaluate two analog signals to get coordinates, radius and angle
 | 
				
			||||||
 | 
					    - Calibration wizard/sequence
 | 
				
			||||||
 | 
					    - Calibration stored persistently in nvs
 | 
				
			||||||
 | 
					- **Fan Control:** Cooling fan for motor driver are activated when needed only
 | 
				
			||||||
 | 
					- **Buzzer:** Provides acoustic feedback when switching modes or interacting with menu
 | 
				
			||||||
 | 
					- **OLED-Display + Rotary-encoder:**
 | 
				
			||||||
 | 
					  - Various status screens showing battery status, speed, RPM, motor current, mode, power, duty cycle, stick data
 | 
				
			||||||
 | 
					  - Menu for setting various options using encoder
 | 
				
			||||||
 | 
					  - Changed settings are stored persistently in NVS flash
 | 
				
			||||||
 | 
					  - Menu for selecting the control mode
 | 
				
			||||||
 | 
					- **UART Communication between 2 Boards (V2.1)**
 | 
				
			||||||
 | 
					- **Electric Chair Adjustment:** Control 4 Relays powering motors that adjust the chair rest positions
 | 
				
			||||||
 | 
					- **Wi-Fi:**
 | 
				
			||||||
  - Hosts wireless network
 | 
					  - Hosts wireless network
 | 
				
			||||||
  - Webserver with webroot in SPIFFS
 | 
					  - Webserver with webroot in SPIFFS
 | 
				
			||||||
  - HTTP API for controlling the chair
 | 
					  - HTTP API for controlling the chair (remote control)
 | 
				
			||||||
- UART Communication between 2 boards (V2.1)
 | 
					- **React web-app:** Virtual joystick sending data to http-API (placed in SPIFFS)
 | 
				
			||||||
- Speed Measurement: Measures speed and direction of each tire individually using custom encoders
 | 
					
 | 
				
			||||||
- Current Measurement: Monitors current of each motor
 | 
					 | 
				
			||||||
- Battery Capacity: Measures battery voltage and calculates percentage according to discharge curve
 | 
					 | 
				
			||||||
- Fan Control: Cooling fan for motor driver activated only when needed
 | 
					 | 
				
			||||||
- Display + Rotary encoder:
 | 
					 | 
				
			||||||
  - Various status screens showing battery status, speed, RPM, motor current, mode, power, duty cycle, stick data
 | 
					 | 
				
			||||||
  - Menu for setting various options using encoder (options are stored persistently in nvs flash)
 | 
					 | 
				
			||||||
  - Menu for selecting the control mode
 | 
					 | 
				
			||||||
- Buzzer: Provides acoustic feedback when switching modes or interacting with menu
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Planned Features
 | 
					## Planned Features
 | 
				
			||||||
 | 
					#### Hardware
 | 
				
			||||||
- More Sensors:
 | 
					- More Sensors:
 | 
				
			||||||
  - Accelerometer
 | 
					  - Accelerometer
 | 
				
			||||||
  - Lidar sensor / collision detection
 | 
					  - Lidar sensor / collision detection
 | 
				
			||||||
  - GPS receiver
 | 
					  - GPS receiver
 | 
				
			||||||
  - Temperature sensors
 | 
					  - Temperature sensors
 | 
				
			||||||
 | 
					- Lights
 | 
				
			||||||
 | 
					- Camera
 | 
				
			||||||
 | 
					#### Algorithms
 | 
				
			||||||
- Anti-Slip Regulation
 | 
					- Anti-Slip Regulation
 | 
				
			||||||
- Self-Driving Algorithm
 | 
					- Self-Driving Algorithm
 | 
				
			||||||
- Lights
 | 
					#### UI
 | 
				
			||||||
- Improved Web Interface
 | 
					- Improved Web Interface
 | 
				
			||||||
- App
 | 
					  - Settings
 | 
				
			||||||
- Camera
 | 
					  - Chair adjustment
 | 
				
			||||||
 | 
					- Simple App
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## Hardware Setup / Electrical
 | 
				
			||||||
 | 
					### PCB
 | 
				
			||||||
 | 
					The firmware is designed for an ESP32 microcontroller integrated into a custom PCB developed here: [Project Work 2020](https://pfusch.zone/project-work-2020)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					### Connection Plan
 | 
				
			||||||
 | 
					A detailed diagram illustrating all components and wiring can be found in the file [connection-plan.drawio.pdf](connection-plan.drawio.pdf).   
 | 
				
			||||||
 | 
					For more details refer to the documentation on the [website](https://pfusch.zone/electric-armchair-v2).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Installation
 | 
					# Installation
 | 
				
			||||||
### Install esp-idf
 | 
					### Install ESP-IDF
 | 
				
			||||||
For this project **ESP-IDF v4.4.4** is required (with other versions it might not compile)
 | 
					For this project **ESP-IDF v4.4.4** is required
 | 
				
			||||||
```bash
 | 
					```bash
 | 
				
			||||||
#download esp-idf
 | 
					#download esp-idf
 | 
				
			||||||
yay -S esp-idf #alternatively clone the esp-idf repository from github
 | 
					yay -S esp-idf #alternatively clone the esp-idf repository from github
 | 
				
			||||||
#run installation script in installed folder
 | 
					#run installation script in installed folder
 | 
				
			||||||
/opt/esp-idf/install.sh
 | 
					/opt/esp-idf/install.sh
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
### Clone this repo
 | 
					### Clone Repository
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
git clone git@github.com:Jonny999999/armchair_fw
 | 
					git clone git@github.com:Jonny999999/armchair_fw
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
### Instal node packages
 | 
					### Install Node Packages
 | 
				
			||||||
For the react app packages have to be installed using npm. TODO: add this to cmake?
 | 
					Navigate to the react-app directory and install required packages using npm:
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
cd react-app
 | 
					cd react-app
 | 
				
			||||||
npm install
 | 
					npm install
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
# Building the Project
 | 
					# Building the Project
 | 
				
			||||||
## React-webapp
 | 
					## React-webapp
 | 
				
			||||||
When flashing to the ESP32, the files in the `react-app/build/` folder are written to a SPIFFS partition.  
 | 
					When flashing to the ESP32, the files in the `react-app/build/` folder are written to a SPIFFS partition.  
 | 
				
			||||||
These files are then served via HTTP in the Wi-Fi network "armchair" created by the ESP32.  
 | 
					These files are then served via HTTP in the Wi-Fi network "armchair" created by the ESP32.  
 | 
				
			||||||
In HTTP control mode, you can control the armchair using a joystick on the provided website.  
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
Initially, or when changing the React code, you need to manually build the React app:
 | 
					Initially, or when changing the React code, you need to manually build the React app:
 | 
				
			||||||
```bash
 | 
					```bash
 | 
				
			||||||
@ -95,31 +114,31 @@ npm run build
 | 
				
			|||||||
#remove unwanted license file (filename too long for spiffs)
 | 
					#remove unwanted license file (filename too long for spiffs)
 | 
				
			||||||
rm build/static/js/main.8f9aec76.js.LICENSE.txt
 | 
					rm build/static/js/main.8f9aec76.js.LICENSE.txt
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
Note: Use `npm start` for starting the webapp locally for testing
 | 
					**Note:** For testing the app locally, use `npm start`
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Firmware
 | 
					## Firmware
 | 
				
			||||||
### Set up environment
 | 
					### Environment Setup
 | 
				
			||||||
```bash
 | 
					```bash
 | 
				
			||||||
source /opt/esp-idf/export.sh
 | 
					source /opt/esp-idf/export.sh
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
(run once per terminal)
 | 
					Run once per terminal
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Compile
 | 
					### Compilation
 | 
				
			||||||
```bash
 | 
					```bash
 | 
				
			||||||
cd board_single
 | 
					cd board_single
 | 
				
			||||||
idf.py build
 | 
					idf.py build
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Upload
 | 
					### Upload
 | 
				
			||||||
- connect FTDI programmer to board (VCC to VCC; TX to RX; RX to TX)
 | 
					- Connect FTDI programmer to board (GND to GND, TX to RX, RX to TX)
 | 
				
			||||||
- press REST and BOOT button
 | 
					- Press RESET and BOOT button
 | 
				
			||||||
- release RESET button (keep pressing boot)
 | 
					- Release RESET button (keep pressing boot)
 | 
				
			||||||
- run flash command:
 | 
					- Release boot button
 | 
				
			||||||
 | 
					- Run flash command:
 | 
				
			||||||
```bash
 | 
					```bash
 | 
				
			||||||
idf.py flash
 | 
					idf.py flash
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
- once "connecting...' was successfully, BOOT button can be released
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Monitor
 | 
					### Monitor
 | 
				
			||||||
@ -130,8 +149,6 @@ idf.py monitor
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Usage / User Interface
 | 
					# Usage / User Interface
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Encoder Functions
 | 
					## Encoder Functions
 | 
				
			||||||
@ -167,6 +184,6 @@ idf.py monitor
 | 
				
			|||||||
Control the armchair via a virtual joystick on the web interface.
 | 
					Control the armchair via a virtual joystick on the web interface.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
**Usage:**
 | 
					**Usage:**
 | 
				
			||||||
- Switch to HTTP mode (4 button presses).
 | 
					- Switch to HTTP mode (4 button presses or via mode-select menu).
 | 
				
			||||||
- Connect to WiFi `armchar`, no password.
 | 
					- Connect to WiFi `armchair`, no password.
 | 
				
			||||||
- Access http://192.168.4.1 (note: **http** NOT https, some browsers automatically add https!).
 | 
					- Access http://192.168.4.1 (note: **http** NOT https, some browsers automatically add https!).
 | 
				
			||||||
@ -4,6 +4,6 @@ dependencies:
 | 
				
			|||||||
    source:
 | 
					    source:
 | 
				
			||||||
      type: idf
 | 
					      type: idf
 | 
				
			||||||
    version: 4.4.4
 | 
					    version: 4.4.4
 | 
				
			||||||
manifest_hash: dcf4d39b94252de130019eadceb989d72b0dbc26b552cfdcbb50f6da531d2b92
 | 
					manifest_hash: 81327a7819f5bc7bf271896e30d778a5c5f8f8f754dfbc8e245723b4a37d3107
 | 
				
			||||||
target: esp32
 | 
					target: esp32
 | 
				
			||||||
version: 1.0.0
 | 
					version: 1.0.0
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user