PLC/Modbus read coil status (modbus tk)
<p>Hopefully there is a bored PLC modbus expert out there who needs some entertainment.. I'm going crazy trying to figure this out.</p>

<p>I'm trying to read the status of the output coils Q1 to Q8 on a teco SG2 20VR-D.  </p>

<p>I'm using Modbus-TK in python and I can easily communicate with the plc to write to coils, read registers etc. But I can't figure out how the heck to read the output coils Q1-Q8 so I can check their status.  </p>

<p>The address table is on page 29/31 of the attached PDF.  My unit is a V3 type.</p>

<p>If you read the small print on page 29 there is some cryptic message about multiplying by 10h???? help!</p>

<p>When I use this command I get a simple tuple with a zero for the only value.</p>

<pre><code>slave_address = 1

command = 1 #read coils

coil_address = 11312 # this is 2c30h converted to decimal.  2c30h is the address for Q1 according to the pdf

master.execute(slave_address, command, coil_address)
</code></pre>

<p>(when I evaluate the expression in Pycharm.. this what I get)
Returns:</p>

<pre><code>result = {tuple} &lt;type 'tuple'&gt;:()
__len__ = {int} 0
</code></pre>

<p>The trouble is Q1 is energized (closed) so it should show 1 or 65280 not 0, so this can't be right.</p>

<p>Should I be using some kind of range for the coil addresses?  Can anyone explain how this should be done?</p>

<p><a href="http://www.bb-elec.com/Products/Manuals/SG2_V-typeModbusProtocol_0807.pdf" rel="nofollow noreferrer">Teco SG3 Modbus Manual</a></p>