LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Sharing Data between Asynchronous Timers

Solved!
Go to solution

Is it possible to have an asynchronous timer setting the values of a CAN Signal and having another asynchronous timer getting the values written?

 

Say AsyncTimerA transmits Message 0x4FF at an interval of 250ms.

 

AsyncTimerB gets Message 0x4FF also at an interval of 250ms. 

 

Currently I am not getting the value I have written with AsyncTimerA. I am getting an error saying that 0x4FF is not found on the CAN bus. 

0 Kudos
Message 1 of 7
(3,868 Views)

Hi,

You’re trying to send a periodic message with arbitration ID of 0x4FF from one CAN port to another? This is definitely possible.  The NI CAN driver comes with a lot of good examples that can let you make messages with custom ARBs and also receive all messages on your CAN bus. First, make sure that your bus is working and you can send and/or receive CAN messages, the CAN examples and a CAN card (PCI, PXI, USB, etc.) will be helpful. Then you will be better equipped to know where the system is not working like you expect. Hope this information helps and good luck!

Matt
Applications Engineer
National Instruments
0 Kudos
Message 2 of 7
(3,846 Views)

Sorry about the miscommunication. This is what I am doing:

 

 

AsyncTimerAId = NewAsyncTimer(0.25, -1, 1, AsyncTimerAThreadFunc, 0);

 

AsyncTimerBId = NewAsyncTimer(0.25, -1, 1, AsyncTimerBThreadFunc, 0);

 

 

int CVICALLBACK AsyncTimerAThreadFunc(int reserved, int timerId, int event, void *callbackData, int eventData1, int eventData2) 

 

{

if (event == EVENT_TIMER_TICK)
   

     //puts 0x4FF on the bus

}

 

int CVICALLBACK AsyncTimerBThreadFunc(int reserved, int timerId, int event, void *callbackData, int eventData1, int eventData2) 

{

if (event == EVENT_TIMER_TICK)
   

     //reads the value of 0x4FF on the bus

}

 

By checking the values being transmitted on the bus, 0x4FF is correctly transmitted every 250ms.

However, when I try reading the values of 0x4FF on the bus, I am getting an error of signal not in bus.

0 Kudos
Message 3 of 7
(3,840 Views)
are sure your CAN library  allows you to read back what you wrote on the bus ? this does not look good to me... (but i never used a standard CAN board)
Message Edited by dummy_decoy on 2009-10-13 01:17 AM
0 Kudos
Message 4 of 7
(3,832 Views)
The CAN Library is functional. It reads and sets Messages accordingly outside of the Asynchronous Timer. :manhappy:
0 Kudos
Message 5 of 7
(3,828 Views)

Hi,

What hardware and version of NI CAN are you using? I’m afraid I didn’t get much out of looking at your pseudo code; can you try looking at some of the examples in the example finder. “CAN receive” should show you anything that is on the bus. Make sure that you are sending a message with a payload of “0x4FF” and trying to read a message with Arbitration ID “0x4FF”. I believe this might give you an error similar to what you see.

Matt
Applications Engineer
National Instruments
0 Kudos
Message 6 of 7
(3,804 Views)
Solution
Accepted by topic author J001

As forementioned, the message transmits correctly and is seen on the bus Smiley Happy

 

I have found the problem to it. Asynchronous timers utilises the multimedia clock.

When too many asynchronous timers are started at the same time with a very short interval, eg. 10ms, the timers will start operating in a very unstable way.

 

I have now reduced the number of asynchronous timers used, replacing them with multithreading instead. Smiley Very Happy 

0 Kudos
Message 7 of 7
(3,777 Views)