driving via canbus Eltek 2kW Flatpack2 supplies


Author Message
poida

Guru

Joined: 02/02/2017
Location: Australia
Posts: 1117
Posted: 07:12am 29 Mar 2020      

I have the DS1054Z with all options enabled here at home. At work I have a DS2072 with all options.

But decoding canbus is no longer needed. I have some code working now that can talk to and listen from the Eltek.

I just changed the default output voltage to 48.00V
Now to change default current limits...

#include <SPI.h>
#include "mcp_can.h"
#include <mcp_can_dfs.h>

unsigned char login[8] = {0x16, 0x36, 0x71, 0x07, 0x03, 0x76, 0x00, 0x00}; //this is for logging into your flatpack. Must use your serial number.

const int SPI_CS_PIN = 10;
MCP_CAN CAN(SPI_CS_PIN); // Set CS pin

#define VOLTAGE 4800
#define CURRENT 0100

uint8_t outset[8] = {CURRENT & 0xff, (CURRENT >> 8) & 0xff, VOLTAGE & 0xFF, (VOLTAGE >> 8) & 0xFF ,VOLTAGE & 0xFF, (VOLTAGE >> 8) & 0xFF ,0x3E, 0x17};

void setup()
{
   Serial.begin(115200);
   pinMode(3,INPUT);
START_INIT:
   if(CAN_OK == CAN.begin(MCP_ANY, CAN_125KBPS, MCP_8MHZ))
   {
       Serial.println("CAN BUS Shield init ok!");
   }
else
   {
   Serial.println("CAN BUS Shield init fail");
   Serial.println("Init CAN BUS Shield again");
   delay(100);
   goto START_INIT;
   }
CAN.setMode(0);    
delay(200);
CAN.sendMsgBuf(0x05004804, 1, 8, login);    // id = 1 so XX = 04    
}


void loop() {
   unsigned char len = 0;
   unsigned char buf[8] ;
   int c=0;
   if(CAN_MSGAVAIL == CAN.checkReceive())
   {
       
       CAN.readMsgBuf(&len, buf);
         uint32_t canId = CAN.getCanId();
         Serial.print("0");
         Serial.print(canId,HEX);
         Serial.print("\t");
       for(int i = 0; i<len; i++)
       {
           if( buf[i] < 0x10){ Serial.print("0");} Serial.print(buf[i],HEX);
           Serial.print(" ");
       }
       Serial.println();
      Serial.print("Temperature = ");
      Serial.println(buf[0]);
      Serial.print("Current = ");
      Serial.println(buf[2]*255*0.1+buf[1]*0.1);
      Serial.print("OutputVoltage = ");
      Serial.println(buf[4]*255*0.01+buf[3]*0.01);
      Serial.print("OutputPower = ");
      Serial.println((buf[4]*255*0.01+buf[3]*0.01)*(buf[2]*255*0.1+buf[1]*0.1));
      Serial.print("InputVoltage = ");
      Serial.println(buf[5]);
     
      //send request for new update
      CAN.sendMsgBuf(0x05004804, 1, 8, login);     // XX = 04
     
      //CAN.sendMsgBuf(0x05FF4004, 1, 8, outset);
   
     }
}


and I get

(etc.)
05014004 20 0F 00 C1 12 F3 00 2D
Temperature = 32
Current = 1.50
OutputVoltage = 47.83
OutputPower = 71.74
InputVoltage = 243
(etc.)


in the serial terminal.
I can talk to it!
wronger than a phone book full of wrong phone numbers