Skip to content

Latest commit

 

History

History
406 lines (339 loc) · 15.1 KB

SPI.md

File metadata and controls

406 lines (339 loc) · 15.1 KB

SPI Bus

Interface

The AC is the SPI master. MHI uses the signals SCK, MOSI and MISO. A slave select signal is not supported.

Name Function input/output
SCK serial clock Clock output from AC
MOSI Master Out, Slave In Data output from AC
MISO Master In, Slave Out Data input to AC

Protocol

Clock polarity: CPOL=1 => clock idles at 1, and each cycle consists of a pulse of 0 Clock timing: CPHA=1 => data is captured with the rising clock edge, data changes with the falling edge

Timing

TFrame Time for one frame
TFramePause Time between two frames
TByte Time for one byte
TBytePause Time between two bytes
TBit Time for one bit

grafik

The following timing is used by SRK xx ZS-S

TFrame TFramePause TByte TBytePause TBit
10ms 40ms 250µs 250µs 31.25µs

Other models could have different timing

A frame consists of 20 bytes. A frame consumes 20x2x250µs=10ms. Between 2 frames is a pause of 40ms. 20 frames per second will be transmitted. The following oscilloscope screenshot shows 3 bytes: grafik

Yellow: SCK; Purple: MOSI

SPI Frame

A frame starts with three signature bytes, followed by 15 data bytes and 2 bytes for a checksum. The following table shows the structure of a frame. In the ESP8266 program code and in the description mainly the short names are used.

raw byte # long name short name
0 signature byte 0 SB0
1 signature byte 1 SB1
2 signature byte 2 SB2
3 data byte 0 DB0
4 data byte 1 DB1
5 data byte 2 DB2
6 data byte 3 DB3
7 data byte 4 DB4
8 data byte 5 DB5
9 data byte 6 DB6
10 data byte 7 DB7
11 data byte 8 DB8
12 data byte 9 DB9
13 data byte 10 DB10
14 data byte 11 DB11
15 data byte 12 DB12
16 data byte 13 DB13
17 data byte 14 DB14
18 checksum byte high CBH
19 checksum byte low CBL

In the description we differ between

MOSI frame -> frame send by AC
MISO frame -> frame send by remote control, e.g. MHI-AC-Ctrl, received by AC.

For the testing and evaluation of the protocol the remote controls MH-AC-WIFI-1 and RC-E5 were used.

Signature

The MOSI signature bytes indicate the start of a frame with the 3 bytes 0x6c, 0x80, 0x04. The first signature byte varies with the AC. For some Mitsubishi AC models it is 0x6d. The MISO frame has the signature 0xa9, 0x00, 0x07.

Data

The following clauses describe the MOSI/MISO decoding for power, mode, fan, vanes, temperature setpoint and room temperature.

Power

Power status is coded in MOSI DB0[0].

DB0 Function
Bit 0 Power
0 off
1 on

The same coding is used for setting the Power status. The set bit in the MISO frame is DB0[1].

Mode

The mode is coded in MOSI DB0[4:2].

DB0 Function
bit 4 bit 3 bit 2 Mode
0 0 0 Auto
0 0 1 Dry
0 1 0 Cool
0 1 1 Fan
1 0 0 Heat

The same coding is used for setting the Mode. The set bit in the MISO frame is DB0[5].

Fan

The fan level is coded in MOSI DB1[1:0] and in DB6[6].

DB1 DB6 Function
bit 1 bit 0 bit 6 Fan
0 0 0 1
0 1 0 2
1 0 0 3
x x 1 4

The same coding is used for setting Fan=1..3. The set bit in the MISO frame is DB1[3]. But for setting Fan=4 DB6[4], not DB6[6] of the MISO frame is used:

DB1 DB6 Function
bit 1 bit 0 bit 4 Fan
0 1 0 4
note: With the Infrared-remote control (IR-RC) you can select "auto" for the fan. But this is not reflected by the SPI payload.

The following table shows the mapping between Fan and IUFANSPEED (opdata) and the IR-RC for Mode=Fan:

Fan IUFANSPEED IR-RC
last 0 off
1 2 1 bar
2 3 2 bars
3 4 3 bars
4 5 4 bars
n/a variable, up to 7 auto

'last' in the first row (when AC is powered off) means that the value of Fan is according to the last setting.

For the following diagram Fan was set to auto via IR-RC for Mode=Cool, you see the increase of IUFANSPEED from 0 to 2, 4, 6, 7: grafik

Note that IUFANSPEED=2 is not visible in the diagram due to the low sample rate used for it.

Vanes

Vanes up/down swing is enabled in DB0[6]. When vanes up/down swing is disabled the vanes up/down position in MOSI DB1[5:4] is used.

DB0 Function
Bit 6 vanes up/down swing
0 off
1 on
DB1 Function
bit 5 bit 4 Vanes up/down position
0 0 1
0 1 2
1 0 3
1 1 4

note: Vanes status is not applicable when using IR remote control. The latest vanes status is only visible when it was changed by the SPI-RC. The latest vanes status is only visible when MOSI DB0[7]=1 or MOSI DB1[7]=1.

The same coding is used for setting vanes. The set bit for enabling vanes up/down swing in the MISO frame is DB0[7]. The set bit for vanes up/down position in the MISO frame is DB1[7].

Room temperature

