Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

Sensor device for LV subroutine using CAN?

The product of our project will be a LabView subroutine that would take in a list of messages and output the responses to those messages. A named cluster might be an appropriate format for the output. The subroutine should be generic in that once it is fed the appropriate message(s), it can query across the CAN to the appropriate sensor. We need this capability because many new sensors that we use for testing come only with CAN outputs rather than the traditional voltage outputs. These are relatively simple transducers that don't have extensive vocabularies. Six messages may be sufficient for each of these applications.

CAN subroutine suggestions:

-six message (word?) capability These messages can be fed in as inputs specific to the particular transducer the routine to be used.

-named cluster output

-should be able to run in a 20 hz main loop if possible

**In order to proceed with this project, we need communication between the sensor and the bus, which is our main problem. When using MAX, we only get error transmission with a 100% bus load, does this means the sensor is actually working? Also, does anyone knows how to insert the sensor as a LV subroutine, once is communicating?

Thank you!

0 Kudos
Message 1 of 10
(7,683 Views)
Hi Nones,

What happens when you try to communicate with the sensor in MAX? What CAN interface are you using, and are you using an NI-CAN cable? If you are using a regular null modem cable, you have to make sure that it is terminated properly as described here.

"When using MAX, we only get error transmission with a 100% bus load, does this means the sensor is actually working?"

Could you tell me what you were doing in MAX that you saw the above information? I would advise that you refer to the NI-CAN example VIs to test communication with your sensor. You can find this in LabVIEW by going to Help > Find Examples > Hardware Input and Output > CAN. You will have to choose between using Frame and Channel API, and the differences between the two are described well here.


Also, what exactly do you mean when yo usayd "insert the sensor in the LV subroutine"?

Let us know how it goes!
Rasheel
0 Kudos
Message 2 of 10
(7,658 Views)
Hello Rasheel,
 
"What happens when you try to communicate with the sensor in MAX? What CAN interface are you using, and are you using an NI-CAN cable? "
I will fix my wiring tomorrow and will let you know. Are the termination resistors required for the sensor to function? Since it is only one sensor I thought it wouldnt ne necessary.
 
"Could you tell me what you were doing in MAX that you saw the above information?"
I was checking the Bus Monitor tool from the Devices and Interfaces tab.
 
"Also, what exactly do you mean when yo usayd "insert the sensor in the LV subroutine"?"
I was refering to a Lab View subroutine or a sub-VI that could be arranged as a named cluster for further use in larger VIs. Basically a readout of the sensor data, expressed as an data indicator or graph to be displayed on a set of other tools (more comprehensive VI).
 
Thank you!
 
 
0 Kudos
Message 3 of 10
(7,654 Views)
*********************************************
Sensor Specs from other post by Nones:

Here are some sensor specs on CAN Communication:
 
-SAE J1939 (BOSCH CAN 2.0B active)
-Driver: 82C250
-Length of Message ID: 29 bits
-Baud Rate: 500kbps
 
**How does kbps converts to kBaud?


*********************************************
Regards,

Nicholas K
National Instruments
Applications Engineer
0 Kudos
Message 4 of 10
(7,644 Views)
If you are using an NI-CAN cable, you will not require termination. However, if you are NOT using an NI-CAN cable, you will need to terminate accordingly.

Please run the some of the example code I pointed to in my previous post to check for communication with the sensor. The Bus Monitor just checks on the CAN bus activity, and does not actually communicate with the device. I imagine that there were error messages possibly because the sensor saw that it was the only device on the network.

Let us know how that goes!

Rasheel
0 Kudos
Message 5 of 10
(7,628 Views)
I just got back from lab. I fixed the wiring (added termination resistance), and there are no error frame messages on the CAN bus monitor, and actually can see the arbitration ID of the device on the CAN bus monitor. However, there are some new issues:
 
1) One of the capabilities of the sensor is temperature which is allocated within byte 1, however when I run the test panel for the temperature channel and increase the external temperature, the temperature goes down on the panel. I used the following numbers when setting up the channel: start bit 0, number of bits 8, byte order motorola, data type unsigned, the min max and offset values were given by the manufacturer but not the scaling factor which I figured out by assuming room temperature at lab. Are these setup parameters correct, am I ignoring or not knowing something?
 
2) Once the CAN communication with the sensor is up and running, the next step is to write a simple labview cluster to show the readings of the sensor. However, we must include some capabilities (see the initial post for details) and don't exactly know how to do it:

-six message (word?) capability These messages can be fed in as inputs specific to the particular transducer the routine to be used.

-named cluster output

-should be able to run in a 20 hz main loop if possible

Ay suggestions? Thanks!!!

0 Kudos
Message 6 of 10
(7,626 Views)
For your first question, it would seem that the best people to ask about the parameters would be the manufacturer of the device. These parameters seem to be device specific, so I would imagine that confirming what you have with them might be the best way to figure out a solution.

You can use a timed loop to run your code at 20Hz. However, if you are not running in a realtime operating system, this might not be exactly 20Hz, as there are other operations going on in the background. '

What do you mean by named cluster output?

Could you also describe more what you mean by six message/word capability?
Rasheel
0 Kudos
Message 7 of 10
(7,607 Views)
Ok, lets assume the device channel parameters are alright.
 
By named cluster I mean, just that, a cluster with a name that if save as a subVI, when use in a VI it displays as a cluster within the main VI. But thats not a big issue.
 
Today I finally created the subVI and is reading form the CAN device, now...how do I get it to writethe data is gathering into a file, preferably Excel? I am attaching what I have sor far, which works given a CAN device.
 
"Could you also describe more what you mean by six message/word capability?"
 
-The subroutine should be generic in that once it is fed the appropriate message(s), it can query across the CAN to the appropriate sensor. We need this capability because many new sensors that we use for testing come only with CAN outputs rather than the traditional voltage outputs. Some examples are the urea quality sensor that I've shown you, NH3 sensor, and NOx/O2 sensors all are CAN based. These are relatively simple transducers that don't have extensive vocabularies. Six messages may be sufficient for each of these applications, but this should be confirmed.
 
Thank you.
0 Kudos
Message 8 of 10
(7,595 Views)
Some clarification about the purpose of the subroutine:
 
We are dealing with a series of CAN based sensors to do testing on vehicles. The project is to write a Labview subroutine (ie subVI) which can be incorporated to a mainframe VI which involves other devices and read outs. The message capability of our project consists of inputing a list of messages and output the responses to those messages. As in a CAN system, we want to get, lets say, a reading for the sensor and if its passes a treshold, then query the messages through the network into other devices or panels.
 
Please let me know if further clarification is needed.
 
Thanks!
0 Kudos
Message 9 of 10
(7,579 Views)
For your named cluster, it sounds like you're looking to create a cluster as a global variable. There is more information about how you can do this here.

To log your data in an excel file, you can use the Write To Measurement File Express VI in the loop, with the append to file option on. You can also use the Export Waveform to Spreadsheet File VI, and wire a true to the append to file option.

I'm still kind of unsure as to what you mean by six message or word capability...
Rasheel
0 Kudos
Message 10 of 10
(7,572 Views)