ni.com is currently experiencing unexpected issues.
Some services may be unavailable at this time.
10-27-2015 10:22 AM
I am trying to use an Agilent 6812B AC power source with the ACPWR class IVI driver over RS232. I have everything setup in NI Max but I can't get through the initialization routine. I've tried in both LabView and LabWindows and neither will work.
I decided to monitor the RS232 RX/TX lines and I see it is sending the "*IDN?" command and it times out before receiving a response. Unfortunately, it is not sending the line feed terminating character at the end of the string. I can go through NI MAX and send "*IDN?\n" and it replies back with the ID just fine.
So my question is, could it be possible that the IVI specific driver is just not written properly to send a line feed as a terminating character or do I need to setup the comport to send this character seperately? The IVI driver was downloaded from NI's instrumement driver network and it says it is compatible with the 6812B but has been tested with a 6813B.
Solved! Go to Solution.
10-27-2015 02:09 PM
I looked into the ag6800.c IVI specific driver and it does not show a line feed when it writes "*IDN?"
/***************************************************************************** * Function: ag6800_IviInit * Purpose: This function is called by ag6800_InitWithOptions * or by an IVI class driver. This function initializes the I/O * interface, optionally resets the device, optionally performs an * ID query, and sends a default setup to the instrument. *****************************************************************************/ static ViStatus ag6800_IviInit(ViRsrc resourceName, ViBoolean IDQuery, ViBoolean reset, ViSession vi) { ViStatus error = VI_SUCCESS; ViSession io = VI_NULL; ViInt32 modelNum = AG6800_VAL_MODEL_6834; ViChar modelStr[BUFFER_SIZE] = ""; ViChar* szRepCapIdentifiers = VI_NULL; if (!Ivi_Simulating(vi)) { ViSession rmSession = VI_NULL; /* Open instrument session */ checkErr(Ivi_GetAttributeViSession(vi, VI_NULL, IVI_ATTR_VISA_RM_SESSION, 0, &rmSession)); viCheckErr(viOpen(rmSession, resourceName, VI_NULL, VI_NULL, &io)); /* io session owned by driver now */ checkErr(Ivi_SetAttributeViSession(vi, VI_NULL, IVI_ATTR_IO_SESSION, 0, io)); /* Configure VISA Formatted I/O */ viCheckErr(viSetAttribute(io, VI_ATTR_TMO_VALUE, 5000 )); viCheckErr(viSetBuf(io, VI_READ_BUF | VI_WRITE_BUF, 4000)); viCheckErr(viSetAttribute(io, VI_ATTR_WR_BUF_OPER_MODE, VI_FLUSH_ON_ACCESS)); viCheckErr(viSetAttribute(io, VI_ATTR_RD_BUF_OPER_MODE, VI_FLUSH_ON_ACCESS)); /*- Identification Query ------------------------------------------------*/ if (IDQuery) { ViChar rdBuffer[BUFFER_SIZE]; ViChar *queryResponse6811 = "6811"; ViChar *queryResponse6812 = "6812"; ViChar *queryResponse6813 = "6813"; ViChar *queryResponse6814 = "6814"; ViChar *queryResponse6834 = "6834"; ViChar *queryResponse6843 = "6843"; viCheckErr(viQueryf(io, "*IDN?", "%256[^\n]", rdBuffer)); sscanf(rdBuffer, "%*[^,],%s", rdBuffer); if (strncmp(rdBuffer, queryResponse6811, strlen(queryResponse6811)) == 0) { szRepCapIdentifiers = AG6800_OUTPUT_PHASE_LIST_6811; modelNum = AG6800_VAL_MODEL_6811; } else if (strncmp(rdBuffer, queryResponse6812, strlen(queryResponse6812)) == 0) { szRepCapIdentifiers = AG6800_OUTPUT_PHASE_LIST_6812; modelNum = AG6800_VAL_MODEL_6812; } else if (strncmp(rdBuffer, queryResponse6813, strlen(queryResponse6813)) == 0) { szRepCapIdentifiers = AG6800_OUTPUT_PHASE_LIST_6813; modelNum = AG6800_VAL_MODEL_6813; } else if (strncmp(rdBuffer, queryResponse6814, strlen(queryResponse6814)) == 0) { szRepCapIdentifiers = AG6800_OUTPUT_PHASE_LIST_6814; modelNum = AG6800_VAL_MODEL_6814; } else if (strncmp(rdBuffer, queryResponse6834, strlen(queryResponse6834)) == 0) { szRepCapIdentifiers = AG6800_OUTPUT_PHASE_LIST_6834; modelNum = AG6800_VAL_MODEL_6834; } else if (strncmp(rdBuffer, queryResponse6843, strlen(queryResponse6843)) == 0) { szRepCapIdentifiers = AG6800_OUTPUT_PHASE_LIST_6843; modelNum = AG6800_VAL_MODEL_6843; } else viCheckErr(VI_ERROR_FAIL_ID_QUERY); } } /*-- Simulation mode or IDQuery == VI_FALSE -----------------------------*/ if ((Ivi_Simulating(vi)) ||(!IDQuery)) { checkErr(ag6800_GetDriverSetupOption(vi, "Model", 20, modelStr)); if ((strncmp(modelStr, "6834", strlen("6834")) == 0) ||(modelStr[0] == 0)) { szRepCapIdentifiers = AG6800_OUTPUT_PHASE_LIST_6834; modelNum = AG6800_VAL_MODEL_6834; } else if ((strncmp(modelStr, "6811", strlen("6811")) == 0) ) { szRepCapIdentifiers = AG6800_OUTPUT_PHASE_LIST_6811; modelNum = AG6800_VAL_MODEL_6811; } else if ((strncmp(modelStr, "6812", strlen("6812")) == 0) ) { szRepCapIdentifiers = AG6800_OUTPUT_PHASE_LIST_6812; modelNum = AG6800_VAL_MODEL_6812; } else if ((strncmp(modelStr, "6813", strlen("6813")) == 0) ) { szRepCapIdentifiers = AG6800_OUTPUT_PHASE_LIST_6813; modelNum = AG6800_VAL_MODEL_6813; } else if ((strncmp(modelStr, "6814", strlen("6814")) == 0) ) { szRepCapIdentifiers = AG6800_OUTPUT_PHASE_LIST_6814; modelNum = AG6800_VAL_MODEL_6814; } else if ((strncmp(modelStr, "6843", strlen("6843")) == 0) ) { szRepCapIdentifiers = AG6800_OUTPUT_PHASE_LIST_6843; modelNum = AG6800_VAL_MODEL_6843; } else viCheckErrElab(IVI_ERROR_INVALID_VALUE, "The model specified is not valid"); } /*- Atention: May add some optr relative sententce */ checkErr(Ivi_BuildRepCapTable(vi, AG6800_REPCAP_OUTPUT_PHASE, szRepCapIdentifiers)); /* Add attributes */ checkErr(ag6800_InitAttributes(vi, modelNum)); /* Record the model */ checkErr(Ivi_SetAttributeViInt32(vi, VI_NULL, AG6800_ATTR_INSTR_MODEL, 0, modelNum)); /*- Reset instrument ----------------------------------------------------*/ if (reset) checkErr(ag6800_reset(vi)); else /*- Send Default Instrument Setup ---------------------------------*/ checkErr(ag6800_DefaultInstrSetup(vi)); checkErr(ag6800_CheckStatus(vi)); Error: if (error < VI_SUCCESS) { if (!Ivi_Simulating(vi) && io) viClose(io); } return error; }
Should I try modifying the driver myself and recreate the DLL or request someone from NI to update it? The Agilent 6812B AC power sources are pretty commonly used so I find it surprising that someone else hasn't come across this issue. Am I doing something wrong?
10-27-2015 03:11 PM
@dblok wrote:
I have everything setup in NI Max but I can't get through the initialization routine. I've tried in both LabView and LabWindows and neither will work.
I have no idea what this means.
If you have the serial port set up properly, you can simply use NI-MAX's VISA Interactive Control panel to query the instrument with *IDN? and see the response.
You can experiment with whether a new line is needed or not.
10-27-2015 05:35 PM
I can communicate through the control panel just fine using "*IDN?\n". The problem is trying to use the IVI class drivers to handle the initialization routine does not work.
Here is a code snippet from one of the examples in LabWindows/CVI:
/* Initialize Instrument -- optionally calling ID Query and/or Reset */ checkErr(IviACPwr_init(logicalName, IDQuery, reset, &instrumentHandle));
I pass my logical name into the function and it is supposed to perform all the initialization for the instrument. I always receive a timeout because the driver does not send a line feed at the end of the string. The driver is approved by NI.
I realize that I can just use VISA to communicate with the device but I'm trying to use the IVI class drivers for interchangeability between AC power sources. I am using Agilent now but may want to use Kikusui or California Instruments without changing my software.
10-27-2015 06:56 PM
What happens when you send *IDN? in NI-MAX?
That will give you the answer.
10-27-2015 07:39 PM
10-28-2015 12:33 AM
Another option might be to check the intruments manual if there is an option to disable the need for an termination character.
10-28-2015 11:29 AM
@nyc_(is_out_of_here) wrote:
What happens when you send *IDN? in NI-MAX?
That will give you the answer.
*IDN? does not work. It needs the line feed but the IVI driver does not send the line feed.
10-28-2015 11:30 AM
10-28-2015 11:38 AM
@Dennis_Knutson wrote:
I've never used IVI with a serial instrument. The termination is not required with GPIB. With LabVIEW drivers, the termination is set with a property node when the resource type is serial. Since that seems to be missing, try doing it in MAX when you configure the port settings.
There is a LabView driver using VISA that does work with the 6812B and it uses property nodes for the termination. I can setup the VISA test panel to use the line feed as a termination but it does not permanently save this setting to the port. It only applies the property while I'm using the test panel. Is there a way to permanently set this in MAX?
I went into the IVI driver and tried setting the property nodes and rebuilding the DLL. I pointed my driver session to the new DLL but it gave me an error while running the intialization. I then added a line feed at the end of the *IDN? string and it got a reply back but then timed out later in the initialization. I think the property node for the termination is the way to go. I just have to get it to work and rebuild the DLL.