Showing posts with label MT-5. Show all posts
Showing posts with label MT-5. Show all posts

Wednesday, 1 March 2017

Tracer MT-5 Protocol. Communications to Tracer MPPT

Summary
Featured in this blog is a tear down of the EPSolar MT-5. The aim of the tear down was to assist in determining the communication protocol between the
MT-5 display and main EPSolar MPPT unit. 


Hardware
Although the Tracer MPPT and display models shown below are no longer sold by EPSolar, there were still numerous re-seller sites with stocks which raised my interest in using one for garden lighting control. This would require manual control of the load output.
EPSolar Tracer RN MPPT
EPSolar - Tracer MPPT Module


EPSolar MT-5 Display
EPSolar - MT-5 Display

There are more than a dozen sites with example code for the communications however none of it is complete. In order to determine the protocol the only two methods that came to mind were connecting with the EPSolar PC Monitoring software or monitoring the communications between the MPPT and display. The latter of the two methods was used.

MT-5 Teardown
The MT-5 from the rear appeared as a sealed unit, so removing the front window (lexan) was the first step to gain access.


MT-5 front cover removed
EPSolar MT-5 with front cover removed

After the window was removed, there were four screws to retain the main board and a few melted plastic posts to hold a secondary board containing the buttons.



EPSolar MT-5 PCB
EPSolar MT-5 PCB

After removing the boards both the main microcontroller ST - STM8S903K and LCD driver from Holtek - HT1621 were visible on the rear of the board. On the top side of the board was the LCD and LED light box serving as the LCD backlight.


MT-5 Protocol
Initial documentation for the EPSolar communications protocol was reviewed from Steve PomeroyJohn Geek and a document site with concise documentation by Marc Dilasser. 

Validation of the CRC16 was made using a site from Bastian Molkenthin.

MT-5 Hardware
To determine the protocol, a test system consisting of an MPPT connected to an MT-5 display with a pair of USB to TTL converters were used in conjunction with RealTerm.

Upon measuring the supply for the ST micro the voltage was confirmed to be 3.3VDC. A Prolific PL2303 adaptor, such as the unit from Core Electronics shown in the image below, was interfaced with the transmit and receive lines on the RJ45 connector. 
Prolific USB to TTL Adaptor
Prolific USB to TTL Adaptor

Pin 5 and 6 of the EPSolar RJ45 were receive and transmit respectively. Additionally it was noted that the transmit line was not driven from rail to rail but between 1.2V and 3.3V. This resulted in incorrect or no data seen by RealTerm in most cases. After consulting the datasheet for the driver in the USB adaptor (PL2303RA) it was noted that this specified 0.3 * 3V3 as the maximum voltage for a CMOS low (VIL). To resolve this a resistor divider with two 22K resistors was added to lower the amplitude of the signal.


Data Collection
The MT-5 sent two request packets to the MPPT on startup:

EB 90 EB 90 EB 90 01 AC 01 00 82 7B 7F      Current Battery, Modes Request *

* It should be noted that the battery and mode request is performed only once where as the real time data is updated on a regular basis.

EB 90 EB 90 EB 90 01 A0 01 03 BD BB 7F      Real Time Data Request


The responses for the unit under test were:
EB 90 EB 90 EB 90 00 AC 07 00 00 0A 03 01 11 12 D9 4A 7F


EB 90 EB 90 EB 90 00 A0 18 B9 09 00 00 00 00 00 00 AC 08 68 0B 00 00 00 26 00 00 00 00 38 00 00 00 E6 26 7F

Each of the settings on the MT-5 menu were changed and the packet exchange recorded.

Battery Type
EB 90 EB 90 EB 90 01 AD 07 00 00 03 01 14 10 12 3D 22 7F         Sealed
EB 90 EB 90 EB 90 01 AD 07 00 00 03 02 14 10 12 CD 21 7F GEL
EB 90 EB 90 EB 90 01 AD 07 00 00 03 03 14 10 12 9D 20 7F         Flooded

