Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

Read out from OBD-II Freematic Emulator using ELM327 with USB and LabView

Hello. I have an Freematic OBD-II mk2 emulator which simulates diagnostics of a real car. I have connected an ELM327 diagnostic device with USB cable to the emulator and a PC. The connection between emulator, diagnostic device and computer works. Now I need to read out parameters in LabView. How do I do it? I tried to use the NI VISA functions, but didn't manage to read out anything sensible. How can I for example read out Engine RPM? Do you have some example code?

I want to avoid using Automotive Diagnostic Command Set, because it's to expensive for me. 

0 Kudos
Message 1 of 12
(14,585 Views)

@paalbrok wrote:

Hello. I have an Freematic OBD-II mk2 emulator which simulates diagnostics of a real car. I have connected an ELM327 diagnostic device with USB cable to the emulator and a PC. The connection between emulator, diagnostic device and computer works. Now I need to read out parameters in LabView. How do I do it? I tried to use the NI VISA functions, but didn't manage to read out anything sensible. How can I for example read out Engine RPM? Do you have some example code?

I want to avoid using Automotive Diagnostic Command Set, because it's to expensive for me. 


Why is VISA involved are you talking to a COM port?  You do realize that a RS-232 port which is a DB-9, is not the same as a CAN port which is a DB-9 correct?  Assuming you have a real CAN port, usually in the form of a NI USB CAN device, you can run any of the examples shipped with the NI-CAN or NI-Xnet software to read and write raw frames.  But getting usable data out of this like Engine RPM is going to need some kind of database, or understanding of what the bits are, some times that is OEM specific, but Engine RPM is probably defined somewhere.

0 Kudos
Message 2 of 12
(14,578 Views)
It looks like the ELM327 should appear like a serial device and support some form of AT commands. The automotive diagnostic toolkit is going to be useless for communicating with that network device.

It looks like you should be able to connect with the device with any terminal (hyper term, putty). The settings will vary depending on your specific unit but 9600 8N1 is a pretty safe assumption. On connection you should be presented with a command prompt.

I'm not sure on what commands you need to send to communicate over the OBD network, but the very first step needs to be to make sure you can talk to your CAN interface. According to the data sheet you should be able to send "I" followed by a CR and optionally a LF to get the version information of your device
0 Kudos
Message 3 of 12
(14,569 Views)

Hello. Thanks for your answer. Yes, I'm talking to a COM port. I used this tutorial: http://www.ni.com/tutorial/4478/en/

I don't use any DB-9 or NI CAN device. OBD-II adapter is connected to USB port on PC. My problem is how to handle this in LabView. Do you have any experience or ideas?

 

As you see from picture under, the OBD-II adapter is connected to USB on PC and to the OBD-II emulator which is also connected to a computer with a software simulating different parameters. 

 

OBD2.jpg

 

0 Kudos
Message 4 of 12
(14,568 Views)
Your device, the ELM327, has a serial to USB bridge. It's basically the same thing as connecting an actual DB9 software wise.

I have no experience with this specific device, but like I said, you need to make sure you can talk with the adaptor. For right now forget what's beyond the OBD port. You might want to disconnect it for now (assuming your adaptor doesn't require external power that it gets over the port).

Make sure you know the communication settings for the device. Then try to talk to it using any serial console program. You need to take that step before even thinking of communicating over the vehicle network.
0 Kudos
Message 5 of 12
(14,561 Views)

Oh yes, I didn't realize what this hardware does.  Some beginners think that a DB9 is a standard interface for a CAN bus, and when they see the DB9 serial port on their computer they think they can just use that.  I was worried this was what you were attempting.

 

So yes VISA is the right way to go.  Once you have this device installed and recognized in Windows it should appear as a COM port.  You can open the Windows Device Manager and by plugging and unplugging your device you should see a COM port appear and disappear.  

 

Assuming you do launch LabVIEW and go to the example finder and search for Simple Serial.  This is an example VI that can send serial data to a COM port, wait, then read the response.  It can basically work like hyperterminal.  Assuming there are no already made LabVIEW drivers (I haven't seen any) this will be a good place to start.  Using documentation on your hardware you can start to come up with commands to do things like read and write CAN data, by sending the appropriate commands to the hardware over serial.

 

http://www.elmelectronics.com/obdic.html

 

Depending on what you want to do it might be a decent amount of work.  Of course if you do get anything good and working feel free to post your progress here so others can benefit.

Message 6 of 12
(14,552 Views)

Hello Guys. Thanks for your response. My weekend is close to be destroyed by annoying OBD-II problems..:) I've verified that the drivers are up-to-date and the hardware of the emulator and the ELM327 adapter works well. As you see of picture under, I manage to change values of the OBD-II emulator and register it in real-time with a OBD-II software called OBD Auto Doctor Lite. My problem next is that when I try to read only the ELM327 adapter with a terminal it screws up the keyboard when I put the correct COM-port (COM 6 in Device Manager as in picture) and I can't write commands like for example the "ATZ"-command. If I try another COM port in terminal which is not in use, the keyboard works well! I've tried several terminals like Tera Term, putty, hyperterminal and the same thing is happening to all of them.

 

I don't understand why I can't read the ELM327 adapter with a terminal when my first setup with the emulator and the ELM OBD-II adapter works. Because it works the port settings should be OK. But I have also used a software called "Scan Tool Finder" which detect OBD-II tool on COM-ports, but this tool doesn't find anything....I hope you can help me guys!!

 

Simulator OBD-2.png

 

 

0 Kudos
Message 7 of 12
(14,517 Views)

Did you use the simple serial example?  This gives you more control over what is sent, and what is received.

0 Kudos
Message 8 of 12
(14,465 Views)

Hello. I managed to write out parameters in LabView from the emulator like for example the speed parameter. My next step is to do the same with an ELM327 Bluetooth unit which I've ordered from Ebay, but haven't recieved yet. Now I would like to find out more about the SAE J1939 protocol and do some writing and reading with LabView. I see they sell some simulators for this protocol, but they're fairly expensive.

 

0 Kudos
Message 9 of 12
(14,429 Views)

Hello paalbrook,

I haven't worked with any of the ELM family, but if I remember correctly they handle any of the supported OBDII standards. The SAE J1979 document largely shows how the shared functions are accomplished with the various network varieties. The CAN bus functionality may be abstracted on the LabVIEW/terminal side, for better or worse.

 

J1939 has a more ambitious scope than 1979, since control functionality, rather than just common parameter reporting, is the main goal. My professional experience with J1939 (not Volvo or Scania in particular, but similar market) shows that most manufacturers follow the J1939 standards fairly well, with a few caveats. A couple proprietary messages are often required to the ECU, and I have yet to work on a system that follows the full described process for claiming source addresses. Overall 1939 works fairly well for allowing CANbus devices from various manufacturers to play nicely however.

 

I'd suggest figuring out if your ELM devices can handle raw CAN functions first, which would make it useful for J1939 projects. If not you may want to look into some other available CANbus adapter options. Snagging the J1979 or J1939 standards from SAE could also be on your list, although there's a fair chance your employer already owns, or could be convinced to purchase them. A realtime J1939 simulator may not be necessary for awhile. I get by with CSV recordings of CAN traffic for most purposes like that.

 

Aaaand I've blathered. Sorry. Hopefully somewhere in there is some useful info.

Have fun,
Mark

0 Kudos
Message 10 of 12
(14,417 Views)