Feed on
Posts
Comments

Category Archive for 'Projects'

I’ve built a 32KB Gameboy cartridge before to add support for certain flash chips to GBxCart RW but those were wired straight through without the need of an MBC so I thought it might be interesting to jump back into CPLDs by building an 2MB Gameboy cart.

We have a few options when building a Gameboy cart, use 5V Flash chips (which are pretty rare these days) with 5V SRAM chips or go 3.3V Flash/SRAM chips and use level shift transceiver with direction control to interface with the Gameboy’s 5V logic. Because this is my first real cart, I’m going with easier the 5V flash/SRAM chip option for the moment.

(sneak peak of the cart running a game)

The only flash chip I have on hand is the 512KB AT49F040 so I’ll use that at the start and then we’ll transition to the 2MB AM29F016B in a later part once it arrives. For the MBC, I have an Altera EPM3032 CPLD handy so we’ll go with that, it runs off 3.3V so we’ll need an LDO for it and the inputs accept 5V logic.

Initial Planning

 

Let’s get started, firstly we’ll review the MBC5 documentation to determine which addresses the CPLD will need to read for changing ROM banks/RAM banks, etc. The lowest address is 0x0000 – 0x1FFF for RAM enable, the highest bit of that address that’s a 1 is A12 so that’s where we will start. The highest address is 0xBFFF when accessing the RAM, so A15 is where we will end, that makes 4 bits which are needed for listening to incoming MBC requests.

(more…)

Read Full Post »

Building a Simple LiFePO4 USB Charger

Since I’m starting to use more LiFePO4 14500 batteries I thought it would be a good idea to build a simple USB charger for them instead of having to charge 2 at a time on the xxx battery charger. The most simplest way would be to stick it on a CV/CC power supply or another way is to stick it on a CV power supply set to 3.6V with say a 1 ohm resistor and wait for it to reach 3.6V, not the quickest to charge but it works.

My first design was to use a voltage reference such as a TL1431M (or a resistor & zener diode) set to 3.3V with a decent op-amp like the MCP6242 with hysteresis threshold set to 3.2V – 3.6V and an PNP transistor to switch the 5V through say a 10-20 ohm resistor to the battery. This would only charge the battery if it was under 3.2V, stop at 3.6V and won’t start charging again until the battery dropped back to 3.2V which it shouldn’t.

It works one problem arises when you unplug the USB side and leave the battery in, it would start discharging a few mA due to being connected to the op-amps output but it’s not like that would really ever happen. But let’s put in an MCU, say an ATtiny13A to sort it out. I have plans to make a device in the future run off the LiFePO4 battery and recharge itself when the USB cable is connected if it matches the threshold voltages as before.

(more…)

Read Full Post »

From our previous part, we designed a client with the nRF24 which communicates the LiPo battery cell voltages to a server running from an ESP8266 so we could easily jump onto it and check the cell voltages. In this part we’ll add in email alerts with adjustable battery voltage thresholds, add an easy server setup process to join your Wifi and give the system a test.

First things first, the client PCBs arrived (34 x 23mm), built one up and it worked well. I sprayed the board with PCB lacquer and put clear heat shrink over it. When trying to link it up to the server, it wasn’t working, seemed to just stay waiting to receive the packet from the server. I eventually found out that I had to bump the voltage up to at least 3.9V for it to link up properly, I’m guessing the 3 diodes dropping the voltage down is part of the issue when listening as it can take quite a bit of current. Sending a packet when it checks in works fine at lower voltages. When ATtiny and nRF24 are sleeping, it takes about 6uA so I’m happy with that.

I was thinking about redesigning the board to make it even smaller (32 x 16mm) if you just had up to a 4 cell battery, it would be a little bit harder to build.

(more…)

Read Full Post »

From the previous part, we designed a small power supply based on a Richtek DC-DC, added an 128X64 OLED display and gave it a quick test which it seemed to cover most voltage ranges with better increments than the old SPPS.

(sneak peak)

The PCB’s arrived and we’re ready to start populating each segment individually to make sure each part works. I put on the ATmega328 with the LCD, tested ok. Next was the main DC-DC converter with digital potentiometer and to test controlling it from the ATmega which seemed to work fine. One thing I hadn’t really paid attention to was that the DC-DC converter only goes up to supply voltage – 2V or so from my testing, the reference voltage starts to drop from the nominal 0.8V and it started to oscillate, so I might need a 18V power supply if I want up to 15V output.

