Skip to main content

You are here

Wake up on user action

3 posts / 0 new
Last post
Rawbear
Wake up on user action

I have a Jeenode that is attached to a midi keyboard. I want the jeenode to sleep until the user presses a key and only then wake up and send the midi message (or messages if more keys are pressed). Basically, unless a key has been pressed recently (let's say 10 seconds) the jeenode should go back to sleep (as deep as possible... maybe the user is gone for the day and forgot to turn the equipment off!).

Question 1 : would it be better to wake the jeenode at EACH key press, or wake, wait for a while in case other keys are pressed (let's say within a fews seconds) and go to sleep if no action? Question 2: How do I wake up the jeenode if all I have is an incoming midi message on the serial port (no separate interrupt signal)? Question 3: Can the receiving jeenode reduce power when it's not actively receiving?

About MIDI communication: the baud rate for midi is 31250 bps. The midi line is usually not very busy when a musician plays an instrument, but can get saturated when many instruments are connected and there are also other midi messages than transit on the line (time codes, etc). So the processing speed has to be quite snappy, considering that I use a baud rate of 49K bps or so on the RFM12B.

Question 4: How long does the jeenode take to wake up from deep sleep and is it fast enough to prevent dropping of midi messages?

Rawbear

I think that I solved questions 1 to 3. Midi is a TTL signal. Also, the Midi specifications stipulate that midi IN should be isolated from one midi device to another. The specs recommend using an opto isolator for that purpose. The same opto-isolator, or a separate one, could be used to signal an interrupt to the Jeenode and wake it up right? Or a simple circuit might start to conduct when a sgnal is present on the midi-IN pins that could last just long enough to power up the Jeenode, which would then take over and keep the circuit alive for a little while, at least long enough to transmit the incoming packet(s) and maybe wait a while before going back to sleep. I'll try to build a little example and I will come back.

In the mean time, can someone answer question 4?

Thanks.

padvinder95

Check out the datasheet of the ATmega328: if you go into standby mode with an external crystal (chapter 9, paragraph 7 for me), the "device wakes up in six clock cycles." I'd say that at 16 MHz 375 ns is fast enough to capture the message. :)

If you want to go to complete power-down mode, you're talking much higher delays: a couple of ms (4, even up to 70) for voltage stabilisation, then 1K or 16K cycles of the ceramic resonator or crystal (respectively)---which sounds like a lot but amounts to 1/16 or 1 ms. Although, if the power supply is steady and you're sure of fast-rising power (which is the case if you go into power-down mode, rather than actually turning the device on), you can set the fuses such that the delay is only a couple of clock cycles.

That being said, if you disable all external devices and go into stand-by mode, the most significant contribution to power usage will be the self-discharge of your batteries (check out the low power series on the weblog) and I'd go with the standby mode.

[edit] Oh, and keep us posted on your progress!

Premium Drupal Themes by Adaptivethemes