Battery Capacity (AH)
EB 90 EB 90 EB 90 01 AD 07 00 00 00 03 01 10 12 05 4A 7F   10AH min

EB 90 EB 90 EB 90 01 AD 07 00 00 00 03 5A 10 12 84 AC 7F 900AH max

Battery Compensation (mV/C)
EB 90 EB 90 EB 90 01 AD 07 00 00 00 03 14 10 12 51 1F 7F         0mV/C
EB 90 EB 90 EB 90 01 AD 07 00 00 0A 03 14 10 12 D9 1F 7F         -10mV/C

Timer 1 Setting
EB 90 EB 90 EB 90 01 AD 07 00 00 00 03 5A 00 12 80 F9 7F         Setting 0

EB 90 EB 90 EB 90 01 AD 07 00 00 00 03 5A 11 12 D1 FD 7F Setting 17

Timer 2 Setting
EB 90 EB 90 EB 90 01 AD 07 00 00 00 03 5A 12 01 0A 9C 7F         Setting 1

EB 90 EB 90 EB 90 01 AD 07 00 00 00 03 5A 12 11 1E CD 7F         Setting 17

For any change in settings the MPPT responded with a confirmation.
EB 90 EB 90 EB 90 00 AD 00 B0 5C 7F

To determine the battery and modes packet on startup some of the settings were changed to determine the packet structure.

EB 90 EB 90 EB 90 00 AC 07 00 00 0A 03 01 11 12 D9 4A 7F         Timer 1 17, Timer 2 n
EB 90 EB 90 EB 90 00 AC 07 00 00 0A 03 5A 11 12 58 AC 7F Battery capacity 900AH
EB 90 EB 90 EB 90 00 AC 07 00 00 0A 01 5A 11 12 F8 AE 7F         Battery type sealed
EB 90 EB 90 EB 90 00 AC 07 00 00 01 01 5A 11 12 34 BB 7F         Battery compensation 1mV/C

There appeared to be some additional data in the packet however it was not identified at the time.

From the MT-5 manual load control was enabled with Timer 1 set to Manual (On/Off Mode). The Power/Esc button on the MT-5 was presses and the packets recorded.

EB 90 EB 90 EB 90 01 AA 01 01 1D 9B 7F Load ON


EB 90 EB 90 EB 90 01 AA 01 00 0D DA 7F       Load OFF

To verify the position of the load status in the real time data packet this was also collected.

EB 90 EB 90 EB 90 00 A0 18 B2 09 09 00 00 00 00 00 AC 08 16 0B 01 00 00 2A 00 00 00 00 37 00 00 00 15 1A 7F        Load ON

EB 90 EB 90 EB 90 00 A0 18 B9 09 00 00 00 00 00 00 AC 08 16 0B 00 00 00 2B 00 00 00 00 37 00 00 00 A3 29 7F         Load OFF


Updated Protocol Document
With the jumble of packets collected, the original MPPT Protocol PDF document, Ver 3, "Protocol-Tracer-MT-5.pdf" by Alex Ruhmann was updated.

The protocol document was reformatted into "Protocol-Tracer-MT-5 V5.pdf". An example of the new layout in the V4 PDF shown below.


Battery / Timer Control Settings Request
Request
Command
Data Size
Data
Checksum
0x1
0xAC
0x01
0x00
CRC-16 0x1041

Example: EB 90 EB 90 EB 90 01 AC 01 00 82 7B 7F

Battery / Timer Control Settings Reply
Reply
Command
Data Size
Data
Checksum
0x0
0xAC
0x07
Byte 1: Load type (unused, 0x00)
CRC-16 0x1041



Byte 2: Charging mode (unused, 0x00)




Byte 3: Battery temperature compensation voltage. Range from 0 to 10. Units -mV/V




Byte 4: Battery Type, 1 – Sealed, 2 – Gel, 3 – Flooded




Byte 5: Battery Capacity, Range from 1 to 90 decimal. Units AH. Multiplied by 10 for actual AH battery rating.




