Feed on
Posts
Comments

Today we’ll be modifying the ATtiny85_Blink WinAVR example to convert the Standalone Temperature Logger from using the Arduino software to WinAVR so that we can easily integrate it in with V-USB. Download here: Standalone_Temperature_Logger_v2.0_Beta_1

Changes to setup.c

Let’s begin with the setup.c file, to make things easier we will put all of our commonly used functions in this file too.

// Used from http://www.arduino.cc/playground/ComponentLib/Thermistor2
double Thermistor(int RawADC) {
  double Temp;
  Temp = log(((10240000/RawADC) - 10000));
  Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp));
  Temp = Temp - 273.15; // Convert Kelvin to Celcius
  return Temp;
}

First we put in the Thermistor function without any changes made.

// Used from http://interface.khm.de/index.php/lab/experiments/sleep_watchdog_battery/
void system_sleep(void) {
  DDRB &= ~((1<<ledPin) | (1<<dataPin)); // Set outputs to inputs to save some power
  cbi(ADCSRA,ADEN); // Switch Analog to Digital converter OFF
  set_sleep_mode(SLEEP_MODE_PWR_DOWN); // Set sleep mode
  sleep_mode(); // System sleeps here
  sbi(ADCSRA,ADEN);  // Switch Analog to Digital converter ON
  DDRB |= ((1<<ledPin) | (1<<dataPin)); // Set those outputs back to outputs
}

Next we insert the system_sleep function, other than the switching between outputs and inputs which is done using DDRB. Notice that we have referenced ledPin and dataPin, we will define those ports in the main.c file.

(more…)

Read Full Post »

Playing around with V-USB for AVR

Today I’ll be showing you one of the example projects of V-USB called EasyLogger, it’s basically a project using the ATtiny45 that logs a voltage and writes the value to your computer via USB. I choose EasyLogger because it’s very similar to the sort of things I’ll be using, i.e an ATtiny85 and no external crystal.

We’ll start off by downloading the latest version of EasyLogger and then viewing the schematic for it.

It looks pretty simple but to make it even simpler we’ll actually be ignoring the LED, button and input voltage so it’s just the USB connection and nothing else.

(more…)

Read Full Post »

ISP to Breadboard Connector

So I’ve finally gotten myself a USBtinyISP Programmer to use instead of the Arduino acting as an ISP. It comes with a 10 and 6 pin cable. For my needs I’ll just be using it on a breadboard and using wires from the 6 pin cable was a little tedious.

I decided just to make a simple PCB to convert those 6 pins (2×3 pins) into a 6 pin header specifically made for the ATtiny25/45/85 as it you can just simply plug it on the right hand side of the ATtiny and then just wire up the Reset and Ground lines.

More information  and download available at the ISP to BB Connector project page.

Read Full Post »

So the Arduino software has been easy to use but I’m thinking about using V-USB in one of my projects. V-USB is an implementation of the USB protocol that can run on an Atmel AVR microcontroller but in order to integrate it into one of my projects it’s time to move away from the Arduino software.

I’ll show you how we can create our own version of the ATtiny45/85 Blink without the Arduino software. We will use setup/timer functions from the internal Arduino wiring.c file because it’s easier to use something that works.

First thing we’ll do is download WinAVR from http://winavr.sourceforge.net. After installation, the default directory is C:\WinAVR-20100110.

But before we start with WinAVR we need a starting template, so what I did was download AVR Studio 5 Beta and start a new blank project. The reason I’m using Programmers Notepad instead of AVR Studio is that it’s a very simple interface and from my testing actually compresses things better when compiling.

(more…)

Read Full Post »

So I’ve been able to read/write to a Gameboy cartridge so the next step is emulating one using an Arduino. I wasn’t be able to emulate the whole cartridge using my current methods but I did emulate the cartridge sending the Gameboy the Nintendo Logo. I’ll show you how we can analyse the data coming from the Gameboy and the various steps I went through to get it working.

Let’s jump to the Youtube video straight away to see the results.

