Skip to content

Commit

Permalink
Commit for LabVIEW compatibility
Browse files Browse the repository at this point in the history
LabVIEW does not support dicts and complex numbers, use of arrays as replacements.
  • Loading branch information
maxkrapp1 committed Jun 24, 2024
1 parent e40ef47 commit 4a682e5
Show file tree
Hide file tree
Showing 14 changed files with 610 additions and 447 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- run: python3 -m pip install --upgrade build && python3 -m build
Expand Down
12 changes: 6 additions & 6 deletions Examples/BCMuxInterface/BCMuxInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


class BCMuxInterface:
"""BC-Mux control class.
r"""BC-Mux control class.
With this class the `BC-MUX Multiplexer <https://zahner.de/products-details/multiplexer/bc-mux>`_ can
be controlled remotely without the BC-Mux Controller software.
Expand Down Expand Up @@ -36,15 +36,15 @@ def __init__(self, ip, port):
return

def close(self):
"""Closing the connection.
r"""Closing the connection.
Disconnects the TCP/IP connection to the BC-MUX.
"""
self.socket.close()
return

def connectChannel(self, channel):
"""Connects the channel to the zennium.
r"""Connects the channel to the zennium.
With this command, a channel is disconnected from the cyclizer and switched to the Zennium,
for example for impedance measurements.
Expand All @@ -57,7 +57,7 @@ def connectChannel(self, channel):
return self._executeCommandAndReadReply(command.format(channel))

def disconnectChannel(self):
"""Disconnects all channels from the zennium.
r"""Disconnects all channels from the zennium.
All channels are disconnected from the Zennium and switched to the specific cyclizer channel.
Expand All @@ -68,7 +68,7 @@ def disconnectChannel(self):
return self._executeCommandAndReadReply(command)

def setPulseLength(self, length):
"""Setting the relais control.
r"""Setting the relais control.
The BC-MUX supports switchboxes containing monostable or bistable relais. With this command,
the control of the relais is set.
Expand All @@ -84,7 +84,7 @@ def setPulseLength(self, length):
return self._executeCommandAndReadReply(command.format(length))

def _executeCommandAndReadReply(self, command):
"""Private function to send a command to the device and read a string.
r"""Private function to send a command to the device and read a string.
This command sends the command to the device and returns the response from the device.
Expand Down
196 changes: 125 additions & 71 deletions Examples/ExternalDeviceFRA/ExternalDeviceFRA.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# FRA measurements with 3rd party devices\n",
"# FRA-X measurements with 3rd party devices\n",
"\n",
"If sources or sinks have analog interfaces for control, it is possible to use them for impedance measurement with Thales and the [FRA probe](https://www.zahner.de/products-details/probes/fra-probe).\n",
"\n",
Expand All @@ -13,13 +13,12 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 84,
"metadata": {},
"outputs": [],
"source": [
"import sys\n",
"from thales_remote.connection import ThalesRemoteConnection\n",
"from thales_remote.script_wrapper import PotentiostatMode,ThalesRemoteScriptWrapper\n",
"from thales_remote.script_wrapper import PotentiostatMode, ThalesRemoteScriptWrapper\n",
"import time"
]
},
Expand All @@ -32,17 +31,33 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 85,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"devel version\n"
]
},
{
"data": {
"text/plain": [
"'128,ScriptRemote,5,6,0,0'"
]
},
"execution_count": 85,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"zenniumConnection = ThalesRemoteConnection()\n",
"zenniumConnection.connectToTerm(\"192.168.2.47\", \"ScriptRemote\")\n",
"\n",
"if __name__ == \"__main__\":\n",
" zenniumConnection = ThalesRemoteConnection()\n",
" zenniumConnection.connectToTerm(\"localhost\", \"ScriptRemote\")\n",
" \n",
" zahnerZennium = ThalesRemoteScriptWrapper(zenniumConnection)\n",
" zahnerZennium.forceThalesIntoRemoteScript()"
"zahnerZennium = ThalesRemoteScriptWrapper(zenniumConnection)\n",
"zahnerZennium.forceThalesIntoRemoteScript()"
]
},
{
Expand All @@ -64,48 +79,73 @@
"\n",
"This results in the settings of the gains in the following lines of code. It may be, as in this example, that some gains must have a negative sign. This must be tested with the respective device.\n",
"\n",
"The FRA probe has a maximum +-10 V target signal and one input each for +-10 V current and voltage signal.\n",
"\n",
"The source must be controlled separately so that the analog interface is used, the source is switched on and off or for potentiostatic and galvanostatic. The Thales software only provides the analog signals, everything else must be done via the device interface.\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 86,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"'OK\\r'"
]
},
"execution_count": 86,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
" zahnerZennium.disableFraMode()\n",
" \n",
" zahnerZennium.setFraVoltageMinimum(0)\n",
" zahnerZennium.setFraVoltageMaximum(18)\n",
" zahnerZennium.setFraCurrentMinimum(0)\n",
" zahnerZennium.setFraCurrentMaximum(220)\n",
" \n",
" zahnerZennium.setFraVoltageInputGain(18.0/5.0)\n",
" zahnerZennium.setFraVoltageOutputGain(18.0/5.0)\n",
" zahnerZennium.setFraCurrentInputGain(-220.0/5.0)\n",
" zahnerZennium.setFraCurrentOutputGain(-220.0/5.0)\n",
" \n",
" zahnerZennium.setFraPotentiostatMode(PotentiostatMode.POTMODE_GALVANOSTATIC)"
"zahnerZennium.enableFraMode()"
]
},
{
"cell_type": "markdown",
"cell_type": "code",
"execution_count": 87,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'OK\\r'"
]
},
"execution_count": 87,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"After parameterization the FRA mode can be switched on."
"zahnerZennium.setFraVoltageMinimum(0)\n",
"zahnerZennium.setFraVoltageMaximum(18)\n",
"zahnerZennium.setFraCurrentMinimum(0)\n",
"zahnerZennium.setFraCurrentMaximum(220)\n",
"\n",
"zahnerZennium.setFraVoltageInputGain(5 * (4 / 5)) # gain * (4 / 5)\n",
"zahnerZennium.setFraVoltageInputOffset(-25e-3)\n",
"\n",
"zahnerZennium.setFraVoltageOutputGain(18.0/5.0)\n",
"zahnerZennium.setFraVoltageOutputOffset(-0.3)\n",
"\n",
"zahnerZennium.setFraCurrentInputGain(-242)\n",
"zahnerZennium.setFraCurrentInputOffset(-15.03)\n",
"\n",
"zahnerZennium.setFraCurrentOutputGain(-220.0/5.0)\n",
"zahnerZennium.setFraCurrentOutputOffset(-3)\n",
"\n",
"zahnerZennium.setFraPotentiostatMode(PotentiostatMode.POTMODE_GALVANOSTATIC)\n",
"zahnerZennium.setCurrent(0)"
]
},
{
"cell_type": "code",
"execution_count": null,
"cell_type": "markdown",
"metadata": {},
"outputs": [],
"source": [
" zahnerZennium.enableFraMode()\n",
" zahnerZennium.setCurrent(0)"
"After parameterization the FRA mode can be switched on."
]
},
{
Expand All @@ -121,26 +161,42 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 88,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Potential:\t0.004607167\tV\n",
"Potential:\t1.913566\tV\n",
"Potential:\t3.952542\tV\n",
"Potential:\t6.068166\tV\n",
"Potential:\t8.130561\tV\n"
"Potential:\t0.0005221556\tV\n",
"Current:\t0.04569409\tA\n",
"Potential:\t0.01014815\tV\n",
"Current:\t1.006116\tA\n",
"Potential:\t0.01979393\tV\n",
"Current:\t2.000953\tA\n",
"Potential:\t0.02997681\tV\n",
"Current:\t3.007906\tA\n",
"Potential:\t0.04010656\tV\n",
"Current:\t3.994758\tA\n",
"Potential:\t0.05025365\tV\n",
"Current:\t5.002351\tA\n",
"Potential:\t0.05973741\tV\n",
"Current:\t6.009117\tA\n",
"Potential:\t0.06979417\tV\n",
"Current:\t7.020814\tA\n",
"Potential:\t0.07994695\tV\n",
"Current:\t8.008658\tA\n",
"Potential:\t0.09013592\tV\n",
"Current:\t9.006383\tA\n"
]
}
],
"source": [
" for i in range(5):\n",
" zahnerZennium.setCurrent(i)\n",
" time.sleep(1)\n",
" print(f\"Potential:\\t{zahnerZennium.getPotential()}\\tV\")"
"for i in range(10):\n",
" zahnerZennium.setCurrent(i)\n",
" time.sleep(0.5)\n",
" print(f\"Potential:\\t{zahnerZennium.getPotential()}\\tV\")\n",
" print(f\"Current:\\t{zahnerZennium.getCurrent()}\\tA\")"
]
},
{
Expand All @@ -153,7 +209,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 89,
"metadata": {},
"outputs": [
{
Expand All @@ -165,29 +221,27 @@
}
],
"source": [
" zahnerZennium.setEISOutputPath(r\"C:\\THALES\\temp\\test1\")\n",
" zahnerZennium.setEISNaming(\"counter\")\n",
" zahnerZennium.setEISCounter(13)\n",
" zahnerZennium.setEISOutputFileName(\"spectra\")\n",
"\n",
" zahnerZennium.setAmplitude(0.5)\n",
" zahnerZennium.setCurrent(5)\n",
" zahnerZennium.setLowerFrequencyLimit(0.1)\n",
" zahnerZennium.setStartFrequency(10)\n",
" zahnerZennium.setUpperFrequencyLimit(100)\n",
" zahnerZennium.setLowerNumberOfPeriods(3)\n",
" zahnerZennium.setLowerStepsPerDecade(2)\n",
" zahnerZennium.setUpperNumberOfPeriods(20)\n",
" zahnerZennium.setUpperStepsPerDecade(3)\n",
" zahnerZennium.setScanDirection(\"startToMax\")\n",
" zahnerZennium.setScanStrategy(\"single\")\n",
" \n",
" zahnerZennium.measureEIS()\n",
" \n",
" zahnerZennium.disableFraMode()\n",
"\n",
" zenniumConnection.disconnectFromTerm()\n",
" print(\"finish\")"
"zahnerZennium.setEISOutputPath(r\"C:\\THALES\\temp\\test1\")\n",
"zahnerZennium.setEISNaming(\"counter\")\n",
"zahnerZennium.setEISCounter(13)\n",
"zahnerZennium.setEISOutputFileName(\"spectra\")\n",
"\n",
"zahnerZennium.setCurrent(10)\n",
"zahnerZennium.setAmplitude(2)\n",
"zahnerZennium.setLowerFrequencyLimit(1)\n",
"zahnerZennium.setStartFrequency(1000)\n",
"zahnerZennium.setUpperFrequencyLimit(10e3)\n",
"zahnerZennium.setLowerNumberOfPeriods(3)\n",
"zahnerZennium.setLowerStepsPerDecade(2)\n",
"zahnerZennium.setUpperNumberOfPeriods(20)\n",
"zahnerZennium.setUpperStepsPerDecade(3)\n",
"zahnerZennium.setScanDirection(\"startToMax\")\n",
"zahnerZennium.setScanStrategy(\"single\")\n",
"\n",
"zahnerZennium.measureEIS()\n",
"\n",
"zenniumConnection.disconnectFromTerm()\n",
"print(\"finish\")"
]
}
],
Expand All @@ -207,7 +261,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.1 (tags/v3.11.1:a7a450f, Dec 6 2022, 19:58:39) [MSC v.1934 64 bit (AMD64)]"
"version": "3.12.2"
},
"orig_nbformat": 4,
"vscode": {
Expand Down
Loading

0 comments on commit 4a682e5

Please sign in to comment.