Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Sending Ascii commands through RS-232 (NIOPS-4)

Hello,

 

I am trying to control a power supply (NIOPS-4, attached manual) for an ion pump using basic serial read and write vi (attached), but having troubles with it.

I set baud rate to 115,200 as suggested in the manual and tried simple commands like V<CR>, V, B<CR>, B .. but I get timed out at the read section. I don't see any errors at the write section but "B" command which is supposed to turn off the power supply doesn't really work.

Can anyone tell me what I am missing? Also, what bytes to read should I use?

 

1.png2.png

 

 

0 Kudos
Message 1 of 6
(4,120 Views)

It state right in section 9.2 of the manual that this uses a handshaking protocol.  You will need to send your command then await 2 bytes at port [ACK,CR].

 

Here is the handshaking at work (The <CR><LF> is shown as \r\n).  Your entries/responses are on the left while the instrument ones are on the right below.  There is normally a time limit to when the response needs to be received before timing out.  This is one of the few cases where using the "Bytes at Port" for awaiting the 2 character acknowledgement from the instrument is useful and appropriate.

V\r\n

               < ACK>\r

<ENQ>

               NEGH.3 Jun 04 2011\r

 

The <ACK> and <ENQ> have the hexadecimal ASCII values of 0x06 and 0x05 respectively. 

Help the Community (and future reviewers) by marking posts as follows:
If it helped - KUDOS
If it answers the issue - SOLUTION
Message 2 of 6
(4,094 Views)

Hello,

 

   I'd recommend do not use "Read" with predefined bytes count. It's better (and more efficient) first to check for bytes at port available. The main idea behind (sketched  below):

  • Every N ms. check for bytes available
  • If Current bytes count is equal to Previous one (and NOT zero) then exit loop and read all available bytes.
  • A loop timeout (in this case 2.5 s.) must be added  to avoid an infinite loop .

You can play with poling interval (5 ms.) but it's good enough for 115,200 baud rate. Too big interval will slow down execution ... too short interval could miss the whole response (critical at low baud rate).

 

RS232_CheckBytes.png

Message 3 of 6
(4,074 Views)

schem.PNG

I tried attached script, but I don't get anything on read buffer when V command was sent. Please let me know if anything seems wrong.

0 Kudos
Message 4 of 6
(4,045 Views)

I tried "Bytes at Port" as you mentioned, but unfortunately I am not still getting anything from the device unfortunately. I attached the block diagram above.

0 Kudos
Message 5 of 6
(4,041 Views)

1. Are you using a Null Modem cable?  Page 24 under paragraph 9.1 clearly states "With the PC use a Null Modem cable."  A normal straight through cable will not work.

2. Ignore the advice you were given about the Bytes At Port.  This instrument uses a Command-Response communication scheme and a termination character.  So it is fairly safe to assume you will get a message back within the default 10 second timeout.  So first, enable the termination character and set it to the Carriage Return (13, 0xD).  Then tell VISA Read to read more bytes than you expect back.  The read will stop when the termination character is read.  Here is how you should be able to read the software version from the instrument.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Download All
0 Kudos
Message 6 of 6
(4,025 Views)