commit fc21959a0c4481b5f9725702e9e24df6458a7c46 from: ale date: Sat Aug 1 05:52:56 2026 UTC Reorganize examples/ into one folder per demo, track the personal ones Every example is now its own self-contained folder (matching the arquimedes/matlab-laser-mic pattern that was already here), instead of a flat mix of loose .md files and asset folders. Updates the few repo-root-relative paths that pointed at the old flat layout: Makefile, docs/development, custom_theme.md's theme path, and preprocess.md's import path. arquimedes/ and matlab-laser-mic/ are no longer gitignored -- they're real presentations built with this fork, worth keeping versioned instead of local-only. commit - 97a534a90733f873f1ed2846bc82a2d016797ccb commit + fc21959a0c4481b5f9725702e9e24df6458a7c46 blob - c13d40130ab9288d30d00873846d76289864ac96 blob + 831bfad5f935135afedacb20444085599ba04f44 --- .gitignore +++ .gitignore @@ -6,7 +6,3 @@ slides_ed25519.pub # Nix /result /result-* - -# personal example presentations, kept local only -/examples/arquimedes/ -/examples/matlab-laser-mic/ blob - 27bcda5977b43916edd3038856a27ed24b69c17e blob + 0b70a52b8c80dd3783b50d00115be46103ae3dd3 --- Makefile +++ Makefile @@ -1,5 +1,5 @@ make: - go run main.go examples/slides.md + go run main.go examples/basics/slides.md test: go test ./... -short blob - 6833fc7c9e81360319e09d86f3f7fb25d676951b blob + a671321cc109bac88daa11b4dc666a54eb76c2a6 --- README.md +++ README.md @@ -58,7 +58,7 @@ run a code block, `y` to yank one, `gg`/`G` to jump to slide. `slides` also reads from `stdin` and reloads live on file changes. Frontmatter (`theme`, `author`, `date`, `paging`, `bibliography`) is -optional — see [examples/metadata.md](./examples/metadata.md). +optional — see [examples/basics/metadata.md](./examples/basics/metadata.md). See [examples/](./examples) for every feature above in a working presentation: LaTeX, images, GIFs, bibliography, reveal, Julia plots, and blob - 57ebeac41bf18c77ab8071158dc40c813509f98a blob + cbea198576f9e744a5bac6d83b05bedd88f27d87 --- docs/development/README.md +++ docs/development/README.md @@ -5,7 +5,7 @@ Make changes, and test them by running: make ``` -This will run `go run main.go examples/slides.md`, you can then ensure +This will run `go run main.go examples/basics/slides.md`, you can then ensure everything still works. If you're adding a feature that requires a specific piece of markdown, you can @@ -18,7 +18,7 @@ make test ### Breaking Changes Most changes should be entirely backwards compatible. -Ensure that `slides examples/slides.md` still works. +Ensure that `slides examples/basics/slides.md` still works. ### Codebase Initialization (command-line interface, defaults) happens in [`cmd/root.go`](../../cmd/root.go). blob - 9786c2aa3f397876ff0ec5ac0d1c2abc7cb63ac6 (mode 644) blob + /dev/null --- examples/ascii_slides.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -theme: ascii ---- - -# Welcome to Slides -A terminal based presentation tool - -```go -package main - -import "fmt" - -func main() { - fmt.Println("Written in Go!") -} -``` - ---- - -## Everything is markdown -In fact this entire presentation is a markdown file - ---- - -# h1 -## h2 -### h3 -#### h4 -##### h5 -###### h6 - -# Markdown components -You can use everything in markdown! -* Like bulleted list -* You know the deal - -1. Numbered lists too - -| Tables | Too | -| ------ | ------ | -| Even | Tables | - ---- - -All you need to do is separate slides with triple dashes `---` on a separate line, -like so: - -```markdown -# Slide 1 -Some stuff - ---- - -# Slide 2 -Some other stuff -``` blob - /dev/null blob + 65369c4c13da976ba267632fc3eae6ee3f01be2b (mode 644) Binary files /dev/null and examples/arquimedes/images/empuje_vs_volumen.png differ blob - /dev/null blob + c581881c800ffd9b510b8ccbc63a7946fea10494 (mode 644) --- /dev/null +++ examples/arquimedes/presentation.md @@ -0,0 +1,97 @@ +--- +author: Bernal, Falcón, Moedano, Morales +date: 2026-07-31 +paging: Slide %d / %d +bibliography: refs.bib +--- + +# El Principio de Arquímedes + +### Licenciatura en Física y Tecnología Avanzada + +*Bernal Estrada Alejandro · Falcón Martínez Noelia Nallely +Moedano Romero Ismeray Esmeralda · Morales García Yoceline* + +--- + +## Resumen + +Se verificó experimentalmente el Principio de Arquímedes midiendo la fuerza +de empuje ejercida por tres fluidos (agua, glicerina y alcohol) sobre +distintos objetos. + +Se pesó cada objeto en aire y sumergido para obtener el empuje experimental. +Los resultados concuerdan razonablemente con la teoría, y permitieron +calcular las densidades de los fluidos desconocidos con un margen de error +aceptable. + +--- + +## Introducción + +El Principio de Arquímedes establece que todo cuerpo sumergido en un fluido +experimenta una fuerza de empuje vertical hacia arriba, igual al peso del +fluido desalojado. + +**Objetivo:** comprobar esta relación y usarla para caracterizar las +propiedades de distintos fluidos. + +--- + +## Marco teórico + +La fuerza de empuje $E$ se define como: + +$$E = \rho_f \cdot V_s \cdot g = W_{aire} - W_{fluido}$$ + +Donde $\rho_f$ es la densidad del fluido, $V_s$ el volumen sumergido y $g$ +la gravedad. + +--- + +## Datos en agua + +Se usó agua (ρ = 1000 kg/m³) para determinar el volumen de cada objeto. + +| Objeto | W aire (N) | W fluido (N) | E (N) | V (10⁻⁵ m³) | +|-------------|-----------:|--------------:|------:|-------------:| +| Cil. Latón | 2.033 | 1.792 | 0.241 | 2.46 | +| Cil. Alum. | 0.641 | 0.400 | 0.241 | 2.46 | +| Cubo Latón | 0.637 | 0.563 | 0.074 | 0.75 | +| Cubo Alum. | 0.641 | 0.401 | 0.240 | 2.45 | +| Forma Alum. | 0.644 | 0.401 | 0.243 | 2.48 | + +--- + +## Comparación de empuje + +La relación entre volumen y fuerza de empuje en los tres fluidos es +claramente lineal, lo que valida el principio de Arquímedes. + +![Relación entre empuje y volumen en los tres fluidos.](images/empuje_vs_volumen.png "Relación entre empuje y volumen en los tres fluidos.") + +--- + +## Densidades calculadas + +A partir de los volúmenes obtenidos se calcularon las densidades de los +fluidos desconocidos. + +| Objeto | ρ Glicerina (kg/m³) | ρ Alcohol (kg/m³) | +|--------------|---------------------:|--------------------:| +| Cil. Latón | 1302.9 | 800.8 | +| Cubo Latón | 1364.9 | 635.1 | +| Cubo Alum. | 1279.2 | 766.7 | +| Cil. Alum. | 1273.9 | 813.3 | +| Forma Alum. | 1271.6 | 901.2 | +| **Promedio** | **1298.5** | **783.4** | + +--- + +## Conclusión + +Se verificó que la fuerza de empuje depende directamente del volumen +sumergido y la densidad del fluido. + +Los valores promedio obtenidos (ρ Glicerina ≈ 1298 kg/m³, ρ Alcohol ≈ 783 +kg/m³) son consistentes con los valores bibliográficos [@young2019university][@serway2018physics]. blob - /dev/null blob + 4b4140ba33c1b9a54870dd1ebc6068a8a65f2474 (mode 644) --- /dev/null +++ examples/arquimedes/refs.bib @@ -0,0 +1,13 @@ +@book{young2019university, + author = {Young, Hugh D. and Freedman, Roger A.}, + title = {University Physics with Modern Physics}, + publisher = {Pearson}, + year = {2019}, +} + +@book{serway2018physics, + author = {Serway, Raymond A. and Jewett, John W.}, + title = {Physics for Scientists and Engineers}, + publisher = {Cengage}, + year = {2018}, +} blob - 7bb2550f5781a0cfe6afefc2ece12b75588671c3 (mode 644) blob + /dev/null --- examples/code_blocks.md +++ /dev/null @@ -1,194 +0,0 @@ -# Code blocks - -Slides allows you to execute code blocks directly inside your slides! - -Just press `ctrl+e` and the result of the code block will be displayed as virtual text in your slides. - -Currently supported languages: - - - -* `bash` -* `zsh` -* `fish` -* `elixir` -* `go` -* `javascript` -* `python` -* `ruby` -* `perl` -* `rust` -* `java` -* `cpp` -* `swift` -* `dart` -* `v` - - ---- - -### Bash - -```bash -ls -``` - ---- - -### Zsh - -```zsh -ls -``` - ---- - -### Fish - -```fish -ls -``` - ---- - -### Elixir - -```elixir -IO.puts "Hello, world!" -``` - ---- - -### Go - -Use `///` to hide verbose code but still allow the ability to execute it. - -If you press `y` to copy (yank) this code block it will return the full snippet. - -And, if you press `ctrl+e` it will run the program without error, even though -what is being displayed is not a valid go program because we have commented out -some boilerplate to focus on the important parts. - -```go -///package main -/// -import "fmt" -/// -///func main() { -fmt.Println("Hello, world!") -///} -``` - ---- - -### Javascript - -```javascript -console.log("Hello, world!") -``` - ---- - -### Lua - -```lua -print("Hello, World!") -``` - ---- - -### Python - -```python -print("Hello, world!") -``` - ---- - -### Ruby - -```ruby -puts "Hello, world!" -``` - ---- - -### Perl - -```perl -print ("hello, world"); -``` - ---- - -### Rust - -```rust -fn main() { - println!("Hello, world!"); -} -``` - ---- - -### Java -```java -public class Main { - public static void main(String[] args) { - System.out.println("Hello, world!"); - } -} -``` - ---- - -### Julia -```julia -println("Hello, world!") -``` - ---- - -### C++ -```cpp -#include - -int main() { - std::cout << "Hello, world!" << std::endl; - return 0; -} -``` - ---- - -### Swift -```swift -print("Hello, world!") -``` - ---- - -### Dart -```dart -void main() { - print("Hello, world!"); -} -``` - -### V - -```v -println('Hello, world!') -``` - ---- - -### Scala - -```scala -//> using dep com.lihaoyi::pprint:0.8.1 - -object Main extends App { - println("Hello") -} -``` blob - /dev/null blob + 9786c2aa3f397876ff0ec5ac0d1c2abc7cb63ac6 (mode 644) --- /dev/null +++ examples/basics/ascii_slides.md @@ -0,0 +1,56 @@ +--- +theme: ascii +--- + +# Welcome to Slides +A terminal based presentation tool + +```go +package main + +import "fmt" + +func main() { + fmt.Println("Written in Go!") +} +``` + +--- + +## Everything is markdown +In fact this entire presentation is a markdown file + +--- + +# h1 +## h2 +### h3 +#### h4 +##### h5 +###### h6 + +# Markdown components +You can use everything in markdown! +* Like bulleted list +* You know the deal + +1. Numbered lists too + +| Tables | Too | +| ------ | ------ | +| Even | Tables | + +--- + +All you need to do is separate slides with triple dashes `---` on a separate line, +like so: + +```markdown +# Slide 1 +Some stuff + +--- + +# Slide 2 +Some other stuff +``` blob - /dev/null blob + f5e16264e2583551519bb4205459b3e9b349f64c (mode 644) --- /dev/null +++ examples/basics/metadata.md @@ -0,0 +1,31 @@ +--- +author: Gopher +date: May 22, 2022 +paging: Page %d of %d +--- + +# Metadata Example + +Customize the bottom information bar by adding metadata to your `slides.md` file. + +``` +--- +author: Gopher +date: May 22, 2022 +paging: Page %d of %d +--- +``` + +--- + +# Metadata Example + +You can also hide the bottom bar by leaving all of the fields blank + +``` +--- +author: "" +date: "" +paging: "" +--- +``` blob - /dev/null blob + f2440ed5d89b73adc9f56c8a0b9ef3920d96e740 (mode 644) --- /dev/null +++ examples/basics/slides.md @@ -0,0 +1,74 @@ +# Welcome to Slides +A terminal based presentation tool + +```go +package main + +import "fmt" + +func main() { + fmt.Println("Written in Go!") +} +``` + +--- + +## Everything is markdown +In fact this entire presentation is a markdown file + +--- + +# h1 +## h2 +### h3 +#### h4 +##### h5 +###### h6 + +--- + +# Markdown components +You can use everything in markdown! +* Like bulleted list +* You know the deal + +1. Numbered lists too + +--- + +# Tables + +| Tables | Too | +| ------ | ------ | +| Even | Tables | + +--- + +# Graphs + +``` +digraph { + rankdir = LR; + a -> b; + b -> c; +} +``` +``` +┌───┐ ┌───┐ ┌───┐ +│ a │ ──▶ │ b │ ──▶ │ c │ +└───┘ └───┘ └───┘ +``` +--- + +All you need to do is separate slides with triple dashes +`---` on a separate line, like so: + +```markdown +# Slide 1 +Some stuff + +--- + +# Slide 2 +Some other stuff +``` blob - 3762b645e9093ef9f44eee1409c0f76c84fc11df (mode 644) blob + /dev/null --- examples/custom_remote_theme.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -theme: https://github.com/maaslalani/slides/raw/main/styles/theme.json ---- - -# Slides - -The theme of this slide is fetched from https://github.com/maaslalani/slides/raw/main/styles/theme.json, the title above should be green. blob - /dev/null blob + 7bb2550f5781a0cfe6afefc2ece12b75588671c3 (mode 644) --- /dev/null +++ examples/code-execution/code_blocks.md @@ -0,0 +1,194 @@ +# Code blocks + +Slides allows you to execute code blocks directly inside your slides! + +Just press `ctrl+e` and the result of the code block will be displayed as virtual text in your slides. + +Currently supported languages: + + + +* `bash` +* `zsh` +* `fish` +* `elixir` +* `go` +* `javascript` +* `python` +* `ruby` +* `perl` +* `rust` +* `java` +* `cpp` +* `swift` +* `dart` +* `v` + + +--- + +### Bash + +```bash +ls +``` + +--- + +### Zsh + +```zsh +ls +``` + +--- + +### Fish + +```fish +ls +``` + +--- + +### Elixir + +```elixir +IO.puts "Hello, world!" +``` + +--- + +### Go + +Use `///` to hide verbose code but still allow the ability to execute it. + +If you press `y` to copy (yank) this code block it will return the full snippet. + +And, if you press `ctrl+e` it will run the program without error, even though +what is being displayed is not a valid go program because we have commented out +some boilerplate to focus on the important parts. + +```go +///package main +/// +import "fmt" +/// +///func main() { +fmt.Println("Hello, world!") +///} +``` + +--- + +### Javascript + +```javascript +console.log("Hello, world!") +``` + +--- + +### Lua + +```lua +print("Hello, World!") +``` + +--- + +### Python + +```python +print("Hello, world!") +``` + +--- + +### Ruby + +```ruby +puts "Hello, world!" +``` + +--- + +### Perl + +```perl +print ("hello, world"); +``` + +--- + +### Rust + +```rust +fn main() { + println!("Hello, world!"); +} +``` + +--- + +### Java +```java +public class Main { + public static void main(String[] args) { + System.out.println("Hello, world!"); + } +} +``` + +--- + +### Julia +```julia +println("Hello, world!") +``` + +--- + +### C++ +```cpp +#include + +int main() { + std::cout << "Hello, world!" << std::endl; + return 0; +} +``` + +--- + +### Swift +```swift +print("Hello, world!") +``` + +--- + +### Dart +```dart +void main() { + print("Hello, world!"); +} +``` + +### V + +```v +println('Hello, world!') +``` + +--- + +### Scala + +```scala +//> using dep com.lihaoyi::pprint:0.8.1 + +object Main extends App { + println("Hello") +} +``` blob - 550262b5bd2630880261b87e75095b6764ec5153 (mode 644) blob + /dev/null --- examples/custom_theme.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -theme: ./examples/theme.json ---- - -# Slides - -The above title should be orange and be prefixed with `CUSTOM`. blob - /dev/null blob + f662ff07f62effed028259d51fc6a0349e803774 (mode 644) --- /dev/null +++ examples/gif/gif.md @@ -0,0 +1,19 @@ +--- +author: Gopher +paging: Slide %d / %d +--- + +# Animated GIFs + +`![alt](path.gif)` plays back for real, looping, entirely on the +terminal's side -- once the frames are sent there's nothing left for +`slides` to do every tick. + +--- + +# Simple pendulum + +Generated with Julia (Plots.jl + GR): θ(t) = θ₀ cos(ωt), one frame per +render, transparent background, colors matching this theme. + +![Simple pendulum swinging under gravity](images/pendulum.gif) blob - /dev/null blob + c10c61a7e80d05b0d0f855d6595195e85e8e37b8 (mode 644) Binary files /dev/null and examples/gif/images/pendulum.gif differ blob - f662ff07f62effed028259d51fc6a0349e803774 (mode 644) blob + /dev/null --- examples/gif.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -author: Gopher -paging: Slide %d / %d ---- - -# Animated GIFs - -`![alt](path.gif)` plays back for real, looping, entirely on the -terminal's side -- once the frames are sent there's nothing left for -`slides` to do every tick. - ---- - -# Simple pendulum - -Generated with Julia (Plots.jl + GR): θ(t) = θ₀ cos(ωt), one frame per -render, transparent background, colors matching this theme. - -![Simple pendulum swinging under gravity](images/pendulum.gif) blob - /dev/null blob + 741f9b276a37a7b8fb18170ef6e3084d97843096 (mode 644) --- /dev/null +++ examples/julia/julia.md @@ -0,0 +1,66 @@ +--- +author: Gopher +paging: Slide %d / %d +--- + +# Julia plots + +Press `ctrl+e` on a Julia code block to run it. Text output (like +UnicodePlots) shows up right on the slide; if the code saves an image file +(`savefig`/`save`), it's shown below the output as a real image. + +First run of each library can take a while (Julia precompiles it) -- +that's expected, not a hang. + +--- + +### UnicodePlots.jl + +Draws straight to stdout, so it needs no image at all. + +```julia +using UnicodePlots +println(lineplot(1:100, x -> sin(x / 5), title="sin(x / 5)")) +``` + +--- + +### Plots.jl + GR + +`GKSwstype` is set automatically so this never tries to open a window. + +```julia +using Plots +gr() +plot(1:100, x -> cos(x / 5), title="cos(x / 5)", legend=false) +savefig("plot.png") +``` + +--- + +### CairoMakie + +```julia +using CairoMakie +fig = Figure() +ax = Axis(fig[1, 1], title = "x²") +lines!(ax, 1:100, x -> x^2) +save("fig.png", fig) +``` + +--- + +### An animated GIF from code + +A saved `.gif` is displayed the same way any other executed-code image +is -- and if it has more than one frame, it plays back in a loop just +like a `.gif` referenced directly in markdown. + +```julia +using Plots +gr() +anim = @animate for i in 1:40 + plot(1:100, x -> sin(x / 10 + i / 4), ylim=(-1.2, 1.2), legend=false) +end +gif(anim, "wave.gif", fps=20) +``` blob - c10c61a7e80d05b0d0f855d6595195e85e8e37b8 (mode 644) blob + /dev/null Binary files examples/images/pendulum.gif and /dev/null differ blob - /dev/null blob + 940000ce00347f0a2d5f73413e97ebde8e3203d0 (mode 644) Binary files /dev/null and examples/matlab-laser-mic/images/analisis-svd.png differ blob - /dev/null blob + aa45a717ab7518ce46f005f57f501119b966f69c (mode 644) Binary files /dev/null and examples/matlab-laser-mic/images/diagrama-circuito.png differ blob - /dev/null blob + eb31fa5bdcb417a25981b1aa2f13ae27b2d77559 (mode 644) Binary files /dev/null and examples/matlab-laser-mic/images/montaje-3d.png differ blob - /dev/null blob + fe2d1897d5993de457b1c66529cd12d61afc5f35 (mode 644) Binary files /dev/null and examples/matlab-laser-mic/images/resultados-completos.png differ blob - /dev/null blob + b12e639e9ee2213570f4c387b48552a9914b0272 (mode 644) --- /dev/null +++ examples/matlab-laser-mic/presentation.md @@ -0,0 +1,245 @@ +--- +author: B.E. Alejandro +date: 2026-03-15 +paging: Slide %d / %d +--- + +# Reconstrucción de Sonido con Láser y Fotosensor + +### De la Teoría al Código + +Un proyecto de Física II: ondas, transformadas de Fourier y álgebra lineal +para capturar y reconstruir audio con un haz láser y un fotosensor. + +*Validado completamente en simulación MATLAB antes de construir el hardware.* + +--- + +## ¿Puede un Rayo de Luz Transportar Sonido? + +Pregunta de clase de física: si el sonido vibra el aire, ¿podría esa +vibración modular un haz de luz y recuperarse después? + +**Sí.** El principio: + +- El sonido dentro de una caja insonorizada hace vibrar un panel de vidrio +- Un láser de 650 nm apunta al vidrio; el reflejo modulado lo capta un fotodiodo BPW34 +- La fotocorriente pasa por un TIA (LM358) → voltaje +- Un MAX9814 con AGC amplifica +- MATLAB digitaliza y reconstruye el audio original + +--- + +## El modelo de la señal + +$$V(t) = A \cdot \sin(2\pi f t) + \eta(t)$$ + +donde $\eta(t)$ es el ruido del sistema óptico-electrónico. + +El reto: dado que $\eta(t)$ siempre existe, ¿cómo recuperamos +$A \cdot \sin(2\pi f t)$ con la mayor fidelidad posible? + +Este es el resumen de la **fase de simulación completa en MATLAB** que +valida los algoritmos antes del hardware real. + +--- + +## Fundamentos: Transformada de Fourier + +Cualquier señal periódica se descompone como suma de senos y cosenos. +La DFT lo hace numéricamente: + +$$X[k] = \sum_{n=0}^{N-1} x[n] \cdot e^{-j2\pi kn/N}$$ + +La **FFT** calcula la DFT en $O(N \log N)$ en vez de $O(N^2)$, y acá cumple +dos funciones: + +1. **Identificar** qué frecuencias componen la señal capturada +2. **Filtrar** el ruido eliminando componentes espectrales débiles + +--- + +## Fundamentos: Descomposición SVD + +Conecta con *espacios vectoriales* del semestre. Dada una matriz de +trayectoria $M$ construida a partir de la señal: + +$$M = U \cdot \Sigma \cdot V^T$$ + +Los valores singulares $\sigma_i$ en $\Sigma$ revelan cuántos "modos +independientes" necesita la señal para representarse. + +> **Conexión con el curso:** el SVD es un cambio de base ortogonal. Las +> columnas de $U$ son la nueva base del espacio de la señal, y los valores +> singulares son las coordenadas de importancia de cada vector base — el +> mismo concepto de base ortonormal que vimos en clase. + +--- + +## El Hardware + +| Componente | Función | Parámetro clave | +|---------------------------|-----------------------|--------------------------------------| +| Láser 650nm 5mW | Fuente de luz | Enfocable, soporte Neiko ~30° | +| BPW34 (fotodiodo PIN) | Luz → corriente | R = 0.3 A/W @ 650 nm | +| LM358 (TIA) | Corriente → voltaje | Rf = 10 kΩ, Cf = 100 pF | +| MAX9814 | Amplificador AGC | Av = 40 dB | +| Jack 3.5mm | Interfaz PC | Entrada micrófono, breakout TRRS | +| ESP32 | Alimentación 5V | Pin VIN → rail protoboard | + +El **BPW34** gana sobre un LDR por tiempo de respuesta: 20 ns frente a +~1 ms — audio hasta 20 kHz sin degradación del sensor. + +--- + +## Diagrama del circuito + +![Diagrama de circuito](./images/diagrama-circuito.png "BPW34 → TIA LM358 → MAX9814 → Jack PC") + +--- + +## Montaje experimental + +![Montaje 3D](./images/montaje-3d.png "Simulación 3D del montaje: caja insonorizada, láser, fotodiodo y circuito completo") + +La animación sincroniza la vibración del vidrio con las señales en tiempo +real en cada etapa del pipeline. + +--- + +## Metodología: simulando el pipeline físico completo + +No basta con sumar ruido gaussiano — el modelo simula la cadena física real: +generación → modulación óptica → BPW34 → TIA → MAX9814 → filtrado FFT → +reconstrucción → validación. + +```matlab +function v_out = pipeline_sensor(audio, P_laser, mod_depth, ... + R_bpw34, Rf_TIA, Av_MAX, ruido) + % 1. Modulacion optica: el vidrio vibrante modula el reflejo + P_luz = P_laser * (1 + mod_depth * audio); + + % 2. BPW34: fotocorriente = responsividad x potencia + shot noise + I_foto = R_bpw34 * P_luz + ruido * 1e-4 * randn(size(audio)); + + % 3. TIA LM358: I -> V, eliminar offset DC + V_tia = I_foto * Rf_TIA; + V_tia = V_tia - mean(V_tia); + + % 4. MAX9814: amplificar y saturar (+-1.65V) + V_max = Av_MAX * V_tia; + v_out = max(-1.65, min(1.65, V_max)); +end +``` + +El shot noise del BPW34 es de apenas **0.8%** de la señal, frente al 5% +típico de un LDR. + +--- + +## Las cuatro señales de prueba + +| Señal | Frecuencias | Por qué es interesante | +|-------------------|-----------------------|-------------------------------------| +| Tono puro | 1000 Hz | Caso base, más simple | +| Acorde Do Mayor | 262 + 330 + 392 Hz | Tres frecuencias simultáneas | +| Barrido (chirp) | 100 → 1000 Hz | Frecuencia variable en el tiempo | +| Señal compleja | 262·k Hz, k=1..5 | Serie armónica, simula voz humana | + +--- + +## El algoritmo de reconstrucción + +Máscara binaria sobre el espectro FFT: conserva componentes que superan el +10% del pico máximo, reconstruye con IFFT manteniendo **simetría +hermitiana** para obtener valores reales: + +```matlab +function senial_rec = reconstruir_por_fft(senial_ruidosa) + N = length(senial_ruidosa); + Y = fft(senial_ruidosa); + + mag_pos = abs(Y(1 : floor(N/2) + 1)); + umbral = max(mag_pos) * 0.1; + mascara_pos = double(mag_pos > umbral); + + mascara = zeros(N, 1); + mascara(1 : floor(N/2) + 1) = mascara_pos; + mascara(floor(N/2)+2 : N) = flipud(mascara_pos(2 : floor(N/2))); + + senial_rec = real(ifft(Y .* mascara)); +end +``` + +> **Error que cometí:** usar `N/2` directo para indexar falla cuando `N` +> es impar. La solución: `floor(N/2)` en todos los índices, construyendo +> la simetría conjugada explícitamente. + +--- + +## Resultados: pipeline completo + +![Resultados completos](./images/resultados-completos.png "Ideal, capturado, reconstruido y espectro FFT para las 4 señales") + +La columna "Reconstruido" recupera la forma de onda con fidelidad casi +indistinguible del original, a pesar del ruido visible en "Capturado". + +--- + +## Métricas cuantitativas + +| Señal | Error RMS | SNR (dB) | Correlación | Resultado | +|-----------|-------------|--------------|-------------|------------| +| Tono puro | 2.79 × 10⁻⁶ | **102.1 dB** | 1.0000 | Excelente | +| Acorde | 2.87 × 10⁻⁴ | **62.1 dB** | 1.0000 | Excelente | +| Barrido | 1.06 × 10⁻² | **30.5 dB** | 0.9996 | Muy bueno | +| Compleja | 3.00 × 10⁻⁴ | **63.1 dB** | 1.0000 | Excelente | + +> Un SNR por encima de 20 dB ya es aceptable para voz; por encima de 40 dB +> es transparente para el oído humano. Este sistema: entre 30.5 y 102.1 dB. + +--- + +## Análisis SVD + +![Análisis SVD](./images/analisis-svd.png "Descomposición SVD de la matriz de trayectoria para las 4 señales") + +| Señal | Varianza acumulada (5 modos) | +|-----------|-------------------------------| +| Tono puro | **99.0%** — casi toda la energía en 1–2 modos | +| Acorde | **84.3%** — ~3 modos (uno por frecuencia) | +| Barrido | **9.3%** — energía muy distribuida | +| Compleja | **88.6%** — varios modos armónicos | + +El barrido necesita cientos de vectores singulares: ningún modo fijo +captura una frecuencia que cambia continuamente. + +--- + +## Conclusiones + +1. **El filtrado espectral FFT funciona** — SNR hasta 102.1 dB, correlación 1.0000 en 3 de 4 señales +2. **El barrido es el caso más difícil** — 30.5 dB revela el límite del filtro de umbral fijo; STFT o Wavelet serían mejores +3. **El SVD confirma la teoría** — rango efectivo refleja la complejidad de la señal +4. **El BPW34 supera al LDR** — shot noise de 0.8% vs 5%, se traduce en más SNR +5. **La simulación valida la arquitectura** antes de construir el hardware + +--- + +## Próximos pasos + +- **Montaje físico:** láser sobre soporte Neiko, BPW34 en tubo negro, protoboard 830 puntos +- **Primera captura real:** comparar SNR experimental vs. simulado (objetivo: >20 dB) +- **Señales de prueba:** tono puro → voz → música +- **Futuro:** STFT para mejorar la reconstrucción del chirp + +El siguiente post documenta la construcción del hardware y la primera +captura real de audio. + +--- + +# Gracias + +*Física II — Ondas, Oscilaciones y Espacios Vectoriales* + +Código completo: `github.com/Richard7987/Proyecto-Fisica-2do` blob - dbb8049ecc7d2c389c856ea4eedc17b5d3d6dbf9 (mode 644) blob + /dev/null --- examples/import.md +++ /dev/null @@ -1,2 +0,0 @@ -This is just an example of how to import text from other files with -preprocess.md blob - /dev/null blob + dbb8049ecc7d2c389c856ea4eedc17b5d3d6dbf9 (mode 644) --- /dev/null +++ examples/preprocessing/import.md @@ -0,0 +1,2 @@ +This is just an example of how to import text from other files with +preprocess.md blob - /dev/null blob + 61932c89a2f0db1c2afd7e76eb7ce649548442a6 (mode 755) --- /dev/null +++ examples/preprocessing/preprocess.md @@ -0,0 +1,82 @@ +# Slides + +You can add a code block with three tildes (~) and write a command to run before displaying +the slides, the text inside the code block will be passed as stdin to the command +and the code block will be replaced with the stdout of the command. + +``` +~~~graph-easy --as=boxart +[ A ] - to -> [ B ] +~~~ +``` + +The above will be pre-processed to look like: + +NOTE: You need `graph-easy` installed and in your `$PATH` + +``` +┌───┐ to ┌───┐ +│ A │ ────> │ B │ +└───┘ └───┘ +``` + +For security reasons, you must pass a file that has execution permissions +for the slides to be pre-processed. + +``` +chmod +x file.md +``` + +--- + +~~~sd replaced processed +This content will be passed in as stdin and will be replaced. +~~~ + +--- + + +Any command will work + +~~~echo "You can do whatever, really" +This doesn't matter, since it will be replaced by the stdout +of the command above because the command will disregard stdin. +~~~ +--- + + +You can use this to import snippets of code from other files: + +~~~xargs cat +examples/preprocessing/import.md +~~~ + +--- + + +## More pre-process examples: + +### PlantUML + +``` +~~~plantuml -utxt -pipe +@startuml +A --> B: to +@enduml +~~~ +``` + +The above will be pre-processed to look like: + +NOTE: You need `plantuml` installed and in your `$PATH` + +``` +┌─┐ ┌─┐ +│A│ │B│ +└┬┘ └┬┘ + │ to │ + │ ─ ─ ─ ─ ─ >│ +┌┴┐ ┌┴┐ +│A│ │B│ +└─┘ └─┘ + blob - 741f9b276a37a7b8fb18170ef6e3084d97843096 (mode 644) blob + /dev/null --- examples/julia.md +++ /dev/null @@ -1,66 +0,0 @@ ---- -author: Gopher -paging: Slide %d / %d ---- - -# Julia plots - -Press `ctrl+e` on a Julia code block to run it. Text output (like -UnicodePlots) shows up right on the slide; if the code saves an image file -(`savefig`/`save`), it's shown below the output as a real image. - -First run of each library can take a while (Julia precompiles it) -- -that's expected, not a hang. - ---- - -### UnicodePlots.jl - -Draws straight to stdout, so it needs no image at all. - -```julia -using UnicodePlots -println(lineplot(1:100, x -> sin(x / 5), title="sin(x / 5)")) -``` - ---- - -### Plots.jl + GR - -`GKSwstype` is set automatically so this never tries to open a window. - -```julia -using Plots -gr() -plot(1:100, x -> cos(x / 5), title="cos(x / 5)", legend=false) -savefig("plot.png") -``` - ---- - -### CairoMakie - -```julia -using CairoMakie -fig = Figure() -ax = Axis(fig[1, 1], title = "x²") -lines!(ax, 1:100, x -> x^2) -save("fig.png", fig) -``` - ---- - -### An animated GIF from code - -A saved `.gif` is displayed the same way any other executed-code image -is -- and if it has more than one frame, it plays back in a loop just -like a `.gif` referenced directly in markdown. - -```julia -using Plots -gr() -anim = @animate for i in 1:40 - plot(1:100, x -> sin(x / 10 + i / 4), ylim=(-1.2, 1.2), legend=false) -end -gif(anim, "wave.gif", fps=20) -``` blob - /dev/null blob + 3671cbdd35692f60d6c716bc3607ca387f494b47 (mode 644) --- /dev/null +++ examples/reveal/reveal.md @@ -0,0 +1,36 @@ +--- +author: Gopher +paging: Slide %d / %d +--- + +# Progressive reveal + +Split a slide into steps with an HTML comment on its own line: + +``` + +``` + +Press the same keys you'd use to advance/go back — space, `j`, `k`, arrows — +to reveal or retract one step at a time. Jumping (`3j`, `5G`, `gg`) always +skips straight to the target slide, fully revealed. + +--- + +# One point at a time + +- First point, always visible + +- Second point, appears on the next keypress + +- Third point, appears on the keypress after that + +--- + +# Works with anything on the slide + +An equation can wait for its own step: + +Rearranging Newton's second law: + +$$F = ma \implies a = \frac{F}{m}$$ blob - f5e16264e2583551519bb4205459b3e9b349f64c (mode 644) blob + /dev/null --- examples/metadata.md +++ /dev/null @@ -1,31 +0,0 @@ ---- -author: Gopher -date: May 22, 2022 -paging: Page %d of %d ---- - -# Metadata Example - -Customize the bottom information bar by adding metadata to your `slides.md` file. - -``` ---- -author: Gopher -date: May 22, 2022 -paging: Page %d of %d ---- -``` - ---- - -# Metadata Example - -You can also hide the bottom bar by leaving all of the fields blank - -``` ---- -author: "" -date: "" -paging: "" ---- -``` blob - /dev/null blob + 3762b645e9093ef9f44eee1409c0f76c84fc11df (mode 644) --- /dev/null +++ examples/themes/custom_remote_theme.md @@ -0,0 +1,7 @@ +--- +theme: https://github.com/maaslalani/slides/raw/main/styles/theme.json +--- + +# Slides + +The theme of this slide is fetched from https://github.com/maaslalani/slides/raw/main/styles/theme.json, the title above should be green. blob - /dev/null blob + 736fb319cdaf5e4bb996a7787727c7099d62e8ee (mode 644) --- /dev/null +++ examples/themes/custom_theme.md @@ -0,0 +1,7 @@ +--- +theme: ./examples/themes/theme.json +--- + +# Slides + +The above title should be orange and be prefixed with `CUSTOM`. blob - /dev/null blob + df322958308dc7ce264cd7ad9519722418f32204 (mode 644) --- /dev/null +++ examples/themes/theme.json @@ -0,0 +1,103 @@ +{ + "document": { + "block_prefix": "\n", + "block_suffix": "\n", + "color": "252", + "margin": 2 + }, + "block_quote": { + "indent": 1, + "indent_token": "│ " + }, + "paragraph": {}, + "list": { + "level_indent": 2 + }, + "heading": { + "block_suffix": "\n", + "color": "39", + "bold": true + }, + "h1": { + "prefix": "CUSTOM ", + "suffix": " ", + "color": "#fa0", + "bold": true + }, + "h2": { + "prefix": "▓▓▓ ", + "color": "#1cc" + }, + "h3": { + "prefix": "▒▒▒▒ ", + "color": "#29c" + }, + "h4": { + "color": "#559", + "prefix": "░░░░░ " + }, + "h5": {}, + "h6": {}, + "text": {}, + "strikethrough": { + "crossed_out": true + }, + "emph": { + "italic": true + }, + "strong": { + "bold": true + }, + "hr": { + "color": "240", + "format": "\n--------\n" + }, + "item": { + "block_prefix": "• " + }, + "enumeration": { + "block_prefix": ". " + }, + "task": { + "ticked": "[✓] ", + "unticked": "[ ] " + }, + "link": { + "color": "30", + "underline": true + }, + "link_text": { + "color": "35", + "bold": true + }, + "image": { + "color": "212", + "underline": true + }, + "image_text": { + "color": "243", + "format": "Image: {{.text}} →" + }, + "code": { + "prefix": " ", + "suffix": " ", + "color": "203", + "background_color": "236" + }, + "code_block": { + "theme": "dracula", + "margin": 2 + }, + "table": { + "center_separator": "┼", + "column_separator": "│", + "row_separator": "─" + }, + "definition_list": {}, + "definition_term": {}, + "definition_description": { + "block_prefix": "\n🠶 " + }, + "html_block": {}, + "html_span": {} +} blob - d7d3fdebc5ce652c82b5d252b59b5fd5945c5828 (mode 755) blob + /dev/null --- examples/preprocess.md +++ /dev/null @@ -1,82 +0,0 @@ -# Slides - -You can add a code block with three tildes (~) and write a command to run before displaying -the slides, the text inside the code block will be passed as stdin to the command -and the code block will be replaced with the stdout of the command. - -``` -~~~graph-easy --as=boxart -[ A ] - to -> [ B ] -~~~ -``` - -The above will be pre-processed to look like: - -NOTE: You need `graph-easy` installed and in your `$PATH` - -``` -┌───┐ to ┌───┐ -│ A │ ────> │ B │ -└───┘ └───┘ -``` - -For security reasons, you must pass a file that has execution permissions -for the slides to be pre-processed. - -``` -chmod +x file.md -``` - ---- - -~~~sd replaced processed -This content will be passed in as stdin and will be replaced. -~~~ - ---- - - -Any command will work - -~~~echo "You can do whatever, really" -This doesn't matter, since it will be replaced by the stdout -of the command above because the command will disregard stdin. -~~~ ---- - - -You can use this to import snippets of code from other files: - -~~~xargs cat -examples/import.md -~~~ - ---- - - -## More pre-process examples: - -### PlantUML - -``` -~~~plantuml -utxt -pipe -@startuml -A --> B: to -@enduml -~~~ -``` - -The above will be pre-processed to look like: - -NOTE: You need `plantuml` installed and in your `$PATH` - -``` -┌─┐ ┌─┐ -│A│ │B│ -└┬┘ └┬┘ - │ to │ - │ ─ ─ ─ ─ ─ >│ -┌┴┐ ┌┴┐ -│A│ │B│ -└─┘ └─┘ - blob - 3671cbdd35692f60d6c716bc3607ca387f494b47 (mode 644) blob + /dev/null --- examples/reveal.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -author: Gopher -paging: Slide %d / %d ---- - -# Progressive reveal - -Split a slide into steps with an HTML comment on its own line: - -``` - -``` - -Press the same keys you'd use to advance/go back — space, `j`, `k`, arrows — -to reveal or retract one step at a time. Jumping (`3j`, `5G`, `gg`) always -skips straight to the target slide, fully revealed. - ---- - -# One point at a time - -- First point, always visible - -- Second point, appears on the next keypress - -- Third point, appears on the keypress after that - ---- - -# Works with anything on the slide - -An equation can wait for its own step: - -Rearranging Newton's second law: - -$$F = ma \implies a = \frac{F}{m}$$ blob - f2440ed5d89b73adc9f56c8a0b9ef3920d96e740 (mode 644) blob + /dev/null --- examples/slides.md +++ /dev/null @@ -1,74 +0,0 @@ -# Welcome to Slides -A terminal based presentation tool - -```go -package main - -import "fmt" - -func main() { - fmt.Println("Written in Go!") -} -``` - ---- - -## Everything is markdown -In fact this entire presentation is a markdown file - ---- - -# h1 -## h2 -### h3 -#### h4 -##### h5 -###### h6 - ---- - -# Markdown components -You can use everything in markdown! -* Like bulleted list -* You know the deal - -1. Numbered lists too - ---- - -# Tables - -| Tables | Too | -| ------ | ------ | -| Even | Tables | - ---- - -# Graphs - -``` -digraph { - rankdir = LR; - a -> b; - b -> c; -} -``` -``` -┌───┐ ┌───┐ ┌───┐ -│ a │ ──▶ │ b │ ──▶ │ c │ -└───┘ └───┘ └───┘ -``` ---- - -All you need to do is separate slides with triple dashes -`---` on a separate line, like so: - -```markdown -# Slide 1 -Some stuff - ---- - -# Slide 2 -Some other stuff -``` blob - df322958308dc7ce264cd7ad9519722418f32204 (mode 644) blob + /dev/null --- examples/theme.json +++ /dev/null @@ -1,103 +0,0 @@ -{ - "document": { - "block_prefix": "\n", - "block_suffix": "\n", - "color": "252", - "margin": 2 - }, - "block_quote": { - "indent": 1, - "indent_token": "│ " - }, - "paragraph": {}, - "list": { - "level_indent": 2 - }, - "heading": { - "block_suffix": "\n", - "color": "39", - "bold": true - }, - "h1": { - "prefix": "CUSTOM ", - "suffix": " ", - "color": "#fa0", - "bold": true - }, - "h2": { - "prefix": "▓▓▓ ", - "color": "#1cc" - }, - "h3": { - "prefix": "▒▒▒▒ ", - "color": "#29c" - }, - "h4": { - "color": "#559", - "prefix": "░░░░░ " - }, - "h5": {}, - "h6": {}, - "text": {}, - "strikethrough": { - "crossed_out": true - }, - "emph": { - "italic": true - }, - "strong": { - "bold": true - }, - "hr": { - "color": "240", - "format": "\n--------\n" - }, - "item": { - "block_prefix": "• " - }, - "enumeration": { - "block_prefix": ". " - }, - "task": { - "ticked": "[✓] ", - "unticked": "[ ] " - }, - "link": { - "color": "30", - "underline": true - }, - "link_text": { - "color": "35", - "bold": true - }, - "image": { - "color": "212", - "underline": true - }, - "image_text": { - "color": "243", - "format": "Image: {{.text}} →" - }, - "code": { - "prefix": " ", - "suffix": " ", - "color": "203", - "background_color": "236" - }, - "code_block": { - "theme": "dracula", - "margin": 2 - }, - "table": { - "center_separator": "┼", - "column_separator": "│", - "row_separator": "─" - }, - "definition_list": {}, - "definition_term": {}, - "definition_description": { - "block_prefix": "\n🠶 " - }, - "html_block": {}, - "html_span": {} -}