home.social

#arduinonano — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #arduinonano, aggregated by home.social.

  1. Arduino and AY-3-8910 – Part 5

    My next bit of messing around with Arduno and AY-3-8910 takes my AY-3-8910 Experimenter PCB Design and adds some simple MIDI reception to create a 12-channel AY-3-8910 tone module.

    https://makertube.net/w/hLo4HLYcQkcGvf8N9XzgCS

    Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments!

    These are the key tutorials for the main concepts used in this project:

    If you are new to Arduino, see the Getting Started pages.

    Parts list

    The Code

    This is taking a combination of the following previous projects:

    I had the option of assigning unique MIDI channels to each of the 12 channels of the quad AY-3-8910s, but instead opted for a system that listens on all MIDI channels but assigns incoming notes to the next free channel.

    If there are no spare channels, the notes are ignored.

    I’ve included an option to respond to velocity, by translating a MIDI velocity value (0 to 127) into a AY-3-8910 amplitude level (0 to 15). But for now, I’m using it with a fixed velocity.

    In order to map a polyphonic note index onto a chip and channel, I use the following:

    void ayNoteOn (int chan, int pitch, int vel) {
    int ay = chan / 3;
    int ch = chan % 3;
    aySetFreq (ay, ch, pitch, vel);
    }

    The aySetFreq() function takes a MIDI nonte number and turns it into a course an fine frequency value for programming into the AY-3-8910.

    void aySetFreq (int ay, int ch, int note, int vel) {
    int vol = vel >> 3;
    uint16_t freq = 0;
    if (note != 0) {
    freq = pgm_read_word(&Notes[note-NOTE_START]);
    }

    switch (ch) {
    case 0:
    ayFastWrite (ay, AY38910Regs::A_TONE_C, freq >> 8);
    ayFastWrite (ay, AY38910Regs::A_TONE_F, freq & 0x0FF);
    ayFastWrite (ay, AY38910Regs::A_AMP, vol);
    break;
    }
    }

    Additional case statements are provided for channels 1 (B) and 2 (C). The Notes array is the list of frequencies calculated for a 1MHz clock using the equation provided in the data sheet:

    • Freq (tone) = Freq (clock) / (16 TP)

    Where TP is the 12-bit value placed in the course and fine frequency registers. So turning this around and plugging in the frequencies for MIDI notes, we can figure out the 12-bit values required to be programmed into the registers.

    In the end, I cheated and used the table already provided here: https://github.com/Andy4495/AY3891x/blob/main/src/AY3891x_sounds.h

    This covers all notes from C0 (MIDI 12) to B8 (MIDI 119).

    I should also note that I’ve now removed all of the original AY3891x library and am using my own fast-access routines now tailored for supporting four devices.

    As I’m using port IO though, this does mean there is a fair bit of hardcoded assumptions about Arduino PORT usage and GPIO pins.

    Find it on GitHub here.

    Closing Thoughts

    The video shows my, now, go-to test of anything linked to Arduinos and tones – a 12-channel arrangement of the end titles of Star Wars Episode IV – A New Hope.

    As the code will select the next free channel for incoming notes, sometimes consecutive notes sound slightly different due, presumably, to differences in the output channels of the devices. Something to look at, at some point.

    It would also be useful to have a “multi-track” version where each channel is an independent MIDI channel in its own right, but for now, using OMNI and “next free channel” is fine.

    I have to say, when the theme really gets going with those vintage 8-bit tone sounds, I could be sitting back in that 80s Star Wars vector graphics video arcade machine… (although apparently that used several Atari POKEY chips, not AY-3-891x- shame. I wonder if you can get hold of those too…)

    “The force will be with you. Always.”

    Kevin

    #arduinoNano #ay38910 #midi #tone

  2. AY-3-8910 Experimenter PCB Build Guide

    Here are the build notes for my AY-3-8910 Experimenter PCB Design.

    https://makertube.net/w/fULfpG9LNwpb3iCfavVkAp

    Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments!

    If you are new to electronics and microcontrollers, see the Getting Started pages.

    Bill of Materials

    • AY-3-8910 Experimenter PCB (GitHub link below)
    • Arduino Nano
    • Up to 4x AY-3-8910 40-pin DIP devices (see notes here on obtaining devices: Arduino and AY-3-8910)
    • 1x 6N138 optoisolator
    • 1x 1N4148 or 1N914 signal diode
    • Resistors: 4x 220Ω, 1x 4K7, 14x 1K
    • 6x 100nF ceramic capacitors
    • 2x 1uF electrolytic capacitors (the PCB has 220uF on the sinkscreen)
    • 1x 100uF electrolytic capacitor
    • Either: 3x 3.5mm TRS PCB mount sockets
    • Or: 1x 3.5mm TRS PCB mount sockets and 2x 180 DIN PCB mount sockets
    • 1x 2.1mm barrel jack socket
    • 2x 15-way pin header sockets
    • 4x 40-way wide DIP sockets
    • Pin headers
    • Optional: 1x SPDT, 1x DPDT both with 2.54mm pitch connectors
    • Optional: 1x 8-way DIP socket

    Build Steps

    Taking a typical “low to high” soldering approach, this is the suggested order of assembly:

    • All resistors and diode.
    • DIP and TRS socket(s).
    • Disc capacitors.
    • Switches (if used).
    • Electrolytic capacitors.
    • 15-way pin header sockets.
    • Barrel jack socket.
    • DIN sockets (if used).

    It is necessary to add two additional 1K resistors as patch-links on the underside of the board. Details below.

    Here are some build photos.

    The DIP sockets should go on next before the TRS sockets.

    Pin headers and jumpers could be used for the MIDI on/off switch. The power switch could be bypassed with a wire link if not required.

    There are a number of optional pin header breakouts: power, UART, additional IO and all the IO for the four AY-3-8910 chips. For this build I’m not populating those.

    Errata Fixes

    As mentioned in the design notes, two additional resistors must be added to pull the audio outputs to GND as part of the output/mixer circuit. I used two additional 1K resistors.

    These can be added to the underside of the board as shown below.

    Testing

    I recommend performing the general tests described here: PCBs.

    Once everything appears electrically good, here is a test application that will play a chord on each of the devices at a different octave. If this works it should be possible to hear all 12 notes in the four chords across four octaves sounding.

    Find the code here: https://github.com/diyelectromusic/sdemp/tree/main/src/SDEMP/ArduinoAY38910QuadTest

    PCB Errata

    As already mentioned there are the following issues with this PCB:

    • The two 220uF capacitors should be replaced with 1uF capacitors.
    • Two additional resistors need to be patched into the audio output circuit.

    Enhancements:

    •  None

    Find it on GitHub here.

    Sample Applications

    Here are some applications to get started with:

    •  (on their way)

    Closing Thoughts

    It took quite a long time to realise the issue with the output channels. For ages, it appeared that the interface to the chip just wasn’t functioning correctly. With hindsight, some kind of register read/write test would have confirmed that a lot earlier.

    It was only when going back to the schematics of other designs and recognising that the output was always HIGH did the penny drop that the additional resistor was required. Then there was some experimentation to find something that would work with my board and not cause issues in use.

    But it seems like I got there in the end. Now I can get on with doing something a little more interesting MIDI and music wise.

    Kevin

    #arduinoNano #ay38910 #pcb

  3. @fast_code_r_us I build this with (more for) my nephew with #arduinonano clone and an #SSD1306 128x32 #oled display.

    I used the #U8g2 to display the text and the u8g2_font_unifont_t_weather to display the thermometer icon.

  4. This takes the Arduino Nano Mozzi Experimenter Shield PCB and swaps out three of the pots for the optional use of the following:

    • MCP4725 DAC.
    • SSD1306 display.
    • IO links for an analog multiplexer.

    This is in addition to the remaining three potentiometers, the MIDI interface and the audio filter output.

    Warning! I strongly recommend using old or second hand equipment for your experiments.  I am not responsible for any damage to expensive instruments!

    The Build Guide is available here: Nano Audio Experimenter Sheild PCB Build Guide.

    If you are new to Arduino, see the Getting Started pages.

    The Circuit

    The board includes a 5V MIDI IN and unbuffered MIDI OUT. It includes a barrel jack for power directly into the Arduino Nano’s raw input.

    It includes pin headers for an SSD1306 display and MCP4725 DAC and headers to allow connection to an analog multiplexer such as a 4051 (8-way) or 4067 (16 way). This is connected to A3.

    There is also an audio output filter stage that can be switched between D3 or D9 for PWM output or the DAC.

    The following Arduino pins are used in total:

    • A0, A1, A2: potentiometers.
    • A3: optional analog multiplexer input.
    • A4, A5: SCL, SDA I2C interface.
    • D0, D1: UART MIDI RX and TX.
    • D3 or D9: optional PWM output.
    • D4, D5, D6 and optionally D7: multiplexer “address” outputs.

    PCB Design

    Key aspects of the design:

    • It follows quite closely the format of the Arduino Nano Mozzi Experimenter Shield PCB on the power, MIDI and Nano side.
    • A jumper allows the audio output to be connected to D3, D9 or neither if a DAC is plugged in.
    • The multiplexer’s S4 pin can be hard-jumpered to ground if required or left unconnected (or both) if not using a 4067 16-way device.
    • There are header pins which match the footprint of a DPDT switch to disable the MIDI link to D0/D1 to allow uploading of sketches.
    • The audio section of the DAC has a separate GND plane for the analog output section. If the DAC is not used this has to be connected to the GND plane of the rest of the board, so an additional connecting, plated hole is provided near to the DAC header footprint.

    Closing Thoughts

    I believe it is possible to use both the SSD1306 display and the MCP4725 DAC whilst servicing the other IO on the board, but I can’t imagine it would yield any practical or useful function to do so!

    This is a board with options that aren’t necessarily meant to all be used at the same time. It is the latest in my line of “experimenter” boards, essentially designed for messing about with audio on the Arduino Nano.

    The only thing I wished I’d added was some test points for an oscilloscope probe.

    Kevin

    https://diyelectromusic.wordpress.com/2023/11/12/nano-audio-experimenter-sheild-pcb/

    #74hc4067 #arduinoNano #cd4051 #mcp4725 #midi #multiplexer #mux #pcb #pwm #ssd1306