The room temperature is coded in MOSI DB3[7:0] according to the formula T[°C]=(DB3[7:0]-61)/4 The resolution is 0.25°C. When writing a value <255, this temperature value is used instead of the build in room temperature sensor.

Temperature setpoint

The temperature setpoint is coded in MOSI DB2[6:0] according to the formula T[°C]=DB2[6:0]/2 The resolution of 0.5°C is supported by the wired remote control RC-E5 and MHI-AC-Ctrl. But the IR remote control supports a resolution of 1°C only. The same coding is used for setting the temperature. The set bit in the MISO frame is DB2[7].

Error code (read only)

The Error code is a number 0 ... 255 in MOSI DB4[7:0]. 0 means no error. According my understanding the error codes listed here are supported, but I haven't really checked it.

Checksum (read only)

The two byte checksum is calculated by the sum of the signature bytes plus the databytes. The high byte of the checksum CBH is stored at byte position 18 and the low byte of the checksum CBL is stored at byte position 19.

checksum[15:0] = sum(SB0:SB2) + sum(DB0:DB14)
CBH = checksum[15:8]
CBL = checksum[7:0]

Settings

For writing MHI-AC - depending on the function - a specific MISO set-bit is used:

function set-bit
Power DB0[1]
Mode DB0[5]
Fan DB1[3] and DB6[4] for Fan=4
Vanes DB0[7] for swing and DB1[7] for up/down position
Tsetpoint DB2[7]

Once a set-bit is set to 1, the according bit in the MOSI frame becomes and remains '1' until the IR remote control is used. All set-bits are cleared when the IR remote control is used. Settings can be done independent from the power state.

Operation Data

You can read different operating data of the AC related to the indoor and outdoor unit. The following example shows the reading of the outdoor air temperature:

MISO-DB6 MISO-DB9 MISO-DB10 MISO-DB11 MISO-DB12
0x40 0x80 0xff 0xff 0xff
MOSI-DB6 MOSI-DB9 MOSI-DB10 MOSI-DB11
bit7==0 0x80 0x10 outdoor temperature

Please check the program code for further details. You find here the list of some supported topics related to operating data. And some details related to the operating data are listed in section Operation Data Details. Please consider that the decoding of the data could be imcomplete since only one AC (SRK 35 ZS-S) was available for testing.

Last Error Operation Data

The AC stores some operation data of the last error event. This error operation data can be read with the command:

MISO-DB6[7] MISO-DB9
1 0x45

AC answers with the following MOSI data sequence:

MOSI-DB6[7] MOSI-DB9 MOSI-DB10 MOSI-DB11
1 0x45 0x11 error code

If error code > 0 the following MOSI data sequence is send in addition:

MOSI-DB6[7] MOSI-DB9 MOSI-DB10 MOSI-DB11
1 0x45 0x12 count of the following error operation data

Examples for error operation data

MOSI-DB6[7] MOSI-DB9 MOSI-DB10 MOSI-DB11
1 0x02 0x30=Stop, 0x31=Dry, 0x32=Cold, 0x33=Fan, 0x34=heat
1 0x05 0x33 SET TEMP = MOSI-DB11 / 2
1 0x1e 0x30 TOTAL I/U RUN = MOSI-DB11 * 100

Summary

MOSI frame: grafik

Operation Data Details

Here you find detailed information related to some operating data. It is mainly based on my observations and might be partly not correct. It seems that there are different operating data available for different ACs. So there might be operating data not supported by your AC (e.g. the number of implemented temperature sensors) or there might be additional operating data available for your AC but not supported by the SW. The same is valid for the error operation data. I'm not aware how to find out addtional operation data w/o using a third party wired remote control.

1 "MODE"

Stored in the lower 4 bits of DB10:

DB10[3:0] MODE
0x0 Auto or Stop in error mode
0x1 Dry
0x2 Cool
0x3 Fan
0x4 Heat

2 "SET-TEMP" [°C]

The setpoint for the temperature is coded in MOSI-DB11[6:0] according to the formula T[°C]=DB11[6:0]/2. The value is identical to Temperature setpoint but with the lower resolution of 1°C when the AC is not powered. But when the AC is powered and Mode=HEAT then SET-TEMP=Temperature setpoint+2°C. This behavior can be changed for some ACs, see here.

3 "RETURN-AIR" [°C]

Nearly identical to Room temperature. Sometimes the two values differ by <0.5 ° C. Background is not clear. The RETURN-AIR temperature is calculated by T[°C]=(DB11[7:0]-61)/4. The resolution is 0.25°C.

12 "TOTAL-IU-RUN" [h]

Operating hours Indoor Unit[h]=DB11*100

21 "OUTDOOR" [°C]

Outdoor temperature [°C]=DB11

24 "COMP" [Hz]

Compressor frequency=(db10-0x10)*25.6f + 0.1f * db11, for db10>=0x10

27 "TD" [°C]

Discharge Pipe Temperature,
if db11 < 0x12 TD <=30°C,
else TD = db11 / 2 + 32 (approx)

29 "CT" [A]

Current CT[A]=DB11*14/51

Resolution is 274.5mA. Multiply the current by the voltage (230V) to calculate the power.

32 "TDSH" [°C]

TDSH[°C]=DB11/2

37 "TOTAL-COMP-RUN" [h]

Operating hours compressor [h]=DB11*100

Unknown

In the SPI frames are more information coded than known for me. In MOSI-DB13 some bits seem to represent the status of the outdoor unit. I would appreciate your support to close these gaps.