// Eltek Flatpack Permanent Voltage changer, Code By RHO
// Used Arduino board is a Leonardo CANbus Board, abtainable at http://www.hobbytronics.co.uk
// The procedure for permanent default voltage change is :
// You have to have a connection to the CAN-bus (obviously)
// if the serial number of your Flatpack is 123456789012
// Change line 46 with the serial nr in the code as below
// send 0x05004804 0x12 0x34 0x56 0x78 0x90 0x12 0x00 0x00 (to log in to the rectifier)
// send 0x05009C02 0x2B 0x15 0x00 0x80 0x16 (to set the permanent default voltage)
// upload code to Arduino
// disconnect Arduino from usb so it powers down
// First power on the Flatpack
// Then power on Arduino via usb
// After about 10 seconds or so the output voltage should change to the new default voltage.
// Now wait 30 seconds and disconnect the power to the rectifier.
// When you start up again the voltage will default to (in this sketch ) 57.5 Volt. The default voltage is determined by the last 2 bytes of the second command.
// Multiply your desired voltage with 100 (57.50 => 5750).
// Convert this number to HEX values (5700 => 0x1680). switch the two bytes (0x1680 => 0x80 0x16) and you have your code for setting the voltage
// NOTE: Some Flatpacks needs to run this procedure several times to change the Voltage.
// Sometimes the Flatpack shows an yellow led, but no Voltage change. Just repeat the procedure until it changes the voltage.
//CHANGES: LED showing start/end proces
#include <mcp_can.h>
#include <mcp_can_dfs.h>
#include <SPI.h>
const int SPI_CS_PIN = 17; // Set CS pin to pin 17
MCP_CAN CAN(SPI_CS_PIN); // Set CS pin for CANBUS shield
void setup() // Initialisation routine
{
pinMode(23, OUTPUT); // Set pin 9 to output (backlight of the LCD)
digitalWrite(23, HIGH); // LED on
delay(250);
digitalWrite(23, LOW);
START_INIT:
if(CAN_OK == CAN.begin(CAN_125KBPS)) // init can bus : baudrate = 125k !!
{
}
else
{
delay(100);
goto START_INIT;
}
unsigned char login[8] = {0x15, 0x12, 0x72, 0x00, 0x08, 0x46, 0x00, 0x00}; //this is the serial number of the Flatpack + 2 added bytes of 00 each)
CAN.sendMsgBuf(0x05004804, 1, 8, login); //send message to log in and assign ID=1 (last 04 means ID=1, for ID=2 use 05004808 )
unsigned char setdefaultvolt[5] = {0x2B, 0x15, 0x00, 0x80, 0x16}; //this is the command for setting the default output voltage (Last two bytes, LSB first). 16 80 is the maximum voltage of 57.6 V
CAN.sendMsgBuf(0x05009C02, 1, 5, setdefaultvolt); //send message to set ouput voltage to all Flatpacks connected to the CAN-bus
digitalWrite(23, HIGH);
}
void loop() // main program (LOOP)
{ // nothing to do :)
}
/*********************************************************************************************************
END FILE
Voltage settings
80 16 => 1680 HEX = 57,60 Volt (= highest possible voltage
E6 14 => 14E6 HEX = 53,50 Volt (= factory set voltage)
FE 10 => 10FE HEX = 43,50 Volt (= lowest possible voltage)
*********************************************************************************************************/