Glenn,
I see now how the status byte and standard event byte work. Thanks for that link. I still haven't gotten my program to work as I wanted, but I am much closer. I use "*SRE 0" and "*ESE 0" to clear the enable registers then "*SRE 32" and "*ESE 32" to enable the ESR(standard event register) byte and the command error bit in the ESR. I use the following chunk of code after a command is entered. This is supposed to check to see if the command caused an error, and if it did to write the command to put the error into the output buffer.
Dim StatusByte(0) as Byte
If (m_Multimeter.SerialPoll = SerialPollFlags.EventStatusRegister) Then
'm_Multimeter.Write("*ESR?")
'StatusByte = m_Multimeter.ReadByteArray(1)
'If (StatusByte(0) And 32) Then
m_Multimeter.Write("SYST:ERR?")
'End If
End If
Right now I have commented out the *ESR? section since the only bit in the register I have enabled is for command errors, and this makes things more simple to work with for the time being. However the following are my results:
- When entering a command for the first time as a user of the application I do not get passed the conditional (the Event Status Register Bit in the Summary Register is not toggled for some reason). Entering an invalid command only sets the flag if I enter a valid one first. Strange.
- If I enter a valid command first, it will detect an invalid command afterwards just fine and I catch the error message from the output buffer. After this I cannot enter valid commands without them getting interrupted because execution gets passed the conditional again. I have tried using the *CLS command to clear out the ESR as the manual claims, and then I can enter a valid command followed by an invalid command and then as many valid commands as I want, but as soon as I enter another invalid command I do NOT get passed the conditional (the ESR bit in the Status Byte is not toggled on).
It seems like the Status Byte and ESR are being cleared by *CLS but then are not working again afterwards, invalid commands no longer turn on the command error bit and then the ESR bit (in the Status Byte). I've tried reissuing the *SRE 32 and *ESE 32 commands to make sure they are on but this makes no difference (the enable bits are not cleared by *CLS or *ESR? anyway...was just taking a shot in the dark). I have also tried calling the clear method on both the board and device, and calling reset on both...and many combinations of all of these things in various orders. Nothing seems to be allowing the ESR bits and the ESR bit in the status byte to be retoggle-able. *CLS is supposed to clear both the Status Byte and the ESR; it does so, but then the bits never get turned on again when they should. Does anyone know what I need to do to reset the status byte and ESR so that their bits will be toggled on appropriately after a *CLS command?
CLA, CCVID, Certified Instructor