I am currently using PLIN view pro to send master requests to a slave. The requests send fine but I want to be able to send frames at different periods. Currently I can only change the delay of the frame but the delays just seem to get added together into one period. Is there anyway to get frames to have different periods?
Thank you.
Setting different periods for Master requests
Re: Setting different periods for Master requests
Hi,
yes, you can use vbscript to handle your master requests. See the following forum post or the help of PLIN-View pro for more details in how to use a vbscript in PLIN-View Pro:
viewtopic.php?f=45&t=7266#p18112
regards
Michael
yes, you can use vbscript to handle your master requests. See the following forum post or the help of PLIN-View pro for more details in how to use a vbscript in PLIN-View Pro:
viewtopic.php?f=45&t=7266#p18112
regards
Michael
Re: Setting different periods for Master requests
Im not sure what I'm doing wrong. I am using the example script but the obj.wait function does not seem to separate the periods. They are just adding together.
Im pretty new to Visual Basic. I also don't have an LDF file, not sure if that is needed to have different delays with PLIN.
Im pretty new to Visual Basic. I also don't have an LDF file, not sure if that is needed to have different delays with PLIN.
Code: Select all
Imports System
Imports System.Linq.Expressions
Module Program
Sub Main(args As String())
' Enumeration PLINHardwareMode
Const plinHardwareModeNone = 0
Const plinHardwareModeSlave = 1
Const plinHardwareModeMaster = 2
' Enumeration PLINDirection
Const plinDirectionDisabled = 0
Const plinDirectionPublisher = 1
Const plinDirectionSubscriber = 2
Const plinDirectionSubscriberAutoLength = 3
' Enumeration PLINChecksumType
Const plinChecksumTypeClassic = 1
Const plinChecksumTypeEnhanced = 2
Const plinChecksumTypeAutomatic = 3
Dim obj
Dim arr(1)
arr(0) = &H0
obj = CreateObject("Peak.Lin.ViewPro.COM.Interfaces.Application")
If Not obj Is Nothing Then
'WScript.Sleep(1000)
obj.OpenProject("C:\LIN\LIN_ECM_Headers.linproj", True)
'Connedt to LIN Bus 1
If obj.ConnectTo(1, 1, plinHardwareModeMaster, 10458) Then
obj.Wait(100)
'Wakeup
Do
obj.SubscribeData(&H2B, 4, plinChecksumTypeEnhanced)
obj.Wait(25)
obj.SubscribeData(&H2A, 5, plinChecksumTypeEnhanced)
obj.Wait(12.5)
Loop While True
End If 'End ConnectTo
' Finally you can call obj.Close
'obj.Close True
End If
End Sub
End Module
- Attachments
-
- Screenshot 2024-04-23 105527.png (5.7 KiB) Viewed 3016 times
Re: Setting different periods for Master requests
Hi,
yes, the wait command does not specify the period of the signal, it just defines the wait time between the next command. It is similar to the wait time in a scheduler. So to have different periods, you have to call it like this:
Do
send frame1
wait 10
send frame2
wait 20
send frame2
wait 20
send frame2
wait 10
send frame1
wait 10
send frame2
wait 20
send frame2
wait 20
send frame2
wait 10
Loop While True
in this case frame1 will be send every 60ms, frame2 will be send every 20ms.
regards
Michael
yes, the wait command does not specify the period of the signal, it just defines the wait time between the next command. It is similar to the wait time in a scheduler. So to have different periods, you have to call it like this:
Do
send frame1
wait 10
send frame2
wait 20
send frame2
wait 20
send frame2
wait 10
send frame1
wait 10
send frame2
wait 20
send frame2
wait 20
send frame2
wait 10
Loop While True
in this case frame1 will be send every 60ms, frame2 will be send every 20ms.
regards
Michael
Re: Setting different periods for Master requests
Thank you! I get that part now.
One more thing. I am trying to publish a frame with data along with the headers but I keep getting errors trying to add the Array portion of .PublishData. I am not sure how to do this. I have looked online for a solution but no luck.
My error is that Array is a class type and can't be used as expression
The frame is 0x00, 0x55, 0x28, 0x00, 0x57. 0x57 is the checksum.
One more thing. I am trying to publish a frame with data along with the headers but I keep getting errors trying to add the Array portion of .PublishData. I am not sure how to do this. I have looked online for a solution but no luck.
My error is that Array is a class type and can't be used as expression
The frame is 0x00, 0x55, 0x28, 0x00, 0x57. 0x57 is the checksum.
Code: Select all
Dim obj
obj = CreateObject("Peak.Lin.ViewPro.COM.Interfaces.Application")
If Not obj Is Nothing Then
'WScript.Sleep(1000)
obj.OpenProject("C:\LIN\LIN_ECM_Headers.linproj", True)
If obj.ConnectTo(1, 1, plinHardwareModeMaster, 10458) Then
Do
obj.SubscribeData(&H2A, 5, plinChecksumTypeEnhanced)
obj.Wait(25)
obj.SubscribeData(&H2B, 4, plinChecksumTypeEnhanced)
obj.Wait(25)
obj.SubscribeData(&H2B, 4, plinChecksumTypeEnhanced)
obj.Wait(25)
obj.PublishData(&H28, 2, plinChecksumTypeEnhanced, Array(&H0))
obj.Wait(1)
obj.SubscribeData(&H2B, 4, plinChecksumTypeEnhanced)
obj.Wait(25)
obj.SubscribeData(&H2B, 4, plinChecksumTypeEnhanced)
obj.Wait(25)
Loop While True
End If 'End ConnectTo
' Finally you can call obj.Close
'obj.Close True
End If
End Sub
End Module
Re: Setting different periods for Master requests
Hi,
your length code for your publisher frame is set to 2, but your array only contents one byte. Please add another byte to your array, or reduce the length code to 1.
Also your wait time of 1ms is far to low for a LIN bus system with 10458bits/s. With that speed and 2 bytes publisher you should keep a wait time of at least 10ms. Check your ldf file for more details about scheduler timings.
regards
Michael
your length code for your publisher frame is set to 2, but your array only contents one byte. Please add another byte to your array, or reduce the length code to 1.
Also your wait time of 1ms is far to low for a LIN bus system with 10458bits/s. With that speed and 2 bytes publisher you should keep a wait time of at least 10ms. Check your ldf file for more details about scheduler timings.
regards
Michael