[Server-devel] smooth shutdown for 12V-DC powered XS

James Cameron quozl at laptop.org
Thu May 10 04:54:30 EDT 2012

On Thu, May 10, 2012 at 10:20:57AM +0200, K??vin Raymond wrote:
> >
> > It might not be necessary to calibrate, if the raw value is sent to
> > the computer, the computer software can be calibrated instead.
> >
> > It is still be necessary to ensure the values are within the range of
> > the analog to digital converter. ??If you only see 1023, the voltage is
> > out of range.
> It's exactly what I meant, I haven't checked yet but the input should
> be on the range 0-5V, and we need to define the average threshold in
> order to get an accurate measure.
> I'll see with Xavier about the power expected values.

If you only need to detect undervoltage, you can set the maximum much
lower, and wait for the sample to fall below 1023.

If you also want to provide a log of voltages, then you must set the
maximum based on the expected voltage under full charge current.

A log of voltages is very useful for analysis and history.

Using the first method, each bit of the sample has a smaller voltage

> >
> >> I don't really know Arduino, neither how to put the board asleep, it
> >> could consume less???
> >
> > avr/sleep.h
> >
> > See also
> > http://www.arduino.cc/playground/Learning/ArduinoSleepCode
> > http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?action=print;num=1289769139
> > http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1256298397
> > http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1286856144
> >
> > However, you face an important problem, which is how to wake from
> > sleep. ??You might configure it to wake on serial input, and have the
> > computer software wake the arduino to take a reading. ??I did that a
> > few weeks ago with a fridge power monitor.
> >
> > You might still have power to the USB chip, U4.
> What, there is no internal timer, to awake it?

The timers are in use by the Arduino library, if I recall correctly.
Please do read up about it.  There is very likely a way to wake with
timer interrupt, but with extra programming.

> Ok, I'll dig around this.
> PICs only consume few uAmps when sleeping???

Yes, nice aren't they?  I would not use Arduino where power was
critical.  I had assumed that since a server was involved, one more
device wouldn't stretch the power budget that far, especially given
the benefit that voltage monitoring brings.

> I still think that building our own board could be better as it will
> be smaller and more robust (no unuseful I/O, no wasted components???)

If you wish to lower cost and size, and do not need a log of voltages,
then consider avoiding a microcontroller altogether; use a comparator,
a reference voltage, generating a "voltage is low" output, that can
then be fed into a serial port modem control pin, or drive a relay
that briefly presses the power button on the server.

> >
> >> At the analog input I just have a voltage divider (passive is best,
> >> but more current is drawn???).
> >
> > The current drawn by a voltage divider is related by ohms law to the
> > total resistance of the divider, from top to bottom.
> >
> > Increasing the resistance has a bad side effect of increasing the
> > noise on the reading.
> >
> > Adding a capacitor from the centre of the divider to ground will
> > decrease the noise. ??But too large a capacitor will slow the response
> > to rapid changes.
> Yep I know, thanks
> >
> > I suggest a 100k potentiometer with a 1uF capacitor.
> I would prefer to choose only resistances, not potentiometer, as
> people won't try to change settings! (And the threshold would be
> updated on the host software).

In that case, I recommend a three-fold divider, so that 15V is
translated to 5V.  50k resistor to ground, 100k resistor to input
voltage, common to analog input.

I would use a potentiometer, then glue it down, or cover it up.

> >
> > C? ??I guess that has the lowest power cost. ??I have used Python, or
> > Bash. ??Fast to develop.
> >
> Sure, I've already done something similar in bash and perl, but this
> time I wanted to do it properly with system libs :).
> This to have only one code and not hand made udev script calling the
> monitoring one.
> What is really ugly with Arduino is the USB management through the
> ftdsio chip, we can't choose the VID/PID???

I agree.  An Arduino Uno is a bit better, as it uses a USB Atmel
processor instead.  It should be possible to change the VID/PID.

Otherwise, use a USB PIC.

> I need to catch the right tty port, and be sure to handle
> connection/reconnection???

My point about using /dev/serial/by-path is that you don't need to
worry too much ... just label the port as dedicated to that purpose.

> Oh, I know how to do it with bash and udev, but a single binary would fit best.
> Cheers,
> -- 
> K??vin Raymond
> (shaiton)
> GPG-Key: A5BCB3A2

James Cameron

More information about the Server-devel mailing list