Sunday, October 5, 2014

Do not stay at the Guest Quarters Hotels - Dumping The Miracle Piano Teaching System

I had my Willem programmer pulled out for some Sega Genesis programming stuff and decided to finally dump the eprom inside of the Miracle Piano teaching System Keyboard. If you recall from a previous post of mine, it contained a 27c256 OTP eprom. It also contained many proprietary ICs of which I may never figure out. We may never know what microcontroller they used or what language the machine code is suppose to be written in. z80, 6502, etc.

In any case; with many vintage computers and other devices containing ROM, the authors always find the space to sign and date their work and in rare cases they may even decide to add a little easter egg. Although I cannot locate a date, here is some clear text I found in the ROM image:

"This Eprom contains code created by Mike Collins. Anne Graham and Ray Livingston. Do not stay at the Guest Quarters Hotels. Keep that Coke classic and that Piping hot coffee coming."



I got a real kick out of reading that. For anyone who knows what to do with it, here is the binary file:
http://www.mediafire.com/download/eo3zujca7jvw44f/MPTS_ROM.zip

Sunday, July 27, 2014

Intec PS2 LCD screen Mod

I found a controller at a junk shop for $5, and figured I would mod it onto a console. For the longest time I couldn't figure out how to add it to a console because I didn't know which cable was which. Now I figured it out: Orange: +12v (connects to a 7808 regulator so the voltage range should be greater and lesser than 12.) Black: Ground Brown: Ground Red: Right Audio input White: Left Audio input yellow: Composite video input Now I can finally build it into something. Maybe my new Sega Genesis 3, since it will fit right on the face of it and hopefully can share the same +10v power supply!

Monday, July 14, 2014

Arduino Mega eeprom programmer - Willem Killer - Pt. 1

After years of struggling with Sivava's Willem Programmer, I decided it high time to make a new affordable option. A new option which will remain open source so that everyone can made modifications and improvements to both the hardware and software.

If you own a Willem programmer, you're probably concerned with how difficult it is to get running and even once you do, it probably does a shit job of programming and reading proms of any sort. Mine in particular will program any and all 8-bit eproms, but once I use the adapter to interface with 16-bit eproms, it fails miserably to finish a write. Sometimes it doesn't even make it past the first byte ... Another person I know can program the 42-pin 16-bit eproms, but not the 40-pin versions. Together, lets fix that.

The idea is that the arduino Mega has an external memory interface which will natively (kinda) read and write to various RAM modules, so whats keeping it from reading and writing eeproms? If you erase the IC's and follow the specs in the datasheet, it has to work! Whats even better is that it will be fully USB compatible and has a massive number of GPIO just waiting for expansion.

For starters, I want get it working with both 32-pin DIP eeproms and 32-pin PLCC eeproms. Then I want to add some sort of software controlled relay or transistor switch to control VPP which is +12v. VPP is required to program older UV erasable eproms. A simple and small 7812 can be used on the board to get +12v and since the VIN or RAW pin will connect from the Mega, a single wall wart PSU can power both the arduino and the VPP. If just flashing or reading eeproms requiring only +5v then just the USB connection should suffice.

Here is what I have so far. Please give me suggestion on how to switch our VPP signal to different pins of the ROM via software. It may potentially need to go to pins 22, 1, or maybe even others. WE can figure those out later. One thing that I may change later on is adding a 42-pin socket instead of a 32-pin socket and removing the PLCC. If that were done, then the board could support more chips without so many adapters but to program a PLCC one would need an adapter. These are quite cheap though.


v

Sunday, July 13, 2014

Arduino Nano to Atmega328 DIL-28 Adapter

Threw together a quick adapter board which converts your Arduino Nano to the 28 pin DIL footprint for implementing a Nano into Atmega168/328 projects.

Original thread:
http://www.muffwiggler.com/forum/viewtopic.php?t=117310&start=0&postdays=0&postorder=asc&highlight=

Feel free to distribute and please check my schematic for faults. I would appreciate it if you all kept my blog printed on the back. Thanks!

Download Eagle source:
http://www.mediafire.com/download/6uxxp92c4fbfvot/nanoToDilByJazz.zip

OSHpark wants  $5.95 for three:
Just upload the BRD file to them and order.


Wednesday, July 9, 2014

From Casio to Modular - Pt. 2

The Service manual for the Casio CTK 150 is not available online, but it looks like the CTK 100 is! Obviously the two have very different CPU's and very different circuits, but the two also have the same number of keys and are in the same series of keyboards at least. Both keyboards have 4 octaves plus one key for a total of 49 keys. Here is the supplied key nomenclature picture:




It applies to both the CTK 100 and CTK 150. There are several methods of reading a key matrix, but clearly this is a multiplexed matrix because of all of the diodes. Wiring a multiplexed matrix to a microcontroller, or keyboard CPU in this case, is as simple as this:


With some specially wired buttons and diodes, you can read a massive number of button inputs, as many as the columns times the number of rows. This brings me to my next point: the logic table of the matrix. The logic table visually illustrates where a button lies in respect to the columns and rows which are the Inputs and Outputs. The picture below shows the table for the CTK 100, which after much probing and inspection is the same as the CTK 150. I have removed the unimportant choices, but only because I cannot use them in my own circuit. There are 15 pins that I had to trace back and name according to the table below:



At long last, I came up with the following; this is the pinout of the 15-pin ribbon cable to the key PCB in the CTK 150:

1. KO0
2. KO1
3. KO2
4. KO3
5. KO4

6. KI2
7. KI3
8. KI4
9. KI5
10. KI6
11. KI7

12. KO5
13. KO6
14. KO7
15. KO8