The first thing required is a Gameboy that we can solder some wires to; the Gameboy that I took the cartridge header from was perfect for this and then just place those wires into a breadboard.

(more…)

Read Full Post »

GBCartRead the Arduino based Gameboy Cart Reader project is now completed. I’ve done everything I set out in terms of saving and restoring my Gameboy saves :). GBCartRead has been updated to version 1.3 which has all the features of reading the ROM, reading RAM and writing to RAM.

The video above shows all features being used.

Now I just need to think about what my next project will be… the logical thing would be do the same with the SNES or I was thinking of working more on the gameboy by emulating a gameboy cartridge with the Arduino 😉

Read Full Post »

So what good is reading the RAM if we can’t write back to it? This is what we’ll cover in Part 3: Write to RAM.

Writing to the RAM is quite similar to reading the RAM except instead of reading the data pins you write to them. This part won’t be as large as our previous parts because we’re really just re-using our Reading the RAM code. Let’s jump right to the code.

...

  // Initialise MBC: 0x0A
 digitalWrite(3, HIGH);
 digitalWrite(5, HIGH);
 digitalWrite(wrPin, LOW); // WR on
 digitalWrite(wrPin, HIGH); // WR off

 // Write RAM (512 addresses)
 for (addr = 0xA000; addr <= 0xA1FF; addr++) {
   digitalWrite(latchPin, LOW);
   shiftOut(dataPin, clockPin, MSBFIRST, (addr >> 8));
   shiftOut(dataPin, clockPin, MSBFIRST, (addr & 0xFF));
   digitalWrite(latchPin, HIGH);
   delayMicroseconds(50);

All code up to the end of the shifting out the address is the same as in Part 2.

(more…)

Read Full Post »

I thought I’d take a little break and tear something apart, this time it’s the Super Gameboy SNES Adapter which allows you to play Gameboy games on the SNES.

Lets flip it over to see some chips.

(more…)

Read Full Post »

I hope you’ve gotten a feel of how we can access the Gameboy Cartridge in Part 1 and now it’s time for the real part that I was looking forward to: Reading the RAM of the cartridge. Before we start I recommend you read Part 1: Reading the ROM.

In this tutorial I’ll still be using my F1RACE game that uses MBC2 which is actually simpler compared to others because some of the other MBC’s use RAM banking; which is just like ROM banking as you should already know if you read Part 1. I’ll also cover another MBC to show how RAM banking works.

When we want to access the SRAM for reading or writing we firstly have to enable the SRAM, this is done by setting RD/WR and sending a specific command to the MBC. The command is called “initialise MBC” which is found on the VBG website and is given to us as 0x0A, this translates to data pins D1 & D3 should be on (00001010). The other thing to take note of is that RD needs to be set to 1 (off) and WR to be set to 0 (on) when we give the 0x0A command.

(more…)

Read Full Post »

Recently I’ve been collecting retro gaming consoles such as the Gameboy and SNES and whilst playing a game on the SNES I actually lost all my saves when I turned it off (turns out the battery got disconnected from the cartridge). The thought came to me, how can I backup the save game from these devices? There are cart readers around but they seem to be harder to find in this day and age so I thought why not make one myself using the Arduino as it’s so versatile!

Before I begin looking into extracting the save games I’ll look into dumping the ROM which was a way for me to learn how to communicate with the Gameboy cartridge. I’ll now guide you in how to communicate with the Gameboy cartridge to read the ROM so without further delay, let’s begin!

Gameboy Cartridge


Let’s firstly take a look inside a Gameboy cartridge. A typical Gameboy cartridge contains:

  • ROM is where the game’s data is stored
  • SRAM is where your save games/high scores are keep. Some cartridges (like the one of the left) don’t have this chip because they don’t store any data or it’s built into the MBC
  • MBC is the memory bank controller, it allows us switch ROM banks to read the game’s data from the ROM.
  • MM1134 IC to control when SRAM should be run from battery or not
  • 3v coin cell

(more…)

Read Full Post »

« Newer Posts - Older Posts »