Control an Emerson R48-2000eR rectifier over CAN with an ESP32-C3 and MCP2515 to charge a LiFePO4 battery
The Emerson R48-2000eR is a 48 V telecom rectifier rated for about 2 kW. It is cheap second-hand and, once you can set its voltage and current limit, it makes a good charger for a LiFePO4 battery. The settings are changed over CAN.
This is the first stage of the project: an ESP32-C3 SuperMini with an MCP2515 CAN module that sends a fixed voltage and current limit to the rectifier. It charges a 16S LiFePO4 battery of 314 Ah cells, protected by a JK BMS. A later version added an encoder and a display and also supports a Huawei rectifier; it is described in One ESP32-C3 controller for Huawei R4850G2 and Emerson R48-2000e rectifiers.
Parts
| Part | Notes |
|---|---|
| Emerson R48-2000eR | 48 V rectifier |
| ESP32-C3 SuperMini | controller |
| MCP2515 CAN module | 8 MHz crystal, transceiver marked NXP A 1050/C |
| 16S LiFePO4 battery | 314 Ah cells, JK BMS |
Wiring
| Function | ESP32-C3 SuperMini pin |
|---|---|
| MCP2515 SCK | GPIO4 |
| MCP2515 MISO | GPIO5 |
| MCP2515 MOSI | GPIO6 |
| MCP2515 CS | GPIO7 |
The MCP2515 module works at 5 V, while the ESP32-C3 is a 3.3 V device, so the MISO line from the module to the ESP32 goes through a resistor divider. I did not have the usual values, so I used 1.8 kohm and 3 kohm, which brings 5 V down to about 3.1 V.
The rectifier’s connector
The DC connector of my unit has six positions. Pin 1 is plus, pin 6 is minus and pin 2 is absent. Pins 3, 4 and 5 are the small signal pins, with pin 3 slightly thicker.
CAN is on pins 4 and 5, with the signal ground on pin 3. With a scope on those pins I saw complementary square waves, and the frames decode at 125 kbit/s.
I measured more than 12 V DC between each of pins 3, 4 and 5 and pin 6 (output minus), so the CAN side is not at the output-minus potential. Measure your own unit before connecting anything to the connector.
CAN protocol (Emerson R48-2000e)
The bus runs at 125 kbit/s with 29-bit IDs. At first I read the bus as 250 kbit/s, but those frames were just misdecoded; 125 kbit/s in normal mode is correct.
The rectifier sends its own frames, ID 0x0707F803 with data 01 F0 00 00 00 00 00 00 or 02 F0 00 00 00 00 00 00. I have not decoded them.
Commands to the rectifier all use ID 0x0607FF83 (extended) and 8 data bytes: 03 F0 00 CMD followed by a 32-bit big-endian float.
| CMD | Meaning | Value |
|---|---|---|
0x21 | Voltage, online (volatile) | float, volts |
0x24 | Voltage, offline (stored in the rectifier) | float, volts |
0x22 | Current limit, online (volatile) | float, fraction of 47 A |
0x19 | Current limit, offline (stored in the rectifier) | float, fraction of 47 A |
The current limit is a fraction of the rated current, 47 A for this model. Worked examples:
- 56.8 V online:
03 F0 00 21 42 63 33 33 - 20 A online: 20 / 47 = 0.4255, so
03 F0 00 22 3E D9 DF 52
Online versus offline. The online values are volatile, so the sketch resends them every 10 seconds. The offline values are the ones the rectifier keeps for itself and uses at power-up.
Code
Written in the Arduino IDE for the ESP32-C3 with the autowp/arduino-mcp2515 library. The values are set in the code:
const float RATED_A = 47.0; // rated current of the R48-2000eR
const float TARGET_V = 56.8; // 3.55 V per cell on 16S
const float TARGET_I = 20.0; // current limit, amps
One function sends all four commands:
bool sendFloat(uint8_t cmd, float value) {
union { float f; uint8_t b[4]; } u;
u.f = value;
can_frame f;
f.can_id = 0x0607FF83 | CAN_EFF_FLAG;
f.can_dlc = 8;
f.data[0] = 0x03;
f.data[1] = 0xF0;
f.data[2] = 0x00;
f.data[3] = cmd;
f.data[4] = u.b[3]; // big-endian
f.data[5] = u.b[2];
f.data[6] = u.b[1];
f.data[7] = u.b[0];
return mcp.sendMessage(&f) == MCP2515::ERROR_OK;
}
What the sketch does:
- At start-up it sends the online voltage and current, so the rectifier goes to the right values at once.
- It then stores the same values in the rectifier’s permanent memory as offline values.
- In the loop it resends the online values every 10 seconds, to keep control of the rectifier, and prints the frames it receives from the rectifier on the serial port every 5 seconds.
This first version writes the offline values on every boot, which wears the rectifier’s non-volatile memory. In the later firmware I write them only on an explicit long press of the encoder.
Repo:
First test
With no battery connected, I sent an online voltage of 56.4 V. The output went from 54.5 V to 56.4 V on a multimeter.
Problems and fixes
- Which pins are CAN: a scope on the connector found them. See the connector section.
- Wrong bitrate: the bus looked like 250 kbit/s, but the correct value is 125 kbit/s.
- MISO level: the 5 V MCP2515 module needs a divider on MISO for the 3.3 V ESP32.
- Fan: the fan runs at full speed at power-up and slows down clearly once the voltage is set. With the later firmware I also found that it keeps running when the output is switched off over CAN.
Safety
This rectifier delivers real power at 48 V and can supply a lot of current. Put an ideal diode or a MOSFET on its output so it never sees the battery voltage, use a BMS, set the voltage and current limit to your battery’s specification (56.8 V is 3.55 V per cell on a 16S pack), and test first on a resistive load before connecting a battery. Check the connector voltages on your own unit before wiring anything to it.