How does one send the variables within a multiplexer?

Professional Windows® software to communicate with CAN and CAN FD busses and its add-ins: Plotter, CANdb Import, Instruments Panel, and J1939
Locked
apprentice
Posts: 2
Joined: Mon 11. Nov 2024, 14:07

How does one send the variables within a multiplexer?

Post by apprentice » Wed 13. Nov 2024, 14:47

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
Attachments
PCAN Explorer 6 Transmit list entry
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

M.Heidemann
Sales & Support
Sales & Support
Posts: 1060
Joined: Fri 20. Sep 2019, 13:31

Re: How does one send the variables within a multiplexer?

Post by M.Heidemann » Wed 13. Nov 2024, 15:36

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:

Code: Select all

Sub SignalsExample()

   Dim objSignal

   For Each objSignal In Signals

      ' Access objSignal here.

      ' For example:

      PrintToOutputWindow objSignal.Name

   Next

End Sub

To access a specific signal you assign it to a dim:

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")

To change the value of this signal do:

Code: Select all


Signal.Value = 123

You can also send this multiplexer with current values:

Code: Select all

Message.Send 1, peSendPeriodic, 100
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
---
Marvin Heidemann
PEAK-Support Team

apprentice
Posts: 2
Joined: Mon 11. Nov 2024, 14:07

Re: How does one send the variables within a multiplexer?

Post by apprentice » Mon 18. Nov 2024, 15:14

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
Attachments
Macro Drop Down List.png
Macro Drop Down List.png (301.06 KiB) Viewed 1860 times
Duplicated Trasnmit List Entries.png
Duplicated Trasnmit List Entries.png (76.47 KiB) Viewed 1860 times
Send Multiplexer.pem
(1.19 KiB) Downloaded 36 times

M.Heidemann
Sales & Support
Sales & Support
Posts: 1060
Joined: Fri 20. Sep 2019, 13:31

Re: How does one send the variables within a multiplexer?

Post by M.Heidemann » Mon 18. Nov 2024, 15:23

Hello,

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
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

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

dmeir
Posts: 12
Joined: Thu 29. Aug 2024, 10:58

Re: How does one send the variables within a multiplexer?

Post by dmeir » Thu 16. Jan 2025, 10:45

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
[...]
Could you elaborate further on this?
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.

M.Riedl
Software Development
Software Development
Posts: 33
Joined: Wed 22. Sep 2010, 13:28

Re: How does one send the variables within a multiplexer?

Post by M.Riedl » Fri 17. Jan 2025, 11:28

Hello
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:
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.
They are part of the Multiplexers Collection and are displayed under ActiveSymbols in the Project Items:
PE6-YourProjectWithMultiplexers-2025-01-17.png
PE6-YourProjectWithMultiplexers-2025-01-17.png (20.35 KiB) Viewed 1193 times

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
Regards
M.Riedl

dmeir
Posts: 12
Joined: Thu 29. Aug 2024, 10:58

Re: How does one send the variables within a multiplexer?

Post by dmeir » Fri 24. Jan 2025, 15:33

Thank you, this works as intended.

Locked