Professional Windows® software to communicate with CAN and CAN FD busses and its add-ins: Plotter, CANdb Import, Instruments Panel, and J1939
-
UlfMuller
- Posts: 4
- Joined: Wed 9. Oct 2019, 16:36
Post
by UlfMuller » Thu 10. Oct 2019, 09:12
Hi Team,
I'm quite new to using and writing macro, so I would appreciate a little help.
I'm using PCAN Exlplorer 6 and trying to write a macro using Standard Macro with Format version=6.
The thing I want to do is to send a extended frame with a counter that loops in the first byte.
Sofar I have writen this code:
Code: Select all
// This is a PCAN-Explorer Standard Macro sample
FormatVersion=6.0
Start: Send 1 0CFC2530h 8 00h 00h 03h 03h 00h 00h 00h DEh
Loop: IncSignal TJS_Heartbeat_TJSGW
ClearQueue
WaitData 50 1 0CFC2530h 8 FFh * * * * * * *
If True
Goto Start
If False
Goto Loop
But the counter only counts up once, and never restarts when first byte reaches FF.
Could you please tell me what I'm doing wrong, and describe a solution for this?
Or is it possible at all to use the standard macro to solve this?
Thanks
Best regards
Ulf Müller
Last edited by
M.Gerber on Mon 14. Oct 2019, 18:08, edited 1 time in total.
Reason: Inserted [code] tags for improved readability
-
UlfMuller
- Posts: 4
- Joined: Wed 9. Oct 2019, 16:36
Post
by UlfMuller » Thu 10. Oct 2019, 10:43
Hi Again,
I found a solution in using the VBS macro function as you has described in another question
Following code did the trick:
Code: Select all
Sub CounterChecksumExample()
Dim msg, counter
counter = 0
Set msg = TransmitMessages(1)
While True
msg.Data(0) = counter
'msg.Data(7) = CalcMyChecksum(counter)
counter = counter + 1
If counter > 255 Then _
counter = 0
msg.Write 0
Wait 50
Wend
End Sub
Thanks!
BR
Ulf
Last edited by
M.Gerber on Mon 14. Oct 2019, 18:09, edited 1 time in total.
Reason: Inserted [code] tags for improved readability
-
PEAK-Support
- Sales & Support

- Posts: 1646
- Joined: Fri 10. Sep 2010, 19:34
Post
by PEAK-Support » Fri 11. Oct 2019, 11:56
OK - you solved it by your own - perfect !
With the latest Versions of PCAN-Explorer 6 we also offer the option to include Callback DLLS.
With the help of the Callback Library window you can assign functions from external function libraries (DLLs) to different events, so that they are called when the events occur. In this way, for example, you can evaluate or modify data of CAN messages.
There are 3 differnet Event Types available:
General, Transmit and Receive
So you are able to change CAN Date "on the fly" . Here a short sample for using it with the "Transmit" event:
You change data inside the CAN Frame and send it (in PE6). In the Callbackk DLL (not visibel for the "end user") you calculate a CRC for Byte 0 to Byte 6 and store it in Byte 7. After that the CAN Frame will send.
You also could add a Rolling Counter etc.
See PE6 Online Help "Callback Library Window"
--------------------------------
PEAK-System Technik
Technical Support Team
support[at]peak-system.com
-------------------------------