Archive for the ‘POKEY (Atari)’ Category

Cheap FPGA Graphics, First Attempt

Sunday, December 30th, 2012

I need to find a better way to record video. An iPhone camera doesn’t do justice to the 70 frames per second of the screen.

This was a weekend project proof-of-concept for a low budget FPGA GPU. To be fair, it took a couple nights beforehand to get the display configured to recognize an RGB interface. That configuration is handled by a PIC at the moment.

The FPGA design is made of several engines running in parallel:

1) Background grid generator

2) Audio data plotter (including a UART receiver for getting data from a computer)

3) Geometry engines (one per shape)

4) Parallel RGB interface (this drives the LCD)

To keep the memory requirements tiny, there is no frame buffering of any kind for the geometry engines. The RGB interface steps through each pixel on the screen and passes the current coordinate location data to the other engines. Each engine returns a 1 (pixel on) or 0 (pixel off). The last step is a mixing block that defines the color and depth for the output of each engine. For example, the lowest layer is the background grid. Next up is the circle, and so on up to the audio plot. Only the highest illuminated pixel is shown for each location on the screen.

The geometry engines store the size and locations of their shapes in registers, so the only memory usage comes from the audio data drawn on top of everything. Audio data is being generated by Max/MSP and sent over a USB > serial cable. The FPGA double buffers it so that there aren’t any glitches due to synchronization issues.

A major downside to this general approach is that the amount of logic scales proportionally to the number of objects on the screen. If there are going to be 5 circles on the screen, this design needs 5 circle generators. One way to improve that is to use a faster clock in geometry calculations. Then each engine could handle multiple shapes per pixel.

Long-term goals: thick lines, anti-aliasing, sprites, and text rendering.

Tech details

The display is 320 * 240 pixels running at 70 fps. The complete design as shown uses 415 logic elements, 8192 bits of memory, and three 9-bit multipliers (for circle calculations). For a reference, the smallest Altera Cyclone IV FPGA has 6272 logic elements, 270 kbit of memory, and thirty 9-bit multipliers.

Hurdles

Sunday, July 29th, 2012

The 2nd version Atari synth prototypes came back from assembly early this week, but something has them bricked.
The worst case is that there might be hardware damage (soldering too hot, static zap during handling, moisture problems), since that leaves little I can prove in a post-mortem. At $500 a run, prototypes are not cheap.

<geek notes>
The power supplies measure fine, and JTAG diagnostic tests on the FPGA pass with flying colors. The configuration pins all check out, too. Yet somehow the FPGA will not run. It is not simply a code issue, because the part won’t even run factory code from the manufacturer.
The 2.5V I/O banks appear to be driving out 0.45V intermittently, which can’t be a good sign of anything.
</geek notes>

So that is unfortunate.

To get back to something that *is* working, the 2A03 synth is coming along. It currently has voltage control of:
Pulse wave 1 pitch
Pulse wave 1 volume
Pulse wave 2 pitch
Pulse wave 2 volume
Triangle wave pitch
Noise wave volume

…and knob controls for:
Pulse wave 1 pitch
Pulse wave 1 volume
Pulse wave 1 duty cycle
Pulse wave 2 pitch
Pulse wave 2 volume
Pulse wave 2 duty cycle
Triangle wave pitch
Noise wave pitch
Noise wave volume

Click here for audio of one pulse wave modulated by a couple envelope generators

One of the downsides to using the actual NES CPU is that it has unobvious quirks. It would be far easier to make an FPGA clone of the 2A03 audio engine and just fix the quirks, but what’s the challenge in that?

The pulse wave pitch control registers are a good example. They are 11 bits wide, which isn’t anything special. On the other hand, any write command to the greatest 3 bits will cause a phase reset in the output waveform. In a videogame soundtrack where each note starts with a volume of 0, it might never be a problem. In a synthesizer where oscillators are “on” constantly, it leads to clicking as pitch changes.

I am experimenting with workarounds. One trick is to use the pitch sweep hardware built into the part to trigger an increase or decrease in the upper 3 bits without issuing a write command. That has two downsides:
1) Worst case, it takes almost 20 times longer than just letting the click happen
2) It is more difficult to keep stable

It takes so much longer because it involves writing several non-pitch registers multiple times. That ends up lowering the sample rate on pitch control voltage. The stability issue is just that I see the pulse wave pitch occasionally lock up and refuse to change for several seconds. It is probably due to some corner case I have not found yet, but it never happens in the clicky version.

I cannot take credit for the clever idea to use the sweep unit, by the way. That came from the nesdev.parodius.com forum.

I made a demo to show the difference. The following audio file alternates clicky/smooth/clicky/smooth through some pitch modulation.

Click here for audio

POKEY.synth Manual Version 1.0

Tuesday, March 8th, 2011

Click here for the manual.

I wanted to get a manual of some sort uploaded before shipping the rest of the first batch of modules. I will be stepping through the names on waiting list soon to see who is still interested and ready to buy a tested module.

