RBComb 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. rbcomb-0.2.0/Examples/ArbiPhase.ipynb +240 -0
  2. rbcomb-0.2.0/Examples/Example Scope captures/ArbiPhase/Detail.png +0 -0
  3. rbcomb-0.2.0/Examples/Example Scope captures/ArbiPhase/Full sequence.png +0 -0
  4. rbcomb-0.2.0/Examples/Example Scope captures/Sweeps/Full sequence.png +0 -0
  5. rbcomb-0.2.0/Examples/Example Scope captures/Sweeps/Sweep details.png +0 -0
  6. rbcomb-0.2.0/Examples/Example Scope captures/UniformBraiding/Braiding sequence.png +0 -0
  7. rbcomb-0.2.0/Examples/FrequencySweep.ipynb +292 -0
  8. rbcomb-0.2.0/Examples/PascalPlayground.ipynb +266 -0
  9. rbcomb-0.2.0/Examples/Playground.ipynb +288 -0
  10. rbcomb-0.2.0/Examples/README.md +8 -0
  11. rbcomb-0.2.0/Examples/RogueDrum.ipynb +8193 -0
  12. rbcomb-0.2.0/Examples/SetOutputInteractive.ipynb +280 -0
  13. rbcomb-0.2.0/Examples/SimpleLaserExample-original.ipynb +428 -0
  14. rbcomb-0.2.0/Examples/SoftwareLockin.ipynb +1443 -0
  15. rbcomb-0.2.0/Examples/TightBinding.ipynb +767 -0
  16. rbcomb-0.2.0/Examples/UniformBraiding.ipynb +417 -0
  17. rbcomb-0.2.0/Examples/data/coefficients_A.npy +0 -0
  18. rbcomb-0.2.0/Examples/data/coefficients_B.npy +0 -0
  19. rbcomb-0.2.0/PKG-INFO +18 -0
  20. rbcomb-0.2.0/RBComb/Helper/BoardPinout.py +584 -0
  21. rbcomb-0.2.0/RBComb/Helper/BoardPinout.pyc +0 -0
  22. rbcomb-0.2.0/RBComb/Helper/BoardUnits.py +35 -0
  23. rbcomb-0.2.0/RBComb/Helper/BoardUnits.pyc +0 -0
  24. rbcomb-0.2.0/RBComb/Helper/FunctionInterpolator.py +52 -0
  25. rbcomb-0.2.0/RBComb/Helper/FunctionInterpolator.pyc +0 -0
  26. rbcomb-0.2.0/RBComb/Helper/__init__.py +0 -0
  27. rbcomb-0.2.0/RBComb/Helper/__init__.pyc +0 -0
  28. rbcomb-0.2.0/RBComb/Helper/__pycache__/BoardPinout.cpython-36.pyc +0 -0
  29. rbcomb-0.2.0/RBComb/Helper/__pycache__/BoardUnits.cpython-36.pyc +0 -0
  30. rbcomb-0.2.0/RBComb/Helper/__pycache__/FunctionInterpolator.cpython-36.pyc +0 -0
  31. rbcomb-0.2.0/RBComb/Helper/__pycache__/__init__.cpython-36.pyc +0 -0
  32. rbcomb-0.2.0/RBComb/LaserInterface.py +103 -0
  33. rbcomb-0.2.0/RBComb/RBComb576.py +131 -0
  34. rbcomb-0.2.0/RBComb/SerialBridge.py +75 -0
  35. rbcomb-0.2.0/RBComb/__init__.py +0 -0
  36. rbcomb-0.2.0/RBComb.egg-info/PKG-INFO +18 -0
  37. rbcomb-0.2.0/RBComb.egg-info/SOURCES.txt +41 -0
  38. rbcomb-0.2.0/RBComb.egg-info/dependency_links.txt +1 -0
  39. rbcomb-0.2.0/RBComb.egg-info/requires.txt +2 -0
  40. rbcomb-0.2.0/RBComb.egg-info/top_level.txt +1 -0
  41. rbcomb-0.2.0/pyproject.toml +8 -0
  42. rbcomb-0.2.0/setup.cfg +4 -0
  43. rbcomb-0.2.0/setup.py +19 -0
