Name | easy-scpi JSON |
Version |
0.1.7
JSON |
| download |
home_page | None |
Summary | An easy library for controlling SCPI instruments. |
upload_time | 2024-12-21 06:07:24 |
maintainer | None |
docs_url | None |
author | None |
requires_python | None |
license | None |
keywords |
scpi
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Easy SCPI
A simple and robust library making communication with [SCPI](https://en.wikipedia.org/wiki/Standard_Commands_for_Programmable_Instruments) (Standard Control of Programmbale Instruments) instruments easy. After creating an instrument object that connects to an actual instrument, commands are sent to the instrument using a property-like format. This class is useful for inheritance when creating a controller for a specific instrument. Communication with instruments is done with [PyVISA](https://pyvisa.readthedocs.io).
## Install
`python -m pip install easy-scpi`
## API
### SCPI Commands
Generic SCPI commands can be executed by transforming the SCPI code in to attributes via the hierarchy relationship, then calling it. Instrument properties can be queried by passing no arguments to the call (or specifying query=True). Commands with no arguments are run by passing an empty string to the call.
## Examples
For more examples see the [`examples`](./examples) folder.
### Basic
```python
# import package
import easy_scpi as scpi
# Connect to an instrument
inst = scpi.Instrument(<port>)
inst.connect()
# Read the voltage [MEASure:VOLTage:DC?]
inst.measure.voltage.dc()
# or
inst.meas.volt.dc()
# Passing args to a query [MEASure:VOLTage:DC? MIN]
inst.measure.voltage.dc("MIN", query=True)
# Set the voltage to 1 V [MEASure:VOLTage:DC 1]
inst.measure.voltage.dc(1)
# or
inst.source.voltage('1')
# Execute a command to take a reading [SYSTem:ZCORrect:ACQuire]
inst.syst.zcor.aqc('')
```
### Full
#### For use with Tektronix PWS4305
```python
import easy_scpi as scpi
class PowerSupply( scpi.Instrument ):
def __init__( self ):
super().__init__(
port = None,
timeout = 5000,
read_termination = '\n',
write_termination = '\n'
)
# other initialization code...
@property
def voltage(self):
"""
Returns the voltage setting.
"""
return self.source.volt.level()
@voltage.setter
def voltage(self, volts):
"""
Sets the voltage of the instrument.
"""
self.source.volt.level(volts)
@property
def current(self):
"""
Returns the current setting in Amps
"""
return self.source.current.level()
@current.setter
def current(self, amps):
"""
Set the current of the instrument
"""
self.source.current.level(amps)
def on(self):
"""
Turns the output on
"""
self.output.state('on')
def off(self):
"""
Turns the output off
"""
self.output.state('off')
```
Raw data
{
"_id": null,
"home_page": null,
"name": "easy-scpi",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "scpi",
"author": null,
"author_email": "Brian Carlsen <carlsen.bri@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/f9/74/f6eb533dc6d61a8edfbe609bb52354047b8d7cf2fa4dac6cea244fd1b517/easy_scpi-0.1.7.tar.gz",
"platform": null,
"description": "# Easy SCPI\nA simple and robust library making communication with [SCPI](https://en.wikipedia.org/wiki/Standard_Commands_for_Programmable_Instruments) (Standard Control of Programmbale Instruments) instruments easy. After creating an instrument object that connects to an actual instrument, commands are sent to the instrument using a property-like format. This class is useful for inheritance when creating a controller for a specific instrument. Communication with instruments is done with [PyVISA](https://pyvisa.readthedocs.io).\n\n## Install\n`python -m pip install easy-scpi`\n\n## API\n### SCPI Commands\nGeneric SCPI commands can be executed by transforming the SCPI code in to attributes via the hierarchy relationship, then calling it. Instrument properties can be queried by passing no arguments to the call (or specifying query=True). Commands with no arguments are run by passing an empty string to the call.\n\n## Examples\nFor more examples see the [`examples`](./examples) folder.\n\n### Basic\n```python\n# import package\nimport easy_scpi as scpi \n\n# Connect to an instrument\ninst = scpi.Instrument(<port>)\ninst.connect()\n\n# Read the voltage [MEASure:VOLTage:DC?]\ninst.measure.voltage.dc()\n# or\ninst.meas.volt.dc()\n\n# Passing args to a query [MEASure:VOLTage:DC? MIN]\ninst.measure.voltage.dc(\"MIN\", query=True)\n\n# Set the voltage to 1 V [MEASure:VOLTage:DC 1]\ninst.measure.voltage.dc(1)\n# or\ninst.source.voltage('1')\n\n# Execute a command to take a reading [SYSTem:ZCORrect:ACQuire]\ninst.syst.zcor.aqc('')\n```\n\n### Full \n#### For use with Tektronix PWS4305\n```python\nimport easy_scpi as scpi\n\nclass PowerSupply( scpi.Instrument ):\n def __init__( self ):\n super().__init__( \n port = None, \n timeout = 5000,\n read_termination = '\\n', \n write_termination = '\\n' \n )\n\n # other initialization code...\n\n @property \n def voltage(self):\n \"\"\"\n Returns the voltage setting.\n \"\"\"\n return self.source.volt.level()\n \n @voltage.setter\n def voltage(self, volts):\n \"\"\"\n Sets the voltage of the instrument.\n \"\"\"\n self.source.volt.level(volts)\n \n @property\n def current(self):\n \"\"\"\n Returns the current setting in Amps\n \"\"\"\n return self.source.current.level()\n \n @current.setter\n def current(self, amps):\n \"\"\"\n Set the current of the instrument\n \"\"\"\n self.source.current.level(amps)\n \n def on(self):\n \"\"\"\n Turns the output on\n \"\"\"\n self.output.state('on')\n \n def off(self):\n \"\"\"\n Turns the output off\n \"\"\"\n self.output.state('off')\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "An easy library for controlling SCPI instruments.",
"version": "0.1.7",
"project_urls": {
"Homepage": "https://github.com/bicarlsen/easy-scpi",
"Issues": "https://github.com/bicarlsen/easy-scpi/issues",
"Source": "https://github.com/bicarlsen/easy-scpi"
},
"split_keywords": [
"scpi"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "273276b8bc505b28b40a9835a04ff62d47b006fd88600a5e7d8d07d3235f74d7",
"md5": "1b752c48f0d691df5b71e827728d83bc",
"sha256": "f69dba785acf83a5da6b09d54a400127732c9e27228e28243d198dc28d117846"
},
"downloads": -1,
"filename": "easy_scpi-0.1.7-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "1b752c48f0d691df5b71e827728d83bc",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 11141,
"upload_time": "2024-12-21T06:07:20",
"upload_time_iso_8601": "2024-12-21T06:07:20.274182Z",
"url": "https://files.pythonhosted.org/packages/27/32/76b8bc505b28b40a9835a04ff62d47b006fd88600a5e7d8d07d3235f74d7/easy_scpi-0.1.7-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "f974f6eb533dc6d61a8edfbe609bb52354047b8d7cf2fa4dac6cea244fd1b517",
"md5": "c476f49f97b2e3fd2d77e9d88ff54f01",
"sha256": "0f2ceb898acb7b34b1a0038f3ffc8918ed741133b39584ca79b7332eff96566b"
},
"downloads": -1,
"filename": "easy_scpi-0.1.7.tar.gz",
"has_sig": false,
"md5_digest": "c476f49f97b2e3fd2d77e9d88ff54f01",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 10732,
"upload_time": "2024-12-21T06:07:24",
"upload_time_iso_8601": "2024-12-21T06:07:24.045313Z",
"url": "https://files.pythonhosted.org/packages/f9/74/f6eb533dc6d61a8edfbe609bb52354047b8d7cf2fa4dac6cea244fd1b517/easy_scpi-0.1.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-21 06:07:24",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "bicarlsen",
"github_project": "easy-scpi",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "easy-scpi"
}