Increase Message Cyclic Time

Universal CAN Converter
Post Reply
MHeine
Posts: 2
Joined: Wed 2. Sep 2020, 11:42

Increase Message Cyclic Time

Post by MHeine » Wed 2. Sep 2020, 11:49

Hi,

I want to increase the CyclicTime of a routed message from 100ms to 200ms. I thought it wil be simple, using your "Timer"-Example, but I got stuck with it. Maybe I think too short.

For testing, I modified your Example:

Code: Select all

// process messages from CAN2
if ( CAN_UserRead ( CAN_BUS2, &RxMsg) != 0)
{
    // message received from CAN2
    LED_toggleCAN2 ^= 1;

    if ( LED_toggleCAN2)
    {
        HW_SetLED ( HW_LED_CAN2, HW_LED_ORANGE);
    }		
    else
    {
        HW_SetLED ( HW_LED_CAN2, HW_LED_GREEN);
    }
			
			
    // copy message
    TxMsg.Id   = RxMsg.Id;
    TxMsg.Type = RxMsg.Type;
    TxMsg.Len  = RxMsg.Len;
			
    TxMsg.Data32[0]	= RxMsg.Data32[0];
    TxMsg.Data32[1]	= RxMsg.Data32[1];
			
    // send
    //CAN_UserWrite ( CAN_BUS1, &TxMsg);
}		

// send a message every 50 millis
timenow = SYSTIME_NOW;
		
if ( SYSTIME_DIFF ( LastCycleMsg, timenow) >= 200000)
{
    // adjust last time of message by 50 millis
    LastCycleMsg += 200000;
			
    // increment a simple counter
    //CycleMsg.Data16[0] += 1;
			
    // send
    //CAN_UserWrite ( CAN_BUS1, &CycleMsg);
    CAN_UserWrite ( CAN_BUS1, &TxMsg);
[/code]

Where went I wrong?
Thx & Best regards
Mirko
Last edited by K.Wagner on Wed 2. Sep 2020, 13:17, edited 1 time in total.

User avatar
PEAK-Support
Sales & Support
Sales & Support
Posts: 1646
Joined: Fri 10. Sep 2010, 19:34

Re: Increase Message Cyclic Time

Post by PEAK-Support » Wed 2. Sep 2020, 12:43

Please first tell us, which Hardware (Part Number) and/or SW you are talking about You post it in a completly wrong part of the forum (third party ?!?)
We could shift it if we have that correct information and then could answer!
--------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------

MHeine
Posts: 2
Joined: Wed 2. Sep 2020, 11:42

Re: Increase Message Cyclic Time

Post by MHeine » Thu 3. Sep 2020, 12:22

Hi,


I'm sorry for that. :oops:
I'm using a PCAN-Router IPEH-002210. I'm able to compile the C++-Code into the *.bin /*.elf /etc. -file and flash the compiled firmware via PCAN-Flash to the Router-Device.

Thx a lot.

User avatar
PEAK-Support
Sales & Support
Sales & Support
Posts: 1646
Joined: Fri 10. Sep 2010, 19:34

Re: Increase Message Cyclic Time

Post by PEAK-Support » Thu 3. Sep 2020, 13:08

OK - no problem - now it´s clear - i have moved the Topic to the correct Forum Section (Hardware Support -- Routers & Gateways -- PCAN-Router)

--

to change the send frequenzy you need to change this

Code: Select all

		// send a message every 50 millis
		timenow = SYSTIME_NOW;
		
		if ( SYSTIME_DIFF ( LastCycleMsg, timenow) >= 50000)
		{
			// adjust last time of message by 50 millis
			LastCycleMsg += 50000;
			
			// increment a simple counter
			CycleMsg.Data16[0] += 1;
			
			// send
			CAN_UserWrite ( CAN_BUS2, &CycleMsg);
		}
to

Code: Select all

		// send a message every 200 millis
		timenow = SYSTIME_NOW;
		
		if ( SYSTIME_DIFF ( LastCycleMsg, timenow) >= 200000)
		{
			// adjust last time of message by 200 millis
			LastCycleMsg += 200000;
			
			// increment a simple counter
			CycleMsg.Data16[0] += 1;
			
			// send
			CAN_UserWrite ( CAN_BUS2, &CycleMsg);
		}
But you wrote the "routetd" message - the sample show a cycling self generated message - no routed Message.
What exact do you want to do ?
--------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------

Post Reply