Now Reading
Sport Of the 2313 speaking Geese (by makapuf)

Sport Of the 2313 speaking Geese (by makapuf)

2024-03-08 10:07:29

https://blinkingrobots.com/wp-content/uploads/2024/03/Game-Of-the-2313-talking-Geese-by-makapuf.jpg

The origin of this prototype is a recreation of the goose [goose] board recreation. It is a well-known multiplayer board recreation in France, the place the gamers advance with a cube alongside instances and attempt to attain the top, with particular “bonus/malus” instances. My son designed one as a drawing, with particular guidelines for every case and I needed to do an electronic-enhanced model of it for him.

I did not need it to be screen-based – it is not a video game-, so a lot of the interactions have been to be audio-based, multiplayer. I made a decision to report my voice and say what every of the gamers has to do, say the cube consequence … The toy must also be autonomous, so I made a decision in opposition to needing an exterior amplifier, and easy 1.2V batteries have been wanted, ideally two of them (we’ll see that powering a speaker beneath these circumstances is not simple (for me at the least)- with out boosting it with an “costly” further IC).

The ultimate result’s a functioning board recreation working on batteries, but additionally a pleasant foundation on which to make low-cost speaking toys : solely about 4$ of elements [cost] have been used to construct an entire amplified audio recreation with 1 minute Audio storage and lots of sentences. Evaluate this with the high-end answer of an arduino (15$?)+wave defend (22$) +SD card (round 5$?) (not the identical sound high quality after all, I discover this defend nice !). On the different excessive, ISD chips can have the identical high quality, can report, however they price at the least 10$ (that is the naked chip) and can’t embed any logic whereas an entire board recreation+sentence producing is built-in right here.

I made a decision to simplify the design and cut back pin rely to make use of the MCU PWM output methodology as an alternative of a devoted DAC to play the audio.

The Audio, exported as 8bit unsigned at 8kHz with Audacity, was saved in a small Flash based mostly IC (Atmel Dataflash). I used an AT45DB041d [dataflash] -type flash reminiscence, as a result of it is easy to interface with an MCU due to its SPI bus, and has some RAM buffers so RAM on the MCU will not be wanted.

The AT45DB 04 1d is 4Mbits giant, in order I sampled my audio as 8kHz/8bits uncompressed (for now – [compression]), 64kbps permits 64s of audio, which was sufficient for my use.

The flash used is an At45DB041, because it has sufficient storage and is sort of low-cost ($1.3 on digikey for the 4Mb model). A small PCB adapter was wanted since no DIP model exists.

The MCU chosen is an AVR atmel, programmed with ArduinoISP. Since we’d like 4 pins to speak to the flash (CS+CLK+DI+DO)+ Speaker output + a button for enter + a led standing, we would have liked 7 pins, so a 8-pins attiny was tough (even at 6 pins if we multiplex the button+LED, there could be no reset .. ), so I made a decision to make use of an attiny2313 as an alternative with pins to spare (or a 4313 if the code was too huge). This one remains to be very low-cost, quick sufficient and has an USI, which may serve if talked to politely to behave as an SPI for the dataflash.

The sound era is finished through the Quick PWM mode [pwmaudio].

The toy needed to be self-contained, so a speaker driving was wanted to have the ability to output loud sound. I used a easy transistor to drive the speaker, and it is a lot louder than a direct drive by attiny pins after all, even on 3V (LM386 amps are rated low voltage however want 4V on the very minimal and I needed easy cells batteries, ideally two of them). I am utilizing the truth that the output is PWM, driving the (normal NPN) transistor in saturation. I might mayeb have used a MOSFET, however it’s not a PA amplifier, so a bc548c by instance has loads sufficient of achieve.

A RC lowpass filter was added earlier than the transistor to enhance the sound.

https://blinkingrobots.com/wp-content/uploads/2024/03/Game-Of-the-2313-talking-Geese-by-makapuf.png

