4 ms·
I've developed a few things on my Espruino Pico[1] board, some Raspberry pi and also so arduino things. Just toys really. One of the nice this I've found with
by Already__Taken 11y ago
I've developed a few things on my Espruino Pico[1] board, some Raspberry pi and also so arduino things. Just toys really.
One of the nice this I've found with the Pico is because of the JS vm, when I don't do anything in the code all the power in the chip goes to sleep state, and just wakes up for me as I've got scheduled. Yes Arduino has sleeps but i've also go to go learn that as another thing, yes the Pi can be configured so but that's even more tinkering.
JS seems like a really great "Just get it done" sort of phase to work in. After that you'd no doubt make a better job of the project with a myriad of other technologies.
1: http://www.espruino.com/Pico http://www.espruino.com/Pico
- swiley 11y agoC does that too unless you sit in a tight loop polling something all the time.
- mwambua 11y agoMost embedded applications consist of a tight loop of constant polling. People slow things down by using delays... But if you use the wrong sort of delay (read: the most popular one https://www.arduino.cc/en/Reference/Delay https://www.arduino.cc/en/Reference/Delay), you'll end up executing nops instead of powering down the processor
- benten10 11y agoWhat would then be the right way to sleep? I've always wanted to do something like 'sleep until event <X> and do absolutely nothing till them', but end up using the delay every time.
- Fradow 11y agoFrom what I searched, it's dependant on your microcontroller, so there is no generic way to do this (since different Arduinos have different microcontrollers). For a very low power project I had, I basically found a lib that did deep sleep correctly for my microcontroller (an ATTiny), then you sleep for a significative period of time each time (for example, 500ms), and check if the event happened when sleep ends. That results in a consumption under 10uA. It is obviously very dependant of what you want to do, some applications can't afford to check only every X ms. And be careful too, you need to put everything possible behind your microcontroller, to be able to disable things during sleep (otherwise, you are just powering the rest of your circuit for nothing).
- mwambua 11y agoUnfortunately there's no easy answer to the correct solution. One method is to setup interrupt service routines and put the mcu to sleep the rest of the time. There are a couple libraries that provide convenient interfaces to AVR's sleep lib e.g http://playground.arduino.cc/Code/Enerlib http://playground.arduino.cc/Code/Enerlib The basic idea is that it is possible to put the chip into lower-power mode... but you need a way to wake it up after that. That could be an interrupt, watchdog timer... etc Another thing to note is that for most applications the mcu's power consumption will be negligible with respect to the peripherals', so the average person shouldn't care much.
- pjc50 11y agoMost microcontrollers let you configure a timer that runs while the processor is in sleep, then triggers an interrupt to wake you up. In this style of coding you end up with main() { configure_interrupts(); while(1) { do_irq_bottom_halves(); sleep(); // "wfi" in ARM } }
- HeyLaughingBoy 11y agoAs others said, it depends. I have one application where the CPU literally does nothing other than process switch actions (it turns a double click into a single click), so it goes into deep sleep and pressing a pushbutton is the only thing that wakes it up.
- espadrine 11y agoIndeed, JS being event-driven probably makes it a better fit for such devices. Most devices don't need to be realtime, so the GC pauses likely don't cause much harm. Speed isn't an issue most of the time either. As Dart is similar, it is also trying to lodge itself in that niche: http://dart-lang.github.io/fletch/ http://dart-lang.github.io/fletch/.
- petra 11y agoThe Mbed, which is the Arduino' "professional" brother, does support event driven sleep using callbacks: https://developer.mbed.org/blog/entry/Using-the-new-mbed-power-management-API/ https://developer.mbed.org/blog/entry/Using-the-new-mbed-pow... Since this is a part of the new mbed-2.0 os , i think there are already 5 micro controllers that support it.