Index
RSS

Welcome Guest [ Log In | Register ]

> Logging together with CAN data?
disturbedsaint
post Jun 30 2009, 04:34 PM
Post #1

Joined: 30-June 09
Posts: 12




Hi!

Im really interested in a Labjack (probably U6 or UE9) for logging car data (I have a carPC in it).
It looks like a really nice piece of hardware (and software)!

Since my ECU already has a lot of sensors (RPM, water and oil-temp for example) and exposes the values through its CAN-bus I would like to incorporate these values in the data I log.
How could I do this?

Is it somehow possible to log the data from the Labjack and add/append the ECU data through CAN?
Or maybe the other way around (log my CAN data and add/append the Labjack data, like for example the zemulator and Ecutek DeltaDash do)?

And how would I know for sure the logged data is from the exact same moment/100% sync?
 
Quote Post
 
Start new topic
Replies (1 - 21)
LabJack Support
post Jun 30 2009, 04:50 PM
Post #2

Joined: 9-June 03
Posts: 5513




Do you have something particular in mind for software. If you are thinking about using DAQFactory, I suggest posting on their forum, and mention what sort of CAN adapter you have for your computer.

http://www.azeotech.com/board/
 
Quote Post
disturbedsaint
post Jul 1 2009, 02:02 AM
Post #3

Joined: 30-June 09
Posts: 12




QUOTE (LabJack Support @ Jul 1 2009, 01:50 AM) *
Do you have something particular in mind for software. If you are thinking about using DAQFactory, I suggest posting on their forum, and mention what sort of CAN adapter you have for your computer.

http://www.azeotech.com/board/

Thanks for your prompt reply and help!

I would like to use racing specific data analysis software.
The software I use allows me to import data from csv files.

Basically all I need is a way to log the data from the ECU and the Labjack in sync together in a single file (which either is already a csv file or can be converted to csv).
 
Quote Post
LabJack Support
post Jul 1 2009, 10:05 AM
Post #4

Joined: 9-June 03
Posts: 5513




To collect data files from the LabJack, you could use DAQFactory, or perhaps LJStreamUD or LJLogUD.

You have software for analysis, but do you have software you plan to use to collect the CAN data?

Say some other program collects the CAN data. You could put some common signal to both that program and the LabJack related program, such that later you have a common signal in both files that allows you to synchronize them.

If you are looking for a single program to collect both the CAN data and the LabJack data into a single file, then I would post about that on the Azeotech forum. Let them know more about the CAN, and let them know how synchronized you want the data to be.
 
Quote Post
disturbedsaint
post Jan 19 2010, 03:21 PM
Post #5

Joined: 30-June 09
Posts: 12




QUOTE (LabJack Support @ Jul 1 2009, 06:05 PM) *
To collect data files from the LabJack, you could use DAQFactory, or perhaps LJStreamUD or LJLogUD.

You have software for analysis, but do you have software you plan to use to collect the CAN data?

Say some other program collects the CAN data. You could put some common signal to both that program and the LabJack related program, such that later you have a common signal in both files that allows you to synchronize them.

If you are looking for a single program to collect both the CAN data and the LabJack data into a single file, then I would post about that on the Azeotech forum. Let them know more about the CAN, and let them know how synchronized you want the data to be.

Although I haven't made any progress for this project I haven't abandoned it.

After some research I found several IC's that can connect to a CAN network which have an SPI interface.
Would it be possible to log CAN data through the SPI interface of a LabJack this way?
Basically save (send to the PC) a full CAN message each time it has been received?

Is this correct, or am I missing something?
If it works, what would be the expected maximum logging rate?
How would the data integrate with the other LabJack channels? Would it simply be a sample from timestap x containing CAN data and measured data?
 
Quote Post
LabJack Support
post Jan 20 2010, 09:04 PM
Post #6

Joined: 9-June 03
Posts: 5513




There is a ton of detail you can get into, but basically when you want to read something from the SPI chip you would call code like you see in Section 4.3.10 of the U3 User's Guide. In DAQFactory you would use a sequence containing code just like this. It would take a few milliseconds for this code to execute and transfer a few bytes.

If you put code like this in a DAQFactory Channel Event, I think you could make it integrate pretty well with other DAQFactory Channels, but it would not be trivial to do and would depend on how exactly the CAN-SPI IC works.
 
Quote Post
disturbedsaint
post Jan 26 2010, 12:01 PM
Post #7

Joined: 30-June 09
Posts: 12




