Rank: 514 based on 279 downloads (last 30 days) and 18 files submitted
photo

Geoffrey Akien

E-mail
Company/University
University of Nottingham

Personal Profile:

 

Watch this Author's files

 

Files Posted by Geoffrey Akien View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
03 Sep 2014 CO2gui - lab control and automation Software used for controlling and data logging lab equipment. Author: Geoffrey Akien serial, rs232, communications, gui, hplc, eurotherm 55 0
  • 4.0
4.0 | 1 rating
01 Aug 2014 Pico Technology PicoLog Recorder data acquisition (DDE) Retrieves data from a running instance of PicoLog Recorder via DDE. Author: Geoffrey Akien picolog, pico, dde, daq, communications 8 0
03 Apr 2014 Eurotherm Modbus RS232 Control Reads and writes information to Eurotherm controllers via Modbus RTU protocols. Author: Geoffrey Akien eurotherm, modbus, serial, rs232 22 8
  • 5.0
5.0 | 1 rating
12 Nov 2013 Tooltip - GUI modeless feedback "Tooltip" for displaying unobtrusive modeless feedback to the user. Author: Geoffrey Akien gui, uicontrol, tooltip, modeless feedback 16 0
01 Jul 2013 Jasco Pumps RS232 communicatios Commands to read and control Jasco pumps via RS232. Author: Geoffrey Akien rs232, pump, communications, serial, jasco, hplc 11 0
Comments and Ratings by Geoffrey Akien View all
Updated File Comments Rating
23 May 2013 TCP/IP Communications in Matlab Sends/receives TCP packets using Matlab's Java interface. Now handles matrices and cell arrays, etc. Author: Kevin Bartlett

I want to use port 502 (I can't change this), but your code formally does not allow the user of ports <1025. I have a device which works just fine using tcpip in the instrument toolbox, but I was hoping to get rid of the dependency by using your code.

Naively changing this limit and using 2012bx64 on W7E I get the following:

>> j = jtcp('REQUEST', '10.10.10.4', 502)
Error using jtcp>jtcp_request_connection (line 293)
Java exception occurred:
java.net.SocketTimeoutException: Read timed out

at java.net.SocketInputStream.socketRead0(Native Method)

at java.net.SocketInputStream.read(Unknown Source)

at java.io.ObjectInputStream$PeekInputStream.read(Unknown Source)

at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown
Source)

at
java.io.ObjectInputStream$BlockDataInputStream.readShort(Unknown
Source)

at java.io.ObjectInputStream.readStreamHeader(Unknown Source)

at java.io.ObjectInputStream.<init>(Unknown Source)

Error in jtcp (line 230)
jTcpObj = jtcp_request_connection(host,port,timeout,serialize);

...but using the same approach with jtcp_version01 seems to work initially:

>> j = jtcp_version01('REQUEST', '10.10.10.4', 502)

j =

socket: [1x1 java.net.Socket]
remoteHost: '10.10.10.4'
port: 502
inputStream: [1x1 java.net.SocketInputStream]
dataInputStream: [1x1 java.io.DataInputStream]
outputStream: [1x1 java.net.SocketOutputStream]
dataOutputStream: [0 java.io.DataOutputStream]

...but then sending something gives this error:

jtcp_version01('WRITE', j, int8(c))
Error using jtcp_version01>jtcp_write (line 384)
Java exception occurred:
java.net.SocketException: Software caused connection abort: socket
write error

at java.net.SocketOutputStream.socketWrite0(Native Method)

at java.net.SocketOutputStream.socketWrite(Unknown Source)

at java.net.SocketOutputStream.write(Unknown Source)

at java.io.DataOutputStream.write(Unknown Source)

Error in jtcp_version01 (line 258)
jtcp_write(jTcpObj,mssg);

...although closing the connection seems to work without complaint.

18 May 2013 Eurotherm Modbus RS232 Control Reads and writes information to Eurotherm controllers via Modbus RTU protocols. Author: Geoffrey Akien

In response to Richard's command (FEX didn't notify me):

1) This is a deliberate feature related to how Modbus works. If you provide a deviceAddress of 0, then this is a broadcast, and modbus devices do not respond to it. So if you wanted to broadcast then then (~~0) would evaluate as true and this section (encapsulating all of the code to do with receiving data) would be run. This does not impact the sending of commands because this is run before the if ~deviceAddress section. I agree that on reflection using a double negative is not the most readable way to have done it, but it does work :).

