Experimental Physics and
| |||||||||||||||
|
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"
| ||||||||||||||
ANJ, 10 Nov 2021 |
·
Home
·
News
·
About
·
Base
·
Modules
·
Extensions
·
Distributions
·
Download
·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing · |