Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

DOS

Hi, I am using the non_cic.c example file that came with DOS GPIB software. I would have included the file in this email but you have a size limit on your emails.    When non_cic.c receives a listen/talk command from a CIC,  it subsequently calls ibrd/ ibwrt respectively.
 
However, I notice that after the ibrd/ibwrt ,  the ibsta bits don't update and remove TACS/LACS or even CMPL.  Consequently, the program again calls ibwait and then performs another ibrd/ibwrt....but because because the CIC has not granted access via the bus lines,  the program hangs the second time in ibrd() or ibwrt().
 
I am using Measurement and Automation Explorer on another computer as the CIC and I'm manually sending a write/read command to the NON_CIC.  My startup sequence is run the NON_CIC program, then  "Scan for devices"  on the CIC computer (using MAE). After that, I bring up the communicator where I issue either a read or write. The hang is not really evident if you enter the same read or write command over and over....that will appear fine but is evident when you switch toggle between read and write.
 
I have a bus analyzer and I see in a CIC "read", for example, that the CIC sent a TALK command and then the NON_CIC responded with some canned text like "HELLO THERE" followed by an EOI. I can't remember if I added "HELLO THERE" in my version or whether its stock.

Since the CIC never sent an UNT command, I suppose technically the NON_CIC is still in a TALK state which is why ibsta is never updated?  If this is the case, how can I protect against going into the same talk/listen state (causing a hang in ibwrt/ibrd)  before the CIC has time to send an UNT or UNL command.
 
Can you advise?   Any other programming methods you recommend?
Thnx
 
0 Kudos
Message 1 of 3
(2,920 Views)
It would be helpful if you posted non_cic.c as an attachment (rather than in the body of the message).  I think that I can surmise the basic flow that you describe:
 
while (true)
{
status=ibwait(TACS || LACS);
if (status & TACS) ibwrt("something");
else if (status & LACS) ibrd(buffer);
}
 
Here, it's possible that after being TACS and then doing an ibwrt, you're still TACS when you loop around again, and ibwait passes that, and you ibwrt again.  The controller hasn't untalked the non-cic just yet, so you keep talking.  Valid, but probably not what you want to do.
 
You may want to consider simply doing a read directly and not trying to "react" to what the controller does.  After all, if the controller addresses you to talk when you have nothing to say, you shouldn't say anything.
 
while (true)
{
while (ibrd(buffer) && ERR);  //keep trying until there's no error
while (ibwrt("response") && ERR); //keep trying until there's no error
}
 
Doing non-controller applications, you'll see that NI-488.2 wasn't really designed for this.  It's made to be a controller, but you can have it act as a non-controller.  I would look into NI-Device if you are interested in making a full-fledged GPIB instrument that is IEEE 488.2 compliant.  C++ programming, interfacing with a parser of your choosing, and perfect for this sort of thing.
 
Scott B.
GPIB Software
National Instruments
0 Kudos
Message 2 of 3
(2,908 Views)

I have NI-DEVICE but I'm not sure it would work in my application since the controller never sends an EOI or EOS termination char. Termination is purely by observation of an "UNTALK".

Moreover, I am unsure of what files to link for NI-DEVICE.  I bought this s/w a year ago but couldn't immediately figure out how to "build" something for non-OS environment so I put it aside. The documentation is very scant.

Today, I decided to look at it again per your recommendation but still am confused of how what files I need to build. My current projects runs in DOS enviroment so I would like to build using Turbo C 3.0 .  I looked at the linux makefile in the "windows\source\build\linux\examples\simpleGpibDevice"  and it refers to some library files......but those are for linux . It appears that I should make my own library files but which directories. The documentation says there are 3 components to the build, Lang IF, ENgine, and Plugin....but it doesn't give very good instructions on how to build this.

Any help is appreciated.  

0 Kudos
Message 3 of 3
(2,896 Views)