If anyone is curious, going Gnuplot -> Inkscape -> PDF had graphical problems, so I had to go Gnuplot -> Inkscape -> PNG -> PDF. That is why the file is huge and the text is unsearchable. The graphics look best in Google Chrome, and worst in Adobe Acrobat… go figure. I am trying to find a better method of making PDFs for the future.

The Magic Octave Effect

The Magic Octave Effect

Pokey Status Update #78234

Monday, January 17th, 2011

It has been difficult to contact me lately via e-mail, so I would like this post to help respond to many of the questions I receive. I am in the process of testing built modules and writing the manual.

What does it do?

Short answer: Pokey.synth takes an old Atari computer soundchip and adds voltage control to the sounds.

The POKEY chip was used in 8-bit Atari computers, some arcades, and some Atari 7800 games. It is like an Atari 2600 soundchip on steroids, with better pitch control and more channels. Pokey.synth uses a POKEY chip to make a 2-voice synthesizer with separate voltage controllable pitch, volume, and distortion waveform for each voice. There is also an audio input for simple bit-crushing-style effects. Detailed information will be available in the manual coming shortly.

How much is a module?

Short answer: $400 + shipping

Each module includes a tested and working Atari POKEY chip. It turns out that authenticity is a little expensive.

How much is a kit?

Short answer: kits are not available

It would cost more for me to kit the SMT components than it does to pay for factory assembly. My preference is to put time into service and new designs instead of making kits. I feel that is more beneficial to everyone in the long run.

Did you get my e-mail/pm?

Short answer: Most likely yes

After my blog post in mid-December, the first 25 spots on the waiting list filled up. I received a slew of requests via e-mails to this blog, e-mails to Analog Bytes, Muffwiggler PMs, and telepathic projections. I really appreciate all the enthusiasm, but I also want to be fair and add people to the waiting list in the order they contacted me. I apologize for the back-log. It takes time to decode the order of messages coming in the different formats, so I chose to sacrifice communication to finish the product.  My focus is on getting modules tested and packed, after which I will get back to correspondence. I also plan to create a mailing list for information, updates, and future waiting lists.

Can you ship to Japan/Greece/[insert non-US country here]?

Short answer: no, I cannot at this time.

I know a little about US laws but am still learning about the laws of other countries. For example, in many countries it is not legal to sell electronics that contain lead (unless they meet special exemptions). Here in the US, we are incredibly pro-lead. It is commonly found in children’s toys, from which it is extracted and concentrated into a purer form for recreational use*. Wealthy Americans often have gold jewelry lead-plated, because otherwise they risk looking cheap*. Using lead in electronics is a perfectly reasonable thing to do by US standards. Coincidentally, the solder in this first round of Pokey modules contains lead.

Why is the module not RoHS-compliant?

Short answer: it was too expensive for this first run. Later runs will be RoHS compliant.

Selling to many countries in Europe requires meeting a set of material restrictions (known as the Reduction of Hazardous Substances Directive).  Meeting the requirements means that solder used cannot contain lead. Sadly, the RoHS alternatives to leaded solder require a higher temperature to melt. That leads to two problems. First, the higher temperatures require a more expensive process than leaded soldering. Second, more expensive printed circuit board material is required to withstand the increase in temperature during soldering. SMT components are baked on, not soldered by hand, so the PCBs are put into an oven. PCBs expand as they are heated, so a specialized material is required in order to avoid over-expansion at higher temperatures. Otherwise, circuit board connections can become damaged during SMT assembly.

Here is a picture of modules that passed initial testing, but are awaiting final testing and knobs:

So... close...

So... close...

*: This is not actually true

Pokey Progress

Tuesday, December 14th, 2010

The Pokey synth main board PCBs are going through surface mount manufacturing this week, so modules should be ready to test and pack in the next couple weeks. In the meantime there are manual pages to write and front panels to assemble. Here’s a shot of some front panels waiting for main boards:

Once the modules are tested and ready to ship, I will start e-mailing everyone on the waiting list. All sales on this first run will be handled directly through Analog Bytes.

Pokey Status Pics

Sunday, October 3rd, 2010

All the hard-to-get parts are in, so I’m sending out for production-ready prototype PCBs. If those don’t have any issues then I’ll have a run of 25 modules done a couple weeks later.

The Panel

The Panel

The Parts

The Parts

The Bench

The Bench

The toaster oven in the corner is for baking prototypes. I haven’t needed it yet, but some parts just can’t be soldered by hand.

Pokey Panel

Tuesday, July 13th, 2010

Just a quick post this time… The Pokey module panel graphics are finished and being sent off to get made. Here’s a rendering:

Pokey Pitch Changes

Sunday, June 13th, 2010

I never really noticed this until I started getting into really low frequencies on the Pokey, but it only actually changes the output pitch on transitions of the current square wave signal. The chip itself can read hundreds of thousands of pitch settings per second, but they are only applied at the next transition of the current square wave. For example, going from a low pitch square wave to a high pitch square wave looks something like this:

Pitch It Up

The first line is the current square wave output, and what it would do if it ran forever. The second line is an instant pitch change, and the third line is along the lines of what the Pokey actually does. Note that the new pitch data in that example was sent soon before a transition in the low frequency. The worst case is when the new data gets written right *after* a transition, and doesn’t kick in for half a cycle of the low frequency wave:

Pitch It Up... again

This implies that the clock dividers driving the logic only update their divide value when they output a pulse. Pokey square waves come from pulsing a T flip-flop, so there are two pulses per output cycle. That means if the current square wave is 1 Hz, the next pitch written won’t happen right away. It can take up to 500 milliseconds to change.

This all came up because of a new feature in the Pokey module design. A Pokey square wave in 16-bit mode with the usual pitch control ranges from about 13.5 Hz to hundreds of kHz. However, the Pokey itself has a bit that can be flipped to drop the range about 4.8 octaves and go down to 0.5 Hz! Initially I planned to have switches on the back of the module for this because I ran out of space on the front. More recently I’ve updated the pitch handling routines to automatically flip that bit as necessary to make the desired pitch. This initially created a slight problem, though, because flipping that bit takes effect almost instantly and drops the current pitch by 4.8 octaves. To go from 14 Hz to 13 Hz, that bit has to get flipped at some point. If the current pitch data is for 14 Hz and the bit gets flipped, the result ends up somewhere inside a 0.5 Hz square. Then, even if the pitch data for 13 Hz is written instantly, it may not take effect until a full second (half of a 0.5 Hz cycle) has passed! In other words, there may be a full second of silence inserted when going from 14 Hz to 13 Hz.

Eventually I came up with a workaround that reliably shortens the silence to about 43 milliseconds when flipping the aforementioned octave-dropping bit. This still creates some audible artifacts when switching between frequencies just above and just below 13.5 Hz, but it lets the pitch CV and knobs control a much greater range without adding any switches.

I made some recording of the worst case switching artifacts. Going from a high note (hundreds of Hz) to a note below 13.5 Hz is not really noticeable. It’s the low frequencies where it becomes clear because of missed/extra pulses when crossing the threshold.

Here’s an example playing two pitches an octave apart that straddle the crossover point:

Click here for audio clip one

This next example is some sweeps that go through the crossover point:

Click here for audio clip two

The more I use the module with this change, the more I like it. It only applies to a channel in 16-bit pitch mode, but there is already a switch on the front panel for that.

More Pokey Module Audio

Sunday, June 6th, 2010

There is now one completely-built Pokey module prototype (though without panel artwork). The FPGA code is around 90% done. It still needs some minor usability tweaks and top secret configuration features.

More importantly, I made a few audio clips to show some of the current features.

This first clip plays a major scale on the 6 different wave settings. I’m running a Kenton Pro Solo into the pitch CV input on channel 1. A Doepfer A-141 VCADSR is going into the channel 1 volume CV input. The different types of noise have different amounts of pitchability. The notes that sound like they’re missing in a couple spots are a side-effect of how the Atari chip generates noise. There’s a little more info about why it happens in this post.

Click here for clip one

The second clip runs a Blacet Micro LFO into the CV wave input for channel 1. It’s set to a sawtooth wave to sweep through the different noise types. I’m tweaking two knobs: LFO rate and Atari channel 1 pitch. I also change the pitch resolution of the channel from 8-bit to 16-bit about halfway through, making the trip back down sound less steppy. Each channel has a switch on the front panel to jump between pitch resolutions.

Click here for clip two

The previous two clips have both been one voice by itself. This third clip starts as one voice, but then adds in the second voice slightly de-tuned. I flip the “highpass” switch that gives a nice octave effect, and then over-drive the channels via their volume knobs. The louder one channel is, the more it will modulate the other. The very end is back to one channel.

Click here for clip three

This last clip is more experimental. It combines the Aux input with low frequency noise. The signal path is a Blacet Micro LFO triangle wave into the Pokey synth AUX input. I’m also running one of the Atari channels set to noise at a sub-audio frequency. The low frequency noise creates rhythmic patterns that vary with pitch and modulate the volume of the AUX input. When the rhythm is changing it’s because I’m tweaking the sub-audio frequency and new patterns form automatically. The changes in pitch and timbre are because I’m also tweaking the Sample Rate knob for the aux input.

Click here for clip four

Keep in mind that even though the channels modulate each other to varying amounts, there are three independent channels on this thing mixed to a single output.
Channel 1: Atari oscillator #1
Channel 2: Atari oscillator #2
Channel 3: Aux input

The two oscillator channels are identical in terms of features and controls. The Aux input has a gain/attenuation control and controllable sample rate.

Pokey Knobbed

Saturday, May 29th, 2010

Still chugging along on the Pokey synth module FPGA code. Last night I finished the first draft of the A/D sequencer. The result: knobs work! Based on the current scheme, the sample rates should be:

Pitch inputs: ~40kHz each
Volume inputs: ~40 kHz each
Wave inputs: > 40kHz each
Aux input: ~40 kHz
Sample rate input: ~20 kHz

The pots are sampled in the single-digit kHz range.

Here are a couple quick audio demos:

Audio 1

Audio 2

I made these to check how the channels modulate each other at different settings. I’m just turning knobs on the front panel; there isn’t anything connected to the inputs yet.