QUOTE (LabJack Support @ Jan 21 2010, 05:04 AM) *
There is a ton of detail you can get into, but basically when you want to read something from the SPI chip you would call code like you see in Section 4.3.10 of the U3 User's Guide. In DAQFactory you would use a sequence containing code just like this. It would take a few milliseconds for this code to execute and transfer a few bytes.

If you put code like this in a DAQFactory Channel Event, I think you could make it integrate pretty well with other DAQFactory Channels, but it would not be trivial to do and would depend on how exactly the CAN-SPI IC works.

I guess there isn't the possibility of an interrupt that the CAN transceiver can trigger as soon as its done receiving?
So I'd have to run the code to retreive the CAN transceiver buffer through SPI manually each 1/x seconds?

Can all this be used in streaming mode?
 
Quote Post
LabJack Support
post Jan 26 2010, 12:29 PM
Post #8

Joined: 9-June 03
Posts: 5513




Is the CAN chip an SPI slave or master? That is, does it have a clock input (slave) like most ICs, or a clock output (master) like a microcontroller would? Generally, the SPI master queries or commands the slave whenever it wants to read or write something.

No, you can't do SPI in stream. You can do SPI while streaming other things.
 
Quote Post
disturbedsaint
post Jan 26 2010, 03:15 PM
Post #9

Joined: 30-June 09
Posts: 12




QUOTE (LabJack Support @ Jan 26 2010, 08:29 PM) *
Is the CAN chip an SPI slave or master? That is, does it have a clock input (slave) like most ICs, or a clock output (master) like a microcontroller would? Generally, the SPI master queries or commands the slave whenever it wants to read or write something.

