Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018 
<== Date ==> <== Thread ==>

Subject: RE: reading negative 16-bit numbers over Asyn modbus
From: <matthew.pearson@diamond.ac.uk>
To: <rivers@cars.uchicago.edu>, <tech-talk@aps.anl.gov>
Date: Thu, 5 Apr 2012 18:06:26 +0000
Thanks Mark, I'll give it a try after Easter and let you know.

Cheers,
Matt

> -----Original Message-----
> From: Mark Rivers [mailto:rivers@cars.uchicago.edu]
> Sent: 05 April 2012 19:00
> To: Pearson, Matthew (DLSLtd,RAL,DIA); tech-talk@aps.anl.gov
> Subject: RE: reading negative 16-bit numbers over Asyn modbus
> 
> Hi Matt,
> 
> Support for Modbus data types 4-10 were only added in Modbus R2-4,
> which is in beta release.  Previous versions do not support signed 16-
> bit integers, only unsigned.
> 
> You can get the 2-4beta1 version at:
> 
> http://cars.uchicago.edu/software/pub/modbusR2-4beta1.tgz
> 
> I'd like to release it soon, so if you could test if it works for your
> application that would be great.
> 
> Mark
> 
> 
> -----Original Message-----
> From: tech-talk-bounces@aps.anl.gov [mailto:tech-talk-
> bounces@aps.anl.gov] On Behalf Of matthew.pearson@diamond.ac.uk
> Sent: Thursday, April 05, 2012 12:51 PM
> To: tech-talk@aps.anl.gov
> Subject: reading negative 16-bit numbers over Asyn modbus
> 
> Hi,
> 
> I have a Eurotherm 3217 controller that I'm talking to using modbus RTU
> over RS485 (via a Moxa terminal server). It seems to work fine, but I'm
> having trouble reading a negative number.
> 
> The Asyn support is configured to use modbus function code 3, like
> this: (from the eurotherm2k support module eurothermModbus.c):
> 
> mkname(str, strmaxlen, asynPortName, modbusAddress, loopNumber, 0,
> "PV");
> asynRet = drvModbusAsynConfigure(str, asynPortName, modbusAddress,
> 		MODBUS_READW, loopStart+PV_OFFSET, 3,
> 		0, EUROTHERM_POLL_MS, "");
> 
> Where:
> loop number is 1.
> modbus addr is 1.
> MODBUS_READW is 3 (this is the function code, so it's reading 16-bit
> words).
> loopStart+PV_OFFSET is 1+0, so 1.
> 3 is the modbus length, which means 3*16-bit.
> The 0 data type is Unsigned 16-bit binary integers.
> 
> This works fine for positive numbers, but negative fails. I tried
> changing the modbus data type to 4, which should mean INT16 2's
> complement, but it seems to fail at some point and just return zero in
> the record.
> 
> If I turn on asyn trace, the negative word I am reading back is "fd
> 1c". The actual reading I expect is about -750. So this looks to be
> correct if assuming 2's complement encoding.
> 
> Anybody successfully read negative integers over modbus?
> 
> I'm using modbus 2-2, and asyn 4-14.
> 
> Update... looking at drvModbusAsyn.c, I see that convertFromBinary()
> only implements 3 types of type conversion (modbus data types 1, 2 and
> 3 in the list in the documentation?)
> 
> Cheers,
> Matthew
> 
> 
> 
> Dr Matthew Pearson
> Senior Software Systems Engineer
> Diamond Light Source
> Chilton, Didcot
> OX11 0DE
> UK
> 
> MX Controls Team Leader
> Beamline Controls - I19, I24, B24
> 
> 
> 
> 
> --
> This e-mail and any attachments may contain confidential, copyright and
> or privileged material, and are for the use of the intended addressee
> only. If you are not the intended addressee or an authorised recipient
> of the addressee please notify us of receipt by returning the e-mail
> and do not use, copy, retain, distribute or disclose the information in
> or attached to the e-mail.
> Any opinions expressed within this e-mail are those of the individual
> and not necessarily of Diamond Light Source Ltd.
> Diamond Light Source Ltd. cannot guarantee that this e-mail or any
> attachments are free from viruses and we cannot accept liability for
> any damage which you may sustain as a result of software viruses which
> may be transmitted in or with the message.
> Diamond Light Source Limited (company no. 4375679). Registered in
> England and Wales with its registered office at Diamond House, Harwell
> Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United
> Kingdom
> 
> 
> 
> 


-- 
This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail.
Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd. 
Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message.
Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom
 





References:
reading negative 16-bit numbers over Asyn modbus matthew.pearson
RE: reading negative 16-bit numbers over Asyn modbus Mark Rivers

Navigate by Date:
Prev: RE: reading negative 16-bit numbers over Asyn modbus Mark Rivers
Next: a question about sequencer wux
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018 
Navigate by Thread:
Prev: RE: reading negative 16-bit numbers over Asyn modbus Mark Rivers
Next: a question about sequencer wux
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014  2015  2016  2017  2018 
ANJ, 18 Nov 2013 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·