diff --git a/drivers/pid_controller/pid_controller.ipynb b/drivers/pid_controller/pid_controller.ipynb index 0a76977e94f0bf4b1eb93b89211b28e685812e82..42837fc24218e281f5685793cdc8401573b40dd5 100644 --- a/drivers/pid_controller/pid_controller.ipynb +++ b/drivers/pid_controller/pid_controller.ipynb @@ -3,17 +3,192 @@ { "cell_type": "code", "execution_count": 1, - "id": "7e06b69d", + "id": "a9d77d5f", "metadata": {}, "outputs": [], "source": [ - "import pidcontroller" + "import pidcontroller\n", + "import pqwsw2\n", + "import rl20001\n", + "import serial" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "id": "19a0cd26", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Smart Switch Connected Successfully\n" + ] + } + ], + "source": [ + "mySwitch = pqwsw2.PQWSW2('192.168.254.1')\n" + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "id": "6429c02c", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "mySwitch.getState()" ] }, { "cell_type": "code", "execution_count": 59, - "id": "dc086560", + "id": "47a4b917", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "135.9" + ] + }, + "execution_count": 59, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "mySwitch.getPower()" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "id": "99c554eb", + "metadata": {}, + "outputs": [], + "source": [ + "mySwitch.turnOn()" + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "id": "4073a63f", + "metadata": {}, + "outputs": [], + "source": [ + "mySwitch.turnOff()" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "id": "2611e40e", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Numato USB Relay Connected Successfully\n" + ] + } + ], + "source": [ + "relay = rl20001.RL20001('COM6')" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "id": "f191cd93", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "RL20001: Communication Error Detected\n" + ] + } + ], + "source": [ + "relay.getState()" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8a441d0a", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "41805be6", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "dbdb50c6", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "22f02a53", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "8fe65477", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b9973c09", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "f304c6e7", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "10c9ce89", "metadata": {}, "outputs": [ { @@ -30,8 +205,29 @@ }, { "cell_type": "code", - "execution_count": 63, - "id": "134b77e1", + "execution_count": 15, + "id": "686bf2c5", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[31.007989, 30.825624, 30.906236, 30.27842, 30.121736]" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "controller.getTemperatures()" + ] + }, + { + "cell_type": "code", + "execution_count": 74, + "id": "93835e25", "metadata": {}, "outputs": [ { @@ -40,7 +236,7 @@ "';'" ] }, - "execution_count": 63, + "execution_count": 74, "metadata": {}, "output_type": "execute_result" } @@ -49,14 +245,15 @@ "controller._sendCommand('P2.254;')\n", "controller._sendCommand('I0.0014;')\n", "controller._sendCommand('D100.348;')\n", - "controller._sendCommand('N370.75;')\n", + "controller._sendCommand('N340.75;')\n", + "controller._sendCommand('E0.5;')\n", "controller._sendCommand('S31.0;')" ] }, { "cell_type": "code", - "execution_count": 64, - "id": "f35f5556", + "execution_count": 75, + "id": "5fcb4a0f", "metadata": {}, "outputs": [ { @@ -65,7 +262,7 @@ "'2.254000,0.001400,100.348000;'" ] }, - "execution_count": 64, + "execution_count": 75, "metadata": {}, "output_type": "execute_result" } @@ -76,17 +273,17 @@ }, { "cell_type": "code", - "execution_count": 115, - "id": "bcf2eedd", + "execution_count": 76, + "id": "915d1fe7", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'-0.027327,381.741730,-0.000098;'" + "'0.262481,342.299172,0.001700;'" ] }, - "execution_count": 115, + "execution_count": 76, "metadata": {}, "output_type": "execute_result" } @@ -97,17 +294,17 @@ }, { "cell_type": "code", - "execution_count": 116, - "id": "ec963ad6", + "execution_count": 77, + "id": "163897bf", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'31.027632,30.811564,30.906875,30.280394,30.118540;'" + "'30.732702,30.754168,30.753851,30.138579,29.942677;'" ] }, - "execution_count": 116, + "execution_count": 77, "metadata": {}, "output_type": "execute_result" } @@ -118,51 +315,70 @@ }, { "cell_type": "code", - "execution_count": 117, - "id": "5965db64", + "execution_count": 80, + "id": "2704803d", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'0.464288;'" + "';'" ] }, - "execution_count": 117, + "execution_count": 80, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "controller._sendCommand('o')" + "controller._sendCommand('?')" ] }, { "cell_type": "code", - "execution_count": 58, - "id": "e1c88aaf", + "execution_count": 79, + "id": "5fd95fee", "metadata": {}, "outputs": [ { - "ename": "TypeError", - "evalue": "connect() missing 1 required positional argument: 'port'", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", - "\u001b[1;32m~\\AppData\\Local\\Temp/ipykernel_34064/1597917223.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mcontroller\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mconnect\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m", - "\u001b[1;31mTypeError\u001b[0m: connect() missing 1 required positional argument: 'port'" - ] + "data": { + "text/plain": [ + "'0.900000;'" + ] + }, + "execution_count": 79, + "metadata": {}, + "output_type": "execute_result" } ], + "source": [ + "controller._sendCommand('o')" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "2fa51f26", + "metadata": {}, + "outputs": [], "source": [ "controller.disconnect()" ] }, + { + "cell_type": "code", + "execution_count": 81, + "id": "f23cc2e3", + "metadata": {}, + "outputs": [], + "source": [ + "controller.ser.close()" + ] + }, { "cell_type": "code", "execution_count": null, - "id": "7154d4dd", + "id": "227a9eed", "metadata": {}, "outputs": [], "source": []