Sending CAN messages in sequence

Comprehensive CAN monitor for Windows® and its add-ins: Plotter, CANdb Import, Instruments Panel, and J1939
Post Reply
kubamtx
Posts: 2
Joined: Sun 4. Sep 2011, 21:56

Sending CAN messages in sequence

Post by kubamtx » Sun 4. Sep 2011, 22:04

Hi
I have 5 messages in my CAN transmit list. One is to close Pre-charge relay, second to close both pre-charge and main relay, third is to close main relay and open pre-charge relay, and last is to open both relays.
To start the procedure I have to send this messages in sequence.
I have to close pre-charge relay and keep it closed for 4 sec.
Then I have to send message close both relays and keep 1 sec and then open pre-charge relay and keep main closed.
I don't know how to do this using one defined button.
I'm pretty sure that I have to define signals (one for each can message) and then make something to send them in sequence- but what?
My can messages are simple, CAN ID for all is the same and just first BIT is changing.
Please help.

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

Re: Sending CAN messages in sequence

Post by PEAK-Support » Mon 5. Sep 2011, 09:17

Hi,
you could simply use Standard Macros in PE4/5:
* Create a new project
* Add a Standard Macro (*.std)
* Add your sending sequenz (line by line)
Syntax:
Function BUS ID DLC DATA
Send 1 101h 3 AAh BBh CCh
sample:

Code: Select all

// PCAN-Explorer Macro File
//  First edited: 05.09.2011 08:56:19
// This is a PCAN-Explorer Standard Macro sample

FormatVersion=5.0

      PrintToOutputWindow "Data transmission..."
      WaitKey
	      Call SubA
	      Wait 10
	      Call SubB
      Repeat
      
      //  Bus ID   DLC  Data
SubA:  Send 1  100h  2   12h 34h
	  Wait 10	//Wait 10ms 
      Send 1  101h  3   AAh BBh CCh
      Wait 5	//Wait 5ms 
      Send 1  112h  6   FDh ACh 34h E1h CDh 44h
      Wait 20	//Wait 20ms 
      Send 1  1D2h  4   34h E1h DCh 44h
      Return

      //  Bus ID   DLC  Data
SubB: Send 1  110h  2   12h 34h
	  Wait 10	//Wait 10ms 
      Send 1  111h  3   AAh BBh CCh
      Wait 5	//Wait 5ms 
      Send 1  122h  6   FDh ACh 34h E1h CCh 44h
      Wait 20	//Wait 20ms 
      Send 1  130h  4   34h E1h CDh 44h
      Return

// To learn more about Standard Macros, see
// Help Contents -> Reference -> Standard Macros
To learn more about Standard Macros, see
Help Contents -> Reference -> Standard Macros
You also could simply add this Macro to a Function KEY on your PC by add a section to your Symbols File:
Sample using F5 to start a Macro called "MyMacro"

Code: Select all

{MACROKEYS}
F5=MyMacro
 
--------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------

kubamtx
Posts: 2
Joined: Sun 4. Sep 2011, 21:56

Re: Sending CAN messages in sequence

Post by kubamtx » Tue 6. Sep 2011, 13:31

Hi
Many thanks for fast answer.
I'm completly new in writing macro files in this language.
Can you also send me a sample how to send one can message for 4 seconds with 250ms interval and then stop?

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

Re: Sending CAN messages in sequence

Post by PEAK-Support » Tue 6. Sep 2011, 16:16

Code: Select all

    // PCAN-Explorer Macro File
    //  First edited: 05.09.2011 08:56:19
    // This is a PCAN-Explorer Standard Macro sample

    FormatVersion=5.0

         PrintToOutputWindow "Data transmission..."   
         //  Bus ID   DLC  Data
         Send 1  100h  2   12h 34h
         Wait 250  //Wait 250ms
         Send 1  100h  2   12h 34h
         Wait 250  //Wait 250ms
         Send 1  100h  2   12h 34h
         Wait 250  //Wait 250ms
         Send 1  100h  2   12h 34h
         Wait 250  //Wait 250ms - 1st Second
         PrintToOutputWindow "1st Second..."   
         Send 1  100h  2   12h 34h
         Wait 250  //Wait 250ms
         Send 1  100h  2   12h 34h
         Wait 250  //Wait 250ms
         Send 1  100h  2   12h 34h
         Wait 250  //Wait 250ms
         Send 1  100h  2   12h 34h
         Wait 250  //Wait 250ms - 2nd Second
         PrintToOutputWindow "2nd Second..."   
         Send 1  100h  2   12h 34h
         Wait 250  //Wait 250ms
         Send 1  100h  2   12h 34h
         Wait 250  //Wait 250ms
         Send 1  100h  2   12h 34h
         Wait 250  //Wait 250ms
         Send 1  100h  2   12h 34h
         Wait 250  //Wait 250ms - 3rd Second
         PrintToOutputWindow "3rt Second..."   
         Send 1  100h  2   12h 34h
         Wait 250  //Wait 250ms
         Send 1  100h  2   12h 34h
         Wait 250  //Wait 250ms
         Send 1  100h  2   12h 34h
         Wait 250  //Wait 250ms
         Send 1  100h  2   12h 34h
         Wait 250  //Wait 250ms - 4th Second
         PrintToOutputWindow "4th Second..."   
         PrintToOutputWindow "and finish!"   
         PrintToOutputWindow "for more information please read the Online Help"   
To learn more about Standard Macros, see
Help Contents -> Reference -> Standard Macros
--------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------

Post Reply