B.7. command 226: set volume, B.8. command 187: set note gap, B.9. command 225: buzzer off – Pololu Orangutan X2 User Manual

Page 15: C. uart commands, C.01. command 200: set serial parameters

Advertising
background image

command byte = 186

3.b.7. Command 226: Set Volume

Effect: Sets the buzzer volume by affecting the duty cycle of the PWM sent to the buzzer. The formula used is
duty cycle = TOP >> (16 – volume), where 0 <= volume <= 15. A max volume of 15 produces a 50% duty cycle.
A minimum volume of 0 produces a 0% duty cycle (however even at a duty cycle of 0% the buzzer pwm will go
high for one timer count every period, thereby introducing some switching noise to your system).

This value can be saved to byte 17 of EEPROM using command 240 (

Section 3.d.02

) so that it will persist after

a hardware reset. When storing in EEPROM, you must ensure the value is within the volume’s allowed range of
0 – 15.

Values sent: volume (4 bits)

command byte = 226

data byte = 4-bit volume (bits 4 – 6 are ignored)

3.b.8. Command 187: Set Note Gap

Effect: Sets the duration in milliseconds of the silent pause inserted after each note/frequency played by the
buzzer. If the note gap is set to zero there is no pause. Additionally, no matter what the value of note gap, no pause
is added to the end of a silent note. As such, silent notes can still be used for timing purposes if so desired. Note
gap is a 7-bit value that allows for pauses of 0 – 127 ms. A note gap allows you to distinctly hear each note in a
stream of the same repeated note. For single non-silent notes, the buzzer is not flagged as finished in the status
byte until after the trailing note-gap period has elapsed.

This value can be saved to byte 19 of EEPROM using command 240 (

Section 3.d.02

) so that it will persist after

a hardware reset. It is possible to safely store an 8-bit value at this location if you need a longer note gap.

command byte = 187

data byte = 7-bit note gap

3.b.9. Command 225: Buzzer Off

Effect: Immediately silences the buzzer. This will terminate any note/frequency or melody that is being played
and immediately set the buzzer-finished flag in the mega168’s status byte (which will in turn set the attention
line). The buzzer will remain silent until the next play note/frequency/melody call is sent.

Values sent: none

command byte = 225

3.c. UART Commands
3.c.01. Command 200: Set Serial Parameters

Effect: Specifies the settings that govern the mega168’s serial port. This command will set the baud (by giving
the three lowest bits of UBRRH, the eight-bit UBRRL, and 2x speed bit), the parity (disabled, even, or odd), and
the number of stop bits in a packet (one or two). The character size of a packet will always be 8 bits. Parity is a
two-bit enumeration as follows: 0 = no parity, 1 = reserved, 2 = even parity, 3 = odd parity. If the 2x-speed bit is
set, the baud rate as set by UBRR is doubled. If the stop-bits bit is cleared, one stop bit will be used; if it is set,
two stop bits will be used. UBRR relates to baud as follows:

Orangutan X2 Command Documentation v1.01

© 2001–2010 Pololu Corporation

3. Low-Level SPI Commands

Page 15 of 27

Advertising