Byte 6: Timer 1 setting, Range 0 to 18




Byte 7: Timer 2 setting, Range 1 to 18



Example: EB 90 EB 90 EB 90 00 AC 07 00 00 0A 03 01 10 12 8C 1B 7F


Downloads
An updated version of the Protocol (Ver5) available with an additional example of a software CRC16.

Protocol-Tracer-MT-5 V5.pdf
Protocol-Tracer-MT-5 V5.pdf

Thursday, 31 December 2015

PSoC to Tracer MPPT 1210RN 2210RN 3215RN 4210RN with Bluetooth and Datalogger

Summary
Although the early EPSolar MPPT Tracer series with remote display have been surpassed by improved MPPT models with inbuilt LCDs, there are plenty of the earlier models that remain in operation. This project is Cypress PSoC 4 BLE based and features connection to the Tracer MPPT, load control, Bluetooth and data logging of the MPPT data.

MPPT
A number of other people have used the EPSolar MT-5 display to reverse engineer the communications protocol, however there was PC software from the same manufacturer which performed all the same functions, possibly more.
EPSolar Tracer RN MPPT
EPSolar Tracer RN MPPT
At last glance of the EPSolar website the Tracer series had reached obsolescence and the PC software on the site no longer supports the Tracer series.

Hardware
Initial documentation for the MPPT connections were taken from a site by Steve Pomeroy, another two sites by John Geek. The 8 way RJ connections to the Tracer were drafted with an optional zero ohm link added such that the MPPT could power the project. Buffers were added to the transmit and receive lines, although not a necessity, to ensure some protection for the PSoC from the real world.


EPSolar Tracer RJ45 Connections
EPSolar Tracer RJ45 Connections

For the display an OLED or LCD capable of being powered from 3.3V for both the logic and backlight was selected. In most instances this results in the LCD contrast voltage being negative however this was generated by the PSoC using the circuit shown below.


LCD Connections
LCD Connections
Four momentary push buttons were used instead of the Cypress Capsense feature. This solution using switches was chosen only due to the design of the hardware as the PCB was to be mounted inside a box and away from the lid.


Buttons / User Interface Connections
Buttons / User Interface Connections

The power supply regulator was chosen to be small and the usual buck topology. The LMR14203 has been my default single output regulator for some time, certainly there are newer devices with higher efficiency in the low current region of operation. In the event the display that was chosen could not have the backlight operate from 3.3V, a linear 5V regulator was added for testing.


Power Supply Connections
Power Supply Connections

Even though the design incorporated Bluetooth, USB was added for debugging, downloading of data and upgrading of the PSoC. Field upgrades would be possibly by using the PSoC bootloader, a program allowing the active application to be updated some time in the future. The FTDI FT230X was chosen for the USB implementation however for those looking for a similar priced and reliable solution the Cy
press CY7C65213A-32 would also be a good choice.

FTDI USB Connections
FTDI USB Connections

The PSoC selected was the CY8C4247LQI-BL483, which features a 48MHz System Clock, 128K FLASH and the all important Bluetooth. Although the PSoC4 libraries did not support SD at the time of writing, there are a few alternatives from the PSoC Community.


PSoC Connections and Supply Filtering
PSoC Connections and Supply Filtering
Lastly bringing all the sub-sheets together is the top sheet as shown below.


Project Top Sheet
Project Top Sheet

PCB Enclosure
The PCB was designed to fit into a plastic enclosure with a clear lid, no bells no whistles. A Ritec case from a local supplier was used, the Altronics H0324.


Altronics H0324 enclosure
Altronics H0324 enclosure

With the enclosure size selected the PCB dimensions were set to 98mm (W) x 75mm (H).

PCB Design
For the schematic and board design Altium was chosen since the board was mixed logic with RF. This combination was always in my mind a four layer board. The board layer stack would follow the usual two middle power planes and signals on the outside layers.

