CAN support

It's all about the code!
blundar
contributor
contributor
Posts: 63
Joined: Tue Jan 07, 2014 4:38 am
Location: Cincinnati, Ohio

Re: CAN support

Post by blundar » Thu Dec 10, 2015 2:56 am

russian wrote:
blundar wrote:And $250 is CHEAP for a J interface! My MyCanic was about $800 when I got it and the CarDAQ plus my buddy has was close to $1600 new)
I guess that's the part which I am failing to comprehend. How comes there is no such thing as a $49 open hardware/open source J2534?
well... There is a lot of nitty gritty annoying programming involved. A friend of mine worked on a J2534 interface using a STM32F103. He got most of the way done with it. I say "most of the way" because there were still issues with some of the protocols, most notably the PWM method used by Ford prior to CANbus.

You might be able to make a $49 CANbus J2534 interface but you're looking at a hell of a lot more work to add support for the other protocols - ISO and PWM. So far, I think that the people who tackled this task did so with profit in mind. The API calls are pretty readily available...

User avatar
russian
Site Admin
Posts: 9755
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Soldering skill: yes
Coding skill?: yes
Contact:

Re: CAN support

Post by russian » Thu Dec 10, 2015 2:59 am

blundar wrote:A friend of mine worked on a J2534 interface using a STM32F103. He got most of the way done with it.
Is your friend planning to release this as a $49 product or open design by any chance? Is he doing smth for himself or a commercial product?
https://rusefi.com/s/howtocontribute
very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions
my skype is arro239

blundar
contributor
contributor
Posts: 63
Joined: Tue Jan 07, 2014 4:38 am
Location: Cincinnati, Ohio

Re: CAN support

Post by blundar » Thu Dec 10, 2015 3:00 am

And in case it wasn't clear from the last post... 95 or 99% working doesn't cut it for a J interface. Many computers can cost $500-1000 to replace if you fuck them up. Bricking computers while programming is extremely undesirable. A lot of what you're paying for with the more expensive J interfaces is high quality engineering. For instance, that $1600 CarDAQ Plus my buddy bought probably had a BOM less than $100 in parts. But it has incredibly stable, high quality software drivers. It is a well-designed piece of hardware that has proper protection circuitry on all of its inputs and outputs. It's stable, reliable and dependable. Inside and out, hardware and software - Drewtech do very good work. If I was programming 20-40 vehicles a week, I would be very particular about my tools, too.

blundar
contributor
contributor
Posts: 63
Joined: Tue Jan 07, 2014 4:38 am
Location: Cincinnati, Ohio

Re: CAN support

Post by blundar » Thu Dec 10, 2015 3:04 am

russian wrote:
blundar wrote:A friend of mine worked on a J2534 interface using a STM32F103. He got most of the way done with it.
Is your friend planning to release this as a $49 product or open design by any chance? Is he doing smth for himself or a commercial product?
My friend is intending to release it as a commercial product, if he ever finishes it.

User avatar
russian
Site Admin
Posts: 9755
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Soldering skill: yes
Coding skill?: yes
Contact:

Re: CAN support

Post by russian » Thu Dec 10, 2015 3:53 am

http://shop.chipsoft.com.ua/index.php?r ... uct_id=114
CHIPSOFT J2534 LITE
Price: $77

Based on stm32 and ChibiOS, apparently not really known in the English-speaking world.
https://rusefi.com/s/howtocontribute
very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions
my skype is arro239

Rhinoman
contributor
contributor
Posts: 246
Joined: Thu Sep 24, 2015 2:14 pm
Location: Wiltshire, UK
Contact:

Re: CAN support

Post by Rhinoman » Thu Dec 10, 2015 8:28 am

I just ordered an interface which is described as J2534 for $15 delivered. there isn't really anything special about the hardware. J2534 primarily specifies an interface that can communicate via two OBD channels simultaneously and has a hardware level driver with a standard interface through a DLL which should be called 'J2534.dll'. Theoretically you should be able to use any application software as long as you use the dll for the interface.

