Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

How to attach transmission of two CAN cyclic frames?

Hi all,

 

I work with:

Hardware: NI-PCI 8512, CAN interface.

Software Environment: C++

OS: Windows7

 

I try to transmit two separate cyclic frames, with gap of up to 125 usec between one other.

I try the approach of sending the nxStart command line after line - and i got a gap of 600 usec. Not good enough...

 

Any ideas?

 

Thanks for advance,

Aviad

0 Kudos
Message 1 of 7
(5,773 Views)

What baud rate are you using?

0 Kudos
Message 2 of 7
(5,764 Views)

1Mbaud.

Thanks.

0 Kudos
Message 3 of 7
(5,762 Views)

EDIT: The second session is transmit SIGNAL - not frame!!

Sorry...

0 Kudos
Message 4 of 7
(5,760 Views)

What cyclic rate are you trying to hit?

 

At 1M, a frame typically takes 125us to transmit on the bus. So, in order to get them 125us apart, you will need to essentially create a 100% busload situation with no gaps. If the frames have the same rate, you can use the property nxPropSessionSub_CANStartTimeOff to set both frame to the same offset. THen they will always transfer back-to-back.

 

Otherwise, you will be unlikely get a 125us rate. XNET typically works in 500us intervals.

 

Maybe the better question - what are you actually trying to accomplish?

0 Kudos
Message 5 of 7
(5,759 Views)

Hi GPIB_Guru,

 

I absolutely agree with your last question... So, here what I want to obtain:

 

1. To generate Cyclic frame on the bus, use as a sync. Payload length = 0. Rate = 10Hz (e.g, Id = 0x1)

2. Close as possible (e.i 125 usec) after the sync transmission, to transmit another frame, with changing payload (e.g, Id = 0x2))

 

So, what I'm doing now:

1. Create Cyclic frame, Id = 0x1.

2. Create Cyclic frame, Id = 0x2.

3. Create Signal, Id = 0x2.

4. Create session to Id = 0x1 (FrameOutSinglePoint)

5. Create session to Id = 0x2 (SignalOutSinglePoint)

6. Start session Id = 0x1

7. Start session Id = 0x2

8. When frame 0x1 echo to the read queue,  changing the payload of frame Id 0x2

 

I really be glad to here another ideas how to get it in another way...

 

Thanks alot,

Aviad

 

0 Kudos
Message 6 of 7
(5,737 Views)

Just to clarify..

You want to send Cyclic Frame (ID = 1) every 100ms
"Immediately" after sending the ID = 1 frame, you want to send ID=2 frame

In theory, I think you could do this. NI-XNET should send the frames in priority order if there is a "collision", meaning that the two frames are attempted to transmit at the same time.

You could try:
Create Cyclic Frame ID = 0x1, set Cyclic rate to 100ms
Create Cyclic Frame ID = 0x2, set Cyclic rate to 100ms
Create Signal for Cyclic Frame 2
Create session to Id = 0x1 (FrameOutSinglePoint)
Set nxPropSessionSub_CANStartTimeOff for the session to some number (>= 1)
Create session to Id = 0x2 (SignalOutSinglePoint)
Set nxPropSessionSub_CANStartTimeOff for the session to the same number
Start session 1 (use session only)
Start session 2 (normal)
I think this should work to accomplish what you want.. however...

You cannot really have any guarantees on the CAN bus due to collisions (if your IDs are exactly 1 and 2 you are pretty safe since those are two of the highest priority frames, but in the normal world those are not typically the two frames that are generated). I think it would be better to do everything the same as above, but set the Set nxPropSessionSub_CANStartTimeOff for the second session to be N+1 (N is the number for the first session). The second frame should transmit 500us after the first one in this case. The advantage of this is that you are not relying on any detected collision in the driver (there is an ever so slight chance that they could be sent in the opposite order). You would see 500us instead of 125us (although you wouldn't actually see 125us in the first situation as the two frames would be sent back-to-back every 100ms).

Is the 125us required? Do you know the data to transmit ahead of time? You could use stream output in replay mode to get precise timing, but that somewhat requries you to know exactly what you want to send ahead of time.

0 Kudos
Message 7 of 7
(5,722 Views)