Just place a VISA Resource Name control on the front panel.
What type of USB resource are you talking about?
I want to get resource name by program, don't ask user to select, I think it is better for user.
I can init device during program is starting.
Can it be implemented by program?
For usb, it is another device, digital oscilloscope.
If you know that the VISA Resource will stay the same (i.e. Com1), then you can just use a block diagram constant. Otherwise, you would need to use the VISA Find Resource function. This will return an array of available resources. Pass the array to a for loop and for each resource, do a write and read of some known query. When you get an expected response, you have found the resource for that particular instrument.
If the scope is USBTMC and you have the appropriate driver installed for it, the device will appear in MAX whenever it is plugged in and you will have it as a VISA resource.
Tha's very good answer. I will try it.
thank your very much.
MY USB visa rource name is :USB0::0x1AB1::0x0588::DS1K00005888::INSTR.
What is the meaning of USBTMC?
As for adding serial support to the driver, you could take a look at the existing DC Power IVI drivers which already implement the code and try to reuse that code in Chroma driver. An example could be Agilent E364XA IVI driver:
Here is the code related to serial support found in the IviInit function:
/* Configure VISA Serial I/O */
viCheckErr( viGetAttribute (io, VI_ATTR_INTF_TYPE, &interface_type));
if (interface_type == VI_INTF_ASRL)
viCheckErr( viSetAttribute (io, VI_ATTR_TERMCHAR, '\n'));
viCheckErr( viSetAttribute (io, VI_ATTR_TERMCHAR_EN, VI_TRUE));
viCheckErr( viSetAttribute (io, VI_ATTR_ASRL_END_IN, VI_ASRL_END_TERMCHAR));
viCheckErr( viSetAttribute (io, VI_ATTR_ASRL_END_OUT, VI_ASRL_END_TERMCHAR));
Once you update the .c file, you need to rebuild the DLL. Also, your serial settings on the instrument, in MAX, and in the driver have to fully match.
If i want to create a driver by myself, Should i use VISA interface to implement it?
Sending command and waiting for resposne, just like that right?
In general, how long should i wait for response and how long interval should be set
between command? Can you give me a basical instruction?
Happy new year!
Yes, VISA is the recomended API. In fact, that is your only option if you use LabVIEW for serial.
You may not need any delays at all. Probably the reason that the IVI driver fails is that it does not send a termination character and my guess is that instrument sends a termination character with it's response. If so, you just have to enable termination character in the VISA Configure Serial Port and set some large number of bytes to read with the VISA Read. The VISA Read will automatically terminate when it detects the termination character. What that means is that you can often follow the VISA Write with a VISA Read. Any necessary delay will be handled by the VISA Read function waiting for the termination character.
Even if you need a delay somewhere, a more sophisticated approach would be use a while loop with the VISA Bytes at Serial Port in it. The loop would be exited when the number of bytes is greater than 0. This would then pass to another loop with a VISA Bytes at Serial Port and a VISA Read. This loop would exit when the number of bytes is 0. You would also need a timeout function in at least the first loop. Fixed delays have a habit of coming back to haunt you. Made to long, they just waste time. On the other hand, you can easily set a delay tha might work fine on one pc or one instrument and require a longer delay on a different pc/instrument.
looking for Help
I have programmable power supply Chroma Model 62012P-40-120. I write RS232 communication based on the protocol from the manufacturer to set volatge ,current to the supply and measure the volatge and current output from the power supply. I have no problem with the communication . i can set the volatge and the current to the power supply and i can remotelly control (ON/OFF) the DC ouput of the supply. But when i try request volatge and current output of the power supply and connect them in series i can read the measure output either the volatge or the current but not both.
if the measure volatge request is 1st i can read it but no the current request and vise versa. But i can see the volatge and current ouput in the screen of the Power supply. Here i have attached the screent shoots of my labview programs. The status message is OK in both cases.
Thank u inadvance