Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Control Consort EV232 power supply via RS-232

Solved!
Go to solution

Hello there,

 

I'm completely new to the world of Labview. I've started an internship yesterday in a protein engineering lab and my first duty is to create a Labview interface that enables us to control a power supply (namely Consort EV232) for an electrophoresis application. The power supply is connected to a MOXA multiport serial board via RS-232, which is in turn connected to the PC.

 

Like I said, I'm completely new to Labview, having only done some really basic programming in class. I've never had the occasion to touch any hardware and am completely at a loss at how to tell the PC or Labview to connect to the power supply and I haven't found any driver that fits the power supply. I'm aware that this is a really basic question, please bear in mind that I really don't know where to start.

 

Have a nice day.

0 Kudos
Message 1 of 28
(6,028 Views)
I would suggest that you first use a program such as hyperterminal, putty, or the test panel in MAX. This will allow you to verify the port settings and the cable you are using. Use the commands in the programming manual with the correct termination character. There are some serial examples that come with LabVIIEW that you can then use as a base for writing your own code. If you get stuck, attach the programming manual along with your code.
Message 2 of 28
(5,996 Views)

Thank you very much for your help. The connection seems to be working fine, since I can communicate with the power supply using the program I've downloaded from the manufacturer's website. The trouble now is sending the right commands. I've downloaded the communication manual, but I don't know how to enter these codes. I've created a simple VI using VISA functions to return the model name (as is often used in VISA tutorials), but I'm at a loss at how to enter the right command. The manual tells me:

 

Send the characters:
'V' + asc(2) + asc(100) + asc(188) + asc(13) + asc(10)

 

where 2 are the number of bytes to follow (excluding carriage return 13 and linefeed 10), 100 is the command for the model request and 188 the low byte checksum. But how do I enter this into the VISA write function? As a string, containing asc() or not? As a numeric command? Or is there a special function for this kind of code? I'm not even sure that using VISA is the correct way to do this.

Download All
0 Kudos
Message 3 of 28
(5,962 Views)
You've got a couple of options. First, get an ASCII table and use that to get the decimal and hex values. You can right click on a string control/constant and select hex display. You can directly enter the hex values. You can also make use of the Byte Array to String function. Create a U8 array and either select decimal or hex display. For example, a string constant of V could be concatenated with the result of the Byte Array to String where the array has elements equal to 2, 100, 188, 13, 10. You do not use the asc() function as it is not recognized in LabVIEW. When you do a read, the String to Byte Array will do the opposite and the index array will be used to get specific bytes that you will need to decode. At some point, you'll need to be able to create the checksum yourself. Numerous examples on how this can be done can be found by doing a search.
Message 4 of 28
(5,945 Views)

Two things which should help you get started:

 

1. Change the Display Style on the control to the VISA Write to '\' Codes Display. You do this from the menu which pops up when you right-click on the control.

 

When a string control is in the '\' Codes Display mode, you can enter non-printing codes by preceeding the numerical value (in hexadecimal) with a backslash. For the command you posted you would type: "V\02\64\BC\0D\10" without the quotation marks.  Note that asc(100) = \64 = "d" and that there are special \ codes for carriage return \r and line feed \n, so you could also type "V\02d\BC\r\n".

 

Also note that you will need to compute a different checksum for other commands.

 

2. Get rid of Bytes at Port. This should never be used when a termination character is enabled. Wire a constant to the VISA Read byte count input. Make the value larger than the number of characters in the longest message you expect to receive, perhaps 50 or 100.

 

Lynn

Message 5 of 28
(5,940 Views)

Again, thanks a lot! Using a string of "\ codes" in hexadecimal, as both of you suggested, I was able to send the commands to the power supply. Now, converting the codes into hexadecimal isn't hard, but very time-consuming. So I wanted to look into the "Byte Array to String" function, but I can't seem to find it on the Labview version used in this lab. Is it available somewhere else?

 

@johnsold: If I get rid of Bytes at Port as you said, the Visa Read experiences a timeout for some commands.

0 Kudos
Message 6 of 28
(5,907 Views)

@Leukocyte wrote:

So I wanted to look into the "Byte Array to String" function, but I can't seem to find it on the Labview version used in this lab. Is it available somewhere else?


That function is in two places: 1) Numeric->Conversion and 2) String->Path/Array/String Conversion palettes.  They have been there for every version of LabVIEW I have ever used.

 

And if you can't find it in the palettes, there is always Quick Drop (Ctrl+Space, type in the name of the function you want, click where you want it).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 7 of 28
(5,903 Views)

Oh well, the perks of being german speaking, being used to a Labview interface in english and then working in a lab where everything is in french. Thanks a lot!

0 Kudos
Message 8 of 28
(5,888 Views)

Are you sure you are sending a valid command? I noticed that the string I suggested does not have the correct termination character.  I posted "V\02\64\BC\0D\10" but it should be "V\02\64\BC\0D\0A". If the last character was not a line feed the power supply might not send a response.

 

Also, you should close the VISA session. 

 

You probably want a loop surrounding the Write and Read so that you do not continually configure and close the VISA session. Doing so repeatedly can lead to a very confused serial port and errors that mihgt be hard to explain.

 

Lynn

Message 9 of 28
(5,886 Views)

@johnsold: To be perfectly honest, I've experienced this problem using a pump that I was practising on while trying to get my head around how to implement the codes of the power supply. The problem hasn't occured using the power supply, so your method works just fine for the moment. Thanks a lot!

 

Also, thanks to all of you guys, I've been able to communicate with the power supply using the controls. I've come to a more Labview-specific problem: using the Event Structure, I've been trying to send the parameters to the power supply during the run. The idea is to be able to change a parameter during the run, simply by entering a new value and hitting enter. Since there's only a control for changing all the parameters at once and not just one at a time, I was trying to find a way to implement all the changes into one code for the control and this is what I came up with. The trouble with this is: when I hit run, nothing changes. When I change the value of a parameter, the value sent to the power supply is the one that was entered before entering the new value. As you can see in the screenshot, when I change the voltage value from 200 to 250, the value sent to the power supply is 200 (4th element in the array). If I was to enter for exemple 300, it would send 250.

The Power-, Current- and Voltage-SubVis are just simple VIs transforming the entered value into arrays that are concatenated and transformed into a code with checksum, etc. with the Code-SubVI. All these I've tested and I'm pretty sure the problem isn't there.

0 Kudos
Message 10 of 28
(5,864 Views)