Today we’ll introduce the N Channel Mosfet and show how we can use it to allow us to switch between voltage sources.
Mosfet explained and example
We can think of a mosfet sort of like a transistor, it has a gate, drain and source compared to the transistor which has base, common and emitter.
With transistors that we want to act as a simple switch it’s all about adjusting the current at the base however with mosfets it’s actually the voltage at the gate that turns them on. Because we don’t lose current when turning the mosfet on, this means that it’s actually more efficient than a transistor.
In datasheets you see it called Vgs and they provide you a minimum voltage that is needed before the mosfet will allow current to flow through the drain and the source.
In this demo we show how we can change the ATtiny85 clock speed on the fly by modifying the prescaler. We note that using _delay_ms() is subject to the F_CPU and if we double the MHz we need to double _delay_ms() in order for the timing to be correct. Changing the clock speed on the fly may be useful for power saving applications where there might be brief moments to increase the clock speed, e.g. communicating with devices like USB.
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.
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.
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.
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.
Learn how to use the Pin Change Interrupt on the ATtiny85 to wake up the microcontroller from sleep. Using the Pin Change Interrupt you can use any of the ATtiny’s 6 pins however remember that all 6 will trigger the same interrupt vector PCINT0.
Ever wanted to know how to reduce the power consumption of your Atmel microcontroller when it’s not doing anything? The 2 videos below will step you though how you can reduce the power consumption of your Atmel microcontroller (in this case the ATtiny85) by using the power down sleep mode with the Watchdog timer.
The beauty of the watchdog timer is it allows us to not require an external interrupt to wake up the microcontroller, instead it wakes up after a certain amount of time by itself.
So I’m playing around more with the Scanalogic 2 Pro and thought instead of just reading the Logitech LX310 receiver’s EEPROM I would actually probe it and see what’s going on when it starts up. My plan for this post is to make it as simple and easy to follow as possible.
As you might know it’s a ST 95160 16Kbit EEPROM which is uses SPI protocol; I’ve found that SPI is harder to understand and use than two-wire (I2C) protocol. I used the Arduino SPIEEPROM page to assist me as well as the datasheet which once you read parts of it enough times and see what’s happening in the logic actually starts to make sense
Download the complete timeline of SPI communication here: Logitech LX310 Reciever SPI 10Mhz
You’ll need to download the Scanalogic software in order to use the above file. Please note that the ms timeline shown in these pictures may be different to the timeline you download, however all queries are still the same.
Here is an overview of the first 10ms upon connecting to my computer.
What I suspect we see up to the first millisecond is the chip in the receiver is initialising itself by looking at the CS line as it’s going high and low very quickly, plus it could just be the rush of power to it causing the CS to go all funny.
I thought I’d look into reading data from an EEPROM that is I2C capable from a PCB, the PCB is from a KVM which is a device that allows you to use your keyboard, video (monitor) and mouse on different PCs without switching out the cables.
Below is the PCB and the EEPROM which we’ll be looking at.
If you can make it out it’s a Atmel 24C32A, a 32Kbit EEPROM, datasheet here: atmel 24c32a