Search This Blog

Wednesday, 18 January 2017

Fiddling with a Transistor


I found myself scratching my head the other day trying to remember the difference between Class A, B and C amplifiers and how that impacted a transistor bias.

To help me, I've drawn this quick schematic:

Now, you will see that R1 has a "*" next to it; that's because we are going to play with this value.

The transistor base will switch on when the voltage on the base is greater than 0.6V.

So, if we place a 10K resistor where R1 is, we place the base at DC voltage of about 1.6V. If we now apply a 2V peak to peak signal to the base (in my example it's a 100KHz signal), then the lowest point of the signal the base will be at 1.6V minus half the voltage peak to peak = 0.6V. Therefore the transistor will be switched on for the full input signal cycle.

The voltages on TP1 are in yellow and TP2 in blue. Here the first example with 10K as R1:

You can see that all of the input signal is above the dotted line (which is at 0.6V) and therefore the transistor is biased on throughout - this is Class A operation. Harmonically it looks like this:

Now, lets change R1 for 39K which will place the base at DC voltage 0.6V and apply the same 2V peak to peak signal. This time the transistor is only switched on for about half the cycle and the resultant voltages look like this:

Here we have 180 degrees of the input signal turning on the transistor - this is Class B operation. Harmonically it looks like this:

Finally, if we remove R1 completely, then the base of our transistor is at DC ground (being pulled low by the 4K7 resistor). If we now apply our signal we see this:

So the transistor is only on for less than 180 degrees of our input signal - this is Class C operation.

Harmonically it looks like this:

Now, you may wonder what use Class B and C are? Well, in an audio amplifier - none at all! You would hear all that distortion and harmonic content and it would sound completely awful. However, from an RF perspective, we can easily remove the harmonics from the output and retain just the target frequency - they all seem pretty much the same now - agree? And Class B and C amplifiers consume much less power (because the transistors aren't turned on the whole time) so are far more efficient. We just need a suitable low pass filter at the output and we can "reconstruct" our signal.

Interesting, egh?

Sunday, 15 January 2017

Have you Really? Wow!


This isn't really radio related, but I'm scribbling here to document my steps (well, thats what a blog is for - isn't it?).

At home we have a really pants copper telephone line based Internet connection provided by Sky. Now, nothing Sky can do really as its the infrastructure that makes the connection speeds so slow. We have also been having issues with Wireless speeds generally and also often hit a "bonkers" (as far as I can work out) restriction on the number of devices that can connect to my network. For some reason the DHCP works fine up to 16 devices, but as soon as device 17 tries to connect it fails.

Often this will be my Spectrum Analyser but also it happens to be the visiting sprogs laptop - all very inconvenient.

So today I've bought a TP-Link router with 5GHz and 2.4GHz wi-fi to replace the Sky provided box. The man in the shop told me this was impossible, as Sky will not release the username and password needed to connect to their network.

So, hacking hat on, here's how I've done it:
  1. First, I downloaded some software called Wire Shark from here
  2. Then I installed the software on a PC connected with a wired connection to my Sky router.
  3. Start Wire Shark recording network traffic and then re-boot the router so we capture the network traffic as the router starts up.
  4. Once re-booted, stop the software capture.
  5. use the filter in the Wire Shark software to look only at "udp.port == 67"
  6. In the search results look for "DHCP Discover" traffic and expand
  7. In the expanded area you will find "Option (61) Client Identifier"
  8. Right click and find the option to copy as printable text
  9. Paste the results into a text editor (I used Notepad++)
  10. Low and indeed behold, there is your Sky username and password in the format "=username|password"
I then quickly connected to the router and noted down the MAC address from the "Broadband Port" section of the config screens.

So, armed with this information I plugged in my new shiny TP-Link router, selected "Sky Broadband" as the ISP and entered my username and password. Bingo! I then checked the help on the router and changed (or rather cloned) the MAC address of the Sky router - this is so that from an external perspective you can't tell that the router has been changed.

Result: Much faster wi-fi and no restriction on the number of devices I can connect.

Local conditions.

AVR dude - really?


Over the past few months or so I have been playing with kits from QRP Labs based on the genius of Mr Hans Summers.

I was using the VFO I made back here to clock my newly built Signal Generator from here and found some rather odd behaviour.

When I investigated this I found that the VFO output switched off every second:

I posted on the QRP Labs forum and very soon had a reply telling me this was an issue that had been fixed in a later version of the firmware.

So now I needed to re-program the AVR processor using the hax file available - I hadnt done this before.

So, here you will find that you can use an Arduino as an AVR Programmer - now I have lots of those. On the Arduino site you can see how to configure the processor on a breadboard:

I added a 7805 regulator and powered the breadboard contents from my local bench PSU. I connected the grounds together of the Arduino and breadboard, but not the power lines! So the Arduino is powered from the USB cable and the breadboard separately.

So assuming you already have an Arduino IDE installed and working here are the steps:

  1. Start Arduino IDE and load the ArduinoISP sketch and upload to your Arduino (the sketch is in the examples folder and my board is an Uno)
  2. Wire the Arduino board as the above diagram - I used a 20MHz crystal and 2 22p capacitors
  3. Download avrdude from here (I put my download into a local directory C:\Users\Mark\Downloads\QRP VFO)
  4.  Download the hex file you want to program from the QRPLabs forum files area 
  5. Open a command window in Windows (type cmd in the search box)
  6. execute the command "cd C:\Users\Mark\Downloads\QRP VFO" (replace my target with your local directory)
  7. then we need two AVRDude commands (replace COM13 with your Arduino COM port):
    1. To set the fuses: avrdude -P COM13 -b 19200 -c arduino -p m328 -v -e -U efuse:w:0x04:m -U hfuse:w:0xDF:m -U lfuse:w:0xF7:m328
    2. To program the flash: avrdude -P COM13 -b 19200 -c arduino -p m328 -v -e -U flash:w:VFO.s1.02c.hex (replace with your hex file)
Here's what it all looks like on the bench (which is rather a mess):

Here is our very beautiful Miss Luna Cat who has been with us since July 2015, and is now, finally, letting me stroke her. She is asleep in the shack on the bag that came with my recently acquired frequency counter:

 Local conditions