uC issues
Toolchains
Designed for industry
Often non-free/crippleware
Badly documented
Bad multiplatform support
vendor-dependent HAL
Debugging often hard or impossible without extra hardware
Silicon Erratas
Arduino
Arduino makes things better
But who hasn't used Serial.write(...) and Serial.read() for debugging?
Bad Multitasking
Not really low power
Scripting
If running in uC then no toolchain to install
Easy to inspect and change while running
Rapid development
Source code is on the device itself
Friendly - no segfaultsQuick to tweak
Instant - more fun!
Why JavaScript?
A little bit like C,simple syntax
Loads of people know it already
Huge amount of learning material
With browers and node.js,you can run JS end to end
JSON built-in
Event-based model
Events on Hardware
Matches real world interaction
A lot like interrupts - without any pain
Low overhead cooperative multi-tasking
Easy to combine different functionality
Plays well with REPLs
Power Saving - interpreter knows when it can go to sleep,and how deeply
Power Saving
Many projects benefit from battery power or even energy harvesting
Navie LED flash on a 700mAh Li-lon battery:
Raspberry Pi : 1-2 hours
Arduino : 1-2 days
Espruino : ~6months
It's not easy. To wake up once a minute:
Start Low Speed Oscillator + Wait
Set up RTC
Set up Alarm
Set up interrupts
Turn off peripherals
Enter sleep mode
Re-initialise peripherals
In Espruino:
setInterval(function(){ ... },60000)
Why not use a desktop JavaScript engine?
Speed RAM NV Storage Power Draw
Typical Desktop 2500MHz*4 4000000kBytes 1000000MBytes ~50W
Typical ARM Mic 72MHz*1 8kBytes 0.125MBytes ~0.001W
~1000000 times less RAM
~10000000 times less storage
So add more RAM...
More parts:more expensive, bigger, 10-100x more power draw
Tessel(32Mb RAM, no OS)
Raspberry Pi(512Mb + node.js)
BeagleBone(256Mb + node.js)
OpenWRT(~32Mb)
And many others...
On-chip RAM
On PC - read all RAM in ~1sec
On uC - read all RAM in ~0.001sec
Less of everything, but 1000x more CPU power per byte.
Espruino Software
Purpose Built JaveScript interpreter for uCs
Open Source, C
No operating System
Can run in less than 8KB RAM
Program using Terminal app
Multi-line editing, command history in chip
Serial or USB CDC
Not just JavaScript
Built-in libraries:
Use require('...') to get drivers for new devicesStandard String/Array/etc
Maths(includeing FFT)
Waveform IO
HTTP(CC3300 and WIZnet W5500)
Graphics (w.Bitmap and Vector fonts)
本文详细分析了在物联网(IoT)应用中,如何利用JavaScript及其在嵌入式硬件上的优势实现高效、灵活且节能的解决方案。通过对比不同平台的性能和功耗,阐述了JavaScript在简化开发流程、提高开发效率方面的显著作用。同时,文章深入探讨了如何利用JavaScript的实时交互特性与硬件设备进行无缝集成,以及如何在有限的资源下实现高效的数据处理与控制。此外,文章还介绍了Espruino等特定于微控制器的JavaScript环境,展示了其在低功耗和快速原型制作方面的独特价值。

被折叠的 条评论
为什么被折叠?



