Skip to content

Commit ad6209c

Browse files
committed
update ALPACA docs
1 parent 49ad140 commit ad6209c

8 files changed

Lines changed: 272 additions & 70 deletions

File tree

book/manuals/intros/alpaca2/_intro.ipynb

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -116,22 +116,6 @@
116116
"\n",
117117
"Curious on how ALPACA was programmed? The software is open source and can be found [here](https://github.com/NB-TUDelft/ALPACA)."
118118
]
119-
},
120-
{
121-
"cell_type": "code",
122-
"execution_count": null,
123-
"id": "2a964b54",
124-
"metadata": {},
125-
"outputs": [],
126-
"source": [
127-
"pico = \"\"\n",
128-
"\n",
129-
"@pico.task\n",
130-
"def update_screen():\n",
131-
" import helper\n",
132-
"\n",
133-
" helper.set_screen_text(\"Hello\", \"Alpaca:)\")"
134-
]
135119
}
136120
],
137121
"metadata": {

book/manuals/intros/alpaca2/programming.ipynb

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@
7272
"increment()\n",
7373
"print(i) # Even if it didn't error, it would print 1\n",
7474
"```\n",
75+
"\n",
76+
"```{figure} ../images/alpaca/bad_coding_practices.png\n",
77+
"---\n",
78+
"max-height: 300px\n",
79+
"name: ALPACA doesn't know what i is\n",
80+
"class: no-invert\n",
81+
"---\n",
82+
"```\n",
7583
":::\n",
7684
"\n",
7785
":::{admonition} DO\n",
@@ -89,6 +97,14 @@
8997
"i = increment(i)\n",
9098
"print(i) # 2\n",
9199
"```\n",
100+
"\n",
101+
"```{figure} ../images/alpaca/good_coding_practices.png\n",
102+
"---\n",
103+
"max-height: 300px\n",
104+
"name: ALPACA does know what i is\n",
105+
"class: no-invert\n",
106+
"---\n",
107+
"```\n",
92108
":::\n",
93109
"\n",
94110
"## Dealing with data\n",
@@ -103,17 +119,49 @@
103119
"\n",
104120
"# Modules\n",
105121
"\n",
106-
"Some modules aren't available in ALPACA and some modules aren't available in the computer. These are the **modules that are available on ALPACA only:**\n",
122+
"Some modules aren't available in ALPACA and some modules aren't available in the computer. These are the **modules that are available on ALPACA only** you have to import them inside the functions.\n",
107123
"\n",
108124
"## `machine` - functions related to the hardware\n",
109125
"\n",
110126
"This module contains functions to control hardware on ALPACA like the digital pins or the analog to digital converter. You will explore this module while [working with signals](./signals.ipynb).\n",
111127
"\n",
128+
"## `helper` - functions to talk with Helper Pico\n",
129+
"\n",
130+
"Helper Pico controls several functions on ALPACA board itself. You can send the following commands:\n",
131+
"\n",
132+
"\n",
133+
"| Function | Description |\n",
134+
"|----------|--------------|\n",
135+
"| `set_screen_text(text_up: string, text_down: string)` | Sets the text on `CSTM` display on the LCD panel |\n",
136+
"\n",
137+
"<span style=\"background:#ff1493;color:#fff;padding:2px 8px;border-radius:4px;font-weight:700;font-size:0.85em;box-shadow:0 0 6px rgba(255,20,147,0.6);\">🚩 TODO: Add FuncGen implementation add AWG as deep dive.</span>\n",
138+
"\n",
139+
"\n",
140+
"The `CSTM` screen is connected to Helper Pico, so you can send a command to change the text\n",
141+
"\n",
142+
"```python\n",
143+
"@pico.task\n",
144+
"def change_text_on_screen():\n",
145+
" import helper\n",
146+
"\n",
147+
" helper.set_screen_text(\"Hello :)\", \"Alpaca\")\n",
148+
"```\n",
112149
"\n",
113150
"## `utime` - time related functions\n",
114151
"\n",
115152
"When working with signals you need to deal with time-senstivity at microscale. `utime` provides functions for this exact purpose.\n",
116153
"\n",
154+
"| Function | Description |\n",
155+
"|----------|--------------|\n",
156+
"| `sleep(sec: float)` | Sleep (waits) for a given number of **seconds** (can be a float) |\n",
157+
"| `sleep_ms(ms: int)` | Sleep (waits) for a given number of **milliseconds** |\n",
158+
"| `sleep_us(us: int)` | Sleep (waits) for a given number of **microseconds** |\n",
159+
"| `ticks` | Returns current uptime (now) in **seconds** |\n",
160+
"| `ticks_us` | Returns current uptime (now) in **ms** |\n",
161+
"| `ticks_ms` | Returns current uptime (now) in **us** |\n",
162+
"| `ticks_diff(a, b)` | Perform a-b on ticks |\n",
163+
"| `ticks_add(a, b)` | Perform a+b on ticks |\n",
164+
"\n",
117165
"```python\n",
118166
"@pico.task\n",
119167
"def blink_led():\n",
@@ -186,7 +234,7 @@
186234
"metadata": {},
187235
"source": [
188236
"\n",
189-
"But the <font color=\"#00819b\">tick</font> itself is never useful cause sometimes <font color=\"#00819b\">**it rollsover to 0 (as it can't count forever)**</font> (see the figure above). Therefore, using `utime.ticks_add(a, b)` and `utime.ticks_diff(a, b)` (basically a + b and a - b) is <font color=\"#00819b\">**essential**</font> when calculating time.\n",
237+
"But the <font color=\"#00819b\">tick</font> itself is never useful cause sometimes <font color=\"#00819b\">**it rollsover to 0 (as it can't count forever)**</font> (see the figure above). So just doing `tick_a - tick_b` can give invalid results, using `utime.ticks_add(a, b)` and `utime.ticks_diff(a, b)` (basically a + b and a - b) is <font color=\"#00819b\">**essential**</font> when calculating time.\n",
190238
"\n",
191239
"```python\n",
192240
"@pico.task\n",
@@ -209,7 +257,12 @@
209257
" total += adc0.read_u16()\n",
210258
"\n",
211259
" return total * 3.3 / 2**16 / n\n",
212-
"```"
260+
"```\n",
261+
"\n",
262+
"\n",
263+
"## `dac` - digital-to-analog converter\n",
264+
"\n",
265+
"See [Digital-to-Analog Converter](./signals.ipynb#generation-dac-digital-to-analog-converter)."
213266
]
214267
}
215268
],

