From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Automotive and Embedded Networks

cancel
Showing results for 
Search instead for 
Did you mean: 

Can I automate a VI to test hardware through CAN with some sort of script?

I am trying to automate some hardware testing over the CAN bus.   I have started a basic VI that I can manually run these tests, but there are testing scripts available to me and I was wondering if there is a way to import some sort of scripts (or similar) into LABView to automatically run my VI to perform the test.  I've done some searches, but looking for scripting only comes up with MathScript that MATLAB related information.

 

Thanks for the help.

0 Kudos
Message 1 of 13
(6,991 Views)

@stupidlogic wrote:

I am trying to automate some hardware testing over the CAN bus.   I have started a basic VI that I can manually run these tests, but there are testing scripts available to me and I was wondering if there is a way to import some sort of scripts (or similar) into LABView to automatically run my VI to perform the test.  I've done some searches, but looking for scripting only comes up with MathScript that MATLAB related information.

 

Thanks for the help.



You need to specify what kind of scripts are available for you to play with. If the scripts are in any other programming method(Python,dspace),then you

might have to re-engineer those scripts into LabVIEW readable format(excel, word) or you can call them in your as a DLL. If the scripts are in LabVIEW itself, you can directly call them as subvi

and run the execution after replacing redundant port access and file operations. Probably you can attach a sample script here so that others can view it

and provide  you suggestions.





0 Kudos
Message 2 of 13
(6,989 Views)

They are in excel and written for dspace machines.  What would be the easiest way to integrate those into my VI?

0 Kudos
Message 3 of 13
(6,981 Views)

If I am correct, the format of the excel sheet would be like:

  1. Write RAM of hardware
  2. Send Periodic CAN Messages
  3. Activate I\O Lines(Analog,Digital,Counter)
  4. Send Periodic Diagnostic Protocol
  5. Read Peridic CAN Message and Verify tghe Value
  6. Read I\O Lines(Analog,Digital,Counter) and Verify the values
  7. Read Periodic Diagnostic Protocol and verify the values
  8. Report the results.

The typicl script would be of something similar to above shown format. Can you confirm that ? If thats the case, I have some good suggestions for you as I have done it before.





0 Kudos
Message 4 of 13
(6,975 Views)

I don't have one in front of me at the moment, but I recall it being pretty darn close to your example.  I'd really appreciate your suggestions.  Thank you.

0 Kudos
Message 5 of 13
(6,967 Views)

@stupidlogic wrote:

I don't have one in front of me at the moment, but I recall it being pretty darn close to your example.  I'd really appreciate your suggestions.  Thank you.


I had a an excel sheet based automation system for one of the CAN based hardware.In that one, each row was my test step. The colomns of the excel based script was subdivided into input conditions and output conditions(from hardware point of view). The input conditions were again sub divided into Input Lines - CAN,Analog In,Digital In - which will be simulated by NI hardware. Similarly output lines will be read by NI hardware in Output colomn subdivision.

All the periodic signals will be kept with default values for each row (test step). Your LabVIEW automation program should read this excel script and process accordingly.

 

My automation script had almost 6000 rows and 150 colomns and later it became very difficullt to analyze the result. I would suggest you to explore the possibility of TestStand if your scripts require significant complexity. After learning teststand,I came to know that I could save lot of my sleepless nights. 😉





0 Kudos
Message 6 of 13
(6,964 Views)

Thank you very much for the help.  To be honest, I'm new to LabVIEW development and so I don't have any experience in importing scripts whatsoever.  Assuming I have the script written in the suggested format...

 

Do I keep it saved as a .xls?

What subVI block do I import it into LabVIEW with?

 

Also, I haven't looked at every script I'll be dealing with (only a couple) and therefore, I don't know how complex it may get.  Do you know where I can access some resources on learning to use TestStand?  I've never used it before.  Even just answering the basic, what does it do/how does it work would be helpful.

 

Once again, I appreciate all the assistance.

0 Kudos
Message 7 of 13
(6,957 Views)

@stupidlogic wrote:

Thank you very much for the help.  To be honest, I'm new to LabVIEW development and so I don't have any experience in importing scripts whatsoever.  Assuming I have the script written in the suggested format...

 

Do I keep it saved as a .xls?

What subVI block do I import it into LabVIEW with?

 

Also, I haven't looked at every script I'll be dealing with (only a couple) and therefore, I don't know how complex it may get.  Do you know where I can access some resources on learning to use TestStand?  I've never used it before.  Even just answering the basic, what does it do/how does it work would be helpful.

 

Once again, I appreciate all the assistance.


We may be calling it as script,but to the core,you are developing an appication to read excel sheet,your logic should segragate each steps action and you should have LabVIEW code wherever an action is required. If you are planning to do this task in LabVIEW, you need following steps to finish.

  1. VI to read your excel sheet and format it to a 2-Dimensional array(Format the array to remove unnecesary characters).
  2. A state machine(code architecture) which will be guided as per the states in your excel sheet.
  3. A hardware handling loop to generate and acquire data for your main code(state machine).
  4. Use CAN Channel API in case you have a defined CAN dbc file.
  5. If no dbc file, go for frame API.

In case you are using TestStand, you need go for an architecture where your CAN periodic data transmission is taken care using LabVIEW.

 

Honestly it's not the task of a novice LabVIEW\TestStand programmer if you have less time ro learn. If you provide your e-mail address, I can send you a scaled down code after removing proprietary stuff. 

 

Following link is an introductuction to Teststand:

http://zone.ni.com/devzone/cda/tut/p/id/6073

Regarding availability of resources to learn LabVIEW and TestStand,Can any one who is following this thread can suggest any materials ?





0 Kudos
Message 8 of 13
(6,934 Views)

I sent you a a PM with my email.

 

I'll also try to do some searches for some more information about TestStand when I get a chance.  Once again, I appreciate the assistance.

0 Kudos
Message 9 of 13
(6,928 Views)

After working through some things last week, I found that TestStand (although powerful) wouldn't be the ideal way to go for me.  So I'm at the point where my excel scripts are imported and after a few array operations, formatted so that each instruction is in a row in an array in LabVIEW.  Now I need to build the state machine.  At first glace, I've been unable to find an easy way to create one from my list of instructions. 

 

My first thought was to use a case statement with an enum and populate the enum with all of my instructions.  The thing is, is the only way I know how to populate an enum is by manually entering in each state.  This obviously would defeat the purpose of importing the excel script.  Since you've done this before, how did you get create the state machine from your instruction list?


Once again, thanks for the help!

0 Kudos
Message 10 of 13
(6,906 Views)