Haltech elite canbus reader

I'm making a lcd gauge for my 1988 rx7 with a haltech elite 750. I'm using this canbus controller and the Longan Labs library. This is the example code I'm using.

// RECV EXAMPLE OF SERIAL CAN MODULE
// unsigned char recv(unsigned long *id, uchar *buf);
// SUPPORT: joney.sui@longan-labs.cc
#include <Serial_CAN_Module.h>
#include <SoftwareSerial.h>

Serial_CAN can;

#define can_tx  2           // tx of serial can module connect to D2
#define can_rx  3           // rx of serial can module connect to D3

void setup()
{
    Serial.begin(9600);
    can.begin(can_tx, can_rx, 9600);      // tx, rx
    Serial.println("begin");
}

unsigned long id = 0;
unsigned char dta[8];

// send(unsigned long id, byte ext, byte rtrBit, byte len, const byte *buf);
void loop()
{
    if(can.recv(&id, dta))
    {
        Serial.print("GET DATA FROM ID: ");
        Serial.println(id);
        for(int i=0; i<8; i++)
        {
            Serial.print("0x");
            Serial.print(dta[i], HEX);
            Serial.print('\t');
        }
        Serial.println();
    }
}

// END FILE

Right now in the seriel moinitor it just prints "begin'. I setup my haltech to output can data, and im pretty sure my wires are right. Can I use a muiltmeter to ensure my haltech is outputting data? Though I'm pretty sure it is. Maybe I'm missing something in my code?

Try

and set the bit rate to CAN_RATE_1000

I tried that and i was successful in updating the rate to 1000 but I'm still only getting "begin". I attached a muiltmeter to my can hi lo and it was showing voltage.

The CAN bus uses two termination resistors at each of the bus ends. Your module has a termination resistors on board. Because you are connecting to an existing CAN network you need to remove the resistor on your board.

supertoast4939:
I attached a muiltmeter to my can hi lo and it was showing voltage.

A multimeter is not the right tool to analyze CAN bus signals. You would need an oscilloscope for that. It could be a very cheap old analog one because the speed of the CAN bus is low.

Why did you choose to use this module instead of one without an additional microcontroller on it that translates to UART? The CAN bus can run up to 1MBit/s. It would be simpler to connect the MCP2515 CAN controller via SPI.

supertoast4939:
I tried that and i was successful in updating the rate to 1000 but I'm still only getting "begin". I attached a muiltmeter to my can hi lo and it was showing voltage.

There is no code in the set_can_baudrate.ino sketch that prints "begin".
If the sketch was loaded successfully you should either see "set can rate ok" or "set can rate fail".

Seeing "begin" implies that the recv.ino sketch is still running.

Klaus_K:
The CAN bus uses two termination resistors at each of the bus ends. Your module has a termination resistors on board. Because you are connecting to an existing CAN network you need to remove the resistor on your board.
A multimeter is not the right tool to analyze CAN bus signals. You would need an oscilloscope for that. It could be a very cheap old analog one because the speed of the CAN bus is low.

Why did you choose to use this module instead of one without an additional microcontroller on it that translates to UART? The CAN bus can run up to 1MBit/s. It would be simpler to connect the MCP2515 CAN controller via SPI.

I'm not trying in analyze them using the multimeter. I don't have an oscilloscope and I just did it to test if any voltage was coming through. I chose this module because it was one of the few non-shield canbus modules I could find.

When you say remove the resistor on the board which ones specificity? The ones next to the rx/tx light or the 120 ohm one on the back?

mikb55:
There is no code in the set_can_baudrate.ino sketch that prints "begin".
If the sketch was loaded successfully you should either see "set can rate ok" or "set can rate fail".

Seeing "begin" implies that the recv.ino sketch is still running.

It successfully updated the baud rate and did say "set can rate ok". But when trying to pull data from the haltech using recv.ino it just said "begin".

supertoast4939:
It successfully updated the baud rate and did say "set can rate ok". But when trying to pull data from the haltech using recv.ino it just said "begin".

You probably need to set the baud rate in every sketch including recv.ino.

The fact that the set_can_baudrate.ino returned "set can rate ok" indicates that CAN_RATE_1000 (1 Mbit) is the correct baud rate. The lack of any CAN data could also indicate that the devices on the bus are waiting for the Arduino to send a query message, as in "give me the engine temperature" or whatever.