book/manuals/intros/alpaca2/signals.ipynb

Lines changed: 197 additions & 47 deletions
Large diffs are not rendered by default.
73.1 KB
Loading
58.4 KB
Loading
42.5 KB
Loading

book/manuals/intros/software_installation.ipynb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@
1919
"\n",
2020
"For this course, you will need a separate conda environment called `ei-env`:\n",
2121
"\n",
22-
"<span style=\"background:#ff1493;color:#fff;padding:2px 8px;border-radius:4px;font-weight:700;font-size:0.85em;box-shadow:0 0 6px rgba(255,20,147,0.6);\">🚩 TODO: create ei-env.yaml and link it</span>\n",
23-
"\n",
24-
"\n",
25-
"1. **Download the `ei-env.yaml` file and save it.**\n",
22+
"1. **Download the [`ei-env.yaml`](../../static/env.yaml) file and save it.**\n",
2623
"\n",
2724
"2. **Go to the directory:** Open Terminal (macOS) or Command Prompt (Windows), then change directory to the location of `ei-env.yaml`.\n",
2825
"\n",

book/static/ei-env.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: ei-env
2+
channels:
3+
- conda-forge
4+
- defaults
5+
dependencies:
6+
- python>=3.18
7+
- pip
8+
- pandas
9+
- matplotlib
10+
- seaborn
11+
- numpy
12+
- scipy
13+
- pip:
14+
- ipykernel
15+
- ipywidgets
16+
- alpaca-stubs
17+
- micropython-rp2-stubs
18+
- belay

0 commit comments

Comments
 (0)