DIY Electric Car Forums banner

Getting Curtis data into computer

7187 21
I'm involved in a project where we're converting a diesel boat to electric. All the electronics and the motor work on the bench, no questions there. My main task in this is getting the data about the rpm, power and everything else from the Curtis 1236 controller, into a raspberry pi. I'm having trouble where to start. What pins on the controller and pi should connect, is something between necessary, what software do I need? Say I want to log the rpm to a file every second, as a start. Thanks!
1 - 7 of 7 Posts

·
Registered
Joined
·
14 Posts
CAN is a automotive bidirectional address-based bus. Each "frame" has an ID, length, and data bytes.
A Pi can use CAN if you add an MCP2515 module (cheap on Amazon etc.).
Python works well for CAN since there are lots of libraries you can use.

Software side:
Send an NMT message to put the inverter into state 5. Repeat at least every 100ms.
ID:0x000
DLC:2
Data: 0x01 0x00

Response will be sent with ID=0x700 + node ID. You need the Node ID for the next step (remember it's all in hex).

Then send PDO1 and PDO2 requests.
PDO1
ID:0x200
DLC:8
Data: Whatever

PDO2
ID:0x300
DLC:8
Data: Whatever

Have fun decoding the responses :)


Hardware:
[quick-guide] CAN bus on raspberry pi with MCP2515 - Raspberry Pi Forums

This sets up the MCP2515 CAN interface as a network connection, then you can use can-utils to see what's going on.

Try the python-can library on your Pi. It should work well.

-Isaac

EDIT Also check this thread out: Curtis 1234 and CAN bus
Sir, @Isaac97
I have the hardware setup ready!
I also tested the CAN communication between RPi and arduino which works fine!!
I used CAN python in Pi and seedstudio mcp2515 library in arduino.
Now for connecting Pi to curtis do I need to use the python library called canopen?
Do I need to write VCL code for curtis?
Can you please explain how do I recieve data in RPi?
Thank you
 

·
Registered
Joined
·
14 Posts
Fortunately, VCL is unnecessary.
Python canopen is not necessary either - I am not familiar with it, but it might make the job easier.
You should find some documentation on the CANOpen protocol and learn how to send a NMT message to all nodes. That will tell you which address to use for the next few steps.

-Isaac
Thank you so much sir, where can I find resources regarding sending nmt messages to nodes and finding out address? Is there any documentation from curtis regarding the same? Now I tried to scan nodes and found one of the node being successfully scanned and printed by python canopen. How do I proceed?
 

·
Registered
Joined
·
14 Posts
Hi sir , @Isaac97
Thank you so much for this very useful link.
I wanted to clarify some doubts regarding process data objects.
I will set the NMT function of the curtis to be always operational as only then my node (curtis) will accept a PDO message.
So if I consider RPi as server and curtis as a client , Should I send a Transmit PDO or a Recieve PDO from RPi?
I also checked with curtis datasheet which has both transmit and recieve PDO indexes.
Assuming I am sending a Recieve PDO from RPi , will the curtis be automatically configured to send back a Transmit PDO?
Thank you
 

·
Registered
Joined
·
14 Posts
You can buy an Arduino and a cheap SPI to CAN module and connect it with arduino.
SPI 2 CAN module
A general example to send a NMT message via arduino to curtis to put it into operational state.
C:
#include <SPI.h>
#include <mcp_can.h>

const int spiCSPin = 10;
int ledHIGH    = 1;
int ledLOW     = 0;

MCP_CAN CAN(spiCSPin);

void setup()
{
    Serial.begin(115200);

    while (CAN_OK != CAN.begin(CAN_500KBPS,MCP_8MHz))
    {
        Serial.println("CAN BUS init Failed");
        delay(100);
    }
    Serial.println("CAN BUS Shield Init OK!");
}

unsigned char stmp[2] = {0,0};
 
void loop()
{
  stmp[0]=0x01;//Operational state
  stmp[1]=0x00;//target node ==> set 0x00 for all nodes
  Serial.println("In loop");
  CAN.sendMsgBuf(0x00, 0, 2, stmp);// COB-ID, 0 for standard ID and 1 for extended ID, 2 is the data length , stmp is the data
  delay(120);//heartbeat message rate
}
A general example to send a SDO message via arduino to curtis to retrieve Key Switch Voltage

C:
#include <SPI.h>
#include <mcp_can.h>

const int spiCSPin = 10;

MCP_CAN CAN(spiCSPin);


void recv()
{
  unsigned char len = 0;
  unsigned char buf[8];
  unsigned char a,b,c;
  int a1,b1,c1;
  if(CAN_MSGAVAIL == CAN.checkReceive())
    {
        CAN.readMsgBuf(&len, buf);

        unsigned long canId = CAN.getCanId();

        Serial.println("-----------------------------");
        Serial.print("Data from ID: 0x");
        Serial.println(canId, HEX);

        for(int i = 0; i<len; i++)
        {
            Serial.print(buf[i]);
            Serial.print("\t");
            a = buf[4];
            b = buf[5];
         

         }
        a1 = (int)a;
        b1 = (int)b;
        c1 = b1 << 8 | a1 ;
        Serial.print("\nKey_switch_voltage:");
        Serial.println(c1);
        Serial.println();
    }
}

void setup()
{
    Serial.begin(115200);

    while (CAN_OK != CAN.begin(CAN_500KBPS,MCP_8MHz))
    {
        Serial.println("CAN BUS init Failed");
        delay(100);
    }
    Serial.println("CAN BUS Shield Init OK!");
}

unsigned char stmp[8] = {0,0,0,0,0,0,0,0};
 
void loop()
{
  stmp[0]= 0x40; //Read Dictionary Object
  stmp[1]= 0x4D;//second eight bytes of hex value(sub index)
  stmp[2]= 0x32;// first eight bytes of hex value (index)
  stmp[3]= 0x00;
  stmp[4]= 0x00;
  stmp[5]= 0x00;
  stmp[6]= 0x00;
  stmp[7]= 0x00;
  Serial.println("In loop");
  CAN.sendMsgBuf(0x626, 0, 8, stmp);//... , 0 for standard ID and 1 for extended ID, ... , stmp is the data
  delay(100);// timeout
  recv();
}
 
1 - 7 of 7 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top