0
\$\begingroup\$

I thought about modifying this circuit (Momentary switch power: press to turn on, microcontroller can turn itself off), but I wonder if something simpler might work (or if someone had a better idea)?

I'm using the Atmel SAM R21 Xplained to prototype a device. I want to detect if a tilt sensor has been activated, but I don't want to continuously poll its stated so I can save power. I'd like to poll, let's say once a minute, send it's state over 802.15.4 to the cloud.

Here is the idea I've come up with:

By using a digital output to charge a capacitor and the analog input to detected it's voltage, track the capacitor's voltage to see if it got shorted out within the 1 minute interval. The circuit would look something like this:

schematic

simulate this circuit – Schematic created using CircuitLab

The algorithm would be:

  1. Initially charge the capacitor.
  2. Loop forever - Detect, if the voltage dropped significantly, send a message. Charge the capacitor.

Thanks,

Greg

\$\endgroup\$
3
  • \$\begingroup\$ Looks OK to me. I might consider putting R2 in series with D2 and just use a single-ended digital input. \$\endgroup\$
    – Andy aka
    Commented Oct 24, 2015 at 21:18
  • \$\begingroup\$ The resistor in series was an attempt to not have the tilt sensor dead short the capacitor. Not sure if that would extend its life, but that was the idea. Your suggestion does reduce component count, always good. Thanks, Greg \$\endgroup\$ Commented Oct 25, 2015 at 17:47
  • \$\begingroup\$ R1 will avoid that happening and it is a good idea but mainly to protect the contacts in the switch and prevent an extremely large current surge that could easily reset a micro if not tracked correctly on a PCB! If you can't use an interrupt I can leave this as an answer if you wish. \$\endgroup\$
    – Andy aka
    Commented Oct 25, 2015 at 19:05

2 Answers 2

1
\$\begingroup\$

The usual approach to this sort of problem would be not to poll, but to use an interrupt.

If you mask the interrupt but poll the interrupt request flag you will have essentially the same result as what you have suggested, with no hardware (consider filtering to establish a minimum pulse length in order to reject noise).

\$\endgroup\$
1
\$\begingroup\$

Maybe just use an interrupt? That way the sensor High will wake up the mcu rather than having to poll. A quick check of Amel seems to indicate they are supported. Ie

The Atmel SAM R21 devices provide the following features: In-system programmable Flash, 12-channel direct memory access (DMA) controller, 12-channel Event System, programmable interrupt controller, up to 28 programmable I/O pins, ultra-low power 2.4GHz ISM band transceiver with a data rate of 250kb/s, 32-bit real-time clock and calendar, three 16-bit Timer/Counters (TC) and three 16-bit Timer/Counters for Control (TCC), where each TC can be configured to perform frequency and waveform generation, accurate program execution timing or input capture with time and frequency measurement of digital signals.

\$\endgroup\$
1
  • \$\begingroup\$ I see the document: atmel.com/images/… gives greater detail on how to use this. Your suggestion helped me dig deeper into the example code I had. Atmel provided a great example using this within Atmel Studio 7 IDE, also. Thank you both for getting me to think digital, instead of analog (i.e. think straight!). \$\endgroup\$ Commented Oct 25, 2015 at 17:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.