User avatar
russian
Site Admin
Posts: 9755
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Soldering skill: yes
Coding skill?: yes
Contact:

Re: CAN support

Post by russian » Thu Dec 10, 2015 1:23 pm

Rhinoman wrote:Theoretically you should be able to use any application software as long as you use the dll for the interface.
Only theoretically :(
@ has joined us, he is the developer of chipsoft J2534 device. Unless your device covers the whole J2534 software protocol perfectly with all hardware protocols, you will always have different success with different pieces of software.
https://rusefi.com/s/howtocontribute
very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions
my skype is arro239

Rhinoman
contributor
contributor
Posts: 246
Joined: Thu Sep 24, 2015 2:14 pm
Location: Wiltshire, UK
Contact:

Re: CAN support

Post by Rhinoman » Thu Dec 10, 2015 2:10 pm

russian wrote: Unless your device covers the whole J2534 software protocol perfectly with all hardware protocols, you will always have different success with different pieces of software.
If the device doesn't work perfectly then its not J2534 compliant and that's likely to be the difference between the expensive tools and the cheap ones. The Tech2 and both SDT support J2534 - I will do some experiments with those as well.

User avatar
kb1gtt
contributor
contributor
Posts: 3481
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA
Contact:

Re: CAN support

Post by kb1gtt » Thu Dec 10, 2015 5:29 pm

How do we get .dll's to work with TunerStudio or the Java based DevConsole? Would that be a potential problem? Cool to hear @chipsoft is hanging around.
Welcome to the friendlier side of internet crazy :)

Rhinoman
contributor
contributor
Posts: 246
Joined: Thu Sep 24, 2015 2:14 pm
Location: Wiltshire, UK
Contact:

ISO diagnostics

Post by Rhinoman » Thu Dec 10, 2015 7:12 pm

I'm going to use the term ISO diagnostics rather than 'OBD2' because OBD2 requires some specific capabilities that we don't have. I'm going to implement Mode 1 diagnostics as far as I can, building on what Russian has already done.

Rhinoman
contributor
contributor
Posts: 246
Joined: Thu Sep 24, 2015 2:14 pm
Location: Wiltshire, UK
Contact:

Re: CAN support

Post by Rhinoman » Thu Dec 10, 2015 8:37 pm

kb1gtt wrote:How do we get .dll's to work with TunerStudio or the Java based DevConsole? Would that be a potential problem? Cool to hear @chipsoft is hanging around.
I would imagine that that would need a plug-in. J2534 has no knowledge of the ECU software or the PC application software.

puff
contributor
contributor
Posts: 2736
Joined: Mon Nov 11, 2013 11:28 am
Location: Moskau

Re: CAN support

Post by puff » Sun Nov 12, 2017 11:49 am

any progress?

User avatar
kb1gtt
contributor
contributor
Posts: 3481
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA
Contact:

Re: CAN support

Post by kb1gtt » Sun Nov 12, 2017 2:23 pm

I see this project which might be of interest.
https://github.com/openxc/uds-c
Welcome to the friendlier side of internet crazy :)

User avatar
kb1gtt
contributor
contributor
Posts: 3481
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA
Contact:

Re: CAN support

Post by kb1gtt » Sun Nov 12, 2017 2:32 pm

Also perhaps of interest. It includes a link to an engine simulator which appears to include and OBD interface. This simulator could be a handy tool for development purposes.
https://learn.sparkfun.com/tutorials/ge ... ith-obd-ii

The above includes some links to references about why in the USA you do NOT want to spoof OBD data, which uses the same underlying ISO standard which are likely to be implemented for CAN communicators. As expected in the USA spoofing OBD data streams is illegal, and you SHOULD NOT attempt to spoof OBD data. I don't see any problems with making it work with the ISO standards. However it should either fail to report readiness codes, or it should report that the emissions system is not ready, it SHOULD NOT report a VIN, etc. It SHOULD report RPM, fuel trims, temperatures, etc.
Welcome to the friendlier side of internet crazy :)

