Difference between revisions of "LaserCutterUsageCounter"

From RevSpace
Jump to navigation Jump to search
(Update EEPROM storage slot layout)
Line 35: Line 35:
  
 
The laser cutter usage counter functionally consists of the following parts:
 
The laser cutter usage counter functionally consists of the following parts:
* a display to show the current session time (among other things)
+
* electrical front-end to measure whether the laser tube is on, and at what power it is operating
* a button to reset the current session
+
* user interface
* an electrical front-end to measure whether the laser tube is on, and at what power it is operating
+
** display to show the current session time (among other things)
 +
** button to reset the current session
 
* an arduino that controls all of this, which also implements:
 
* an arduino that controls all of this, which also implements:
 
** a clock to keep track of time (arduino internal clock)
 
** a clock to keep track of time (arduino internal clock)
Line 54: Line 55:
 
TODO: determine a suitable sample rate for the current power (e.g. once per second).
 
TODO: determine a suitable sample rate for the current power (e.g. once per second).
  
=== Display ===
+
=== User interface ===
 
Probably a standard 2-line 16 character display can be used.
 
Probably a standard 2-line 16 character display can be used.
 
We could use one line for the current session counters and the other line for lifetime total counters.
 
We could use one line for the current session counters and the other line for lifetime total counters.
 +
Alternatively, to display all data, a Nokia 5110 display (84x48 pixels, or 6 lines of 14 characters) can be used.
  
=== Button ===
 
 
The button is a push button.
 
The button is a push button.
 
Pressing it causes the session counters to be reset back to zero.
 
Pressing it causes the session counters to be reset back to zero.

Revision as of 20:55, 1 November 2014

Project LaserCutterCounter
Status Initializing
Contact bertrik
Last Update 2014-11-01


Context

This project is about a usage counter for the laser cutter at revspace.

Currently, the original purchase cost of the laser cutter is recouped by asking E2,50 per 15 minutes of usage. People have to keep track of time themselves, it is not very fine-grained and this cost-model does not take into account how intensive the laser cutter is actually used.


A laser cutter usage counter can improve this situation as follows:

  • keep track of usage time per cutting session, for example show the time since power-up on a display
  • count usage in smaller units of time (e.g. 1 minute instead of 15 minutes)
  • account for the actual usage per time unit, for example count usage in proportion to laser power (the assumption is that using lower power produces less wear on the laser tube, which means longer life).


Additional features could be:

  • directly calculate a price instead of just showing time
  • keep track of various other interesting usage counters (a bit like SMART does for disks), for example:
    • on-time (this session)
    • on-time (lifetime total)
    • minutes of laser on-time (this session)
    • minutes of laser on-time (lifetime total)
    • effective minutes of laser on-time (time x power) (this session)
    • effective minutes of laser on-time (time x power) (lifetime total)
    • number of times the laser cutter was powered up
  • publish the usage counters, e.g. on our mosquitto topic over the revspace wireless NRF network
  • a configuration interface to set parameters (e.g. price/minute)

Design

The laser cutter usage counter functionally consists of the following parts:

  • electrical front-end to measure whether the laser tube is on, and at what power it is operating
  • user interface
    • display to show the current session time (among other things)
    • button to reset the current session
  • an arduino that controls all of this, which also implements:
    • a clock to keep track of time (arduino internal clock)
    • non-volatile memory to store usage counters (arduino internal EEPROM)

Electrical front-end

The laser cutter has three wires we can interface with:

  • GND
  • 5V, this could possibly also be the power source for the usage counter
  • PWM, the laser tube intensity signal

Probably a low-pass filter is needed to average the PWM-signal before measuring it.

TODO: figure out the PWM rate of our laser controller.

TODO: determine a suitable sample rate for the current power (e.g. once per second).

User interface

Probably a standard 2-line 16 character display can be used. We could use one line for the current session counters and the other line for lifetime total counters. Alternatively, to display all data, a Nokia 5110 display (84x48 pixels, or 6 lines of 14 characters) can be used.

The button is a push button. Pressing it causes the session counters to be reset back to zero. The lifetime counters are never reset.

Arduino

An arduino nano or mini pro is likely sufficient.

The internal timer is used as a time base, probably accurate within 100 ppm.

The internal EEPROM is used for storage of the counters. By using a smart wear-leveling mechanism, the lifetime of the EEPROM can be stretched to several 100 thousands of operating hours, which should be sufficient (longer than the laser tube lifetime).

Wear-leveling algorithm

The wear-leveling algorithm works by storing the data to be persisted in a different location every time. For example, if we have 16 bytes to store, we can define 64 slots in the arduino 1kB EEPROM. Each slot contains a sequence number and a checksum.

When reading, we read all slots and select the slot which has the highest sequence number and a valid checksum. The checksum makes it likely that a half-written slot can be detected (e.g. when a power-down/crash occurred during writing). An invalid slot can be skipped this way, and we automatically fall back the slot before it. When writing, we simply write to the next slot than we one we read from, using a higher sequence number.

Assuming a write frequency of once per minute, it takes about 64 * 100,000 writes before the EEPROM reaches its official limit, this amounts to about 100,000 hours.

One counter slot could consist of:

  • 22 bits: minutes on-time (lifetime total), this field doubles as the sequence counter because it always increases
  • 10 bits: minutes of on-time (this session)
  • 22 bits: minutes of laser on-time (lifetime total)
  • 10 bits: minutes of laser on-time (this session)
  • 22 bits: effective minutes of laser on-time (time x power) (lifetime total)
  • 10 bits: effective minutes of laser on-time (time x power) (this session)
  • 16 bits: number of times the laser cutter was powered up
  • 16 bits: checksum

Total bytes per slot: 128 bits, or 16 bytes.

A 16-byte slot is nice, because we can fit 60 of those in the EEPROM (1 hour worth of logging) and still have 64 bytes left (e.g. to store settings).

Counter times are counted in minutes. Life-time counters are 22 bits, so they can fit a maximum of about 70k hours. Session counters are 10 bits, so they can fit a maximum of about 17 hours. The power-up counter is 16 bits, so it can log a maximum of 65k times power-up.