Skip to main content

Microsoft Excel LIN Simulation Program

Screen Layout (Setting Sheet)

Excel LIN Simulation Program Setting Sheet
ItemDescription
Connect buttonDetects MicroPeckerX connected to the PC.
SerialDisplays serial number of the detected MicroPeckerX.
Parameter Setting
(area ①)
Sets simulation mode, LIN revision, baudrate, etc.
Master Sim Setting
(area ②)
Sets transmission schedules and interrupt transmission frame for master simulation.
Slave Sim Setting
(area ③)
Sets response ID list for slave simulation.

Screen Layout (Monitoring Sheet)

Excel LIN Simulation Program Monitoring Sheet
ItemDescription
Start buttonStarts monitoring and transmission based on transmission schedule (or responses based on response ID list).
Stop buttonStops monitoring and transmission based on transmission schedule (or responses based on response ID list).
MasterChange Sch. buttonSwitches active transmission schedule.
See Transmission Schedule for details.
Change Data buttonChanges D1 to FFH for the upper frame in current transmission schedule.
See Transmission Schedule.
Interrupt Send buttonSends interrupt transmission frame.
See Interrupt Transmission Frame.
SlaveChange Data buttonChanges D1 to 00H for the upper response in response ID list.
See Response ID List.
Send Wakeup buttonSends wakeup pulse.
StatusDisplays state of monitoring and schedule-based frame transmission (or response-list-based transmission).
Start: running / Stop: stopped
Monitor Log
(area ①)
Displays transmitted/received logs. Logs update every second; previous logs are cleared at each update.
If no logs are available, display is not updated and previous logs remain.
See Monitor Log Details.

Monitor Log Details

ItemDescription
Time StampDisplays timestamp in sssss.mmmuuu format.
DirDisplays log direction.
Rx: receive log / Tx: transmit log
TypeDisplays log type.
IDDisplays LIN ID in hexadecimal.
DLDisplays data length (1 to 8).
DataDisplays data (D1 to D8) in hexadecimal.
CSDisplays checksum in hexadecimal.

Transmission Schedule

Details of each transmission schedule are as follows.
Dir, ID, Delay, and Data can be changed in the Setting sheet (DL is automatically adjusted according to ID).

No.DirIDDelayDLData (Hex)
D1D2D3D4D5D6D7D8
0
(*1)
Tx10H500ms243HCBH
Rx11H500ms-
1
(*1)
Tx20H500ms412H56H9AHDEH
Rx21H500ms-

Implementation Example (Source Code with Comments)

The VBA sample logic is included in MPXCtrl_LIN_ExcelVBA_Sample.xlsm.
MPXCtrlFree.bas contains API declarations, constants, and structure definitions. The following is an example using the same API sequence as the sample.

Option Explicit

Sub StartLinSimulation(ByVal mode As Byte)
Dim dev(0 To 0) As StMPXDeviceInfo
Dim count As Byte
Dim ret As Long
Dim serial As Long
Dim p As StMPXLINParam

' 1) Open
ret = MPXOpen(dev(0), 1, count)
If ret <> E_OK Or count = 0 Then Exit Sub
serial = dev(0).Serial

' 2) LIN parameter setting (mode: Monitor/Master/Slave)
p.Mode = mode
p.Revision = MPX_LIN_REV_21
p.Baudrate = 19200
p.SyncBreak = 13
p.Delimiter = 1
p.HeaderSpace = 1
p.ResponseSpace = 1
p.ByteSpace = 1
ret = MPXLINSetParam(serial, p)
If ret <> E_OK Then Exit Sub

' 3) Set log acquisition mode
ret = MPXSetGetLogMode(serial, MPX_INNERCH_LIN, MPX_GETLOGMODE_GETLOGAPI)
If ret <> E_OK Then Exit Sub

' 4) Set Master/Slave settings as needed
' Master: MPXLINSetMasterSchedule, MPXLINSetMasterSim, MPXLINSetStatus
' Slave : MPXLINSetSlaveSim

' 5) Start
ret = MPXMonitorStart(serial, MPX_SYNC_MASTER)
End Sub

Sub StopLinSimulation(ByVal serial As Long)
Dim ms As Long, us As Integer
Call MPXMonitorStop(serial, ms, us)
Call MPXClose
End Sub

*1: Active transmission schedule switches each time "Change Schedule" button is clicked.

Interrupt Transmission Frame

The interrupt transmission frame is as follows.
Dir, ID, and Data can be changed in the Setting sheet (DL is automatically adjusted according to ID).

DirIDDLData (Hex)
D1D2D3D4D5D6D7D8
Tx35H802H13H46H57H8AH9BHCEHDFH

Response ID List

The response ID list is as follows.
ID and Data can be changed in the Setting sheet (DL is automatically adjusted according to ID).

IDDLData (Hex)
D1D2D3D4D5D6D7D8
12H212H34H
34H8FEHDCHBAH98H76H54H32H10H