Cycling bytes

Comprehensive CAN monitor for Windows® and its add-ins: Plotter, CANdb Import, and Instruments Panel
Post Reply
manfluca
Posts: 2
Joined: Thu 26. Oct 2017, 11:30

Cycling bytes

Post by manfluca » Thu 26. Oct 2017, 16:54

Hello,
I'm using PCAN-Explorer 4 in the development of test & diagnostic equipment for automotive ECUs.
I often need to send messages containing one or more counting bytes (I mean a byte where one or both nibbles are cycling...).
In the case it's just one (or both over a limited range...) I use standard macros with a sequence of "send".
Obviously, I can't do that if the counting range is 0x00 - 0xFF.
By now, I'm having that job done directly by the microcontroller on the card under development, but that means a waste of time until the design is not definitive.
I would like the possibility of automating the task in PCAN Explorer, by means o a variable incremented (or decremented) by a certain step each time the message is sent.
I think that's possible in VBS, but I'm not familiar with that language; I'm programming in C.
Is there an example or a template I can adapt to my need?
Thanks for your help....

M.Maidhof
Support
Support
Posts: 1751
Joined: Wed 22. Sep 2010, 14:00

Re: Cycling bytes

Post by M.Maidhof » Fri 27. Oct 2017, 13:12

Hello,

yes, this will be possible by using a VBmacro. Please have a look on the following demo VBmacro:

Code: Select all

'------------------------------------------------------------------------------
'FILE DESCRIPTION: Testmacro
'------------------------------------------------------------------------------

Sub Senddata()
'DESCRIPTION: Send Message with counter to CAN
 Dim MySec
 Dim client
 Dim counter
  
 Set client = PCANClients.Add("Senddata")
 client.Device = ActivePCANClient.Device
 client.NetName = ActivePCANClient.NetName 
 Set msg = client.Messages.Add

do
  Wait 500
 With msg
   .id = &H100
   .dlc = 8
   .MsgType = pcanMsgTypeStandard
   .Data(0) = counter
   .Data(1) = 0
   .Data(2) = 0
   .Data(3) = 0
   .Data(4) = 0
   .Data(5) = 0  
   .Data(6) = 0
   .Data(7) = 0
   .Write(0)
  End With
 
 counter = counter +1
Loop While 1=1
 

End Sub
regards

Michael

manfluca
Posts: 2
Joined: Thu 26. Oct 2017, 11:30

Re: Cycling bytes

Post by manfluca » Fri 27. Oct 2017, 18:34

Hi Michael,
Thanks a lot for your prompt reply.
I'll take a look at that macro as soon as I can.
Best regards, and have a nice week-end.

Luca

Post Reply