Looking at the library, all it does is generate AT text commands which get sent to the onboard micro. There is no documentation saying what the onboard micro does or whether the 'success' return code is actually a reflection of what is happening at the CAN bus level. It could be that it just checks for a valid baud rate from the Arduino without checking to see if it matches the actual CAN bus baud rate is, it doesn't say.

Effectively the onboard micro is a hindrance rather than a help because of the poor documentation and it prevents you from talking directly to the MCP2515.

supertoast4939:
I'm not trying in analyze them using the multimeter. I don't have an oscilloscope and I just did it to test if any voltage was coming through.

The issue with CAN is that if you connect a CAN node with the wrong CAN speed, it will disturb the bus, because it detects wrong messages. All nodes on the bus are masters and create error frames. So, make sure you figure this part out first, before you start driving around. :slight_smile:

supertoast4939:
When you say remove the resistor on the board which ones specificity? The ones next to the rx/tx light or the 120 ohm one on the back?

The CAN bus termination resistor value is 120Ohm. So, it should be the one on the back. The one next to the LED is likely the current limiter for the LED. See whether the 120 on the back is in parallel/connecting to CANH and CANL. They marked in on the picture but did not assign the numbers on the web page.

supertoast4939:
I chose this module because it was one of the few non-shield canbus modules I could find.

I agree with mikb55. That micro on the module is a pita. You might want to see whether those SPI pins on the back are from the MCP2515. You could remove the micro and connect the SPI pins to your Arduino.

Very very helpful info here guys! I'll give all of this a try in the morning. If this still gives me problems I'll order a new canbus board

supertoast4939:
If this still gives me problems I'll order a new canbus board

If you do, order two. On a CAN bus you always need two nodes, because every message needs to be acknowledged on the bus. It is enough to have a CAN module with the correct baudrate set on the bus. The acknowledge bit will be set by all and any node that sees the message on the bus. This is done in hardware.

So, when you want to experiment before you connect to your cars CAN bus you need two nodes.

If you find a module, we can have a quick look if anything seems wrong with it before you order.

What about the seeed studio CAN-BUS Shield 2.0? [Seeed studio](http://"CAN-BUS Shield V2 - Seeed Studio" https://www.seeedstudio.com/CAN-BUS-Shield-V2.html)

supertoast4939:
What about the seeed studio CAN-BUS Shield 2.0? [Seeed studio](http://"CAN-BUS Shield V2 - Seeed Studio" https://www.seeedstudio.com/CAN-BUS-Shield-V2.html)

Seems expensive. I found small modules on Amazon. 3 units for around $10, 12 Euro or 10 GB Pound. Depends on which country you are from.

What about this module? Feel free to link any usa Amazon links.

supertoast4939:
What about this module? Feel free to link any usa Amazon links.

That is just a transceiver. It converts the digital pins of the CAN module into differential signals on the bus.

Look for something like this

Amazon.com Comidox-MCP2515-Receiver-Controller-Development

The module should have

  • a MCP2515 CAN controller (needs a 8MHz crystal next to it to generate all standard CAN bitrates)
  • a CAN transceiver (see above) there are different ones
  • SPI connection pins
  • CAN LOW and HIGH connection
  • 120 Ohm termination resistor with jumper is a nice to have

That's all on the board above and it say $8.99 for three of them.

Edit: For 1MBit/s a 16MHz crystal is needed. 8MHz allows standard bits rates up to 500kBits/s

I can't remember where or what it was I was reading but it said something about 8mhz crystals not working well with car canbus. Would a 16mhz crystal be better? I might be miss remembering....

supertoast4939:
I can't remember where or what it was I was reading but it said something about 8mhz crystals not working well with car canbus. Would a 16mhz crystal be better? I might be miss remembering....

Usually not a problem as most libraries allow you to set the clock to 8 or 16MHz.

supertoast4939:
I can't remember where or what it was I was reading but it said something about 8mhz crystals not working well with car canbus. Would a 16mhz crystal be better? I might be miss remembering....

You are right. I mixed up the internal clock from the external one. There is a fixed 2x clock divide.

The MCP2510/2515 can create most of the standard CAN bitrates (5,10,20,50,100,125,250,500kbit/s) from a 8MHz crystal, but not 1MBit/s. For 1MBits/s you need at least a 16MHz crystal. There are non-standard bit rates that cannot be created from 8/16MHz. It comes down to the dividers inside the CAN controller.

I read on another post that the haltech elite ecu does 1MBit canbit rate. In other interesting news I did get some output from my 2009 bmw 328i . Though it was only the same code and only the RX light on the can board was flashing. I'll find a new 16mhz canbus board without a extra mirco controller.