LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Set values for the Lock-In Amplifier's Digital Analog Converter Channel?

If I let my user have the freedom to select whatever values they want to select in order for it to show up as the output value for the Digital Analog Channel then I cannot understand why use ibwrt(...) and ibrd(...). Because ibwrt is going to write a specific voltage at the specified channel since the manual for the Amplifier states you must input the string for writing output voltage as DAC2 3000 (the 2 signifying the channel and 3000 - the millivolts). If this hard coding occurs by using ibwrt then how can I write my code so that the user has the capability to change the voltage value and the channel to the one they want? Thanks in advance.

0 Kudos
Message 1 of 7
(3,666 Views)

Hi,

 

you can use the command in the form ibwrt(ud, data, num_bytes) and use a formatting function to modify the value of 'data' according to user input. You can find these formatting functions at Library / Formatting and I/O. For example, Fmt ( data, "%d", voltage ); You could also use the ANSI C formatting functions.

0 Kudos
Message 2 of 7
(3,658 Views)

I have followed your advice and made some changes to my code. But now I am getting numerous Run-Time error which are non-fatal and still the uir is still not communicating to my insrtrument. Can you tell me where I am going wrong this time? I have attached the code. Thank You.

Download All
0 Kudos
Message 3 of 7
(3,629 Views)

Also do I need a ibrd  in this case since that only reads the value from the instrument to my computer? Thanks again.

0 Kudos
Message 4 of 7
(3,628 Views)

Hi,

 

1) I realized that your command sequence is odd: first you need to fill the write buffer using Fmt, and only then send the command:

 

GetCtrlVal (panel, PANEL_VDAC, &VOutput);
Fmt(writeBuffer, "%d", VOutput);
ibwrt(gpibdevice, writeBuffer, 8);

 

2) You are not using the value of DOutput;

 

3) You define writeBuffer[7]; but then you are sending 8 bytes...

 

Wolfgang

0 Kudos
Message 5 of 7
(3,610 Views)

Do I need a Fmt and ibwrt for both DOutput and VOutput? Because DOutput is indicative of the channels 1, 2, 3, 4 in the Lock in Amplifier and the VOutput is for the amount of volts the user can set (i.e. write to the instrument). Also I found this on the following NI website regarding filling in the value of the write buffer: Write Buffer Value. This website signifies that one must use \002 and end with 003\ which I am not sure I even need for this instance of initializing the writeBuffer[8]. Also I used [7] for the writeBuffer because I thought arrays went 0, 1, 2, 3...so on therefore writeBuffer[7] will give me space for 8 bytes? Is that an incorrect assumption? Lastly, here is my modified code according to the changes you mentioned and it still is giving me Non-Fatal Run Time Errors and not communicating. Is there anything else I am missing out on which I can't find. Seemed like I may be making this code much harder than it needs to be. Thank you for your time.

 

Sincerly,

 

Download All
0 Kudos
Message 6 of 7
(3,604 Views)

declaring an array y[50] means that you have an array with 50 elements, that are addressed as y[0] ... y[49].

 

0 Kudos
Message 7 of 7
(3,589 Views)