On Sun, 2008-01-27 at 14:44 -0800, Kirk Wallace wrote: 
> On Sun, 2008-01-27 at 15:53 -0500, Stephen Wille Padnos wrote:
> > Hmmm.
> > 
> > Interesting idea to just have coils and registers presented as pins.  
> > Then you'd only need to specify how many of each you want to access, 
> > along with the base address.  It gets more complicated if you need to 
> > allow access to registers/coils in multiple discontiguous ranges.
> > 
> > There's also a problem with multi-register values.  Some devices can 
> > handle 32-bit values, which are generally composed of two 16-bit %Rxx 
> > values.  I'm not sure if the spec tells you to use a certain 
> > endian-ness, so it may be necessary to be able to specify that as well.  
> > This is why I was thinking about a higher level spec for specific 
> > devices (ideally with a low-level core that's at least from common 
> > source code, and at best a single shared module).  It would be much more 
> > readable in HAL to have a modbus.0.vfd.0.spindle-speed pin rather than 
> > having something like the inverse of a scale block to convert from float 
> > to whatever integer units the VFD uses, then possibly to split that into 
> > two 16-bit words for connection to modbus.1.register001 and 
> > modbus.1.register002.  It would also be possible now that I think of it, 
> > to have a VFD module that converts from "engineering units" to whatever 
> > registers and coils the modbus interface provides.  The downside is that 
> > you end up with a lot of HAL connections that aren't really useful, and 
> > can cause major problems if they're screwed up (imagine the oops of 
> > swapping the high and low words of a spindle speed, for example).

Opps, I changed my mind. The simplicity of only thinking about coils and
registers just moved the necessary complexity to another area. Just like
all other hardware, I think, a file is needed to interface the
hardware's features to EMC, There are just too many variables to try to
make a generic interface. So my latest thinking is to make a component,
SJ200-mb-rtu with pins and parameters for the features I want to
interface with EMC like "SJ200-mb-rtu.0.frequency-in",
"SJ200-mb-rtu.0.run", etc. The SJ200 component would know that to write
to a register, we start with a Modbus address number, function code of
0x06 (register write), 0x00 ( reg. addr. high, 2 bytes), 0x01 (reg.
addr. low, 2 bytes), and pin value (2 bytes). This stream would then be
placed in a message buffer for the Modbus program handling the desired
serial port, Modbus would add a CRC to the end and send it. The buffer
is a mystery to me. I think I saw in the HAL documentation that pins
could be arrays. 

> I didn't want to have any device dependent features in the Modbus RTU
> component. I was hoping that that would be up to mixing other components
> to get the data into the proper form. The Modbus RTU component would
> only handle assembling the packet, managing the communications protocol,
> and handling communications errors.
> 
> I am using the my VFD manual as a guide, and all of its registers are
> eight bit. For 16 bit parameters, it uses two register addresses and no
> floating point, such as:
> 
> Func-  |   Name                  | R | Description | Reg-  | Ra- | Res-
> tion   |                         | / |             | ister | nge | olu-

I was wrong here, the SJ200 uses 16 bit registers. The Modbus standard
indicates a frame as:
Slave   | Function | Data           | CRC
Address | Code     |                | Check
----------------------------------------------
1 byte  | 1 byte   | 0 to 252 bytes | 2 bytes

So, for other Modbus devices the registers could be any number of bytes
long up to 252 bytes.

> > I should stop thinking about it, because it keeps getting more complex 
> > the more I do  :)
> > 
> > - Steve
> 
> My brain is is hurting, too (easy to do though).
> 
> -- 
> Kirk Wallace (California, USA

-- 
Kirk Wallace (California, USA
http://www.wallacecompany.com/machine_shop/ 
Hardinge HNC lathe,
Bridgeport mill conversion, doing XY now,
Zubal lathe conversion pending)


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to