User avatar
Tambralinga
donator
donator
Posts: 174
Joined: Wed Jun 18, 2014 8:36 am
Location: Bangkok, Thailand

Re: CAN support

Post by Tambralinga » Mon Jun 11, 2018 5:05 pm

I want to test signal canbus for Frankenso.
Do not know what's wrong?

What should i use for the test, pls advise

Code: Select all

2018-06-12 00_02: EngineState: CAN TX PB6
2018-06-12 00_02: EngineState: CAN RX PB12
2018-06-12 00_02: EngineState: type=3 canReadEnabled=Yes canWriteEnabled=Yes period=50
2018-06-12 00_02: EngineState: CAN rx count 0/tx ok 3/tx not ok 79
out put H,L
Skype : shiva-p
+66 8 5357 5159

User avatar
russian
Site Admin
Posts: 9755
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Soldering skill: yes
Coding skill?: yes
Contact:

Re: CAN support

Post by russian » Tue Jun 12, 2018 8:59 am

Tambralinga wrote:
Mon Jun 11, 2018 5:05 pm
I want to test signal canbus for Frankenso.
Do not know what's wrong?
Mazda RX8 gauge cluster is my favourite CAN testing device. What is the big picture of what you are trying to do?
https://rusefi.com/s/howtocontribute
very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions
my skype is arro239

User avatar
Tambralinga
donator
donator
Posts: 174
Joined: Wed Jun 18, 2014 8:36 am
Location: Bangkok, Thailand

Re: CAN support

Post by Tambralinga » Tue Jun 12, 2018 9:22 am

i want to try MCP2515 CAN Bus Module Receiver SPI for arduino.


https://www.aliexpress.com/item/Smart-E ... 4c4dOtI3UV
Skype : shiva-p
+66 8 5357 5159

User avatar
kb1gtt
contributor
contributor
Posts: 3481
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA
Contact:

Re: CAN support

Post by kb1gtt » Tue Jun 12, 2018 9:33 am

There might be some comments of interest at this thread.
viewtopic.php?f=13&t=1289
Welcome to the friendlier side of internet crazy :)

puff
contributor
contributor
Posts: 2736
Joined: Mon Nov 11, 2013 11:28 am
Location: Moskau

Re: CAN support

Post by puff » Tue Jun 12, 2018 9:47 am

MCP2515 is a CAN controller, what is the receiver? What is the host device?
My experience: I used frankenstein board as a host, and the power supply there was a bit below 3.3V (somewhat 3V?). Because of that, voltages from the transeiver on the host were a bit below the threshold needed for 5V tranceiver on the test device. So I had similar problems till I switched to 3v3 transceiver.

User avatar
Tambralinga
donator
donator
Posts: 174
Joined: Wed Jun 18, 2014 8:36 am
Location: Bangkok, Thailand

Re: CAN support

Post by Tambralinga » Tue Jun 12, 2018 8:31 pm

What do I use to get value canbus?
Skype : shiva-p
+66 8 5357 5159

puff
contributor
contributor
Posts: 2736
Joined: Mon Nov 11, 2013 11:28 am
Location: Moskau

Re: CAN support

Post by puff » Tue Jun 12, 2018 8:39 pm

as russian has mentioned, you can use Mazda dashboard)
I successfully used 3v3 TI tranceiver chip (SN65HVD234 or something like that) and the blue pill (stm32f103 board).
I bet, if you ensure proper 3v3 power supply for the tranceiver chip on your rusefi board, you should be able to connect it to a 5V tranceiver (your tja1050 board) just fine.

Tomin
Posts: 39
Joined: Fri Oct 18, 2013 8:03 pm

Re: CAN support

Post by Tomin » Wed Jun 13, 2018 8:46 am

Cheapest option for CAN monitoring is ELM327.
comands:
ATSP6 - switch to CAN (pins 6+14)
ATH1 - switch header showing ON
ATCAF0 - CAN autoformating OFF (turn OFF ISO15765 format)
ATMA - start monitoring of the CAN
Tomas

