README 한국어 정리

This commit is contained in:
seo committed 2026-08-02 00:57:10 +09:00
1 parent c1d29b4157
commit a130726907
1 file changed
+69 -63
+69 -63
View File
@@ -1,37 +1,40 @@
# Auto_Seat # 차량 승하차 편의를 위한 자동 시트 조절기
Arduino Nano based automatic seat controller. Arduino Nano와 2채널 릴레이를 이용해 순정 이지억세스가 없는 차량에 자동 시트 이동 기능을 붙이는 개인 프로젝트입니다.
## Hardware 시동 상태와 P단 신호를 읽어 주행 상태가 되면 시트를 저장된 주행 위치까지 올리고, P단 또는 하차 상태가 되면 시트를 아래 위치까지 내립니다. 실제 위치 센서는 없으며, 이동 시간을 기준으로 현재 위치를 추정합니다.
- Board: Arduino Nano ATmega328P ## 하드웨어
- Up relay: D8, active-low
- Down relay: D9, active-low
- Parking raw input: A0
- IG1 input: D7
## Main Behavior - MCU: Arduino Nano ATmega328P
- 릴레이: 2채널 Active-Low 릴레이 모듈
- 상승 릴레이: `D8`, `LOW = ON`
- 하강 릴레이: `D9`, `LOW = ON`
- P단 입력: `A0`, analog raw `0..1023`
- IG1 입력: `D7`, `HIGH = IG1 ON`, `LOW = IG1 OFF`
- If `IG1 HIGH` and parking signal is OFF, drive mode is confirmed after 80ms. ## 기본 동작
- In confirmed drive mode, the seat moves up to the EEPROM saved position.
- If parking/non-drive mode is confirmed for 250ms, the seat moves down to 0.
- Down movement is estimated at 1.1x the up movement speed.
- When the estimated position reaches 0, down relay stays on for an extra 300ms.
- On IG1 startup, relay output is held off for 1000ms to ignore temporary signal bounce.
## Position Setting - `IG1 HIGH`이고 P단 신호가 꺼져 있으면 80ms 확인 뒤 주행 모드로 봅니다.
- 주행 모드에서는 EEPROM에 저장된 주행 위치까지 시트를 올립니다.
- P단 또는 비주행 모드가 250ms 동안 유지되면 시트를 `0ms` 위치까지 내립니다.
- 하강 속도는 상승보다 약 `1.1배` 빠른 것으로 계산합니다.
- 추정 위치가 `0ms`에 도달하면 하단 끝단 보정을 위해 하강 릴레이를 300ms 더 유지합니다.
- IG1이 켜진 직후에는 신호 튐을 피하기 위해 1000ms 동안 릴레이 출력을 끕니다.
- Hard limit: `0..6000ms` ## 위치 저장
- EEPROM saved position is used as the automatic driving position.
- EEPROM initializes saved position to `6000ms` if the magic value is missing or invalid.
- Serial command `p` saves the current estimated position to EEPROM.
- Calibration command `c` does not change the saved position.
## USB / Serial Reset Handling - 시트 주행 위치는 EEPROM에 저장합니다.
- 허용 범위는 `0..6000ms`입니다.
- EEPROM magic 값이 없거나 저장값이 유효하지 않으면 기본 주행 위치를 `6000ms`로 둡니다.
- serial 명령 `p`로 현재 추정 위치를 EEPROM에 저장합니다.
- 보정 명령 `c`는 현재 위치를 다시 맞출 뿐, 저장된 주행 위치를 바꾸지 않습니다.
Opening a USB serial connection can reset an Arduino Nano through DTR. ## USB Serial Reset 보호
If the board boots while `IG1 HIGH` and parking is OFF, the controller assumes the seat is already at the saved driving position: Arduino Nano는 USB serial 연결 때 DTR 때문에 리셋될 수 있습니다.
보드가 부팅되는 순간 이미 `IG1 HIGH`이고 P단이 아니라면, 차가 주행 위치에 있다고 보고 현재 위치와 목표 위치를 EEPROM 저장 위치로 맞춥니다.
```text ```text
currentPositionMs = savedPositionMs currentPositionMs = savedPositionMs
@@ -39,48 +42,48 @@ targetPositionMs = savedPositionMs
relay = OFF relay = OFF
``` ```
This prevents unintended upward movement after USB reconnect while the gear is not in P. If the gear is then moved to P, the controller moves down from the saved position estimate to 0. 이렇게 해서 주행 중 USB 재연결이나 serial monitor 열림 때문에 시트가 불필요하게 위로 움직이는 상황을 막습니다. 이후 기어를 P단으로 옮기면 저장된 위치 추정값에서 `0ms`까지 내려갑니다.
## Serial Console ## Serial Console
Serial is quiet by default. Serial은 기본적으로 조용한 상태입니다.
1. Open serial at `115200`. 1. `115200` baud로 연결합니다.
2. Send an empty Enter once to unlock the console and print help. 2. 빈 Enter를 한 번 보내면 help가 출력되고 콘솔이 열립니다.
3. After unlock, only one-character commands are accepted. 3. 이후에는 한 글자 명령만 받습니다.
Commands: 명령:
```text ```text
s print current status s 현재 상태 출력
u manual up +500ms u 수동 상승 +500ms
d manual down -500ms d 수동 하강 -500ms
p save current estimated position to EEPROM p 현재 추정 위치를 EEPROM에 저장
g start debug output every 1s g 1초 간격 debug 출력 시작
x stop debug mode only x debug 모드만 종료
a return to gear-based automatic target a 기어 상태 기반 자동 목표로 복귀
c run calibration: up 7s, down 6s, set current position to 0 c 보정 실행: 7초 상승, 6초 하강, 현재 위치 0으로 설정
r clear 10-use auto calibration counter r 10회 자동 보정 카운터 초기화
h print help h help 출력
``` ```
These management commands require parking gear for safety: 다음 관리 명령은 안전을 위해 P단에서만 실행됩니다.
```text ```text
a c r a c r
``` ```
If the gear is not P: P단이 아니면 다음처럼 거부합니다.
```text ```text
ERR: check gear state. Command requires P. ERR: check gear state. Command requires P.
``` ```
While debug mode is active, only `x` is accepted. Other input is ignored. debug 모드 중에는 `x`만 받으며 다른 입력은 무시합니다.
Manual position commands `u`, `d`, and `p` are allowed while driving, as long as the controller is not busy with an in-progress movement. ## 상태 출력
Every status output uses one item per line and includes boot uptime: 상태 출력은 한 줄에 한 항목씩 표시하고, 부팅 후 경과 시간을 포함합니다.
```text ```text
[STATUS] [STATUS]
@@ -92,19 +95,19 @@ rawDriveMode=false
confirmedDriveMode=false confirmedDriveMode=false
``` ```
If the use counter reached 10, status/debug output also includes the ignition-off calibration timer: 자동 보정 카운터가 10회에 도달한 상태라면 IG1 OFF 유지 시간을 함께 보여줍니다.
```text ```text
autoCalibrationOffTimer=elapsed 0h 1m 20s 123ms remaining 0h 3m 39s 877ms autoCalibrationOffTimer=elapsed 0h 1m 20s 123ms remaining 0h 3m 39s 877ms
``` ```
If IG1 is still ON: IG1이 아직 켜져 있으면 다음처럼 표시합니다.
```text ```text
autoCalibrationOffTimer=waiting_for_ig_off autoCalibrationOffTimer=waiting_for_ig_off
``` ```
Debug mode prints a readable block every second, one item per line. Boolean values are printed as `true` or `false`: debug 모드는 1초마다 읽기 쉬운 블록을 출력합니다.
```text ```text
[DEBUG] [DEBUG]
@@ -128,11 +131,11 @@ forceCalibration=false
autoCalibrationState=0 autoCalibrationState=0
``` ```
## Automatic Calibration ## 자동 보정
- Each `IG1 HIGH -> LOW` transition increments the EEPROM use counter. - `IG1 HIGH -> LOW` 전환이 발생할 때마다 EEPROM 사용 카운터를 1 올립니다.
- After 10 uses, calibration is scheduled. - 10회가 되면 자동 보정을 예약합니다.
- If IG1 remains OFF for 5 minutes, automatic calibration runs: - IG1이 꺼진 상태로 5분 유지되면 자동 보정이 실행됩니다.
```text ```text
up 7000ms up 7000ms
@@ -142,29 +145,32 @@ targetPositionMs = 0
useCount = 0 useCount = 0
``` ```
If IG1 turns ON during scheduled calibration, calibration is aborted. Manual `c` calibration is allowed only in P and runs to completion. 예약 상태에서 IG1이 켜지면 보정은 취소됩니다. 수동 `c` 보정은 P단에서만 가능하고, 시작되면 끝까지 수행합니다.
## Safety Guards ## 안전 장치
- Commands are rejected while the seat is moving or a relay action is pending. - 시트가 움직이는 중이거나 릴레이 전환 대기 중이면 관리 명령을 거부합니다.
- Internal position values are clamped to `0..6000ms`. - 내부 위치값은 항상 `0..6000ms`로 제한합니다.
- Manual step completion is cancelled if gear state changes before completion. - 릴레이 방향 전환 사이에는 120ms dead time을 둡니다.
- Factory reset command was removed to avoid accidental EEPROM reset. - 수동 이동 중 기어 상태가 바뀌면 수동 step 완료 처리를 취소합니다.
- 실수로 EEPROM을 초기화하지 않도록 factory reset 명령은 제거했습니다.
## Build / Upload ## 빌드와 업로드
Compile: 컴파일:
```powershell ```powershell
& "C:\Program Files\Arduino CLI\arduino-cli.exe" compile --fqbn arduino:avr:nano:cpu=atmega328 --warnings all . & "C:\Program Files\Arduino CLI\arduino-cli.exe" compile --fqbn arduino:avr:nano:cpu=atmega328 --warnings all .
``` ```
Upload: 업로드:
```powershell ```powershell
.\upload.ps1 -Port COM3 .\upload.ps1 -Port COM3
``` ```
## Notes ## 참고
The controller estimates seat position by time. There is no physical position sensor. If power is cut while IG1 is OFF/P state, the next boot starts from estimated position 0. If the board resets while already in drive mode, it starts from the EEPROM saved driving position to avoid USB reconnect induced upward movement. P단 감지 임계값은 현재 코드 기준으로 ON `950`, OFF `940` hysteresis를 사용합니다. 차량별 전압 분배와 신호 특성이 다를 수 있으므로 실제 `analogRead` 값을 확인한 뒤 임계값을 조정해야 합니다.
이 프로젝트는 물리 위치 센서 없이 시간으로 위치를 추정합니다. IG1 OFF/P 상태에서 전원이 끊기면 다음 부팅은 하단 위치 추정값 `0ms`에서 시작합니다. 반대로 이미 주행 상태에서 보드가 리셋되면 EEPROM에 저장된 주행 위치에서 시작해 USB 재연결로 인한 불필요한 상승 동작을 줄입니다.