Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Error with Tcl GPIB commands when passing arguments in a procedure call

If I were to simply make a call to a power supply such as:

 

gpib open -address 5

gpib write -message {VOLT 20}

 

my power supply would set the voltage to 20VDC

However if I were to make a procedure that sets the voltage and pass the voltage value as an argument - then the Agilent instrument gives me an Invalid Character response (code -101).

 

example:
proc SetDCPower {gpibID DCPower} {
 gpib open -address $gpibID
 gpib write -message  {VOLT $DCPower}
 gpib close
}

 

followed by a call to this procedure with the following in the same TCL script

SetDCPower 5 15

 

Other commands such as gpib write -message {POW ON} work fine in a procedure so I know the GPIB address argument works.

I have also output the DCPower argument to the screen and text file - and it looks normal.

Anyone have this issue?

0 Kudos
Message 1 of 8
(4,890 Views)

OK. It looks as though the GPIB command will not accept a variable in place of a number regardless of whether it is an argument from a procedure.

I defined a variable:  set ThisIsATest 15

the made a call with it in the same procedure:  gpib write -message  {VOLT $ThisIsATest} and it still fails.

Thus my question is now - can a TCL GPIB command be given with a variable in the SCPI message

0 Kudos
Message 2 of 8
(4,888 Views)

Krusty,

 

Because youre using a third party language to interface with an Agilent power supply, you may have more luck asking this on the TCL developer's site here:

http://www.tcl.tk/community/

 

Theyre most likely going to have a much more in depth knowledge for how to program and troubleshoot in TCL. 

 

Regards,

 

Kyle Mozdzyn

Applications Engineering

National Instruments

 

 

Regards,

Kyle M.
Applications Engineering
National Instruments
0 Kudos
Message 3 of 8
(4,879 Views)

Yes I agree, and I have actually posted on one of the services from that web page. However, there were some TCL related questions on this discussion board and thought I would see if anyone else had similar experiences. 

0 Kudos
Message 4 of 8
(4,877 Views)

I figured out what the problem was. It had to do with creating a string using the variable prior to sending the command.

0 Kudos
Message 5 of 8
(4,873 Views)

Hi Krusty,

 

I am happy that you were able to figure it out!! Excellent!! Smiley Happy

 

Perry S.

Applications Engineer
National Instruments
0 Kudos
Message 6 of 8
(4,862 Views)

@krusty wrote:

I figured out what the problem was. It had to do with creating a string using the variable prior to sending the command.



I know this is an old post, but I was wondering if you could help me.  I ran into virtually the same problem and its had me stumped. I was wondering if you remember how you fixed this.  If so, could you share the code?

 

Much Appreciation,

CAO

0 Kudos
Message 7 of 8
(4,708 Views)

Have you also posted your questions to the other forum listed for the third party code?

 

As stated above:

 

http://www.tcl.tk/community/

 

Ian M.
National Instruments
0 Kudos
Message 8 of 8
(4,689 Views)