View previous topic :: View next topic |
Author |
Message |
Storic
Joined: 03 Dec 2005 Posts: 182 Location: Australia SA
|
analog value to MODbus to send. |
Posted: Sat Mar 10, 2007 4:46 am |
|
|
I have been toying with MODbus and having trouble with applying an analog value to send via MODbus .
yes obtaining the analog read is OK, it is how to apply the input and input value to the MODbus LAN???
ie if input_1_value = Read_ADC();
How do I assign input_1_value to the modbus LAN.
from example code:
"modbus_read_discrete_input_rsp(MODBUS_ADDRESS, 0x01, &data);" is data the value for input_1_value or is there another method to use.
same with "modbus_read_holding_registers_rsp(MODBUS_ADDRESS,(modbus_rx.data[3]*2),hold_regs+modbus_rx.data[1]);"
is hold_regs+modbus_rx.data[1] the value of input_1_value??
Andrew _________________ What has been learnt if you make the same mistake? |
|
|
Neutone
Joined: 08 Sep 2003 Posts: 839 Location: Houston
|
Re: analog value to MODbus to send. |
Posted: Sun Mar 11, 2007 3:51 pm |
|
|
Storic wrote: | I have been toying with MODbus and having trouble with applying an analog value to send via MODbus .
yes obtaining the analog read is OK, it is how to apply the input and input value to the MODbus LAN???
ie if input_1_value = Read_ADC();
How do I assign input_1_value to the modbus LAN.
from example code:
"modbus_read_discrete_input_rsp(MODBUS_ADDRESS, 0x01, &data);" is data the value for input_1_value or is there another method to use.
same with "modbus_read_holding_registers_rsp(MODBUS_ADDRESS,(modbus_rx.data[3]*2),hold_regs+modbus_rx.data[1]);"
is hold_regs+modbus_rx.data[1] the value of input_1_value??
Andrew |
I think the most important part of your post is that you wish to read an analog value from a discrete input. Discrete means data bit.
MODBUS specification suports 4 standard data types
1) Holding registers, INT16 Read/Write
2) Input Registers, INT16 Read Only
3) Discrete Inputs INT1 Read Only
4) Discrete Outputs INT1 Read/Write |
|
|
Storic
Joined: 03 Dec 2005 Posts: 182 Location: Australia SA
|
Re: analog value to MODbus to send. |
Posted: Mon Mar 12, 2007 6:37 am |
|
|
Neutone wrote: |
I think the most important part of your post is that you wish to read an analog value from a discrete input. Discrete means data bit.
MODBUS specification suports 4 standard data types
1) Holding registers, INT16 Read/Write
2) Input Registers, INT16 Read Only
3) Discrete Inputs INT1 Read Only
4) Discrete Outputs INT1 Read/Write |
from the above Can I assume that discrete input is reading either on or off ("1"or"0") and the input register is 16 bit data. will this mean that I can have the analog value converted to a digital Input Registers (16bit).
if this is the case then do I assign the input register the analog value (in bit form) and the discrete input the input assigned to the input register.
Andrew _________________ What has been learnt if you make the same mistake? |
|
|
magnoedu
Joined: 29 May 2009 Posts: 11
|
help-me |
Posted: Thu Jun 25, 2009 11:29 pm |
|
|
I have same problem but it seems still not learned to get accurate value ad in this matrix and write
Code: | int16 hold_regs [] = (0x8800, 0x7700, 0x6600, 0x5500, 0x4400, 0x3300, 0x2200, 0x1100); |
I'm trying so
Code: | hold_regs [0] = Read_ADC (); |
I wanted to know if and when you do please help us. |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Thu Jun 25, 2009 11:36 pm |
|
|
Holding registers are mainly intended as analog output register and for values, that are updated from both sides.
They must be supposed to be overwritten by the master at any time. ADC values should rather go to input registers. |
|
|
|