puff
contributor
contributor
Posts: 2736
Joined: Mon Nov 11, 2013 11:28 am
Location: Moskau

Re: CAN support

Post by puff » Wed Jun 13, 2018 9:12 am

Do you know if it works with under-3v3 tranceivers?

Tomin
Posts: 39
Joined: Fri Oct 18, 2013 8:03 pm

Re: CAN support

Post by Tomin » Wed Jun 13, 2018 9:31 am

It will depend on used chip there. Some ELM are based on 8bit 5Volt chips and some, ELS27 for example, is PIC24.... which is 3V3 chip.
I use dsPIC (like PIC24) on 3V3 with TJA1057. TJA needs 5Volt power, but is 3V3 compatible on CPU side/inputs (TX+RX pins).
Tomas

puff
contributor
contributor
Posts: 2736
Joined: Mon Nov 11, 2013 11:28 am
Location: Moskau

Re: CAN support

Post by puff » Wed Jun 13, 2018 10:14 am

Yep. Got it.
I've read an appnote from TI stating that their 3v3 chips are compatible with 5V canbus. But in my case (frankenstein board), the supply voltage on the transceiver side was just not sufficient, so that the signal was somewhat half a volt away from the tolerance specified in TJA1050 datasheet.

User avatar
Tambralinga
donator
donator
Posts: 174
Joined: Wed Jun 18, 2014 8:36 am
Location: Bangkok, Thailand

Re: CAN support

Post by Tambralinga » Fri Jun 22, 2018 3:23 pm

uno r3 and mc2515 conect to fankenso canbus

it can connect to 2515, ok.
iso15765-4 i don't know bit and kband.
Image

Code: Select all

/************************************************************************************************* 
  OBD-II_PIDs TEST CODE
  LOOVEE @ JUN24, 2017
  
  Query
  send id: 0x7df
      dta: 0x02, 0x01, PID_CODE, 0, 0, 0, 0, 0

  Response
  From id: 0x7E9 or 0x7EA or 0x7EB
      dta: len, 0x41, PID_CODE, byte0, byte1(option), byte2(option), byte3(option), byte4(option)
      
  https://en.wikipedia.org/wiki/OBD-II_PIDs
  
  Input a PID, then you will get reponse from vehicle, the input should be end with '\n'
***************************************************************************************************/
#include <SPI.h>
#include "mcp_can.h"

// the cs pin of the version after v1.1 is default to D9
// v0.9b and v1.0 is default D10
const int SPI_CS_PIN = 9;

MCP_CAN CAN(SPI_CS_PIN);                                    // Set CS pin

#define PID_ENGIN_PRM       0x0C
#define PID_VEHICLE_SPEED   0x0D
#define PID_COOLANT_TEMP    0x05

#define CAN_ID_PID          0x7DF

unsigned char PID_INPUT;
unsigned char getPid    = 0;

void set_mask_filt()
{
    /*
     * set mask, set both the mask to 0x3ff
     */
    CAN.init_Mask(0, 0, 0x7FC);
    CAN.init_Mask(1, 0, 0x7FC);

    /*
     * set filter, we can receive id from 0x04 ~ 0x09
     */
    CAN.init_Filt(0, 0, 0x7E8);                 
    CAN.init_Filt(1, 0, 0x7E8);

    CAN.init_Filt(2, 0, 0x7E8);
    CAN.init_Filt(3, 0, 0x7E8);
    CAN.init_Filt(4, 0, 0x7E8); 
    CAN.init_Filt(5, 0, 0x7E8);
}

void sendPid(unsigned char __pid)
{
    unsigned char tmp[8] = {0x02, 0x01, __pid, 0, 0, 0, 0, 0};
    Serial.print("SEND PID: 0x");
    Serial.println(__pid, HEX);
    CAN.sendMsgBuf(CAN_ID_PID, 0, 8, tmp);
}