Every part was prototyped on a breadboard, then soldered on a prototyping board. Doing a correct PCB was an excessive amount of of a trouble for my use, however could possibly be executed if anybody is – bonus level for small SMD parts. (I ought to even do a Kickstarter 😉

https://blinkingrobots.com/wp-content/uploads/2024/03/1709947631_689_Game-Of-the-2313-talking-Geese-by-makapuf.jpg

The prototype wiring

https://blinkingrobots.com/wp-content/uploads/2024/03/1709947632_850_Game-Of-the-2313-talking-Geese-by-makapuf.jpg

The used protoboard model wiring (besides for 2 wires added afterwards and current within the schema)

https://blinkingrobots.com/wp-content/uploads/2024/03/1709947632_172_Game-Of-the-2313-talking-Geese-by-makapuf.png

A potential PCB could possibly be like : (zoom picture to see it greater)

https://blinkingrobots.com/wp-content/uploads/2024/03/1709947632_136_Game-Of-the-2313-talking-Geese-by-makapuf.png

(smd elements, 32x22mm=1.25×0.86 in., no ISP but (!), untested )

Some superior made by hand : attiny & dataflash programmers for arduino (sure, they’re crap. I am a cheapo)

https://blinkingrobots.com/wp-content/uploads/2024/03/1709947632_338_Game-Of-the-2313-talking-Geese-by-makapuf.jpg

To retailer the audio, I designed a small/easy filesystem on the AT45db to have the ability to retailer information on it and retrieve it merely based mostly on the 2 264 bytes SRAM buffers of the AT45DB.

The flash is split in pages of 264 bytes.

The filesystem construction is the next :
  • 1-page header (could possibly be 2 pages).

This can reside in a buffer and function a FAT.

4 byte header (“YEAH”), for exams and examine whether or not flash is “formatted”

array of 4 byte data for all information :

Report
web page ID of file (excessive byte)
web page ID of file (low byte)
size of final web page (excessive byte)
size of final web page (low byte)

Web page ID of file is the web page ID of the start of the file report.
The final report used has a final web page size used of 0 bytes.

  • the remainder of the storage are variable size file data, with

    1 web page filename (264 bytes max, padded with 0)
    N web page file knowledge

The FAT will all the time be saved in a SRAM buffer of 264 bytes (1 web page), so there could be (264b -4b header)/4b report -1 EOF report = 64 information most.

So, to stream a file, the MCU must learn the web page ID from the FAT (all the time saved within the first SRAM buffer), and launch a steady learn methodology from the page_id.

I wrote a easy Arduino sketch to program the dataflash, based mostly on the Arduino ISP program + dataflash library, issuing just a few easy instructions similar to learn web page and write web page, utilizing an AVR STK500-like protocol.

I didn’t attempt to emulate precisely the STK500 protocol nevertheless, since I additionally wrote a easy python utility to :

  • record the content material (learn the FAT & show it)
  • format the flash (ie write the header +reset the FAT),
  • append a file,
  • append a wav file (examine the pattern kind take away wav headers, ramp up/down sound to keep away from clicks then retailer uncooked bytes)
  • extract a file
  • extract a wav (including wav headers)

Notice that writing a file means rewriting the identical web page, however I do not plan to alter the information so typically. Additionally, there is no such thing as a methods to delete a file wanting formatting the flash.

Since we solely have 128 bytes of RAM, storing the FAT in SRAM is out of query, however since I saved it within the SRAM buffers, it is all the time prepared (For the reason that AT45DB has two of them, we might have saved 128 information).

The supply of the firmware is offered here, compiled with avr-gcc.

This system is split in a number of elements :

  • the sound producing interrupt : this one is probably the most attention-grabbing. When this system ought to play one thing, a setup operate reads the web page ID of the sound within the FAT and the variety of samples, put together a “steady learn” command for the flash chip and get up the 8kHz interrupt. One other timer is used to generate the quick PWM mode for the speaker output. Notice that the MCU must be run at 8Mhz for this to work, so some fuse modifications utilizing avrdude is required. Notice that the attiny 2313 has no SPI per se, however it has an USI which could be made appear to be a SPI if talked to politely.

    When the interrupt is awaken, it reads a byte on the flash and problem it to the PWM counter, and checks if the sound is completed (whether it is, disable sound interrupt)

  • the primary recreation operate, monitoring the place every participant is on the board, saying traps and misplaced turns, saying gamers.

  • misc utilities to say a given quantity, enter the variety of contributors (with one button), await the button with a timeout whereas flashing the led requiring person enter, launching the cube, …

To examine the logic of the sport and avoiding re flashing the attiny every time, I emulated a easy {hardware} in C, changing saying a given phrase with printing it on stdout, compiling my emulator with gcc however a special “{hardware} library”.

Then I programmed the 2313. I lastly crammed the C code in 2044 bytes (4 complete bytes free on the 2313 ! luxurious ! These huge C change statements bounce tables certain take some house so eliminating the comon instances with an if earlier than helps).

Flashing the 2313 wanted the at45DB to be eliminated for the reason that ISP pins are the identical than the USI DI/DO/CLK. It needs to be potential to desactivate the AT45 mechanically through CS when the reset pin is pushed low by the programmer, however eradicating the cable was less complicated. eh.

So as to add randomness (ie entropy) to the PRNG included, I known as rand() repetitively whereas ready for the participant to press the button (launch a cube, move to the subsequent participant, …). Thus we add randomness to the method which might have been repetitive.

I am glad with the present design, however I would reuse/enhance it later :

  • Reuse for brand spanking new video games / tips / jokes ? (Any concepts ? board video games, time based mostly video games, )
  • elevated audio high quality with increased sampling price, (a)dpcm compression and/or extra reminiscence, higher output filters.
  • Couple with (gentle / IR distant/ motion / different) sensors
  • make a talking alarm clock with a RTC chip
  • headers for isp programming (with a header to pick attiny / dataflash programming)
  • correct pcb
[compression] In fact, including mu-law encoding and/or DPCM coding would let me cut back the dimensions of the given audio or enhance the standard however that may enlarge the code measurement with mu-law tables and/or (a)dpcm algorithms, further exams. So that is left as an train for the reader 🙂
[cost] dunno precisely, I reused some from my inventory. Elements embody : an Attiny MCU, dataflash, a button, a resistor and a led + a small speaker

Licence Creative Commons


comments powered by

Source Link

What's Your Reaction?
Excited
0
Happy
0
In Love
0
Not Sure
0
Silly
0
View Comments (0)

Leave a Reply

Your email address will not be published.

2022 Blinking Robots.
WordPress by Doejo

Scroll To Top