Page 1 of 1
VB : Modify variables to transmit
Posted: Tue 19. Jun 2012, 15:47
by Yan
Hello.
My actual PCAN-Explorer configuration is :
- 1 CAN frame is received in the "Receive/Transmit" tab (eg. 0x300). This frame contains a variable called "my_input" (defined in .sym)
- 100 CAN frames are transmited in a TransimtList.xmt tab (eg. 0x400 & followings). Each frame contains a variable called "my_output_x" (defined in .sym)
I need to modify "on the fly" (running frames), in the .xmt, all the values of each "my_output_x" by the dynamic value of "my_input".
I think I already know how to get the value of "my_input" :
my_temp_var=Signals("my_input").Value
But I don't know how to put it in the .xmt transmited frames, and without modify the others variables of the .xmt frames.
Someone could help me please ?
Have a nice day.
Re: VB : Modify variables to transmit
Posted: Thu 21. Jun 2012, 08:44
by K.Wolf
Hello,
if your 100 CAN frames are transmitted periodically, just assign values to the my_output signals. This will put the value into the correct message at the right location without altering the other variables in the messages:
Signals("my_output_x").Value = 123
If you have duplicate variable names in the .sym file, use the fully qualified syntax:
Signals("MySymbol1.my_output_x").Value = 123
Signals("MySymbol2.my_output_x").Value = 345
etc.
When you assign a value to a my_output signal and the corresponding CAN frame is not transmitted periodically, PCAN-Explorer automatically creates a new frame in the transmit list, which has the trigger "Automation". Subsequent signal changes will then always modify this Automation message, but not the frames you already had in your transmit list.
Re: VB : Modify variables to transmit
Posted: Thu 21. Jun 2012, 10:16
by Yan
Hello,
Thank you for your quick answer.
These commands work well and solve my issue.
As .xmt tab is not modified by it, I just import TransmitList in the "Receive/Transmit" tab before to work on it.
But I have a variant of the issue you said at the end of your answer :
K.Wolf wrote:When you assign a value to a my_output signal and the corresponding CAN frame is not transmitted periodically, PCAN-Explorer automatically creates a new frame in the transmit list, which has the trigger "Automation".
I have a second running CAN bus, and new frames are created on it (trigger Automation, sended at the frequency of my VBS loop)
As the frames I want to modify must only be on the first CAN bus, is it possible to don't send it on the second CAN bus ? (maybe by modifying .sym or VBS...)
Thx
Re: VB : Modify variables to transmit
Posted: Fri 22. Jun 2012, 09:56
by K.Wolf
The Automation messages are sent on all buses to which the Symbols file is assigned, which contains the variables you are modifying.
If you want to transmit the messages only on one bus, you could make a duplicate of your Symbols file and assign this new file to the second bus. But then you would have all signals duplicated also. To make sure the correct signals are accessed by the macro you should rename the variables, or at least the symbols, in the duplicated Symbols file.
Re: VB : Modify variables to transmit
Posted: Fri 22. Jun 2012, 10:29
by Yan
Works well !
I had one .sym for both buses. I just create 2 .sym, one for each bus, with only the necessary frames defined on each.
As the signal I use in VBS is not defined on the other bus, the frame is not created on it.
Thank you for your help.