void setup()
{
    Serial.begin(115200);
    while (CAN_OK != CAN.begin(CAN_500KBPS))    // init can bus : baudrate = 500k
    {
        Serial.println("CAN BUS Shield init fail");
        Serial.println(" Init CAN BUS Shield again");
        delay(100);
    }
    Serial.println("CAN BUS Shield init ok!");
    set_mask_filt();
}


void loop()
{
    taskCanRecv();
    taskDbg();
    
    if(getPid)          // GET A PID
    {
        getPid = 0;
        sendPid(PID_INPUT);
        PID_INPUT = 0;
    }
}

void taskCanRecv()
{
    unsigned char len = 0;
    unsigned char buf[8];

    if(CAN_MSGAVAIL == CAN.checkReceive())                   // check if get data
    {
        CAN.readMsgBuf(&len, buf);    // read data,  len: data length, buf: data buf

        Serial.println("\r\n------------------------------------------------------------------");
        Serial.print("Get Data From id: ");
        Serial.println(CAN.getCanId(), HEX);
        for(int i = 0; i<len; i++)    // print the data
        {
            Serial.print("0x");
            Serial.print(buf[i], HEX);
            Serial.print("\t");
        }
        Serial.println();
    }
}

void taskDbg()
{
    while(Serial.available())
    {
        char c = Serial.read();
        
        if(c>='0' && c<='9')
        {
            PID_INPUT *= 0x10;
            PID_INPUT += c-'0';
            
        }
        else if(c>='A' && c<='F')
        {
            PID_INPUT *= 0x10;
            PID_INPUT += 10+c-'A';
        }
        else if(c>='a' && c<='f')
        {
            PID_INPUT *= 0x10;
            PID_INPUT += 10+c-'a';
        }
        else if(c == '\n')      // END
        {
            getPid = 1;
        }
    }
}
// END FILE

out put

Code: Select all

------------------------------------------------------------------
Get Data From id: 499
0x49	0x24	

------------------------------------------------------------------
Get Data From id: 499
0x49	0x24	

------------------------------------------------------------------
Get Data From id: 499
0x49	0x24	

------------------------------------------------------------------
Get Data From id: 499
0x49	0x24	

------------------------------------------------------------------
Get Data From id: 499
0x49	0x24	

------------------------------------------------------------------
Get Data From id: 499
0x49	0x24	
Skype : shiva-p
+66 8 5357 5159

User avatar
russian
Site Admin
Posts: 9755
Joined: Wed Aug 28, 2013 1:28 am
Location: Jersey City
Soldering skill: yes
Coding skill?: yes
Contact:

Re: CAN support

Post by russian » Fri Jun 22, 2018 5:24 pm

russian wrote:
Tue Jun 12, 2018 8:59 am
What is the big picture of what you are trying to do?
What is the big picture of what you are trying to do?
https://rusefi.com/s/howtocontribute
very limited telepathic abilities - please post logs & tunes where appropriate - http://rusefi.com/s/questions
my skype is arro239

User avatar
kb1gtt
contributor
contributor
Posts: 3481
Joined: Tue Sep 10, 2013 1:42 am
Location: ME of USA
Contact:

Re: CAN support

Post by kb1gtt » Fri Jun 22, 2018 6:02 pm

Sorry had to do it. This seems to be some good CAN support.
Attachments
DSC_0231.jpg
DSC_0231.jpg (1.47 MiB) Viewed 1936 times
Welcome to the friendlier side of internet crazy :)

User avatar
Tambralinga
donator
donator
Posts: 174
Joined: Wed Jun 18, 2014 8:36 am
Location: Bangkok, Thailand

Re: CAN support

Post by Tambralinga » Fri Jun 22, 2018 6:13 pm

russian wrote:
Fri Jun 22, 2018 5:24 pm
russian wrote:
Tue Jun 12, 2018 8:59 am
What is the big picture of what you are trying to do?
What is the big picture of what you are trying to do?
use uino R3 read canbus from vp230 fankenso :D
I don't know PID protocal canbus.
Skype : shiva-p
+66 8 5357 5159

Post Reply