I would like to know, if there are a tips to write on a CAN-BUS with defined period (ojective : 1ms) using Excel sheet and a VBS Macro ?
I used the following script :
Code: Select all
'------------------------------------------------------------------------------
Sub SendMsg_NB_time()
Dim ExcelApp, ExcelWorkbook, ExcelSheet
Set ExcelApp = CreateObject("Excel.Application") ' Start Excel
ExcelApp.Visible = false ' Make Excel visible, not really required
Set ExcelWorkbook = ExcelApp.Workbooks.Open("D:\OneDrive - SymbioFCell\Documents\SEMMOD_SW_PLATEFORM\semmod_b2_platform_dev\semmod_b2_platform\Tools\semmod_b2_platform-release_1.0\List_CAN2.xlsx") ' Adjust path!
Set ExcelSheet = ExcelWorkbook.Worksheets(1) ' go to Sheet 1
' Read all rows in the sheet
Dim Row, Msg, n, NB_SEND, m
NB_SEND = 100 ' Envoie de 100 x la trame
Set Msg = Connections.Transmitmessages.Add
row = 2 ' Messages begin on row 2
For m = 0 To NB_SEND
While ExcelSheet.Cells(Row, 1) <> Empty
'Set Msg = new Connections.Transmitmessages.Add
Msg.ID = CInt("&H" & ExcelSheet.Cells(Row, 1))
Msg.DLC = CInt(ExcelSheet.Cells(Row, 2))
'Msg.MsgType = 2 'pcanMsgTypeExtended
For n = 0 To Msg.DLC-1
Msg.Data(n) = CInt("&H" & ExcelSheet.Cells(Row, 7+n))
Next
Set Msg.Connection = Connections(1)
Msg.Write 0
Msg.IsPaused = False
row =row+1
'Wait 5
wend
Row = 2
Next
'Wait 5
ExcelApp.Quit
End Sub
How can I send each line on my Excel sheet every 1ms or 2ms? Is it possible to be closed to real-time machine?
Is it possible? Should I save the data on the Excel sheet to an array for faster computation?
Thank You, Emilien