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

Subject: hex format convert to a specified length
From: Damek Yahto <[email protected]>
To: [email protected]
Date: Mon, 15 Nov 2010 14:42:53 +0800

HI Tech-talk,I am trying to build an IOC to communicate with serial devices through the serial to Ethernet Device Server.

The serial device supports  the streams of hex format.

The binary command format when using RS232 or RS485 is as follows:
Bytes    Meaning
1        Module address
1        Command number
1        Type number
1        Motor or Bank number
4        Value (MSB first!)
1        Checksum
total:  9 bytes

the checksum is calculated by adding up all bytes (including the module address byte) using
8-bit addition. Here is the examples to show how to do this:
    in C:
    unsigned char i, Checksum;
    unsigned char Command[9];

    //Set the “Command” array to the desired command
    Checksum = Command[0];
    for(i=1; i<8; i++)
        Checksum+=Command[i];
    Command[8]=Checksum; //insert checksum as last byte of the command
     //Now, send it to the module

I want to control the motor to rotate right  through the serial device.

Instruction:
Rotate right,   motor #1, velocity = 350
Binary:
Byte Index         0              1                2          3                   4                5                 6               7                 8
Function          Target-     Instruction   Type      Motor/         Operand     Operand      Operand     Operand      Checksum
                   address     Number                      Bank           Byte3         Byte2           Byte1          Byte0
Value (hex)        0x01       0x01          0x00      0x01             0x00          0x00             0x01            0x5e          0x62

By writing streamDevice protocol file(out'\x01\x01\x00\x01\x00\x00\x01\x5e\x62';),motor can rotate. Using "EDM" or "caput" to

input the variable,where do I do my processing (like calculating the Checksum and convert the velocity to four bytes long)? where

write my own parsing code in C?having other approaches. Could you give any example?

Thanks,
 
Yahto

Navigate by Date:
Prev: Last chance to save the sequencer's pv layer Ben Franksen
Next: EPICS base on Windows with INSTALL_LOCATION on a different drive Dirk Zimoch
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  <20102011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: Patch to subArray record Andrew Johnson
Next: EPICS base on Windows with INSTALL_LOCATION on a different drive Dirk Zimoch
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  <20102011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 15 Nov 2010 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·