Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

python and activeX

Solved!
Go to solution
We want to do some test automation, using Python and LabVIEW.
For example, we want to set rig speed to be 1000 rpm. first, we set speed request in Python to be 1000, then pass this to LabVIEW, then LabVIEW send out speed request to the rig, via analog output(NI9264).
 
I made a script like this but there is an error, as shown below.
 
import win32com.client
Input = 1000
LabVIEW = win32com.client.dispatch('Labview.Application')
  
this error comes up:
 
Traceback (most recent call last):
  File "D:\Synchro_test\test.py", line 3, in <module>
    LabVIEW = win32com.client.dispatch("Labview.Application")
AttributeError: 'module' object has no attribute 'dispatch'
0 Kudos
Message 1 of 9
(11,689 Views)

You've posted this question on the Real-Time forum, which would mean you're using a non-Windows OS, but your question includes code that looks Windows-specific. Can you clarify the environment you're working in?

0 Kudos
Message 2 of 9
(11,637 Views)

I also use python and a cRIO.

 

I however just use UDP, and do not involve LV on Windows side.

 

Have a generic UDP IF on cRIO and just pass registre values over UDP to cRIO using python.

Wireshark is then easy to use as dbg on UDP parcels.

 

Just some input, depending an what you want to do with your system.

0 Kudos
Message 3 of 9
(11,607 Views)

@ScotSalmon wrote:

You've posted this question on the Real-Time forum, which would mean you're using a non-Windows OS, but your question includes code that looks Windows-specific. Can you clarify the environment you're working in?


Real time OS. The code above was for testing on windows which I have now found out works, but now looking to move to real time.

 


@Mauritius wrote:

I also use python and a cRIO.

 

I however just use UDP, and do not involve LV on Windows side.

 

Have a generic UDP IF on cRIO and just pass registre values over UDP to cRIO using python.

Wireshark is then easy to use as dbg on UDP parcels.

 

Just some input, depending an what you want to do with your system.


 Thanks for the informaion can I see an example of this if you don't mind.

0 Kudos
Message 4 of 9
(11,535 Views)

Python UDP or cRIO code?

0 Kudos
Message 5 of 9
(11,531 Views)

@Mauritius wrote:

Python UDP or cRIO code?


Is it possible to see both?

 

Thanks.

0 Kudos
Message 6 of 9
(11,508 Views)

Ok so I've set up a tcp server that works, I'm trying to send data from python to a numeric control which will control the speed of the rig. The problem I'm having now is sequencing. For example I write a script to send the string value 1 and convert it to a double which is then sent to a numeric control which is fine but on the second iteration of the loop 0 is sent to the numeric control which obviously kills the rig, how can I get it to hold the value I send as well as creating a sequence e.g. send 1 then after a defined time send 2 and so so on.

 

Thanks.

 

 

0 Kudos
Message 7 of 9
(11,437 Views)
Solution
Accepted by Maggie_ren

Sorry for the delay, had to do a small project to show how i use cRIO with python.

 

 

The idea is to have a generic registre on a cRIO (As many DBL elements as one whould need) and a generic way to write to those values over UDP. Either one by one or mutible at a time.

 

Have tried to make a simple version to show it.

Can be run on PC but also on a cRIO with small modifications.

 

Have made a small client to show how to use the interface.

 

It can transmit a array of U64, where elements are:

 

0 - Counter

1 - Interface mode.

 

and rest is data and parsed based on Interface mode - dive onto the code to see more.

 

I my real setup i have more interface modes than just "write" which is used here.

I also have some code that load values from a text file to the registre when cRIO is booting, so it works without transmitting all values to it.

 

 Any program can use the UDP interface.

 

 

 

 

 

 

 

 

 

Message 8 of 9
(11,415 Views)

                

0 Kudos
Message 9 of 9
(11,388 Views)