How does one send the variables within a multiplexer?
-
- Posts: 2
- Joined: Mon 11. Nov 2024, 14:07
How does one send the variables within a multiplexer?
Greetings,
I have been using the standard macros within PCAN Explorer 6 to run J1939 CAN testing for the last few years, and I decided I wanted to step up to VBS Macros. I am not a programmer by nature but I have been able to figure out some of the basics of using VBS to send symbols and variables using the help contents. I have figured out how to send multiplexed messages as well, but I am at a loss how to send specific variables within the multiplexers. I was unable to find any examples of this in the help documents or within the forum. I was hoping someone could help with guiding in bein able to send specific variables within the multiplexer. I have attached a basic symbols file with the multiplexer I have been practicing with as well as a screen shot of the transmit list entry created. Any help or simple examples to follow along with are greatly appreciated as I am new to this aspect of PCAN Explorer.
This is the script I have so far for sending the multiplexer:
Sub TireProperties()
Dim sym
set TIRE = SymbolsManager(J1939_allsignals).Item("TIRE")
TIRE.Multiplexers(TireLocation_01).Send 1, peSendPeriodic, 10000
End Sub
I have been using the standard macros within PCAN Explorer 6 to run J1939 CAN testing for the last few years, and I decided I wanted to step up to VBS Macros. I am not a programmer by nature but I have been able to figure out some of the basics of using VBS to send symbols and variables using the help contents. I have figured out how to send multiplexed messages as well, but I am at a loss how to send specific variables within the multiplexers. I was unable to find any examples of this in the help documents or within the forum. I was hoping someone could help with guiding in bein able to send specific variables within the multiplexer. I have attached a basic symbols file with the multiplexer I have been practicing with as well as a screen shot of the transmit list entry created. Any help or simple examples to follow along with are greatly appreciated as I am new to this aspect of PCAN Explorer.
This is the script I have so far for sending the multiplexer:
Sub TireProperties()
Dim sym
set TIRE = SymbolsManager(J1939_allsignals).Item("TIRE")
TIRE.Multiplexers(TireLocation_01).Send 1, peSendPeriodic, 10000
End Sub
- Attachments
-
- PCAN Explorer 6 Transmit list entry
- J1939 TIRE Multiplexer entry.png (65.19 KiB) Viewed 1935 times
-
- TIRE Multiplexer.sym
- Contains Multiplexer imported from J1939 DBC
- (15.93 KiB) Downloaded 42 times
-
- Sales & Support
- Posts: 1060
- Joined: Fri 20. Sep 2019, 13:31
Re: How does one send the variables within a multiplexer?
Hello,
I admit, it can take a bit until you find this in the docs of PE6, but let me give you some options:
1) Please note that any Multiplexer-Signal will also be part of the Signals Collection, so if you just wanna access the Signal, you can use the collection, change the value and this change will automatically trigger a transmission:
To access a specific signal you assign it to a dim:
If you need explicit access from within the multiplexer itself, you can do the following:
To change the value of this signal do:
You can also send this multiplexer with current values:
Bear in mind that these are examples, you can name the dims however you prefer...
Please use the PCAN-Explorer 6 Help, under "Automating tasks with PCAN-Explorer" you will find "reference" -> "objects"
It is a description of every object in PCAN-Explorer 6 and how to use, i myself use it extensively when creating examples, it's a good reference if you wanna get certain things done.
BR
Marvin
I admit, it can take a bit until you find this in the docs of PE6, but let me give you some options:
1) Please note that any Multiplexer-Signal will also be part of the Signals Collection, so if you just wanna access the Signal, you can use the collection, change the value and this change will automatically trigger a transmission:
Code: Select all
Sub SignalsExample()
Dim objSignal
For Each objSignal In Signals
' Access objSignal here.
' For example:
PrintToOutputWindow objSignal.Name
Next
End Sub
Code: Select all
dim TimeStampSignal
Set TimeStampSignal = Signals("TimeStampSignal")
If you need explicit access from within the multiplexer itself, you can do the following:
Code: Select all
dim Symbol, Message, Signal
Set Symbol = SymbolsManager("YourSymbolFileName").Item("MySymbol")
Set Message = Symbol.Multiplexers("MyMultiplexer").Send(1, peSendWait)
Set Signal = Message.Variables("MySignal")
Code: Select all
Signal.Value = 123
Code: Select all
Message.Send 1, peSendPeriodic, 100
Please use the PCAN-Explorer 6 Help, under "Automating tasks with PCAN-Explorer" you will find "reference" -> "objects"
It is a description of every object in PCAN-Explorer 6 and how to use, i myself use it extensively when creating examples, it's a good reference if you wanna get certain things done.
BR
Marvin
---
Marvin Heidemann
PEAK-Support Team
Marvin Heidemann
PEAK-Support Team
-
- Posts: 2
- Joined: Mon 11. Nov 2024, 14:07
Re: How does one send the variables within a multiplexer?
Marvin,
Apologies for the delay in my response. Thank you for the examples you provided, they were most helpful. I took some time to try the different methods you provided and this method that you suggested seems to best accomplish what I do for the testing purposes when sending specific variables within multiplexers:
Sub TireProperties_TL0()
Dim Symbol, Message, Variable
set TIRE = SymbolsManager(J1939_allsignals).Item("TIRE")
set Message = TIRE.Multiplexers("TireLocation_0").Send (1, peSendWait)
set Variable = TIRE.Multiplexers("TireLocation_0").Variables("TirePress_00")
Variable.Value = 80
Message.Write 0
End Sub
However, what I am running into is that this creates two transmit list entries for every message that I send in this manner.
I am also struggling with how to create these automated tasks in a way that doesn't clutter up the Macro drop down list PCAN Explorer. I would like to be able to have sub routines for each test step in the test plan but be able to select one "Parent" Macro, and have it run all the subroutines for a test section without having to select the individual subroutines for each test step. My inexperience with coding and Visual Basic is lending itself to my difficulty in making it work how I would like it to. Do I need to create a VBS Macro for each test step and then create one Overall Macro that calls the other VBS Macro files or can they all be contained within one macro file?
I attached copies of the VBS Macro I have with a few subroutines in it as well as a screen shot of the Macro drop down list, and transmit list for reference.
Thanks,
apprentice
Apologies for the delay in my response. Thank you for the examples you provided, they were most helpful. I took some time to try the different methods you provided and this method that you suggested seems to best accomplish what I do for the testing purposes when sending specific variables within multiplexers:
Sub TireProperties_TL0()
Dim Symbol, Message, Variable
set TIRE = SymbolsManager(J1939_allsignals).Item("TIRE")
set Message = TIRE.Multiplexers("TireLocation_0").Send (1, peSendWait)
set Variable = TIRE.Multiplexers("TireLocation_0").Variables("TirePress_00")
Variable.Value = 80
Message.Write 0
End Sub
However, what I am running into is that this creates two transmit list entries for every message that I send in this manner.
I am also struggling with how to create these automated tasks in a way that doesn't clutter up the Macro drop down list PCAN Explorer. I would like to be able to have sub routines for each test step in the test plan but be able to select one "Parent" Macro, and have it run all the subroutines for a test section without having to select the individual subroutines for each test step. My inexperience with coding and Visual Basic is lending itself to my difficulty in making it work how I would like it to. Do I need to create a VBS Macro for each test step and then create one Overall Macro that calls the other VBS Macro files or can they all be contained within one macro file?
I attached copies of the VBS Macro I have with a few subroutines in it as well as a screen shot of the Macro drop down list, and transmit list for reference.
Thanks,
apprentice
- Attachments
-
- Macro Drop Down List.png (301.06 KiB) Viewed 1860 times
-
- Duplicated Trasnmit List Entries.png (76.47 KiB) Viewed 1860 times
-
- Send Multiplexer.pem
- (1.19 KiB) Downloaded 36 times
-
- Sales & Support
- Posts: 1060
- Joined: Fri 20. Sep 2019, 13:31
Re: How does one send the variables within a multiplexer?
Hello,
That's because the message itself is send and another send is triggered by the value change of the signal, you can however prohibit that, just add:
variable.AutoTransmit = False
One Macro file can contain as many Functions, Subs , etc as you like so you can
use the Main-routine approach.i'd advise you to have a look at functions in VBS too, as they are alot more flexible and can be really useful.
BR
Marvin
Code: Select all
Sub TireProperties_TL0()
Dim Symbol, Message, Variable
set TIRE = SymbolsManager(J1939_allsignals).Item("TIRE")
set Message = TIRE.Multiplexers("TireLocation_0").Send (1, peSendWait)
set Variable = TIRE.Multiplexers("TireLocation_0").Variables("TirePress_00")
Variable.Value = 80
Message.Write 0
End Sub
variable.AutoTransmit = False
Code: Select all
Sub TireProperties_TL0()
Dim Symbol, Message, Variable
set TIRE = SymbolsManager(J1939_allsignals).Item("TIRE")
set Message = TIRE.Multiplexers("TireLocation_0").Send (1, peSendWait)
set Variable = TIRE.Multiplexers("TireLocation_0").Variables("TirePress_00")
Variable.AutoTransmit = False
Variable.Value = 80
Message.Write 0
End Sub
One Macro file can contain as many Functions, Subs , etc as you like so you can
use the Main-routine approach.i'd advise you to have a look at functions in VBS too, as they are alot more flexible and can be really useful.
BR
Marvin
---
Marvin Heidemann
PEAK-Support Team
Marvin Heidemann
PEAK-Support Team
Re: How does one send the variables within a multiplexer?
Could you elaborate further on this?M.Heidemann wrote: ↑Wed 13. Nov 2024, 15:36[...]
Please note that any Multiplexer-Signal will also be part of the Signals Collection, so if you just wanna access the Signal, you can use the collection, change the value and this change will automatically trigger a transmission
[...]
I'm currently looking on sending a Multiplexer signal via a button, but I cannot find said signal in the Signals list (at least in the Project Items list).
I'm looking on sending the multiplexer signal itself, not any of the multiplexed ones.
Reason for this is that at some multiplexer values, the message doesn't have any other signals to work with.
Re: How does one send the variables within a multiplexer?
Hello
They are part of the Multiplexers Collection and are displayed under ActiveSymbols in the Project Items:
To send a multiplexer itself with or without signals, you can proceed as follows:
Regards
M.Riedl
That means that all Signals/Variables in all Symbols and Multiplexers are part of the Signals Collection and can be accessed from there. The multiplexers themselves aren't included.M.Heidemann wrote: ↑Wed 13. Nov 2024, 15:36
1) Please note that any Multiplexer-Signal will also be part of the Signals Collection, so if you just wanna access the Signal, you can use the collection, change the value and this change will automatically trigger a transmission:
They are part of the Multiplexers Collection and are displayed under ActiveSymbols in the Project Items:
To send a multiplexer itself with or without signals, you can proceed as follows:
Code: Select all
Sub SendMuxWithAButton
Dim YourSymbolsFile, YourSymbol, YourMuxWithoutSignals, YourMessage
Set YourSymbolsFile = SymbolsManager("YourSymbolsFile")
Set YourSymbol = YourSymbolsFile.Item("YourSymbol")
Set YourMuxWithoutSignals = YourSymbol.Multiplexers("YourMultiplexerWithoutSignals")
Set YourMessage = YourMuxWithoutSignals.Send(1, peSendWait)
YourMessage.Write 0
End Sub
M.Riedl
Re: How does one send the variables within a multiplexer?
Thank you, this works as intended.