PubInv / general-purpose-alarm-device

A general purpose alarm device (with software) as a module for medical devices (and others)
https://www.pubinv.org/project/general-purpose-alarm-device-gpad/
GNU Affero General Public License v3.0
6 stars 11 forks source link

Enhancement, Firmware : Make Buzzer Firmware Objects #171

Closed ForrestErickson closed 1 year ago

ForrestErickson commented 1 year ago

The GPAD firmware could encapsulate and abstract Buzzer functions in objects perhaps as follows.

The GPAD buzzer system hardware is capable of making tone with the Arduino Tone command on two pins, the Tone pin on PB0 aka D8 and Attenuate pin PD4 aka D4 . . See the Arduino Tone documentation for frequency range and duration. https://www.arduino.cc/reference/en/language/functions/advanced-io/tone/

These tones can ONLY be steady state or with a time out and the Tone command is non blocking.

Buzzer Levels which parallel the alarm levels*.

Buzzer_Alarms can four Buzzer Levels {Off, Low, Medium, High}.

  1. For Off, both the Tone pin is off and the Attenuate pin is DO NOT CARE
  2. For Low, the Attenuate pin is set for output and set to LOW. The Tone Pin is set for a tone(pin, frequency, duration).
  3. For Medium, Tone pin is set is set for output and set to LOW. The Attenuate pin is set for tone(pin, frequency, duration).
  4. For High, Attenuate pin is set for Input and set to DO NOT CARE. The Tone Pin is set for a tone(pin, frequency, duration).

Notes on amplected estimates

Approximate weighting for Low, Medium and High are (0, 300/(300+1000+10000), 1000/(300+1000+10000) and 10000/(1000+10000) Approximate weighting for Low, Medium and High are (0, 300/(11300), 1000/(11300) and 10000/(11000) Approximate weighting for Low, Medium and High are (0, 3/(113), 10/(113) and 10/(11) Approximate weighting for Low, Medium and High are (mute, -31dB, -10dB and -.8dB relative to the full amplitude the buzzer rated sound at 5Vp-p drive and ignoring the loss through the class B stage.

Buzzer Sounds

Each alarm level might have a Buzzers object which can be set for tone and with additional firmware play melodies which could combine in addition to the tone and duration the alarm levels as above.

Each alarm might be assigned a melody and an amplitude or a warble as described below.

Melody

An array of note frequency and durations of notes. An overall and constant level is set and applied to all notes. Caution: The Melody firmware example from Arduino IDE are blocking.

More Elaborate Melody

An array of note frequency, amplitude and durations of notes. Amplitude is set note by note. This would be an elaboration of the Melody example above.

Warbles

A signal note might be time modulated by changing amplitude of the Buzzer with out changing the tone. With complex enough firmware all four levels

References

Referrer to the GPAD schematic for pins driving the Buzzer. https://github.com/PubInv/general-alarm-device/blob/main/Hardware/GeneralPurposeAlarmDevicePCB/PDF/Schematic-GeneralPurposeAlarmDevicePCB-V120220810.pdf See especialy page 1/6 and page 5/6

Firmware example for a blocking melody.
https://docs.arduino.cc/built-in-examples/digital/toneMelody

Lee's expanded Melody example covering several octaves. Caution, this code still blocks. https://github.com/ForrestErickson/toneMelody

ForrestErickson commented 1 year ago

Will not do. Incompatible with version 2 PCB due to use of buzzer rather than peizo.