Step 1.
copy the pcan_basic.bas file to your folder where you like to store the Excel Sheet
Step 2.
Open Excel and create a new Macro
Step 3.
Add the pcan_basic.bas to your module folder
Step 4.
create a own module and copy this simple code into the file:
Code: Select all
Dim myMsg As TPCANMsg
Sub SendCANID()
myMsg.ID = 255
myMsg.LEN = 4
myMsg.MsgType = PCAN_MESSAGE_STANDARD
myMsg.DATA(0) = 1
myMsg.DATA(1) = 2
myMsg.DATA(2) = 3
myMsg.DATA(3) = 4
ret = CAN_Initialize(PCAN_USBBUS1, PCAN_BAUD_500K)
If ret = PCAN_ERROR_OK Then
For a = 1 To 100
ret = CAN_Write(PCAN_USBBUS1, myMsg)
Next a
End If
CAN_Uninitialize (PCAN_USBBUS1)
End Sub
Press F5 to run the macro
If you have a PCAN-USB Adapter installed, the Interface will send out 100 CAN Frames.
Very easy - very nice

To use a differnet CAN Channel, a other Hardware Type or a different Baud Rate, simple exchange the PCAN_USBBUS1 and/or the PCAN_BAUD_500K for you need in the CAN_Initialize(...) function.