@@ -0,0 +1,240 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 1,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "import numpy as np;\n",
10
+ "import time;"
11
+ ]
12
+ },
13
+ {
14
+ "cell_type": "code",
15
+ "execution_count": 2,
16
+ "metadata": {},
17
+ "outputs": [],
18
+ "source": [
19
+ "from RBComb.SerialBridge import *\n",
20
+ "from RBComb.RBComb576 import *\n",
21
+ "from RBComb.Helper.BoardPinout import *\n",
22
+ "from RBComb.Helper.BoardUnits import *;\n",
23
+ "from RBComb.Helper.FunctionInterpolator import *"
24
+ ]
25
+ },
26
+ {
27
+ "cell_type": "code",
28
+ "execution_count": 3,
29
+ "metadata": {},
30
+ "outputs": [],
31
+ "source": [
32
+ "# This document shows how 2 signal generators wit positive/negative amplitude can be combined\n",
33
+ "# to make a single signal generator with arbitrary phase.\n",
34
+ "# This is done by phase-shifting one of the generators by 90 degrees so it acts as the imaginary\n",
35
+ "# part of the amplitude."
36
+ ]
37
+ },
38
+ {
39
+ "cell_type": "code",
40
+ "execution_count": 4,
41
+ "metadata": {},
42
+ "outputs": [],
43
+ "source": [
44
+ "# Construct bridge:\n",
45
+ "currentBridge = SerialBridge('/dev/tty.usbserial-FT35HA60B', True, 300);\n",
46
+ "\n",
47
+ "# Note: the correct baud rate is 5'000'000 but it is not supported in Mac OS X\n",
48
+ "# The solution is to modify the serial port driver so it aliases (\"pretends\") to be working at a standard\n",
49
+ "# rate of 300, but in reality it works at 5000000. This is done by modifying /Library/Extensions/FTDIUSBSerialDriver.kext\n",
50
+ "# following the guide https://www.ftdichip.com/Support/Documents/TechnicalNotes/TN_105%20Adding%20Support%20for%20New%20FTDI%20Devices%20to%20Mac%20Driver.pdf\n",
51
+ "# And subsequently disabling the \"trusted platform\" features of mac since it would no longer accept the modified extension"
52
+ ]
53
+ },
54
+ {
55
+ "cell_type": "code",
56
+ "execution_count": 5,
57
+ "metadata": {},
58
+ "outputs": [],
59
+ "source": [
60
+ "# Construct RBComb576\n",
61
+ "rbComb = RBComb576(currentBridge);"
62
+ ]
63
+ },
64
+ {
65
+ "cell_type": "code",
66
+ "execution_count": 6,
67
+ "metadata": {},
68
+ "outputs": [],
69
+ "source": [
70
+ "# Construct helper objects:\n",
71
+ "pinout = BoardPinout();\n",
72
+ "units = BoardUnits();"
73
+ ]
74
+ },
75
+ {
76
+ "cell_type": "code",
77
+ "execution_count": 7,
78
+ "metadata": {},
79
+ "outputs": [],
80
+ "source": [
81
+ "# We must make sure the clock is disabled, otherwise the boards cannot hear us\n",
82
+ "# as the bridge does not forward commands when the clock is on:\n",
83
+ "rbComb.disableClock()\n",
84
+ "\n",
85
+ "# Select all boards\n",
86
+ "rbComb.selectAllBoards()\n",
87
+ "\n",
88
+ "# Ramp up (won't take effect until turning on the clock)\n",
89
+ "rbComb.outputRampUp();"
90
+ ]
91
+ },
92
+ {
93
+ "cell_type": "code",
94
+ "execution_count": 8,
95
+ "metadata": {
96
+ "scrolled": true
97
+ },
98
+ "outputs": [],
99
+ "source": [
100
+ "# We use the interpolator to raise the signal to V/2 as the output cannot take negative values\n",
101
+ "interpolator = FunctionInterpolator();\n",
102
+ "constantFunction = interpolator.getConstantFunction(0.5)\n",
103
+ "\n",
104
+ "# Upload offset function to the device (Takes 10 seconds, do only once per \"session\")\n",
105
+ "for i in range(576):\n",
106
+ " rbComb.setTaylorCoefficients(i, False, constantFunction);"
107
+ ]
108
+ },
109
+ {
110
+ "cell_type": "code",
111
+ "execution_count": 9,
112
+ "metadata": {},
113
+ "outputs": [],
114
+ "source": [
115
+ "# Parameters for the sine generators\n",
116
+ "frequency = 1000.0; # 1 KHz\n",
117
+ "\n",
118
+ "# Amplitudes and phases are independent for every channel:\n",
119
+ "amplitudes = np.array([units.convertNormalizedAmplitudeToInteger(0.5)]*576); \n",
120
+ "phases = np.array([0]*576); # In degrees.\n",
121
+ "\n",
122
+ "# We will phase shift the output 2,2 by 45 degrees:\n",
123
+ "phases[pinout.getOutputNumber(2,2)] = 45;"
124
+ ]
125
+ },
126
+ {
127
+ "cell_type": "code",
128
+ "execution_count": 10,
129
+ "metadata": {},
130
+ "outputs": [],
131
+ "source": [
132
+ "# Compute real and imaginary amplitudes\n",
133
+ "amplitude_real = amplitudes*np.cos(phases*np.pi/180);\n",
134
+ "amplitude_imag = amplitudes*np.sin(phases*np.pi/180);"
135
+ ]
136
+ },
137
+ {
138
+ "cell_type": "code",
139
+ "execution_count": 11,
140
+ "metadata": {},
141
+ "outputs": [],
142
+ "source": [
143
+ "# Configure the two sine generators:\n",
144
+ "\n",
145
+ "# Ensure that the two signal generators are on. This is the default state at power-on, but may be\n",
146
+ "# affected by previously run experiments if the board has not been unpowered:\n",
147
+ "rbComb.setCurrentState([1,1,0,0,0]);\n",
148
+ "\n",
149
+ "# Configure phases:\n",
150
+ "rbComb.setPhase(0, units.convertDegreesPhaseToInteger(0))\n",
151
+ "rbComb.setPhase(1, units.convertDegreesPhaseToInteger(90))\n",
152
+ "\n",
153
+ "# Configure frequencies:\n",
154
+ "rbComb.setFrequency(0, units.convertFrequencyHzToInteger(frequency))\n",
155
+ "rbComb.setFrequency(1, units.convertFrequencyHzToInteger(frequency))\n",
156
+ "\n",
157
+ "# Make sure that the generators don't sweep\n",
158
+ "for i in range(4):\n",
159
+ " rbComb.setSweepFrequencyStep(i,0);\n",
160
+ "\n",
161
+ "# Configure amplitudes:\n",
162
+ "for i in range(576):\n",
163
+ " rbComb.setAmplitude(0,i,int(amplitude_real[i]));\n",
164
+ " rbComb.setAmplitude(1,i,int(amplitude_imag[i]));\n",
165
+ " # Switch off the other two generators by setting their amplitudes to zero:\n",
166
+ " rbComb.setAmplitude(2,i,0);\n",
167
+ " rbComb.setAmplitude(3,i,0);"
168
+ ]
169
+ },
170
+ {
171
+ "cell_type": "code",
172
+ "execution_count": 12,
173
+ "metadata": {},
174
+ "outputs": [],
175
+ "source": [
176
+ "# Perform experiment:\n",
177
+ "rbComb.outputRampUp();\n",
178
+ "rbComb.enableClock();\n",
179
+ "time.sleep(6);\n",
180
+ "rbComb.disableClock()"
181
+ ]
182
+ },
183
+ {
184
+ "cell_type": "code",
185
+ "execution_count": 13,
186
+ "metadata": {},
187
+ "outputs": [],
188
+ "source": [
189
+ "# Ramp down the output\n",
190
+ "rbComb.outputRampDown();\n",
191
+ "rbComb.enableClock();\n",
192
+ "time.sleep(4);\n",
193
+ "rbComb.disableClock()"
194
+ ]
195
+ },
196
+ {
197
+ "cell_type": "code",
198
+ "execution_count": 14,
199
+ "metadata": {},
200
+ "outputs": [],
201
+ "source": [
202
+ "# Close the serial port:\n",
203
+ "currentBridge.closeConnection()"
204
+ ]
205
+ }
206
+ ],
207
+ "metadata": {
208
+ "kernelspec": {
209
+ "display_name": "Python 3",
210
+ "language": "python",
211
+ "name": "python3"
212
+ },
213
+ "language_info": {
214
+ "codemirror_mode": {
215
+ "name": "ipython",
216
+ "version": 2
217
+ },
218
+ "file_extension": ".py",
219
+ "mimetype": "text/x-python",
220
+ "name": "python",
221
+ "nbconvert_exporter": "python",
222
+ "pygments_lexer": "ipython2",
223
+ "version": "2.7.15"
224
+ },
225
+ "toc": {
226
+ "nav_menu": {},
227
+ "number_sections": true,
228
+ "sideBar": true,
229
+ "skip_h1_title": false,
230
+ "title_cell": "Table of Contents",
231
+ "title_sidebar": "Contents",
232
+ "toc_cell": false,
233
+ "toc_position": {},
234
+ "toc_section_display": true,
235
+ "toc_window_display": false
236
+ }
237
+ },
238
+ "nbformat": 4,
239
+ "nbformat_minor": 2
240
+ }
@@ -0,0 +1,292 @@
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "code",
5
+ "execution_count": 12,
6
+ "metadata": {},
7
+ "outputs": [],
8
+ "source": [
9
+ "import numpy as np;\n",
10
+ "import time;"
11
+ ]
12
+ },
13
+ {
14
+ "cell_type": "code",
15
+ "execution_count": 13,
16
+ "metadata": {},
17
+ "outputs": [],
18
+ "source": [
19
+ "from RBComb.SerialBridge import *\n",
20
+ "from RBComb.RBComb576 import *\n",
21
+ "from RBComb.Helper.BoardPinout import *\n",
22
+ "from RBComb.Helper.BoardUnits import *;\n",
23
+ "from RBComb.Helper.FunctionInterpolator import *"
24
+ ]
25
+ },
26
+ {
27
+ "cell_type": "code",
28
+ "execution_count": 14,
29
+ "metadata": {},
30
+ "outputs": [
31
+ {
32
+ "ename": "SerialException",
33
+ "evalue": "[Errno 2] could not open port /dev/tty.usbserial-FT3HPF65B: [Errno 2] No such file or directory: '/dev/tty.usbserial-FT3HPF65B'",
34
+ "output_type": "error",
35
+ "traceback": [
36
+ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
37
+ "\u001b[0;31mSerialException\u001b[0m Traceback (most recent call last)",
38
+ "\u001b[0;32m<ipython-input-14-20f2b423cf90>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;31m# Construct bridge:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mcurrentBridge\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mSerialBridge\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'/dev/tty.usbserial-FT3HPF65B'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mTrue\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m300\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m;\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 3\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 4\u001b[0m \u001b[0;31m# Note: the correct baud rate is 5'000'000 but it is not supported in Mac OS X\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;31m# The solution is to modify the serial port driver so it aliases (\"pretends\") to be working at a standard\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
39
+ "\u001b[0;32m/Users/control/Desktop/RBComb API and Firmware/Python API/RBComb/SerialBridge.pyc\u001b[0m in \u001b[0;36m__init__\u001b[0;34m(self, serialPort, alwaysOpen, baudRate)\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbaudRate\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mbaudRate\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0malwaysOpen\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 9\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mserialHandle\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mserial\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mSerial\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mserialPort\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbaudRate\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mbytesize\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m8\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstopbits\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m;\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 10\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 11\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0msendArray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtransferBuffer\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
40
+ "\u001b[0;32m/usr/local/lib/python2.7/site-packages/serial/serialutil.pyc\u001b[0m in \u001b[0;36m__init__\u001b[0;34m(self, port, baudrate, bytesize, parity, stopbits, timeout, xonxoff, rtscts, write_timeout, dsrdtr, inter_byte_timeout, exclusive, **kwargs)\u001b[0m\n\u001b[1;32m 238\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 239\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mport\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 240\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 241\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 242\u001b[0m \u001b[0;31m# - - - - - - - - - - - - - - - - - - - - - - - -\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
41
+ "\u001b[0;32m/usr/local/lib/python2.7/site-packages/serial/serialposix.pyc\u001b[0m in \u001b[0;36mopen\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 266\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mOSError\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mmsg\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 267\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfd\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mNone\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 268\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mSerialException\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmsg\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0merrno\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"could not open port {}: {}\"\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mformat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_port\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmsg\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 269\u001b[0m \u001b[0;31m#~ fcntl.fcntl(self.fd, fcntl.F_SETFL, 0) # set blocking\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 270\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
42
+ "\u001b[0;31mSerialException\u001b[0m: [Errno 2] could not open port /dev/tty.usbserial-FT3HPF65B: [Errno 2] No such file or directory: '/dev/tty.usbserial-FT3HPF65B'"
43
+ ]
44
+ }
45
+ ],
46
+ "source": [
47
+ "# Construct bridge:\n",
48
+ "currentBridge = SerialBridge('/dev/tty.usbserial-FT3HPF65B', True, 300);\n",
49
+ "\n",
50
+ "# Note: the correct baud rate is 5'000'000 but it is not supported in Mac OS X\n",
51
+ "# The solution is to modify the serial port driver so it aliases (\"pretends\") to be working at a standard\n",
52
+ "# rate of 300, but in reality it works at 5000000. This is done by modifying /Library/Extensions/FTDIUSBSerialDriver.kext\n",
53
+ "# following the guide https://www.ftdichip.com/Support/Documents/TechnicalNotes/TN_105%20Adding%20Support%20for%20New%20FTDI%20Devices%20to%20Mac%20Driver.pdf\n",
54
+ "# And subsequently disabling the \"trusted platform\" features of mac since it would no longer accept the modified extension"
55
+ ]
56
+ },
57
+ {
58
+ "cell_type": "code",
59
+ "execution_count": 15,
60
+ "metadata": {},
61
+ "outputs": [],
62
+ "source": [
63
+ "# Construct RBComb576\n",
64
+ "rbComb = RBComb576(currentBridge);"
65
+ ]
66
+ },
67
+ {
68
+ "cell_type": "code",
69
+ "execution_count": 16,
70
+ "metadata": {},
71
+ "outputs": [],
72
+ "source": [
73
+ "# Construct helper objects:\n",
74
+ "pinout = BoardPinout();\n",
75
+ "units = BoardUnits();"
76
+ ]
77
+ },
78
+ {
79
+ "cell_type": "code",
80
+ "execution_count": null,
81
+ "metadata": {},
82
+ "outputs": [],
83
+ "source": [
84
+ "# We must make sure the clock is disabled, otherwise the boards cannot hear us\n",
85
+ "rbComb.disableClock()\n",
86
+ "\n",
87
+ "# Select all boards\n",
88
+ "rbComb.selectAllBoards()"
89
+ ]
90
+ },
91
+ {
92
+ "cell_type": "code",
93
+ "execution_count": null,
94
+ "metadata": {
95
+ "scrolled": true
96
+ },
97
+ "outputs": [],
98
+ "source": [
99
+ "# We use the interpolator to raise the signal to V/2 as the output cannot take negative values\n",
100
+ "interpolator = FunctionInterpolator();\n",
101
+ "constantFunction = interpolator.getConstantFunction(0.5)\n",
102
+ "\n",
103
+ "# Upload offset function to the device (Takes 10 seconds, do only once per \"session\")\n",
104
+ "for i in range(576):\n",
105
+ " rbComb.setTaylorCoefficients(i, False, constantFunction);"
106
+ ]
107
+ },
108
+ {
109
+ "cell_type": "code",
110
+ "execution_count": null,
111
+ "metadata": {},
112
+ "outputs": [],
113
+ "source": [
114
+ "# Parameters for the sweep\n",
115
+ "frequencySweepStart = 500; # 1 KHz\n",
116
+ "frequencySweepEnd = 5000; # 5 KHz\n",
117
+ "sweepDuration = 40e-3; # 20 msec\n",
118
+ "amplitudes = np.array([units.convertNormalizedAmplitudeToInteger(1.0)]*576); # We set all channels to max amplitude (could also use different amps per channel)."
119
+ ]
120
+ },
121
+ {
122
+ "cell_type": "code",
123
+ "execution_count": null,
124
+ "metadata": {},
125
+ "outputs": [],
126
+ "source": [
127
+ "# Configure amplitudes\n",
128
+ "for i in range(576):\n",
129
+ " rbComb.setAmplitude(0,i,amplitudes[i]);\n",
130
+ " rbComb.setAmplitude(1,i,0);\n",
131
+ " rbComb.setAmplitude(2,i,0);\n",
132
+ " rbComb.setAmplitude(3,i,0);"
133
+ ]
134
+ },
135
+ {
136
+ "cell_type": "code",
137
+ "execution_count": null,
138
+ "metadata": {},
139
+ "outputs": [],
140
+ "source": [
141
+ "# Configure frequencies and phases:\n",
142
+ "\n",
143
+ "# Start frequency\n",
144
+ "rbComb.setFrequency(0,units.convertFrequencyHzToInteger(frequencySweepStart));\n",
145
+ "\n",
146
+ "\n",
147
+ "# Frequency step>:\n",
148
+ "rbComb.setSweepFrequencyStep(0,units.convertFrequencyRangeToSweepSpeed(frequencySweepStart, \n",
149
+ " frequencySweepEnd, sweepDuration));\n",
150
+ "\n",
151
+ "# Frequency end:\n",
152
+ "rbComb.setSweepFrequencyMax(0,units.convertFrequencyHzToInteger(frequencySweepEnd));\n",
153
+ "\n",
154
+ "rbComb.setPhase(0,0);\n",
155
+ "rbComb.setPhase(1,0);\n",
156
+ "rbComb.setPhase(2,0);\n",
157
+ "rbComb.setPhase(3,0);"
158
+ ]
159
+ },
160
+ {
161
+ "cell_type": "code",
162
+ "execution_count": null,
163
+ "metadata": {},
164
+ "outputs": [],
165
+ "source": [
166
+ "# Ramp up the output up with the generators \"frozen\":\n",
167
+ "rbComb.outputRampUp();\n",
168
+ "rbComb.setCurrentState([0,0,0,0,0]);\n",
169
+ "\n",
170
+ "rbComb.enableClock()\n",
171
+ "time.sleep(4);\n",
172
+ "rbComb.disableClock()"
173
+ ]
174
+ },
175
+ {
176
+ "cell_type": "code",
177
+ "execution_count": null,
178
+ "metadata": {},
179
+ "outputs": [],
180
+ "source": [
181
+ "# Run experiment\n",
182
+ "\n",
183
+ "# Unfreeze first generator:\n",
184
+ "rbComb.setCurrentState([1,0,0,0,0]);\n",
185
+ "\n",
186
+ "# Schedule re-freezing of the first generator once the sweep is finished\n",
187
+ "rbComb.setNextState([0,0,0,0,0], units.convertTimeToSteps(sweepDuration));\n",
188
+ "\n",
189
+ "# Run one sweep:\n",
190
+ "rbComb.enableClock()\n",
191
+ "time.sleep(0.5);\n",
192
+ "rbComb.disableClock()"
193
+ ]
194
+ },
195
+ {
196
+ "cell_type": "code",
197
+ "execution_count": null,
198
+ "metadata": {},
199
+ "outputs": [],
200
+ "source": [
201
+ "# Now run 5 sweeps. This shows that once the system is set up, it is possible to run sweeps very fast\n",
202
+ "# Transients are avoided by not re-setting the phase to zero after each sweep.\n",
203
+ "for i in range(5):\n",
204
+ " # Unfreeze first generator:\n",
205
+ " rbComb.setCurrentState([1,0,0,0,0]);\n",
206
+ "\n",
207
+ " # Schedule re-freezing of the first generator once the sweep is finished\n",
208
+ " rbComb.setNextState([0,0,0,0,0], units.convertTimeToSteps(sweepDuration));\n",
209
+ "\n",
210
+ " # Go back to the initial frequency:\n",
211
+ " rbComb.setFrequency(0,units.convertFrequencyHzToInteger(frequencySweepStart));\n",
212
+ " \n",
213
+ " # Run the sweep:\n",
214
+ " rbComb.enableClock()\n",
215
+ " time.sleep(0.1);\n",
216
+ " rbComb.disableClock()"
217
+ ]
218
+ },
219
+ {
220
+ "cell_type": "code",
221
+ "execution_count": null,
222
+ "metadata": {},
223
+ "outputs": [],
224
+ "source": [
225
+ "# Ramp down the output\n",
226
+ "rbComb.outputRampDown();\n",
227
+ "rbComb.enableClock()\n",
228
+ "time.sleep(4);\n",
229
+ "rbComb.disableClock()"
230
+ ]
231
+ },
232
+ {
233
+ "cell_type": "code",
234
+ "execution_count": 11,
235
+ "metadata": {},
236
+ "outputs": [],
237
+ "source": [
238
+ "currentBridge.closeConnection()"
239
+ ]
240
+ },
241
+ {
242
+ "cell_type": "code",
243
+ "execution_count": 9,
244
+ "metadata": {},
245
+ "outputs": [],
246
+ "source": [
247
+ "rbComb.enableClock();\n",
248
+ "rbComb.selectAllBoards();"
249
+ ]
250
+ },
251
+ {
252
+ "cell_type": "code",
253
+ "execution_count": null,
254
+ "metadata": {},
255
+ "outputs": [],
256
+ "source": []
257
+ }
258
+ ],
259
+ "metadata": {
260
+ "kernelspec": {
261
+ "display_name": "Python 3",
262
+ "language": "python",
263
+ "name": "python3"
264
+ },
265
+ "language_info": {
266
+ "codemirror_mode": {
267
+ "name": "ipython",
268
+ "version": 2
269
+ },
270
+ "file_extension": ".py",
271
+ "mimetype": "text/x-python",
272
+ "name": "python",
273
+ "nbconvert_exporter": "python",
274
+ "pygments_lexer": "ipython2",
275
+ "version": "2.7.15"
276
+ },
277
+ "toc": {
278
+ "nav_menu": {},
279
+ "number_sections": true,
280
+ "sideBar": true,
281
+ "skip_h1_title": false,
282
+ "title_cell": "Table of Contents",
283
+ "title_sidebar": "Contents",
284
+ "toc_cell": false,
285
+ "toc_position": {},
286
+ "toc_section_display": true,
287
+ "toc_window_display": false
288
+ }
289
+ },
290
+ "nbformat": 4,
291
+ "nbformat_minor": 2
292
+ }