12-17-2012 05:41 AM
the program always reads 0 inspite of setting different temperature..wud be really greatful if someone cud help...
12-17-2012 07:42 AM
@skpoudel wrote:
the program always reads 0 inspite of setting different temperature..wud be really greatful if someone cud help...
I don't know what "wud" is. Cud is what a cow chews on.
There are C examples for NI-VISA installed on your computer. Try those first.
12-18-2012 06:29 AM
The programs I tried for setting and reading the temperature are from the NI example programs installed on my computer.Still I am not able to set and read the temperature....
12-18-2012 07:29 AM
@skpoudel wrote:
The programs I tried for setting and reading the temperature are from the NI example programs installed on my computer.Still I am not able to set and read the temperature....
You can try posting your C++ code. Otherwise, who knows what is wrong. No one is clairvoyant.
12-26-2012 05:46 AM
// rmp.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include<stdlib.h>
#include<conio.h>
#include "ni4882.h"
#include <stdio.h>
void GpibError(const char *msg);
void delay(unsigned int);
int Device = 0; /* Device unit descriptor */
int BoardIndex = 0; /* Interface Index (GPIB0=0,GPIB1=1,etc.) */
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// The one and only application object
CWinApp theApp;
using namespace std;
int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
int nRetCode = 0;
// initialize MFC and print and error on failure
if(!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)){
// TODO: change error code to suit your needs
cerr << _T("Fatal Error: MFC initialization failed") << endl;
nRetCode = 1;
}
else{
int PrimaryAddress = 1; /* Primary address of the device */
int SecondaryAddress = 0; /* Secondary address of the device */
char Buffer[101]; /* Read buffer */
/*****************************************************************************
* Initialization - Done only once at the beginning of your application.
*****************************************************************************/
Device = ibdev( /* Create a unit descriptor handle */
BoardIndex, /* Board Index (GPIB0 = 0, GPIB1 = 1, ...) */
PrimaryAddress, /* Device primary address */
SecondaryAddress, /* Device secondary address */
T10s, /* Timeout setting (T10s = 10 seconds) */
1, /* Assert EOI line at end of write */
0); /* EOS termination mode */
if (Ibsta() & ERR) { /* Check for GPIB Error */
GpibError("ibdev Error");
}
ibclr(Device); /* Clear the device */
if (Ibsta() & ERR) {
GpibError("ibclr Error");
}
/*****************************************************************************
* Main Application Body - Write the majority of your GPIB code here.
*****************************************************************************/
ibwrt(Device, "S<cr>", 5); /* Send the identification query command */
delay(100);
if (Ibsta() & ERR) {
GpibError("ibwrt Error");
}
//delay(50000);
//ibwrt(Device, "S<cr>", 5 ); /* Send the identification query command */
//if (Ibsta() & ERR) {
// GpibError("ibwrt Error");
//}
ibrd(Device, Buffer, 100); /* Read up to 100 bytes from the device */
if (Ibsta() & ERR) {
GpibError("ibrd Error");
}
Buffer[Ibcnt()] = '\0'; /* Null terminate the ASCII string */
printf("%s\n", Buffer); /* Print the device identification */
/*****************************************************************************
* Uninitialization - Done only once at the end of your application.
*****************************************************************************/
ibonl(Device, 0); /* Take the device offline */
//printf("\n device is offline");
if (Ibsta() & ERR) {
GpibError("ibonl Error");
}
return nRetCode;
}
}
void GpibError(const char *msg) {
printf("%s\n", msg);
printf("Ibsta() = 0x%x <", Ibsta());
if (Ibsta() & ERR ) printf(" ERR");
if (Ibsta() & TIMO) printf(" TIMO");
if (Ibsta() & END ) printf(" END");
if (Ibsta() & SRQI) printf(" SRQI");
if (Ibsta() & RQS ) printf(" RQS");
if (Ibsta() & CMPL) printf(" CMPL");
if (Ibsta() & LOK ) printf(" LOK");
if (Ibsta() & REM ) printf(" REM");
if (Ibsta() & CIC ) printf(" CIC");
if (Ibsta() & ATN ) printf(" ATN");
if (Ibsta() & TACS) printf(" TACS");
if (Ibsta() & LACS) printf(" LACS");
if (Ibsta() & DTAS) printf(" DTAS");
if (Ibsta() & DCAS) printf(" DCAS");
printf (" >\n");
printf ("Iberr() = %d", Iberr());
if (Iberr() == EDVR) printf(" EDVR <Driver error>\n");
if (Iberr() == ECIC) printf(" ECIC <Not Controller-In-Charge>\n");
if (Iberr() == ENOL) printf(" ENOL <No Listener>\n");
if (Iberr() == EADR) printf(" EADR <Address error>\n");
if (Iberr() == EARG) printf(" EARG <Invalid argument>\n");
if (Iberr() == ESAC) printf(" ESAC <Not System Controller>\n");
if (Iberr() == EABO) printf(" EABO <Operation aborted>\n");
if (Iberr() == ENEB) printf(" ENEB <No GPIB board>\n");
if (Iberr() == EOIP) printf(" EOIP <Async I/O in progress>\n");
if (Iberr() == ECAP) printf(" ECAP <No capability>\n");
if (Iberr() == EFSO) printf(" EFSO <File system error>\n");
if (Iberr() == EBUS) printf(" EBUS <Command error>\n");
if (Iberr() == ESTB) printf(" ESTB <Status byte lost>\n");
if (Iberr() == ESRQ) printf(" ESRQ <SRQ stuck on>\n");
if (Iberr() == ETAB) printf(" ETAB <Table Overflow>\n");
if (Iberr() == ELCK) printf(" ELCK <Lock error>\n");
if (Iberr() == EARM) printf(" EARM <Ibnotify rearm error>\n");
if (Iberr() == EHDL) printf(" EHDL <Invalid Handle>\n");
if (Iberr() == EWIP) printf(" EWIP <Wait already in progress>\n");
if (Iberr() == ERST) printf(" ERST <Notification cancelled due to reset>\n");
if (Iberr() == EPWR) printf(" EPWR <Power error>\n");
printf("Ibcnt() = %u\n", Ibcnt());
printf("\n");
/* Call ibonl to take the device and interface offline */
ibonl(Device, 0);
exit(1);
}
void delay(unsigned int d){
while(d){
d--;
}
}
12-26-2012 11:45 AM
That code is suppose to query the instrument for an indentification string.
Do you get one back?
12-27-2012 12:00 AM
The string"S<cr>" is suppose to return the present set point .....but in my case it always returns 0.00 even after i change the set point manually to different values.
12-27-2012 08:46 AM
12-27-2012 11:28 PM
i tried sending the hex code of carriage return too...but still its giving the same result
12-28-2012 08:24 AM