There were a number of parts added to the component database although none more interesting that the meandered inverted-F antenna (MIFA) to suit the PSoC4 BLE part. The antenna design was well documented in the Cypress Application Note - AN91455. This antenna was implemented as described on Page 10 of the Application Note.


PSoC4 BLE MIFA
PSoC4 BLE MIFA 
The board shape was drawn and a work guide added for the position of the four push buttons, then all components were place on the PCB.

Tracer MPPT Interface Board
Tracer MPPT Interface Board
With some quick shuffling of parts then an idea of the layout could take place.

Tracer MPPT Interface Board Parts Placement
Tracer MPPT Interface Board Parts Placement
Parts positions were changed on the PCB with some connectors and the SD card moved to the bottom layer.


Tracer MPPT Interface Board Final Part Placement
Tracer MPPT Interface Board Final Part Placement
A few hours later the final route is shown below.


Tracer MPPT Interface Board Final Route
Tracer MPPT Interface Board Final Route
The board in 3D shows the stacking of the LCD and logic board.

Tracer MPPT Interface Board with LCD
Tracer MPPT Interface Board with LCD
PCB Prototype
The PCB was hand populated for both top and bottom layer. Some last minute modifications were made to the LCD connector and backlight control because the four line LCD had to be changed to another manufacturer. LCD supply pins were swapped.


Top Layer MPPT PCB Populated
Top Layer MPPT PCB Populated
Bottom Layer MPPT PCB Populated
Bottom Layer MPPT PCB Populated
To mount the LCD to the MPPT board, a male pin header was soldered to the bottom side of the LCD. To space the LCD and MPPT board 12mm tapped metal spacers were used.


Spacers for MPPT PCB and LCD
Spacers for MPPT PCB and LCD

USB Check
Two of the hardware connections that were used for debugging this particular project were the Cypress MiniProg3 programmer and the USB port. Certainly the LCD or on-board status LED could also be useful although the background debugger and serial port usually work sufficiently.

With the USB connected between the MPPT board and a Windows PC, the FDTI chip was configured using the FTDI application FT Prog. This application was used to disable three unused CBUS pins and reconfigure the fourth for USB bus voltage detection.


FT Prog Scan
FT Prog Scan
The Scan command was issued the the FTDI device was located.


FT Prog Default CBUS Settings
FT Prog Default CBUS Settings
From the list shown in the Device Tree pictured above, the 'Hardware Specific' item was expanded and the 'CBUS signals' entry was selected.


FT Prog Updated CBUS Settings
FT Prog Updated CBUS Settings
The settings were modified as shown above which enabled voltage sensing for the USB - VBUS_Sense. All other CBUS pins were unused and therefore tristated.


FT Prog Program
FT Prog Program
To save the CBUS settings changes using FT Prog, the 'Program' command was used. As shown in the capture above a 'Program Devices' dialog allows for confirmation of the Program process then subsequent programming.


RealTerm Loopback Test for MPPT Board
RealTerm Loopback Test for MPPT Board
In order to test the USB a dummy PSoC application was made to loopback the Tx and Rx pins, P0.4 and P0.5 respectively. RealTerm was then used to test the loopback at 921600 - no issues were noted.

Software - Prototype
After the initial hardware checks of the boards power rails some initialisation code was written to check the LCD, buttons and communications. Below is an example of the initialised LCD.


Initialised LCD for Testing
Initialised LCD for Testing

A prototype project, certainly with some bugs, is available for download below.
Prototype Tracer PSoC MPPT Interface
Prototype Tracer PSoC MPPT Interface
The prototype project implements communications to the Tracer MPPT and display of current MPPT readings to LCD. Some of the current MPPT readings are also sent to the USB port for logging.

Serial Data Logging
The data logging 'USB output' was rather raw code with the sole purpose of providing a console output capable of being imported into Microsoft Excel. The UART Update function was called every minute and send some basic information to a terminal application.

