From APIs to Electrons: A JS on Hardware Journey

Post on 01-Dec-2014

89 views 1 download

description

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

Transcript of 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

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

4

5

6

Case study: the Ambient Module

7

8

9

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

12

JS C

Lua

13

14

15

16

17

18

19

Microphone

Light sensor (photodiode)

20

Microphone

Light sensor (photodiode)

Firmware & driver recap

◦ Setup

◦ SPI communication

◦ Interrupt-driven

◦ ADC read

◦ Threshold detect

22

23

To the schematic!

◦ Ambient schematic

◦ All our design docs

24

Functional blocks

25

(Approximate) system block diagram

26

Signal ADC 1/s

To SPICE!

27

Simulation results: time domain

28

Simulation results: frequency domain

29

Simulation results: frequency domain

30

a = 0.9

a = 0.5

a = 0.3

Welcome to the bottom

31

Time to head back to JS!

(This direction is a lot faster)

Simulation results: time domain

32

Simulation results: time domain

33

Everyone’s take on the situation

◦ Analog vs. digital

◦ Binning

◦ Sampling

34

Triggered!

35

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

37

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

Thanks!

Questions?

e@technical.io

@twiddlee

ekolker

39

APPENDICES

40