From APIs to Electrons: A JS on Hardware Journey

39
From API to Electrons A journey on Tessel from JS to the metal… …and back Eric Kolker Technical Machine FIT 2014

description

A journey on Tessel from JS to the metal... and back

Transcript of From APIs to Electrons: A JS on Hardware Journey

Page 1: From APIs to Electrons: A JS on Hardware Journey

From API to Electrons A journey on Tessel from JS to the metal…

…and back

Eric Kolker Technical Machine FIT 2014

Page 2: From APIs to Electrons: A JS on Hardware Journey

Intro

◦ I’m Eric Kolker

◦ Electrical engineer, @technicalhumans

◦ Our adventure today:

What happens when you set a noise trigger

with Tessel and the Ambient module?

3

Page 3: From APIs to Electrons: A JS on Hardware Journey

4

Page 4: From APIs to Electrons: A JS on Hardware Journey

5

Page 5: From APIs to Electrons: A JS on Hardware Journey

6

Page 6: From APIs to Electrons: A JS on Hardware Journey

Case study: the Ambient Module

7

Page 7: From APIs to Electrons: A JS on Hardware Journey

8

Page 8: From APIs to Electrons: A JS on Hardware Journey

9

Page 9: From APIs to Electrons: A JS on Hardware Journey

tessel run ambient.js

◦ JS transpiled to Lua via Colony

◦ Embeddable, low memory footprint,

semantically similar to JS

◦ Dependencies bundled

◦ Bundle stored in RAM, executed

◦ tessel push = saved in flash

11

Page 10: From APIs to Electrons: A JS on Hardware Journey

12

JS C

Lua

Page 11: From APIs to Electrons: A JS on Hardware Journey

13

Page 12: From APIs to Electrons: A JS on Hardware Journey

14

Page 13: From APIs to Electrons: A JS on Hardware Journey

15

Page 14: From APIs to Electrons: A JS on Hardware Journey

16

Page 15: From APIs to Electrons: A JS on Hardware Journey

17

Page 16: From APIs to Electrons: A JS on Hardware Journey

18

Page 17: From APIs to Electrons: A JS on Hardware Journey

19

Microphone

Light sensor (photodiode)

Page 18: From APIs to Electrons: A JS on Hardware Journey

20

Microphone

Light sensor (photodiode)

Page 20: From APIs to Electrons: A JS on Hardware Journey

Firmware & driver recap

◦ Setup

◦ SPI communication

◦ Interrupt-driven

◦ ADC read

◦ Threshold detect

22

Page 21: From APIs to Electrons: A JS on Hardware Journey

23

Page 22: From APIs to Electrons: A JS on Hardware Journey

To the schematic!

◦ Ambient schematic

◦ All our design docs

24

Page 23: From APIs to Electrons: A JS on Hardware Journey

Functional blocks

25

Page 24: From APIs to Electrons: A JS on Hardware Journey

(Approximate) system block diagram

26

Signal ADC 1/s

Page 25: From APIs to Electrons: A JS on Hardware Journey

To SPICE!

27

Page 26: From APIs to Electrons: A JS on Hardware Journey

Simulation results: time domain

28

Page 27: From APIs to Electrons: A JS on Hardware Journey

Simulation results: frequency domain

29

Page 28: From APIs to Electrons: A JS on Hardware Journey

Simulation results: frequency domain

30

a = 0.9

a = 0.5

a = 0.3

Page 29: From APIs to Electrons: A JS on Hardware Journey

Welcome to the bottom

31

Time to head back to JS!

(This direction is a lot faster)

Page 30: From APIs to Electrons: A JS on Hardware Journey

Simulation results: time domain

32

Page 31: From APIs to Electrons: A JS on Hardware Journey

Simulation results: time domain

33

Page 32: From APIs to Electrons: A JS on Hardware Journey

Everyone’s take on the situation

◦ Analog vs. digital

◦ Binning

◦ Sampling

34

Page 33: From APIs to Electrons: A JS on Hardware Journey

Triggered!

35

Page 34: From APIs to Electrons: A JS on Hardware Journey

Back to the firmware, JS

◦ ADC compare, module sets IRQ high

◦ Tessel handles SPI, saves data payload

◦ Callback pushed to top of queue

◦ Callback evaluated with given data

36

Page 35: From APIs to Electrons: A JS on Hardware Journey

37

Page 36: From APIs to Electrons: A JS on Hardware Journey

Recap

◦ User code

◦ JS binds to Lua, Lua VM in C binds to HW

◦ Communication over SPI

◦ Interrupt-driven ADC reads, compares

◦ Yay, op amps for signal processing! SPICE!

◦ Data sent to Tessel, event fires, callback runs 38

Page 37: From APIs to Electrons: A JS on Hardware Journey

Thanks!

Questions?

[email protected]

@twiddlee

ekolker

39

Page 38: From APIs to Electrons: A JS on Hardware Journey

APPENDICES

40