05-29-2015 04:47 AM
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.
05-29-2015 07:01 AM
@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.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
05-29-2015 08:33 AM
05-29-2015 08:39 AM
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.
05-29-2015 08:46 AM
05-29-2015 09:05 AM
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.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
05-30-2015 02:05 PM - edited 05-30-2015 02:08 PM
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!!
06-01-2015 07:09 AM
Did you use the simple serial example? This gives you more control over what is sent, and what is received.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
17 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
06-04-2015 04:22 PM
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.
06-04-2015 11:58 PM
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