EPICS Controls 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  2012  2013  2014  2015  2016  2017  2018  2019  2020  <20212022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  <20212022  2023  2024 
<== Date ==> <== Thread ==>

Subject: StreamDevice checksum methods
From: Josh Fiddler via Tech-talk <tech-talk at aps.anl.gov>
To: tech-talk at aps.anl.gov
Date: Wed, 10 Nov 2021 16:20:09 -0500
Hi EPICS mavens!

Having a lot of fun building IOCs left and right. 

I've got a HV power supply to charge up a system that comms over RS485. 
We send 13 bytes worth of data to the unit, including 2 bytes for the terminator.
byte are
1 for address, 
2 for command
2 used as header in certain commands: to hold status bytes in some, and is null in others
2 when we want to set a voltage
2 when we want to set the ramping current
2 for checksum
2 for terminator

To pass a voltage, it must first be in tens of kV, sensitive to 0.1 kV. This value is multiplied by 100 then can be converted to hex. Current is similar, but is not scaled (x1) 

The checksum is the sum of the bits in the binary representation of the first 9 bytes. When I send the request, I must include this value. It is to ensure the message is composed of characters, according to the docs (which are very, very minimal). 

So, an example command to set the device to 15kV, with 600mA current is:

A1 61 00 00 00 05 DC 02 58 00 11 00 0D
where 05 DC represents 15kV (hex(15 * 100))
and    02 58 represents 600mA (hex(600))
and    00 11 represents checksum on A1 61 00 00 00 05 DC 02 58
The checksum is computed by summing the individual bits in the binary of each value: 
0b10100001', '0b1100001', '0b0', '0b0', '0b0', '0b101', '0b11011100', '0b10', '0b1011000' 
means 3+3+0+0+0+2+5+1+3=17 or 0x11 in hex. 

We would like to be able to vary the voltage setpoints from 0.1 to 15kV 
The current is set from a list. 

I was going to use redirection to take the values from the records that set the voltage and current values, passing as 16-bit values to ensure that the checksum, eg. 17 --> 0x11 becomes 0x0011 using formatters. 

What I need is to compute the checksum (and in a response, decode it). I see that there are a host of checksum methods, but I am not clear if the accumulated bits checksum has an analogue in StreamDevice.

Any advice, tips or examples?

Thanks for reading. 

Also, I have another question about parsing responses to extract status, voltage, current, and the checksum into other records. Search: "StreamDevice response parsing and reditrection"


Navigate by Date:
Prev: Re: How to access PSI Elog data from other web clients Wang, Lin via Tech-talk
Next: StreamDevice response parsing and redirection Josh Fiddler via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  <20212022  2023  2024 
Navigate by Thread:
Prev: Re: EPICS support for the Omega Platinum Series PID Controllers Wlodek, Jakub via Tech-talk
Next: StreamDevice response parsing and redirection Josh Fiddler via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  <20212022  2023  2024 
ANJ, 10 Nov 2021 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·