Last Ray of Hope Home of Kaluriel Hargrove

12Jun/11Off

Discrete Logic continued

New XOR GateSee previous post Discrete Logic.

EDIT: There is a flaw with this XOR circuit, see More Discrete Logic.

In my previous post I used two PNP transistors to perform of the job of XOR gate, however after building and test, the drop in voltage was too much over just a single full-adder.

Using a circuit I got from the EEV Forums, I got help when I needed to supply 14V to my OLED but the open drain on my chip supply a maximum of 2.5V, the XOR will now supply 5V from its output when it is high.

The 1k resistor represents the load. I've also added diodes onto the inputs since I had a problem with my AND circuit getting power from the base of the PNPs.

It requires an additional NPN and PNP transistor and a couple more resistors.

Tagged as: , , No Comments
10Jun/11Off

Discrete Logic

EDIT: There is a flaw with the XOR circuit, see More Discrete Logic.

Continuing on from Sum of Two Bits, I now need to make logic using only discrete components. Addition of one bit requires two AND gates, two XOR gates, and one OR gate.

OR Gate

OR Gate

Originally I had planned to make the OR gates using transistors, I had already ordered 500 NPN and 500 PNP from Farnell so I have plenty to spare for a while. But with my new found love of pull down resistors, I realised that using diodes I could make OR gate.

If A or B are high then Out will be high too. If neither are high, then the pull down resister will pull Out down to ground.

 

AND GateAND Gate

When A and B are low, voltage on the right transistor will be pulled up to high, turning it 'on', causing Out to be grounded.

When both A and B are high, a circuit is formed and the base of the right transistor is grounded, turning it 'off', allowing Out to be pulled up to high.

If only A or only B is on, a circuit to ground won't be formed so the right transistor will remain 'on'.

XOR GateXOR

This one I used iCircuit on iOS to design. It uses two PNP transistors.

If the left switch is high and the right switch is low, the left transistor is turned 'on'. If the right switch is on, the left transistor turn off, with a pull down resister added it can be pulled to ground.

If both switches are high, neither transistor will allow the circuit to complete.

Tagged as: No Comments
9Jun/11Off

Sum of Two Bits

Half AdderA while back I read a blog that claimed that no one knows how to build a processor because of the complexity and computers do all the work today, so I've decided to see if I can make one using only discrete components.

Before working on the actual instruction parsing, I will work on the individual instructions. So the first instruction I'm going to make is ADD. The image to the left adds two bits together.

Out is only set when A or B are set, but never at the same time, so it is A XOR B.
Carry is only set when A and B are both set, so it is A AND B.

 

Full AdderEasy. However, a carry can happen, so this diagram needs to take a third input for the carry for the previous stage. In the first stage, Cin (Carry In) will be zero.

Since it is built on the previous adder, A XOR B and A AND B will still be a part of this circuit.

Out is just an extension of the previous stage, combining the output of the previous adder with the carry, ( A XOR B ) XOR Cin.

Since Out was just another XOR operation, another carry has the possibility of being generated. It is impossible for both carry's to be true at the same time, so we can just OR them together. Cout is ( A AND B ) OR ( ( A XOR B ) AND Cin ).

A quick console app to test the logic

//
//
#include <stdio.h>
 
//
//
unsigned int AddTwoBits( const unsigned int inA, const unsigned int inB, const int inCin, unsigned int * outCout )
{
	unsigned int out = ( inA ^ inB ) ^ inCin;
 
	// Output new carry if needed
	unsigned int cout = ( inA & inB ) | ( ( inA ^ inB ) & inCin );
	if( outCout )
	{
		(*outCout) = cout;
	}
 
	//
	printf( "%d\t%d\t%d\t%d\t%d\n", inA, inB, inCin, out, cout );
 
	//
	return out;
}
 
