Public Member Functions | |
| def | __enter__ (self) |
| def | __exit__ (self, exc_type, exc_value, traceback) |
| def | setup (self, address, rack=0, slot=1, port=102) |
| Connects to a Siemens S7 PLC. More... | |
| def | available_pins (self) |
| def | analog_references (self) |
Public Member Functions inherited from ahio.abstract_driver.AbstractDriver | |
| def | available_pins (self) |
| Returns available pins. More... | |
| def | map_pin (self, abstract_pin_id, physical_pin_id) |
| Maps a pin number to a physical device pin. More... | |
| def | mapped_pins (self) |
| Returns a dictionary containing the mapped pins. More... | |
| def | set_pin_interpolation (self, pin, read_min, read_max, write_min, write_max) |
Interpolates input and output values for pin. More... | |
| def | set_pin_direction (self, pin, direction) |
Sets pin pin to direction. More... | |
| def | pin_direction (self, pin) |
Gets the ahio.Direction this pin was set to. More... | |
| def | set_pin_type (self, pin, ptype) |
Sets pin pin to type. More... | |
| def | pin_type (self, pin) |
Gets the ahio.PortType this pin was set to. More... | |
| def | write (self, pin, value, pwm=False) |
| Sets the output to the given value. More... | |
| def | read (self, pin) |
Reads value from pin pin. More... | |
| def | analog_references (self) |
| Possible values for analog reference. More... | |
| def | set_analog_reference (self, reference, pin=None) |
Sets the analog reference to reference More... | |
| def | analog_reference (self, pin=None) |
| Returns the analog reference. More... | |
| def | set_pwm_frequency (self, frequency, pin=None) |
| Sets PWM frequency, if supported by hardware. More... | |
| def ahio.drivers.snap7.Driver.__exit__ | ( | self, | |
| exc_type, | |||
| exc_value, | |||
| traceback | |||
| ) |
| def ahio.drivers.snap7.Driver.setup | ( | self, | |
| address, | |||
rack = 0, |
|||
slot = 1, |
|||
port = 102 |
|||
| ) |
Connects to a Siemens S7 PLC.
Connects to a Siemens S7 using the Snap7 library. See the snap7 documentation for supported models and more details.
It's not currently possible to query the device for available pins, so available_pins() returns an empty list. Instead, you should use map_pin() to map to a Merker, Input or Output in the PLC. The internal id you should use is a string following this format: '[DMQI][XBWD][0-9]+.?[0-9]*' where:
For example: 'IB100' will read a byte from an input at address 100 and 'MX50.2' will read/write bit 2 of the Merker at address 50. It's not allowed to write to inputs (I), but you can read/write Outpus, DBs and Merkers. If it's disallowed by the PLC, an exception will be thrown by python-snap7 library.
For this library to work, it might be needed to change some settings in the PLC itself. See the snap7 documentation for more information. You also need to put the PLC in RUN mode. Not however that having a Ladder program downloaded, running and modifying variables will probably interfere with inputs and outputs, so put it in RUN mode, but preferably without a downloaded program.
| RuntimeError | if something went wrong |
| any | exception thrown by snap7's methods. |