The CAN controller I would probably use is an SPI slave device (http://ww1.microchip.com/downloads/en/DeviceDoc/21801d.pdf).
It offers an interrupt pin (several actually) that can be driven high when a CAN message has been received.

QUOTE (LabJack Support @ Jan 26 2010, 08:29 PM) *
No, you can't do SPI in stream. You can do SPI while streaming other things.

So basically I run all other channels I need in streaming mode and add a sequence for the CAN/SPI channel.
Does DAQfactory make sure the timestamping would match or does the LabJack driver do that?
 
Quote Post
LabJack Support
post Jan 27 2010, 07:47 AM
Post #10

Joined: 9-June 03
Posts: 5513




DAQFactory would likely do its best with the timestamps, and depending on what sort of sync you are looking for it might be great. Do you really need to use stream mode? How fast do you need to scan the other channels?

How often do you expect a CAN interrupt? Or lets say the CAN chip was getting millions of messages per second and you can't possibly get all of them. How fast do you think you need to service the CAN chip?
 
Quote Post
disturbedsaint
post Jan 27 2010, 05:47 PM
Post #11

Joined: 30-June 09
Posts: 12




QUOTE (LabJack Support @ Jan 27 2010, 03:47 PM) *
DAQFactory would likely do its best with the timestamps, and depending on what sort of sync you are looking for it might be great. Do you really need to use stream mode? How fast do you need to scan the other channels?

Well I need to sample at least 2 wheelspeeds, which with the current car setup running at high velocity would mean upt to 1600 teeth/s.
Furthermore I need to sample at least 4 linear potentiometers at a sampling rate of 500Hz (though if not possible 400 or 200Hz would be sufficient).
The other sensors I'm using right now can all be sampled at speeds <= 100Hz, though I might add more high-speed sensors later.

Sync for the high-speed channels should be as perfect as possible, preferably within 2*period of the samplerate. I don't know if that's realistic?

QUOTE (LabJack Support @ Jan 27 2010, 03:47 PM) *
How often do you expect a CAN interrupt? Or lets say the CAN chip was getting millions of messages per second and you can't possibly get all of them. How fast do you think you need to service the CAN chip?

Well, that depends on which and how many channels I want to log through the CAN bus.
Basically I intend to use the CAN-bus to connect to the ECU. Depending on the ECU it is possible for some channels to broadcast/update several channels up to 1000Hz.

What I could do though would be to connect all high-rate sensors to the LabJack and only send low-rate (say <100Hz) and less important channels over CAN.
I guess that would make an eventual non-perfect sync between stream and non-stream/SPI-data less problematic as well (since I guess the non-perfect sync is a static amount of ms, independent of the samplerate, is that correct?)
 
Quote Post
LabJack Support
post Jan 28 2010, 10:21 AM
Post #12

Joined: 9-June 03
Posts: 5513




One comment, is that this is so detailed I would just proceed in a programming language like C, VB, LabVIEW, Python, or other. I would not try this in DAQFactory.

I suggest you use timers for you speed sensors. Without the CAN, you could easily scan the timers and 4 analog inputs at perhaps 5 kscans/s or more.

In command/response, you could also hit your rates, and could try polling your CAN chip also. You might be able to do all that at 200 scans/s.
 
Quote Post
disturbedsaint
post Jan 28 2010, 12:34 PM
Post #13

Joined: 30-June 09
Posts: 12




QUOTE (LabJack Support @ Jan 28 2010, 06:21 PM) *
One comment, is that this is so detailed I would just proceed in a programming language like C, VB, LabVIEW, Python, or other. I would not try this in DAQFactory.

I was actually planning to do this in Python (or if necessary in C), but since I don't know if the timestamping/syncing is done by the LabJack, the LabJack driver or DAQFactory and DAQFactory seems to be the standard way to use the LabJack I assumed DAQFactory would be the way to go.

QUOTE (LabJack Support @ Jan 28 2010, 06:21 PM) *
I suggest you use timers for you speed sensors. Without the CAN, you could easily scan the timers and 4 analog inputs at perhaps 5 kscans/s or more.

What would be the difference between using counters or timers for the speed sensors?
Does either of them have more overhead than the other?

With 5kscans/s do you mean per channel or total for all channels?

I don't mind to buy a U6 instead of an U3, since it has a higher number of total samples/s (at the same resolution).

QUOTE (LabJack Support @ Jan 28 2010, 06:21 PM) *
In command/response, you could also hit your rates, and could try polling your CAN chip also. You might be able to do all that at 200 scans/s.

That is nice to hear, if streaming with a separate command/repsone SPI/CAN channel doesn't work I will at least have a fallback option.

Since you asked if I have to use streaming mode, is there a disadvantage to using it?
It could be that I'd have to add another 4 to 6 sensor that have to be sampled at 500Hz as well, that's why I was looking into streaming mode.
 
Quote Post
LabJack Support
post Jan 28 2010, 03:47 PM
Post #14

Joined: 9-June 03
Posts: 5513




Python would be great, although if you are really trying to maximize performance you might need to use C.

QUOTE
I don't know if the timestamping/syncing is done by the LabJack, the LabJack driver or DAQFactory

Timestamping is done at the application layer, so DF or Python or C.

One detail is stream mode. When you get data in stream mode, you timestamp the first scan at the application layer (using system time). Then you know the time interval between each scan, so you generally calculate all further timestamps for other scans (rather than reading system time).


QUOTE
What would be the difference between using counters or timers for the speed sensors?

See the following:

http://forums.labjack.com/index.php?showtopic=1105


QUOTE
With 5kscans/s do you mean per channel or total for all channels?

Per channel. See Section 3.2 of the U3 or U6 User's Guide.


QUOTE
I don't mind to buy a U6 instead of an U3, since it has a higher number of total samples/s (at the same resolution).

Yes, that is one advantage to the U6.


QUOTE
Since you asked if I have to use streaming mode, is there a disadvantage to using it?

I just felt that if you were trying to sync SPI data with other data, command/response would be easier.
 
Quote Post
disturbedsaint
post Feb 5 2010, 11:18 AM
Post #15

Joined: 30-June 09
Posts: 12




I think I'll go for the the U6, it seems be able to do what I want without limiting possible future expansion-needs.
Would there be any gain for my purposes to use the UE9?

One final question about this:
Could I calculate (or get an estimate of) the max samplerate over the SPI bus somehow?
I guess I would have to know the time it takes for the code to execute?
(CAN can contain max 64 bits data per message)

2 general questions ;)
Are all channels (which are sampled at the same samplerate) sampled synchronously (at the same moment in time) or in sequence?
Doest command/response or stream mode make a difference for this?
(as far as I understand it Labjacks use a multiplexer so the sampling would be in sequence?)

Why do all LabJacks have different analog voltage input ranges (2.4/3.6V, 5V, 10V)?


Thanks for all your help/effort btw! :)
 
Quote Post
LabJack Support
post Feb 8 2010, 12:35 PM
Post #16

Joined: 9-June 03
Posts: 5513




QUOTE
Would there be any gain for my purposes to use the UE9?

The main advantage to the UE9 is Ethernet. The newer U6 actually has better analog inputs.

QUOTE
Could I calculate (or get an estimate of) the max samplerate over the SPI bus somehow?
I guess I would have to know the time it takes for the code to execute?
(CAN can contain max 64 bits data per message)