Each input has to have a pull up resistor, but arduino for example has programmable pull up resistors built in. All you have to do is activate them via software. With pull up resistors, every time you read a row, you will read 1 and if you write a 1 to your outputs, all inputs will still read 1. To read a button press, you must write 0 to a column and read all inputs. When 0 shows up from a column to a row, you find your "note" or button press. The idea behind multiplexing is writing and reading very quickly so that you get the illusion that you can read all buttons at once. It would be common practice to rotate a single 0 and all 1's to your outputs and read the inputs repeatedly.

Arduino supports PORT manipulation, so I will be using two ports to multiplex the inputs. The IN port will have only 6 pins and the OUT port will have to be made up of an 8-bit port and two other Digital inputs. I will demonstrate this later on. One more thing to note before I go is that KO8 (or the 9th row) has five blank spots. This row uses a whole input for only 1 button instead of 6 which means by adding five more buttons and 5 more diodes, I can add 6 more user definable inputs without using any extra GPIO's! Since I am out of musical keys, the buttons could be used for other variables like holding gate open, changing the waveform or anything else. I could even use two buttons as an octave up and octave down selection to expand the range of sound I can make with only 49 keys. After the hardware is designed, anything can be done with software.

Check back for part 3 when I write some code and hook it up to an arduino of some kind.

From Casio to Modular - Pt. 1

I found this crappy casio CTK-150 at a yard sale for $5. No MIDI communication, only an 1/8" amplified audio output, something like 5-selectable volume choices and a mono speaker. The plastic keys are not the worst I have come across, and for $5, that is about all it has going for it. I don't even care about the "twinkle, twinkle little star" sound loop; this thing can do better. Hah




