data logging after an event

I want to make a data logger that would monitor the input and store the data in a FIFO way.
Storing the last 30 seconds of readings or so.
Then if there is any abrupt change, write that last section to SD card and start to save for another 10 minutes after the last abrupt change.

This is for AC voltage measuring.

I want to put this on the panel and when the Air conditioner compressor kicks in, AND there is a brown out of some value, then it would store that last 30 seconds prior to the brownout and keep recording for 10 minutes to show what effects happened past the last major change.

another question is about how many readings per second/minute that would be needed.

we have brownouts on occasions and I want to track down the cause.

If you want to record the AC sine wave you will need a lot of data readings and I wonder could you write them to an SD card fast enough - but I have never tested that. I suggest writing a short sketch just to test how long it takes to write data. As far as I know the SD card writes will be faster if done in a block rather than one byte at a time.

On the other hand if you have some way to detect the RMS voltage a few times per second there would be a lot less data to handle.

The other important issue is how long is the brown-out - you need to sample often enough to be sure you don't miss it.

You may also have an SRAM problem on the Arduino because the 30 seconds of data that you may never want to keep should be saved to SRAM in a circular buffer - but if you are taking lots of samples 30 seconds could easily run into several kbytes.

Maybe 10 seconds before the event would be enough - after all, by definition, nothing is happening in that period.

...R

I was thinking about 60hz and 120 readings, just the top and bottom of the Ac.

I do not need the ac wave, just raw voltage.
I am loosing power on an energized coil and the relay is failing, then re-making.

as for the readings prior, you are correct that any reading prior would be nearly the same as the instant before the event. if the data were stored in a buffer, the buffer could be overwritten until there is an event.

two buffers ? fill one, then the next, back and forth, if no event, just overwrite, if an event, then store that to SD card.

Take a look at the Open Energy Monitor project specifically the eMonLib

You can specify the window length i.e over what period it samples before returning the voltage or the current or the power (or both) depending on what sensors you have connected.

To just measure voltage you need a step down transformer of at least 6V, e.g. 6V or 9V or 12V are fine, and a few additional components (resistors and capacitors)
(the details are on the open energy monitor website)

However if you are looking for transient spikes rather than sustained brown out, I'm not sure if it would work (i.e you'd need to look at the minimum window time i.e is 1 or 2 cycles at 60Hz enough

I thought you had the same problem as me, but now I think you don't. The voltage before the brownout is kosher and you already know what it is. It seems to me that all you need is the event and the consequence. Therefore Arduino needs to

  1. rapidly and continuously monitor the lines
  2. know when the event happened and start recording until the recovery
  3. check to ensure it is a brownout, and not just a dip.
  • perhaps

4 ditch recordings deemed false.

dave-in-nj:
I was thinking about 60hz and 120 readings, just the top and bottom of the Ac.

.... snip.......

two buffers ? fill one, then the next, back and forth, if no event, just overwrite, if an event, then store that to SD card.

120 samples per second at 2 bytes per sample (assuming you want the full range of the ADC) amounts to 120 x 2 x 10 = 2400 bytes for 10 seconds which is too much for an Uno's SRAM.

And, as I said, you will need to find out if you can write 240 bytes per second to an SD card.

You will need to transform the AC down to a range acceptable for the Arduino ADC and you will need to add an offset so there are no negative voltages going to the ADC.

One buffer (array) will be fine - just have a marker for tail and add every data point at the tail. When the tail gets to the end of the array it starts over at the beginning, overwriting the data that is already there.

...R