From Section 3.1 of the U3 User's Guide you can see that the basic communication time is about 0.6 or 4.0 ms round-trip. From Section 5.3.15, SPI clocks at about 100kHz, so your 64 bits would take about 0.64 ms, so add that to the basic communication time.

QUOTE
Are all channels (which are sampled at the same samplerate) sampled synchronously (at the same moment in time) or in sequence? Doest command/response or stream mode make a difference for this? (as far as I understand it Labjacks use a multiplexer so the sampling would be in sequence?)

Table 3-4 in Section 3.2 shows the interchannel delay from stream mode. In command/response mode it is about 600 us (or about half that if quicksample is on).

QUOTE
Why do all LabJacks have different analog voltage input ranges (2.4/3.6V, 5V, 10V)?

The +/-5 volt max range of the UE9 was just a design decision at the time. The 2.4/3.6 is just the natural range of the converter in the U3, and no signal conditioning was added. The +/-10 volt range of the high voltage channels on the U3-HV and the max range of the U6, is what we are generally going with these days for a max range.
 
Quote Post
disturbedsaint
post Feb 11 2010, 04:58 PM
Post #17

Joined: 30-June 09
Posts: 12




Just wanted to let you know I've ordered my U6 :)

The CAN interfacing will take some time (actually the ECU hasn't been decided, so I can't even test it yet), but I will post my progress here and share it.

Btw. in the U6 manual the interchannel delays column for streaming isn't filled, are they the same as the U3?
 
Quote Post
LabJack Support
post Feb 11 2010, 05:03 PM
Post #18

Joined: 9-June 03
Posts: 5513




You know that the interchannel delay is at most one over the sample rate, so for example in the first row you know the number is 20 us or less. The actual number for Res=1 and Gain=1 is about 16.5 us.

The other thing missing from Section 3.2 is the stream rates at other gains. It does slow down substantially, as it adds lots of settling time in case in has to settle from a big voltage like 10 volts to a microvolt level measurement. You can put in your own lower settling times to get around this.
 
Quote Post
disturbedsaint
post Feb 22 2010, 09:08 AM
Post #19

Joined: 30-June 09
Posts: 12




QUOTE (LabJack Support @ Jan 28 2010, 06:21 PM) *
I suggest you use timers for you speed sensors. Without the CAN, you could easily scan the timers and 4 analog inputs at perhaps 5 kscans/s or more.

See the following:

http://forums.labjack.com/index.php?showtopic=1105

I've been reading the documentation several times, but the different timer-modes are a little difficult for me to comprehend.
What would be the best timer-mode to use?
For some of the modes it is mentioned they can be interrupted, which I guess would be bad, so am I correct I should use one of the other modes?

The signal itself is 0-8V whereas the manual states a maximum of 6V can be used on the digital inputs, what would be a safe way of connecting it to the LabJack?
 
Quote Post
LabJack Support
post Feb 22 2010, 09:46 AM
Post #20

Joined: 9-June 03
Posts: 5513




You want to measure period, so I would use mode 2 (Section 2.9.1.3). Experiment with it using the test panel in LJControlPanel.

If your signal is going to be driven higher than 5 volts, put a resistor in series as discussed in Section 2.8.1.1 of the U6 User's Guide.
 
Quote Post
disturbedsaint
post Feb 23 2010, 09:37 AM
Post #21

Joined: 30-June 09
Posts: 12




Well, we've done our first test and the data is too noisy.
I didn't manage to get a clean speed-input for the digital circuit, so I had to sample it through an analog channel.

When I have the LabJack on my desk everything is fine, when it's inside the car and the car is moving/running I seem to get more noise than data.

I am streaming the following analog connections at 1000Hz, all wiring is shielded:
- 4x linear potentiometer (powered by LabJack 0-5V)
- 2x accelerometer (powered by LabJack 0-5V)
- 1x speed

Could the noise come from the movement/vibration or electrical system/engine of the car?
I tried filtering the data but that didn't work.

The measured speed does show sort of a square wave, but when calculating the time between peaks it shows a very rough/aliased graph, probably because 1000Hz is too slow for it?
 
Quote Post
LabJack Support
post Feb 23 2010, 09:46 AM
Post #22

Joined: 9-June 03
Posts: 5513




I suggest you remove all connections except for USB and 1 signal (the worst one). Then start collecting data with the car off, car on not moving, and car moving, to see how it differs. At that point, if you see noise problems tell us more about the sensor and how it is connected to the U6.
 
Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
RSS