2. I think what you've done to get round that problem is definitely one way to do it. If all the devices on that two-wire bus are using modbus then you could filter out only the responses from that particular deviceAddress. The whole deviceAddress thing is designed into Modbus exactly for multidrop instruments on the same bus. More info here: https://wiki.univie.ac.at/download/attachments/7503909/2kcomms.pdf

11 Sep 2012 GSIOC serial interface Functions for communicating with Gilson GSIOC protocol devices over RS-232 Author: Steven Edmund

I'm glad someone found it useful, it was a PITA to figure out!

28 Mar 2012 Eurotherm Modbus RS232 Control Reads and writes information to Eurotherm controllers via Modbus RTU protocols. Author: Geoffrey Akien

I didn't test it on RS422 so you may have to edit the code to make it work for you.

The message is for your information, and not an error. Modbus allows you to send more than one command per communication, and different Eurotherm devices have different maximum amounts of commands. When it connects tempobjconnect tries to ask what device it is so it knows what the maximum is for future communications (it has a list of known devices). In your case it is either an unknown device, or it didn't respond at all to the request.

11 Mar 2012 Eurotherm Modbus RS232 Control Reads and writes information to Eurotherm controllers via Modbus RTU protocols. Author: Geoffrey Akien

If you *only* want to measure temperature and nothing else then you could use a forever loop:

http://www.mathworks.com/help/techdoc/learn_matlab/f4-1931.html#brbss8u-1

for i = 1:100
temperature(i) = tempobjcomm('read', serialObject, 1, 1, 2);
wait(5)
end

This does not scale very well at all - so learn to use the timer objects if you intend to build something more complicated:
http://www.mathworks.com/help/techdoc/matlab_prog/f9-38055.html

Comments and Ratings on Geoffrey Akien's Files View all
Updated File Comment by Comments Rating
05 Dec 2013 Pico Technology TC-08 USB data acquisition Files to connect, query, and disconnect from the Pico Technology USB TC-08, using DLL's. Author: Geoffrey Akien Kristin

Thank you very much for figuring out how to get the USBTC08 libraries loaded into 64-bit MATLAB. This was very helpful to me.

18 May 2013 Eurotherm Modbus RS232 Control Reads and writes information to Eurotherm controllers via Modbus RTU protocols. Author: Geoffrey Akien Geoffrey Akien

In response to Richard's command (FEX didn't notify me):

1) This is a deliberate feature related to how Modbus works. If you provide a deviceAddress of 0, then this is a broadcast, and modbus devices do not respond to it. So if you wanted to broadcast then then (~~0) would evaluate as true and this section (encapsulating all of the code to do with receiving data) would be run. This does not impact the sending of commands because this is run before the if ~deviceAddress section. I agree that on reflection using a double negative is not the most readable way to have done it, but it does work :).

2. I think what you've done to get round that problem is definitely one way to do it. If all the devices on that two-wire bus are using modbus then you could filter out only the responses from that particular deviceAddress. The whole deviceAddress thing is designed into Modbus exactly for multidrop instruments on the same bus. More info here: https://wiki.univie.ac.at/download/attachments/7503909/2kcomms.pdf

25 Oct 2012 Readtext wrapper A wrapper for READTEXT which builds it in smaller chunks (reduces peak memory footprint). Author: Geoffrey Akien Seth Kenner

Where can I get the getfilesize function?

24 Sep 2012 Eurotherm Modbus RS232 Control Reads and writes information to Eurotherm controllers via Modbus RTU protocols. Author: Geoffrey Akien Richard

I have this code working with a Eurotherm 3216 over two-wire RS-485. Two things needed to be fixed. Neither has been rigorously debugged but it should at least be a helpful start.

1) The NOT operator (~) needs to be removed from the line "if ~deviceAddress" in tempobjcomm.m". I don't really see how anything could have worked in its original state ...

2) As it is a two-wire bus, Matlab receives all outgoing commands. I circumvented that by adding the line " "fread(serialObject, length(command));" immediately after the line described in 1). There may be a way to do this in the serial-port settings but this way seems to work fine.

28 Mar 2012 Eurotherm Modbus RS232 Control Reads and writes information to Eurotherm controllers via Modbus RTU protocols. Author: Geoffrey Akien Geoffrey Akien

I didn't test it on RS422 so you may have to edit the code to make it work for you.

The message is for your information, and not an error. Modbus allows you to send more than one command per communication, and different Eurotherm devices have different maximum amounts of commands. When it connects tempobjconnect tries to ask what device it is so it knows what the maximum is for future communications (it has a list of known devices). In your case it is either an unknown device, or it didn't respond at all to the request.

Contact us