//
//
int main()
{
	printf( "A\tB\tCin\tOut\tCout\n" );
 
	AddTwoBits( 0, 0, 0, NULL );
	AddTwoBits( 1, 0, 0, NULL );
	AddTwoBits( 0, 1, 0, NULL );
	AddTwoBits( 1, 1, 0, NULL );
	AddTwoBits( 0, 0, 1, NULL );
	AddTwoBits( 1, 0, 1, NULL );
	AddTwoBits( 0, 1, 1, NULL );
	AddTwoBits( 1, 1, 1, NULL );
}

And the output gives what I expected.

A	B	Cin	Out	Cout
0	0	0	0	0
1	0	0	1	0
0	1	0	1	0
1	1	0	0	1
0	0	1	1	0
1	0	1	0	1
0	1	1	0	1
1	1	1	1	1

Now I just need to create the logic using discreet components.

31May/11Off

Accelerometer

Accelerometer next to 5mm LEDMy accelerometer arrived. It's not a part of my Programmer Calculator, but just something to play around with. It was a lot smaller than I thought, I knew it was gonna be around 3mm, not sure I will be able to just solder some legs onto it to testing, I will probably have to make an adaptor board for it.

In the picture to the left, I've placed a standard 5mm LED next to it so you can see just how small it is.

Tagged as: No Comments
31May/11Off

Royal Mail

PACKET IN BLACK BOX!!Royal Mail annoys me.

Most of the time they do not bring the package to the door, they just put the card through the door that says they missed you, and either you call up to arrange a new deliver date or you can go collect it in person. However, you can only collect after a certain time in most collection offices because the item needs to return and be shelved.

That I'm semi okay with that, I don't like having to wait in line for a half hour to get a package I paid to be delivered to my front door, but I'd prefer the card arrived before I goto work otherwise I have to wait til the next day.

Well today when waiting for a delivery from Farnell, I had ordered hoping to receive the parts for my Programmer Calculator on Saturday otherwise I would have gotten them delivered to the office, I went downstairs to see a card in the door. I had been awake from 8am waiting for UPS with my accelerometer I had also ordered so I would have heard a knock from Royal Mail.

When pulling it out of the letterbox I was thinking already that I would have to goto the collection office, but they haven't checked any of the boxes. What they had done was they had hidden it. I don't like the hiding places, if they get stolen then I have to wait even longer and claim back the money. I prefer leaving with the neighbours, even though I feel guilty when I need to go collect it.

The hiding place, was "PACKET IN BLACK BOX!!". I don't know what the two two exclamation marks are for, perhaps the delivery man was not happy. Black box? What black box?! Then it was staring right in front of me, they had put it in the recycle collection box. There are so many things wrong with that, one of which is these electrical components can be damaged by moisture, the other being plainly obvious.

Package delivery to a home address is really stupid, I had to take the whole day off since Royal Mail are unreliable at what time they deliver, I've had packages as early as 8:30am, to random deliveries at 6:00pm (which reminded me of that episode of Seinfeld when Newman wanted to work at Hawaii).

So not only am I paying tax on the items, delivery for a package (which most of the time won't be delivered), but I also have to forfeit either a day of wage or a day of holiday. Why don't they deliver at non-work hours during the week.

25May/11Off

From LCD to OLED

OLEDHaving finally gotten the LCD working, I've upgraded to an 96x64 pixel OLED (organic LED) display.

I chose DD-9664FC-2A from Farnell, since it was cheap to replace incase I broke it, and there was a separate development board I could plug it onto.

I was unable to get it to boot up initially, but after reading the datasheet a little more carefully, I found that the display requires 14V, but the logic only requires 2.5v.

The 14V can be generated from a charge pump, the SSD1331 controller chip has one, or it can use an external source. I was unable to find one on Farnell for the correct gain, so I chose to use my new 15V power station, and supply 2.5V to the PIC24 with a voltage regulator.

After accidentally short circuiting my voltage regular, I finally got the screen to turn on. However I'm starting to wonder if I broke it since there is a black band, the refresh rate is slow. I might just have it configured wrong, and the black pixels could just not be set to be on.