Output Enable troubles

Next I soldered the P mosfet for the enable so I could enable or disable the output, that’s where things didn’t go as planned. I hadn’t considered the case where the power supply was set 2V and the gate was low, Vgs would only be -2V which is not enough to turn on the mosfet, you need something like -5V or higher to full switch it on, basically under 5V it was unusable, the mosfet would be dropping most of the voltage.

(more…)

Read Full Post »


Wouldn’t it be nice to know it you have mail? I think it’s a good idea and had it on my to do list for a while. Our letterbox looks similar to the one above, you can place small items on the top, in the letter slot or open it up from the back.

 

At first I thought we could do this with a vibration switch however upon testing the switch it looks like it needs a fast motion in order to activate. Another option is a reed switch on the top part so if the mailbox is opened, it will detect that, but would leave letters undetected. And yet another option, is a light sensor placed inside the mailbox but also results in the same problem.


So one of our last options is to use an accelerometer to detect the slightest touch of the mailbox, most mailboxes are pretty rigid but ours has a tiny bit of moment to it, we can’t really put the device we would make in the letterbox itself as the RF would mostly be blocked so it would have to be placed outside. As usual, I’ll be using an ATtiny84 with the nRF24 to simply send a packet when the interrupt occurs.



The accelerometer I’m looking at as you can tell by the title is the ADXL345 which has 2 interrupts available for single tap, double tap, activity, etc, and current consumption looks to be pretty low. It supports I2C or SPI, we’ll be using 4-wire SPI.

So I tried the SparkFun ADXL345 example which worked well, they have all the interrupts available so all I need to do is take everything I don’t need out, convert it to C and try out the low power modes. Note that the ADXL345 is a 3.3V device so you will need a logic level converter if using it with a 5V Arduino.

(more…)

Read Full Post »

I have a couple of nRF24 devices around the house like the doorbell, front door camera, the single receiver for both and I might look to expand that list in the future but re-programming the receiver when you would like it to handle a new device or perform an additional action can take a while plus the time testing that everything works.

So I thought, why not make an ESP8266 for a web interface where we can store rules and have it connected to the nRF24 to receive incoming packets, it’s similar to IFTTT but all local. The rules would all be based on a single byte packet it would receive, we could have the rules active or not, with rule actions such as sending an email, pulsing a pin for a certain amount of time, sending an nRF packet, writing data to a common variable (with a timeout when it’s reset) and reply back with that variable. We can have a button to save everything to the EEPROM (emulated on flash) and read it all back if the ESP8266 is power cycled.

Some quick use cases:
– Doorbell is pressed, you could either have it pulse the buzzer locally for a second or two and you could also have a remote buzzer anywhere else so it sends a packet to have that buzzer go off too.
– I’m thinking about adding a small sensor to the mailbox, so if it’s moved, it would send a packet, we could have it write data to a variable. Add a battery powered sensor anywhere around the house with either a buzzer or LED, to check in every few seconds and read that variable back so if it changes to a 1, the buzzer or LED goes off for a little while.

(more…)

Read Full Post »

When finding out that one cell of my 3x 4S 1300mAh batteries were discharged to 3.3-3.4V (other cells were 3.7-3.8V) after not flying for 2-3 months, I was a bit surprised, these batteries were one of my first batteries purchased about 1.2 years ago. I’ve tried to be better now, checking packs every month, I’ve got some old packs for the RC car that hardly get used so I wrote down the idea to do battery storage voltage monitoring a few months ago so let’s make it happen.

I’m thinking of using the nRF24L01 module (as it’s pretty low cost), using an ATtiny24/44/84 which should give us 6S support and have it powered from the first cell of the LiPo, it shouldn’t take too much current from the first cell as we stay in sleep/power down most of the time. Add in a few resistors, led, mosfets to turn on when we want to measure the voltage. I will coat the PCB in lacquer and cover it with heat shrink to protect against the environment and since the board needs to be as small as possible, I’m going to try the SMD version of the nRF24.

Check-in times for these sensors might be in the range of hours as battery voltage won’t change too much, it would be nice to have a graph over say 30 days but I might look into that later if I feel it’s worth doing, for the moment it will just show the sensor number, cells, status if it’s ok or not, battery cell voltages and last check in time. Server side would just be an ESP8266 with the nRF24L01 directly attached so no need for any other MCUs.

(more…)

Read Full Post »