I decided that I would salvage the keys to build into my modular gear (at the time of writing includes only a Pittsburgh LFO2 and a Ninstrument's Synthboy+ with MOD3). The idea was that I could either hook it up to an arduino to read the keys and output to a DAC or op amp to CV and possibly Gate. The first step was finding some decent looking wood. Over the holiday I scavenged through my mom's garage and found a cool shelf probably as old as I am. They really don't make things like they used to since this is made from hard-wood as opposed to particle board like the more affordable ones are. The sides are about 12" long and have a gentle curve, which I couldn't have cut even if I wanted to. (no tools, you see)





Now that I have the side panels, I needed to cut the keyboard to pieces. Removing the sides, buttons and guts to shrink it down and find places to mount to. The keyboard seems to have a nice 90 degree side panel at the exact place I would like, so mounting will be no problem. I think I would also like to add a place for mounting some modules either laying flat or at an angle so that I may make a portable kit of sorts, depending on how much spoace I have protruding from the top of the keys.



Keep reading for an unpdate!

EDIT: Here is part 2:
http://jazz-disassemblies.blogspot.com/2014/07/from-casio-to-modular-pt-2.html

Monday, June 16, 2014

The Solution to My Gain Problem - Goofy Op Amps

If you remember,
http://jazz-disassemblies.blogspot.com/2014/06/toying-with-gain-peek-at-differential.html
I had a problem with an operational amplifier. My circuit for multiplying by a fractional gain was successful. 1/2 gain, 1/3 gain, no problem. But when I wanted to increase gain by 2, the output voltage was much too high; exactly +5v too high in all cases. The problem was how to reduce my output by 5v in all cases, but how?

The op amp circuit that we used was a differential amplifier, which means the difference between two input voltages is amplified, and not any one voltage input. I finally found this web site with a much simpler equation:
http://electronics.stackexchange.com/questions/94043/op-amp-design-resistor-values-vs-actual-values-gain-calculation



The equation, Vout = -(R2/R1)(V1-V2)
I knew that the gain was determined by R2/R1
and that the Vin would be 0 to 5v
and Vout should be -5v to +5v

Since the gain I wanted was 2 and I knew my in and out signals, I needed to find V1, which would become my reference voltage. I thought my reference would be 0, because I want my output signal centered at 0v BUT, it is not in fact the center point of our output. It turns out that the reference voltage is also multiplied by the gain and then added to the output. If my output is 5v too high in all cases, then we need to add (-5v/2).
Therefore my range would be:

-(gain)*(V1-V2) = Vout
so,
(-2) * (2.5-5) = -2*-2.5 = +5v
and,
(-2) * (2.5-0) = -2*2.5 = -5v

There is my range! And there is my reference voltage!

R2 = 100K ohms
R1 = 50K ohms
Vref = 2.5v
so,
Gain = 2
Vin = 0/5v
Vout = -5/+5v (10vpp)

If I connect my supply voltages to +5v and -5v, then any voltages outside of that range will be clipped off, protecting any other devices this may be connected to along the line. Success!

Monday, June 9, 2014

Arduino - Cast Int to Byte - What happens?

For a project I need to spread a 16-bit unsigned integer across one byte variable and two 1-bit variables, all of which will be written to pins. The reason is not important, but I needed to know what happens to the byte value when I cast it to the byte variable. I understand that it will be truncated, but what will? The higher 8-bits or the lower 8-bits?

To find out, I wrote a quick program with a lot of clear text output.


// cast test by Jordan
// Test truncation of variables from one type to another
// most importatntly: int to byte

unsigned int intVar = 0x4080; // will it truncate to 01000000 or 10000000?
byte byteVar = 0x33;
void setup(){
  Serial.begin(9600);
  Serial.print("hello world.");
  Serial.println();
  Serial.println();

}

void loop(){
  Serial.println("integer variable equals: ");
  Serial.println(intVar, BIN); // print variable in binary
  Serial.println();
  Serial.println("byte variable equals: ");
  Serial.println(byteVar, BIN);
  Serial.println(".");
  Serial.println("..");
  Serial.println("...");
  byteVar = (byte)intVar;
  Serial.println("byte variable now equals: ");
  Serial.println(byteVar, BIN);
  while(1){} // loop forever
}

Then I uploaded it to my Arduino Nano and opened the serial monitor. I then uploaded it to my Teensy 2.0 to double check the code across platforms. Teensy is a little different in some aspects, so I had to make sure. They both output exactly the same thing:

Serial monitor output:

"hello world.
integer variable equals:
100000010000000
byte variable equals:
110011
.
..
...
byte variable now equals:
10000000"

These are the exact results that I wanted to see. I may continue on with more programming now...

EDIT: Further testing proves that the same theory does NOT hold true with booleans. (get it? "true") I had hoped that the boolean could be used to store a 1-bit number, but it turns out they are actually some sort of integer in disguise! I will have to figure out some fast way to manipulate individual bits...

Toying with Gain - A Peek at the Differential Amplifier

Op Amps have many uses and functions, even more so than a massive wikipedia page can cover. Today I will introduce the Differential Amplifier; one such function. I will also offer some real-life instances in which to use it and then discuss some issues that I found in testing.

Differential Amplifier

With some simple algebra, one may calculate a wide range of gain to apply to an input signal. According to wikipedia, the differential amplifier amplifies the difference in voltage between its inputs. The two inputs are shown as minus (-) and plus (+) or inverting and non-inverting respectively. Depending on the location of Rf, or the feedback resistor the output signal will be inverted or not. With feedback from Vout to minus, the signal will not be inverted. With feedback from Vout to plus, the output will be inverted. I only have a use for a non-inverted signal right now, so Rf will remain from Vout to minus, as shown below:


The image is borrowed from wikipedia, and is how they show a non-inverting differential amplifier. Now for the math behind it.


Not a terrible equation by any means, and it can be reorganized to calculate any of the variables other than Vout if need be. It is probably in the user's best interest to do so since they most likely already know what Vout they want and what the input voltages are.

Applying your own 1/3 or 1/2 Gain

I do have one problem with this though and that is Rg which is connected to 0v. This voltage is not taken into consideration of the equation, but could potentially be any other voltage! Lets say I want to connect V1 to 0v so this functions like an ordinary gain amplifier. According to this guy:
http://www.cnblogs.com/shangdawei/p/3190899.html
If R4 (Rg) is connected to another voltage, that voltage becomes the reference voltage that the output signal centers on. His example illustrates a -5/+5v (10vpp) voltage being multiplied by a fractional gain to output a 0/3v3 siganl. (3.3 - 0)/2 = 1.65, which becomes his reference voltage. This is excellent news since I need to work with a 10vpp signal as well. I however need to apply a 1/2 gain to get 0/5v instead of 0/3v3. Since 33K/100K = 1/3, then 50K/100K - 1/2. All i have to do is replace the 33K resistors with 50K resistors and change the refrence voltage to (5-0)/2 = 2.5v.

Exploitation

Just a note that seems never to be shared is that the power supplies to your op amp must exceed the range of your gain. If you want to amplify (lets say) a 0/5v signal up to 0/10v, then you must have a power supply at or above +10v at the positive voltage input and at most a 0v signal at the negative power pin. If you do not use a supply higher than your what your output could potentially reach, then you will see "clipping" where the signal gets cut off at the levels of the supply.

Another note is that your power supply connections may be less than the input signal if in fact you are applying a fractional gain (1/2 gain, 1/3 gain, etc.). If you have a input signal of 0/5v and want an output of 0/3.3v, then you may happily use a 3.3v input as the positive supply voltage.

Clipping sounds like a bad thing, but at the same time you may exploit it in your advantage. I need to send Vout to a microcontroller, which has a 5v tolerance. If this tolerance is exceeded, then the mC could be damaged which we don't want! Since the 10vpp signal is coming from an outside source, I have no control of how precise it is. It coul be high than +5v or lower than -5v potentially. So I can use clipping to my advantage to protect the mC. How? By applying a voltage supply the same as my Vout limits: 0/5v.
With ground and +5v, any other voltages will be clipped off! Genius. :P

Applying a Gain of 2 - Problematic ...

Within the same project, I have the need to apply another gain to another signal. I need to boost a 0/5v signal into a 10vpp signal. Since this is the exact opposite of my calculation above, I can say with confidence taht we just swap the resistors values. 50K and 100K values are swapped to produce a 2 times gain. I also want my output to be centered on 0v, so I should connect my reference voltage to 0v. It all sounds correct and I set it all up on my breadboard:



Yes, its a mess but I have three voltage supplies (+12, -12, 0 and +5) and a pot (off screen) connected to 5v and 0 as a voltage divider for my input. I also have more resistors than I should because I don't have any 50K ohm resistors, so the 100Ks are in parallel to make 50K. At one point I even had a -5v regulator connected on the board...

The problem is that when I measure my Vout with an input signal of 0/5v I am reading a range from 0 to +10v. Now, this is perfect for my gain calculations, but bad because of my reference voltage. It is referenced at +5v. Clearly, this is wrong or I am wrong, or something...

I want to assume that the reference voltage works only if it is a positive value. 0 and negative do not work as references because of some multiplication in the equations that I am missing. Everyone knows what happens when you multiply by negative numbers or by 0. I believe the fix may be a second op amp, but with a different configuration. A configuration not to apply a gain, but to shift the level down by 5v. By changing the reference and not the gain, I should be able to get the voltages I want to see. I will get back to you all once I do some further reading and testing. Let me know if you have a solution before I find it.

Until then however, I designed a simple board in Eagle that allows the user to configure it in different ways. Gain can be calculated, reference(s) voltage can be chosen Vp and Vn and it even has the option to add some DC clocking capacitors if you are working with audio signals. I call it devGain. It too has the same problem as I am having, but any fractional gain should work accordingly. I designed it sort of as a daughter card to stand upright with 90 degree header pins and take up very little room on a breadboard. What do you think?




As you can see, there are many components not on my breadboard, but like I said it can be configured for multiple purposes. The two lower Ceramic caps can be bridged for non-audio as can the electrolytic caps on the sides. RC can be either a resistor or ceramic capacitor. As a resistors it is used to define a ground reference for the next device to accept the signal. As a cap, it is used to clean up random noise that you might see on the signal if it going to a microcontroller or similar. Ignore the values below each resistor on the schematic. They were set that way for each of the two op amps found in the 8-pin DIP. TL062, 072, 082 or similar may be used.

Let me know what you think or if you have a solution to my 2x gain-reference voltage problem.

Cheers,
Jordan

THE SOLUTION!
http://jazz-disassemblies.blogspot.com/2014/06/the-solution-to-my-gain-problem-goofy.html

Wednesday, June 4, 2014

Repairing an LCD Monitor

I am damn cheap, and this isn't the first time I have gotten a broken monitor to use as my own. By broken, I do not mean that the LCD is cracked, but that it comes on and goes off immediately. Some even went black and had a buzzing noise. More often than not, this means some capacitors on the power board are swollen or popped. This is just a detailing of one monitor in particular, but the method is nearly identical to other modern screens. The other problem that could occur seems less common, so I will not cover it here. The less common problem is the wires connecting to the CCLF tubes coming loose.

Step 1. Open the screen.
Unplug the monitor and press the power button a few times to (mostly) discharge any good capacitors.
Find all of the screws that are visible including VGA/DVI mounting screws and remove them, keeping a good idea of which holes they came from.

Now pry apart the plastic shell carefully. I use an expansion slot cover found on the back of a PC because they are wider than a screwdriver and leave less cosmetic damage (if any at all). Once you have the plastic bevel popped all around the edges, place the screen on your surface area, or lap, face down and lift the plastic off the back. This may not be the exact way for all monitors, but it has been for the last four I repaired.

Step 2. Take note of the orientation of the wires leading from the metal shielding. THese connecto to the high voltage CCFL tubes and may or may not be polarized. Don't screw this up! Take a photo if it helps.



Remove the metal shielding from the power and logic boards. Be very careful of any ribbon cables.
You should find the power board which is suspect.



Step 3. Inspect the power board. If you find swollen capacitors, you probably found the culprit. In our case, there are two swollen capacitors. From my experience, they normally go out in pairs, but I cannot prove that. Can you see the two fatties?




Step 4. Replace the capacitors with a "good" brand. Nichicon is my favorite. Make sure that the Farads are matched exactly and that the voltage is either the same or higher. Higher is better in this case, but normally the caps become larger with a higher voltage tolerance.



Step 5. Put it back together and power it up. ta-da! Although this is not 100% to work for you, it is a common problem and an easy fix. Good luck and good modding.

-Jordan

 ps. The monitor in this example was the Westinghouse L1975NW. I replaced two 220uF 25v capacitors with two 220uF 35v capacitors.
I also repaired an Acer x193w+ with new caps and some other Acer I no longer have.
One time I found that a Dell E2K-SE198WFPF(B) by reconnecting the CCFL tube with its wire which was difficult and apparently dangerous. To do so I had to disassemble the screen itself, LCD, polarizing film, and other layers just to get at the tubes...which were well encased in rubber. It was very difficult and I don't think that I would attempt it again.

Exploring the Miracle Piano Teaching System

A few years back, still living at my parent's house; I visited a small dirty yard sale hosted by a previously incarcerated criminal (or so he liked to brag). Oddly enough it was a combination of baby toys and power tools, but with one gem. Probably the best yard-sadly-deal I have ever found is my $5 Miracle Piano!

The sounds that it produces are pretty basic and common to other digital keyboards, but with a few more interesting ones. The keyboard has a "synth" option which sounds pretty cool and a bunch of drum samples, dog barking, ducks quacking and car screeching. Not only that, but it has MIDI input, MIDI output, RCA audio out, headphone out and internal stereo speakers.  The last two things to mention are the footpedal input which I have yet to use and the data port connection which connects to wither the NES, Sega Genesis, PC, or whatever other game console/computer it was designed for. All I would need is a special cable and the software, but I can't be happier with the keyboard itself.

I can't necessarily play any instruments, but my goal is to incorporate this keyboard into my modular kit. I hope to modify the audio output to be compatible with the "eurorack" parameters such as 10vpp (+/-5v) audio output, maybe a 0/5v gate or trigger output for when a key is pressed. I started by opening it up and tracing the speaker audio back to the source. I started probing from resistor to capacitor to op amp ... and a few hours later I still saw no end to JUST the left audio! This thing is overly complex it seems, so I took a break since then. I would like to not only take the audio signal itself, but also to mod the MIDI out signal with some sort of MIDI-to-CV converter which I am sure there are many different options for.

In any case, here are some photos to tide people over until I make some real progress:




Above is the board covered in what I assume is a ground plane to reduce noise. The screw terminals connect it to ground. Nothing but a pretty blue shielding.



And here is the bottom of the board. On this side you can see the external connectors, audio outputs and voltage regulation components.



And here is the good stuff. Several proprietary "Software Toolworks" ICs, some sort of microcontroller (maybe) ROM, RAM, and some other unidentified IC.



Above you can see the top right corner which has several op amps. The TDA connects most closely to the RCA outputs and speaker and if I recall correctly, the headphone too. The 5532 IC seems to connect only to one of the audio channels though which confuses me since there is only one 5532.



A closeup of the buttons, some LEDs and the key connectors at the bottom. This also shows one of the post-production modifications at the left. There are several modifications that they made the the final board before sale. MOre shown below.



This is a wide shot of several of the jumper wires that they added before sale, but after production. There seems to be a lot of them... It also shows the larger ICs which need identifying.



Yet more ICs and resistor arrays.



Here is a closeup of the ROM and RAM. It also clearly shows the text on some of the unknown ICs.



Above is the same photo, but with the sticker on the ROM removed. I will dump this ROM as soon as I get the chance and release the binary. Speculating, I bet it is some program and some sound samples. If we can figure out what is program and what is a sample, then the samples should be able to be replaced which could prove very interesting!

More soon. Thanks for reading,
Jordan

Wednesday, April 23, 2014

Adding Analog Pins to Arduino pt.2

Don't forget part 1: http://jazz-disassemblies.blogspot.com/2014/01/adding-analog-pins-to-arduino-pt1.html

The first step in part 2 of adding analog pins to an arduino is by getting rid of the MCP3008! Yes, I am sorry but that particular IC is overly complicated and too expensive for what it offers.

Since I wrote that first part, I began looking for alternatives because of the price of the MCP3008. Even in quantities of 10 or more, the IC was still more expensive than a bare Atmel microcontroller! At first I thought that I could buy another microcontroller for less than the MCP3008 at a fraction of the cost and even be able to simplify the methods of communication to my own liking.

After looking for the cheapest, yet adequately powerful uC, I came across the ATtiny48 which has several Analog inputs and even more digital IO's. The Analog inputs would in theory, be read, stored in variables and then transferred to the master microcontroller across an 8-bit wide data bus. The particular analog value that would be transferred would be selected by the master uC via three other pins; select bits. The pins were going to offer a binary value which would select the current pot to be transferred.

This method would allow for me to read many many more pots than the master microcontroller was equipped with, but at a large cost; the cost of many digital IO pins. One way to get those digital IOs back would be to use analogWrite on one of the PWM outputs and connect that pin to an analog input on the master uC. Considering that, I could sacrifice one analog input for 8 more. HOWEVER, the AT48 has no PWM outsputs. :(

After mulling over it for a long time, I realized what I had actually designed. The program I had spent an hour writing... The program that utilized the exact methods of communication to suite my exact needs...was, you guessed it: An analog multiplexer which decodes 3-to-8 inputs. They have an app...I mean IC for that. The 74HC4052 accepts two sets of 4 analog inputs and connects them to one of two outputs respectively. Two select bits, choose the analog input to transfer to the output.

The 4052 is a mere 50 cents, requires no external programming, runs on a large voltage range and comes in a variety of packages!

I will simply import photos and descriptions of my project, so that I can describe how to use the 4052.
Analog pins A0-A3 are used for higher priority data, so that leaves A4-A7 open. Again, we will also need two digital IO to use as select bits on the 4052.

// ***************************************************************
// define pin connections
// ***************************************************************

int pSelect0 = 3;
int pSelect1 = 4;

// ***************************************************************
// define variables
// ***************************************************************

// locate the delay between the select bits and the updated output
// of your 4052 IC and update this value:
int latency = 100; 

byte aVal00 = 0; // analog Value, 4052 # 0, input 0
byte aVal01 = 0; // analog Value, 4052 # 0, input 1
byte aVal10 = 0; // analog Value, 4052 # 1, input 0
byte aVal11 = 0; // analog Value, 4052 # 1, input 1

byte aVal02 = 0; // analog Value, 4052 # 0, input 2
byte aVal03 = 0; // analog Value, 4052 # 0, input 3
byte aVal12 = 0; // analog Value, 4052 # 1, input 2
byte aVal13 = 0; // analog Value, 4052 # 1, input 3

byte aVal04 = 0; // analog Value, 4052 # 0, input 4
byte aVal05 = 0; // analog Value, 4052 # 0, input 5
byte aVal14 = 0; // analog Value, 4052 # 1, input 4
byte aVal15 = 0; // analog Value, 4052 # 1, input 5

byte aVal06 = 0; // analog Value, 4052 # 0, input 6
byte aVal07 = 0; // analog Value, 4052 # 0, input 7
byte aVal16 = 0; // analog Value, 4052 # 1, input 6
byte aVal17 = 0; // analog Value, 4052 # 1, input 7

// ***************************************************************
// Setup
// ***************************************************************

void setup()
{
Serial.begin(9600);
// define pin modes   
pinMode(pSelect0, OUTPUT);
pinMode(pSelect1, OUTPUT);
}  

// ***************************************************************
// Main Loop
// ***************************************************************

void loop()
{
getAnalog();
processAnalog();
}

// ***************************************************************
// Get Analog Values
// ***************************************************************

void getAnalog()
{

  // read the first set of four
  // part 1 of 4
  digitalWrite(pSelect0, LOW), digitalWrite(pSelect1, LOW); // 00
    delayMicroseconds(latency);
  
aVal00 = map(analogRead(A4), 0, 1023, 0, 255),
aVal01 = map(analogRead(A5), 0, 1023, 0, 255),
aVal10 = map(analogRead(A6), 0, 1023, 0, 255),
aVal11 = map(analogRead(A7), 0, 1023, 0, 255);
  
  // read the second set of four
  // part 2 of 4
  digitalWrite(pSelect0, LOW), digitalWrite(pSelect1, HIGH); // 01
    delayMicroseconds(latency);
  
aVal02 = map(analogRead(A4), 0, 1023, 0, 255),
aVal03 = map(analogRead(A5), 0, 1023, 0, 255),
aVal12 = map(analogRead(A6), 0, 1023, 0, 255),
aVal13 = map(analogRead(A7), 0, 1023, 0, 255);
  
  // read the third set of four
  // part 3 of 4
  digitalWrite(pSelect0, HIGH), digitalWrite(pSelect1, LOW); // 10
    delayMicroseconds(latency);
  
aVal04 = map(analogRead(A4), 0, 1023, 0, 255),
aVal05 = map(analogRead(A5), 0, 1023, 0, 255),
aVal14 = map(analogRead(A6), 0, 1023, 0, 255),
aVal15 = map(analogRead(A7), 0, 1023, 0, 255);
  
  // read the last set of four
  // part 4 of 4
  digitalWrite(pSelect0, HIGH), digitalWrite(pSelect1, HIGH); // 11
    delayMicroseconds(latency);
  
aVal06 = map(analogRead(A4), 0, 1023, 0, 255),
aVal07 = map(analogRead(A5), 0, 1023, 0, 255),
aVal16 = map(analogRead(A6), 0, 1023, 0, 255),
aVal17 = map(analogRead(A7), 0, 1023, 0, 255);  
  
  
  return; // return to main loop    
return;
}

// ***************************************************************
// Process the values
// ***************************************************************

void processAnalog()
{
// Do whatever you would like to do with the values here
return;
}

// ***************************************************************

That is all. I realize that the getAnalog function could be simplified using an array, but I did it quickly. If anyone wants to make that change, please share it! Also, I used the map function to change the analog value that was read from 10-bits to 8-bits. I have my reasons, but anyone may remove that if they want a higher resolution. 

There you have it. 16 independent analog values on top of the 4 I needed for something else. With all of the analog pins at our disposal, you could have 32 analog values! I am using this for 16 pots and the other 4 for external control voltages. Just imagine, 32 analog values with a simple Atmega168. 

Keep up with future posts to see when I actually breadboard this out. 

Thursday, March 6, 2014

Update: Sega GameGear CPLD Cartridge(s)

Just an update for an old post I made.

http://jazz-disassemblies.blogspot.com/2013/09/gamegear-cpld-cartridge.html

Remember the Flash cart that Majesco made with a CPLD as the mapper? Well, I tried again to get a pirated ROM to run in place of the old Caesar's Palace ROM and it refuses to!

Dumping the Binary for Caesar's Palace, it is an exact hex match with the copy circulating on the internet, so I know whatever mapper is contained on the CPLD must at least support ROMs up to 256 KBytes, because Caesar's Palace is that large. I tried the Fan translation of Phantasy Star Adventure which is only 128 KBytes and it will not run. I even duplicated it across the full capacity of the flash ROm just in case one of the higher address bits was tied to something I didn't see, like A18 on a 49F040 being tied to VCC. It still refused to run...

Doing some research on the GG and different BIOS versions, some GameGears check 0x7FF0 for a line of text, which is in fact present at the location it needs to be. I have tried everything and yet it still refuses to boot up. I am rather upset by all of this, which is why I am going to make my own flash cart for the GG! BLARG!

VileTim and others have made CPLD versions of the original 315-5912 Mapper chip included in a few Sega Master System and Sega GameGear carts. Obviously the goal is to design a board that makes it so we can use commercial and modern components rather than salvaging and destroying official devices. The first point I am trying to make is to design a board that supports 512 KByte ROMs, homebrew or otherwise. Then I would like to add SRAM and a battery because I am hopeful for a music tracker that runs on SMS and GG in the future.

LSDj is getting old in my opinion and there are other devices that make unique and varied sounds, such as the 76SN489 inside of the GG and SMS.

Anyhow, I have now completed a version with an official mapper that 'should' support up to 512 Kbytes when using a 49F040 ROM.



I am also working on two simultaneous versions that include SRAM and a battery, but they are going much slower because I am running out of room for traces...






The board containing a 49F040 still holds up to 512KBytes, but the TSOP can only hold up to 128KBytes. This downgrade is because the TSOP is much more available than the 49F040 and much easier to route traces to.

The two latter boards are also a little taller than the other board. The first one I designed was based on an actual official game, garfield or something, which does not fill the entire shell. The other boards I measured just how much more I could fit inside of the shell and still have it close without any cutting, which is important to me.

The second biggest concern of my boards is that I hope to get them to support Sega Master System Homebrew and ROMs. The jumper between cart pins 41 and 42 is an SMS/GG selector. when it is bridged, the GG runs in GG mode, but when it is cut, it runs in SMS mode. I have done no (successful) testing of this just yet, but I will surely post about it once I do.

Stay tuned



Tuesday, February 11, 2014

NES TSOP ROM Adapter Development Board

The title is quite a mouth full, but I have been working on an adapter board for use in the NES. While EPROMs are still available for burning ROMs, (for development purposes of course) they are running out.

27C, 29F, 49F series chips, etc. They are no longer produced and as stocks dwindle, prices increase. Some companies do still make ROM chips though! The newly produced chip are rarely made in a DIL package though, so an adapter is needed, else the user very carefully hand solders each pin. Even with each pin hand soldered, how are you supposed to program the ROM to it? With an adapter, thats how.

So say you have an adapter for one such new ROM chip. Is the final pinout the same as a CHR mask ROM, PRG mask ROM or the old 27Cxxx/29Fxxx/49Fxxx pinout? How about all three? The thing that my adapter board has, which others may not, is solder-pad jumpers to change the pinout of the two rows of pins. Each pad is named so the user can see which pads to use when they want the pinout of a CHR ROM, PRG ROM or normal flash ROM.

The only draw back is that the Chip that I used, the GLS29EE010, is only a 1 MegaBit EEPROM. That is only 128 KiloBytes. Many NES ROMs are small enough to use these, but many complex RPG's are much larger. Now for a beginner NES programmer, 128KB is plenty of room.

Anyhow, the biggest reason that I wanted to make this adapter is so I can configure the board to be a 29F010, program it with my Willem Programmer and then reconfigure the pads for either a CHR ROM or a PRG ROM. This makes it so I do not have to modify the traces on an NES cart or connect wires all over the board.

In the pictures, you can see how far I have come. I still need to place the solder pads in convenient locations and the last thing I will do is make the board smaller. As you can see, the board protrudes past the through-hole pins. This small amount of extra board may not cause any problems, but it is best to be safe.

TOP:



BOTTOM:



SCHEMATIC:


UPDATE:





The above pictures are of my finished board. The top side contains the filter capacitor, a pull up resistor for the Write enable pin and the 128 KByte ROM itself.

The bottom side has all of the jumpers which are labelled accordingly. If you want the pinout of a CHR ROM, solder the jumpers which are labelled CHR, but if you want to program the chip with your EPROM burner with factory settings, the solder the 010 jumpers and set your programmer in software as a 29F010. Its as easy as that!

I have also reduced the size to 41.91mm x 19.05mm. The filter capacitor is optional since the standard cart will have one immediately next to the power pin of the original mask ROM. The pull up resistor is required unfortunately. Many IC's now-a-days have internal pull-up or down resistors so that pins can be left open or hanging, but the datasheet does not say anything about pull up resistors and this is not a pin we can leave to self-oscillate!

Thursday, February 6, 2014

The Nintedno Gameboy Pocket's CPU pinout

I finally got around to probing the pins on the gameboy pocket's CPU and made a diagram. The CPU is not the same as the CPU inside of the original gameboy or the super gameboy SNES cartridge. When I get the chance, I will draw a schematic of the entire gameboy pocket.

Pinout photo direct link (huge): http://imageshack.com/a/img835/3936/nyix.png

  1.  A0
  2.  A1
  3.  A2
  4.  A3
  5.  A4
  6.  A5
  7.  A6
  8.  A7
  9.  A8
  10.  A9
  11.  A10
  12.  A11
  13.  A12
  14.  A13
  15.  A14
  16.  A15
  17.  D0
  18.  D1
  19.  D2
  20.  D3
  21.  D4
  22.  D5
  23.  D6
  24.  D7
  25.  /RES
  26.  VIN
  27.  SO1
  28.  SO2
  29.  MD7
  30.  MD6
  31.  MD5
  32.  GND
  33.  MD4
  34.  MD3
  35.  MD2
  36.  MD1
  37.  MD0
  38.  SOUT
  39.  SCK
  40.  SIN
  41.  CPG
  42.  CPL
  43.  ST
  44.  LD0
  45.  LD1
  46.  CP
  47.  FR
  48.  S
  49.  MA0
  50.  MA1
  51.  MA2
  52.  MA3
  53.  VCC
  54.  MA4
  55.  MA5
  56.  MA6
  57.  MA7
  58.  MA12
  59.  /MCS
  60.  MA10
  61.  /MRD
  62.  MA11
  63.  MA9
  64.  MA8
  65.  /MWR
  66.  CK2
  67.  CK1
  68.  P15
  69.  P14
  70.  P13
  71.  P12
  72.  GND
  73.  P11
  74.  P10
  75.  GND
  76.  GND
  77.  CLOCK-OUT
  78.   /WR
  79.   /RD
  80.   /CS

Some notes:

  • The naming convention that I followed is directly from the silkscreen on the gameboy pocket itself. 
  • It would seem that the gameboy pocket's CPU has the video RAM built-in as opposed to being on the PCB since the vram buses are all hanging open. Because of this, rewiring a DMG-01's CPU or a Super Gameboy CPU to the gameboy pocket is not immediately possible. 
  •  The DMG and SGB CPU's have two pins named T1 and T2 which are tied to ground. I believe that pins 75 and 76 of the MGBCPU  are T1 and T2 respectively, but only because of their placement near the clock output. 
  • The "/" means low-enable
  • For more information what some of the pins do, see the photo near the top. Or comment below.

Sunday, January 26, 2014

Secret Project Sneak Peak(s)

Some videos of a project that I have in the works which utilizes two shift registers and a bunch of slide pots. The below videos are just a few sound tests with partial hardware set up. Thanks to a good friend, I now have a scope to view the frequencies. It is an indispensable tool in spite of it being 31 years old. :D









Thursday, January 23, 2014

Build Log 1-23-14

Today I built a simple potentiometer array for testing purposes. It is nothing more than a flat surface with 8 pots with easy access pins on the sides.

If you read my previous post, we are adding analog pins to the Arduino so that we can read many more pot values. This is what I will use to test the reading functions of all 8 channels of the MCP3008 ADC.

The bill of materials includes:
8x potentiometers with fasteners
6x 1" screws
washers
6 - 12x nuts
6x nylon spacers
2 small panels of wood or thick cardboard, yes cardboard. I am cheap. :P

If you want a smaller or larger interface, then you can simply increase or decrease the parts list as per necessary. Here it is:






If you were wondering, the dimensions are 9" L x 2" W x 1.5" D. The depth is a close estimation since the screws hang below about 3mm and the knobs are all of different sizes. I used stuff around the house to build this, but maybe I will find some cheap knobs to buy from China.


Adding Analog Pins to Arduino pt.1

EDIT: I suggest reading this post instead:
http://jazz-disassemblies.blogspot.com/2014/04/adding-analog-pins-to-arduino-pt2.html
It is easier and more straightforward to program for.

All of the commonly used Arduino boards have Analog pins for use in converting analog data to digital data that can be manipulated via code. Arduino Pro Mini, Nano, Mega, Duemilanove, are all examples of boards that have 8 or more ADC pins and in some cases, they're not even all broken out!



In any case, 8 pins may not be enough for your needs, I know this fact first hand. The reasons why you may need so many ADC connections is not important, but figuring out a way around the problem is!

First, lets talk about know about the ADC pins before using them.
1. They may be used as Digital I/O.
2. They convert the analog voltages to digital data with a 10-bit resolution.
3. You don't want to waste them. ;)

The 10 bit resolution means that the data returned when using them as Analog inputs is within the range of 2^10, or 0 - 1023. I like to work with data in binary, but the data may be dealt with in decimal, binary or hex if you wish. Like:
B0000000000 - B1111111111
0x000 - 0x3FF
0 - 1023

Aside from the main point of this post, my needs are to use the values from potentiometers in an 8-bit resolution. I just found out that instead of shifting the data to the right twice (or divided by 2 twice) that the data range itself may be mapped to other values, both higher or lower. One way to read an analog input and mapping the value is as follows:


/*
Stupid simple code to read a pot value and map it to another range.
By Jazzmarazz

map(value, fromLow, fromHigh, toLow, toHigh)
*/

int A0pin = A0;

int potVal = 0;

void setup() {
pinMode(A0pin, INPUT);
Serial.begin(9600);
}
void loop() {
map(analogRead(A0pin), 0, 1023, 0, 255);
Serial.println(A0pin);
delay(500);
}

The map function could allow for you to map it to most any value:
map(analogRead(A0pin), 0, 1023, 0, 9);
map(analogRead(A0pin), 0, 1023, 0, 4095);
map(analogRead(A0pin), 0, 1023, 10, 100);
Whatever you like, for whatever purposes.

In addition, it is a good idea to read the constrain function:
http://arduino.cc/en/Reference/Constrain

Now to the point. To add many more ADC pins to the arduino, I suggest adding an external ADC via an SPI connection. Alternatively, you may use an I2C connection, but it seems like SPI devices come equipped with more analog channels. The MCP3008 for example, is an 8-channel, 10-bit ADC. This means that there are 8 analog inputs which all read back in the above mentioned 10-bit resolution.

To wire one such device to our Arduino, we must follow one of the Communication methods:

UART, I2C, SPI 2 wire, SPI 3 wire and lastly, 4 wire (full) SPI. An example of all four connections are shown below. In all of these cases, you need at least two things, a master device and a slave device. In our case, the master is our Arduino and the slave will be the MCP3008 ADC. Below also shows how you can daisy chain more slave devices to the same master bus. This is incredibly helpful because all of the devices are going to share up to three of the connections, and only have one connection that is unique to itself.


The shared connections are SCK, MOSI, and MISO while the unique connection is SS, but what do these connections mean?

MISO (Master In Slave Out) - The Slave line for sending data to the master,
MOSI (Master Out Slave In) - The Master line for sending data to the peripherals,
SCK (Serial Clock) - The clock pulses which synchronize data transmission generated by the master and one line specific for every device:
SS (Slave Select) - the pin on each device that the master can use to enable and disable specific devices.

Pretty simple, taken straight from the Arduino reference guide. You're probably wondering where the pins are. Now, you can write your own functions if you wanted to drop the external SPI slave anywhere, but a custom code is going to be much slower and it would be more easy to move your other connections somewhere else so that these pins are free for SPI:


Digital pin 13 is the Serial clock, 12 is Master Input, 11 is Master output and lastly, SS or Chip enable is 10, but I believe this can be moved where ever since it just requires a digitalWrite high or low. Low to enable of course.

That is about as complicated as it gets, honestly. Now, back to my needs. To iterate, I need to read the analog values of many potentiometers to assign to other devices, not on the SPI bus. We can do this two ways. Wire up all four connections, or wire up three connections and tie SS to ground on the slave only. If we keep SS connected to the Arduino, then we can expand the SPI bus to have more devices, more analog inputs, sensors, outputs, etc. IF we tie SS to ground, then the slave will always be active but can be the only SPI device on our bus.

Looking at the datasheet, there are two package types, the 3004 and the 3008. Both will take up all of the same connections, so lets focus on the 3008.




Pins 1 - 8 are the Analog input pins where we will connect the wiper of our pots. Pin 10 is the 1CS pin, which we will connect to !SS on the arduino. Pin 11 is the Din or Data input pin which will be connected to the Dout pin of the Arduino, MOSI. Pin 12 is the Dout which will be connected to the MISO pin. and lastly, the clock pin on 13 will be connected to Digital pin 13 on the Arduino.

Pins 16 and 15 will be bridged and connected to VCC or +5v. VDD is the supply and Vref is the reference voltage that the analog inputs are referencing. If we had a lower vref like 3v3, then our pots would have to be connected between Ground and 3v3, while the IC runs on +5v.

Pins 14 and 9 are the two grounds, Analog ground and digital ground, respectively. This may be one of the more confusing parts to hook up if you over think it. Copied stright from the datasheet:

"Utilizing the Digital and Analog Ground Pins The MCP3004/3008 devices provide both digital and analog ground connections to provide additional means of noise reduction. As is shown in Figure 6-5, the analog and digital circuitry is separated internal to the device. This reduces noise from the digital portion of the device being coupled into the analog portion of the device. The two grounds are connected internally through the substrate which has a resistance of 5 -10Ω. If no ground plane is utilized, both grounds must be connected to VSS on the board. If a ground plane is available, both digital and analog ground pins should be connected to the analog ground plane. If both an analog and a digital ground plane are available, both the digital and the analog ground pins should be connected to the analog ground plane. Following these steps will reduce the amount of digital noise from the rest of the board being coupled into the A/D converter."



What this basically means is that having analog ground and digital ground connected together may cause interference in the form of noise on the data traces. Since most of our Arduino board have only a single GND pin, we will have to take separating the two into our own hands. Some suggest dividing the two ground planes by a gap and then connecting them together via a small bridge like so:


They also suggest that you use separate power supplies. You should also remember to route any traces crossing the ground planes trough the bridge and not over the gaps. Being so strict will help you to reduce noise, but how much noise do you think that you actually have in your circuit? Are you running it on an unregulated series of AA batteries? A potato (joke)? Could you not afford filter capacitors? In most cases, the on board Arduino regulator is going to do its job in regulating the power supply, reducing noise and with capacitors between VCC and GND, yet more noise reduction.

Unless you plan on wiring up many different crystal oscillators, high speed devices, and wireless communications all on the same board, then your noise should not be readily noticeable.

Now enough of my tangents. I made up a quick MSpaint drawing of the connections:


That is the wiring diagram we will use, but for the time being, the MCP3008's are still in the mail. Once they arrive, I will write part 2 where we actually wire up the circuit and write some code to read from each pot. You may notice that the pinout is exactly 13 -> 13, 12 -> 12, 11 -> 11 and 10 -> 10. It would seem that the SPI functions were written to accommodate common SPI pinouts. You may see this on other SPI devices as well.

Thanks for reading!
Part 2: http://jazz-disassemblies.blogspot.com/2014/04/adding-analog-pins-to-arduino-pt2.html