void UART_Update() 
{
    char UART_Buf[20];
    uint16_t UART_temp;

    UART_UartPutString(LINE1_PV);
    UART_temp = MPPTPanelVoltage;                           /* Temp memory to modify for display */
    sprintf(UART_Buf, "%d.%02d%s%c", (UART_temp/100), (UART_temp%100),"V",0x9);
    UART_UartPutString(UART_Buf);
    UART_UartPutString(LINE1_BV);
    UART_temp = MPPTBatVoltage;                             /* Temp memory to modify for display */
    sprintf(UART_Buf, "%d.%02d%2s%c", (UART_temp/100), (UART_temp%100),"V ",0x9);
    UART_UartPutString(UART_Buf);   
    UART_UartPutString(LINE2_BI);  
    UART_temp = MPPTBatteryCurrent;                         /* Temp memory to modify for display */
    sprintf(UART_Buf, "%d.%02d%s%c", (UART_temp/100), (UART_temp%100),"A",0x9);
    UART_UartPutString(UART_Buf);
    if (System.MPPT_Load_Is_On == true)
    {
        UART_UartPutString(" Load On\r\n");
    }
    else if (System.MPPT_Load_Is_On == false)
    {
        UART_UartPutString(" Load Off\r\n");
    }
}

Shown below is an example of the data output to a terminal application.
MPPT Example UART Output
MPPT Example UART Output
The output panel voltage displayed in the terminal window was also used to verify the position and angle of the solar panel. Moving the solar panel a few degrees off axis to the sun appeared to make no appreciable difference in the readings.

MPPT Protocol
The protocol was verified and confirmed in another of my blogs which can be found at http://electronicmethods.blogspot.com.au/2017/03/tracer-mt-5-to-mppt-communications.html

SD Card
The SD card implementation was scheduled to use the Element 14 community project #50 implementation for the PSoC4, which uses a modified version of the Segger / Cypress EmFile. In early part of '18 an article appeared Hackser.io with an implementation using Segger libraries by Hima from Cypress allowing SCB (Serial Communication Block) or UDB's (Universal Digital Blocks) for communications to the SD card.

Downloading and compiling the example from Hackster illustrated how easily the project could be changed between SCB or UDB's. Another feature buried in the API's are related SD card functions which are non-blocking. For full details see the Hackster.io site with credit to Hima. Note the Segger library license requirement.

In the capture below, are the two additional directories for adding the SD Card libraries to the MPPT project.


PSoC4 SD Card Libraries Compiler Entries
PSoC4 SD Card Libraries Compiler Entries
Similarly the Linker references one additional directory.


PSoC4 SD Card Library Linker Entry
PSoC4 SD Card Library Linker Entry
To test the SD Card the appropriate File System header file was included and blocking writes were made to the SD card - a snippet is shown below.

#include <FS.h>
...
...
if ((pFile) && (SD_Removed_Read() == false))
    {      
        UARTCrLf[0] = 0x0a;UARTCrLf[0] = 0x0d;

        FS_Write(pFile, PV_string, strlen(PV_string));
        FS_Write(pFile, "," , 1u);
        FS_Write(pFile, BV_string, strlen(BV_string)); 
        FS_Write(pFile, "," , 1u);
        FS_Write(pFile, BI_string, strlen(BI_string)); 
        FS_Write(pFile, "," , 1u);
        FS_Write(pFile, TE_string, strlen(TE_string));
        FS_Write(pFile, "," , 1u);
        FS_Write(pFile, LOAD_string, strlen(LOAD_string));
        FS_Write(pFile, UARTCrLf , strlen(UARTCrLf));
    }

The rather inelegant code above was for testing opening of the log file written to the SD card, by Excel, Libre Office or another similar application with CSV capabilities. Shown below is a sample of the log from the SD card.

0.00V,13.34V,0.00A,25C,OFF
0.14V,13.34V,0.03A,25C,ON 
0.14V,13.32V,0.02A,25C,ON 
0.14V,13.32V,0.02A,26C,ON 

Next up scheduling control of the SD card....