Previously I was looking at making a Dual Output Linear Power Supply, the prototype was working but while designing the PCB it would end up being large, a bit heavy with the heat sinks and I don’t think I would really need a linear power supply, it was a nice idea.

So it’s back to the drawing board as to what I really need, I do still have the SPPS which works but maybe it’s time for an upgrade and now that I know a bit more about DC-DC converters we can stick in the Richtek DC-DC chip instead of using an Ebay DC-DC module. We might as well switch out the 8 digit LED display for an 0.96″ 128X64 OLED SSD1306 display which I’ve seen a lot of projects move to.

The DC-DC converter I’m looking at using is the RT8292B which runs at 1.2MHz versus the 400KHz of the RT8293A which I was using previously, it looks to be almost identical except that it will allow us to use a smaller inductor.

Like we’ve done before, we will use a 10K resistor for R1 and 10K digital potentiometer for R2 to control the output of the DC-DC.

(more…)

Read Full Post »

I thought it might be interesting to go over the noteworthy software/hardware changes since the initial release of GBxCart RW, some of them include changing the MCU, using TinySafeBoot as the boot loader so the firmware can be easily upgraded, some GB flash cart support and various fixes.

Change to ATmega8515L
In the initial release I was using the ATmega32A which was just short on 2 pins for displaying the 3.3V/5V LEDs so I ended up using an inverter to do that. I didn’t really want to keep using an extra part (inverter and supporting parts), plus it wouldn’t be able to support GB flash carts in the future as I didn’t have enough pins for the GB cart audio pin as that’s how you program some of them. I did a more broader search and came to the ATmega8515L which gave me 3 more I/O, just enough for the audio pin and 2 LEDs so I could remove the inverter (it also seems like the MCU some other GB cart devices use too).

Gameboy Camera SRAM misread bytes
One user reported that their GB camera SRAM dumps weren’t consistent, I could replicate the issue and it looked like some of my photos had some vertical lines, some more visible than others. It seems that when reading the SRAM, we have to delay an extra MCU cycle, so it went from 1 nop to 2 nops, shouldn’t be too noticeable, now those lines are gone and the SRAM files are always identical.

Additional EEPROM checks / Fix for GBA 32MB carts
There seemed to be an 4Kbit EEPROM which allowed 64Kbit reads without repeating the same 8 bytes over and over again, if it did repeat, that was the way we would know if it was a 4Kbit EEPROM. So I added another check which read the first 512 bytes and then second 512 bytes which wouldn’t be possible for a 4Kbit EEPROM so it should repeat the same 512 bytes which it did.

Before I was addressing the EEPROM at 0xFFFFFF but it seems like this didn’t work with 32MB carts. I re-read the GBATek information page and I must have missed the part where they briefly mention 32MB carts, in the end I changed it to read at 0xFFFF00 and it worked fine.

Flash save writing, not waiting for sector erase / Forgetting to end write before switching banks / Stuck in Flash ID mode
One user reported that their Pokemon save games weren’t being written correctly. When writing to the flash I was erasing the next sector, waiting 25ms as per some datasheets and then I wrote to that sector. I read somewhere that as flash gets worn out, it takes longer to do the sector erase so instead of waiting for 25ms, I’m now waiting to read back 0xFF from the first byte of that sector which resolved the issue. Later on I bought Pokemon Ruby and I could tell that doing a sector erase on it took longer than 25ms.

(more…)

Read Full Post »

With the LiPo battery fires I hear from time to time, I thought it might be a good idea to build a temperature monitor when charging LiPo batteries. Ideally you would put a little case over the battery with the temperature sensor inside (a low cost thermistor would do) and then if the temperature rises by approximately 15C from when you switch it on then it should alarm you.

Whether the batteries get noticeably hot when they are about to pop is something I will need to test one day (I’m sure they would to some degree) but if they do pop, I have heard that pieces can potentially go everywhere so it’s best to contain the batteries when charging.

(sneak peak)

I decided to go with an ATtiny24A which would have enough pins for 6 thermistors, a buzzer, a shift register to control the LEDs and it will be powered by a LiFe 14500 battery.

Once the battery is inserted, it should read all thermistors to check if they are connected, get the base line temperature and then begin to monitor the connected thermistors. If no thermistors are connected at the start, any thermistor that was connected becomes disconnected or the temperature rises by about 15C, it should indicate which one it was and turn the buzzer on.

(more…)

Read Full Post »

Older Posts »