Electronics

More microscope images (21)

So I got a little carried away and started to take images of everything with my microscope:

Electronics

Magnified image of an intergrated circuit chip

Magnified image of an intergrated circuit chip


Magnified image of an surface mount LED

Magnified image of an surface mount LED


Magnified image of an another integrated circuit chip

Magnified image of an another integrated circuit chip


Magnified image of yet an another integrated circuit chip

Magnified image of yet an another integrated circuit chip


Magnified image of a crocodile clip

Magnified image of a crocodile clip


Magnified image of a surface mounted resistors

Magnified image of a surface mounted resistors


Magnified image of a digital printed circuit board

Magnified image of a digital printed circuit board


Magnified image of a digital camera

Magnified image of a digital camera


Magnified image of a camera focussed on the glass

Magnified image of a camera focussed on the glass


Magnified image of a camera

Magnified image of a camera


Magnified image of a headphone

Magnified image of a headphone


Magnified image of a mobile phone speaker

Magnified image of a mobile phone speaker


Magnifieid image of a DVD

Magnifieid image of a DVD

Materials

Magnified image of a dry sponge (with some solder burns)

Magnified image of a dry sponge (with some solder burns)


Magnified image of a wet sponge (with some solder burns)

Magnified image of a wet sponge (with some solder burns)


Magnified image of a caramel shortbread biscuit

Magnified image of a caramel shortbread biscuit


Magnified image of a flapjack

Magnified image of a flapjack


Magnified image of demin

Magnified image of demin


Magnified image of paper

Magnified image of paper

Eyes

Magnified image of the queen's eye from a £10 note

Magnified image of the queen's eye from a £10 note


Magnified image of an eye

Magnified image of an eye

Note the reflection in the image of my eye, if you zoom in and enhance you may be able to read what is on my screen which will then possibly lead to the solving of a murder.

Read More

DigiMicro 200X Zooming USB Digital Microscope in ubuntu (linux)

I’ve wanted a USB microscope for a long time, and I have finally purchased a DigiMicro 200X Zooming USB Digital Microscope from dealextreme (product link) It only cost $40.23 USD (about £27.34 GBP) which I think is quite reasnoble for the fun and cool photos I’m getting out of it.

DigiMicro 200X Zooming USB Digital Microscope

DigiMicro 200X Zooming USB Digital Microscope

Quick Review
Advantages

  • Very Cheap
  • Easy to setup (plug and play)
  • Can take some awesome photos, see below
  • Three illumination settings (full on, half on, off) on top of software compensation

Disadvantages

  • Controls (lights, zoom/focus and snapshot) are located on the body which make using them difficult if you are trying not to move your sample
  • The stand is not very stable, tightening it to maximum holds it steady at certain angles for short periods of time
  • Takes ~ 2 weeks to arrive from dealextreme as they are based in hong kong

Setup

The beauty of this webcam is that it requires no installation with ubuntu 9.10 you simply need to run the software and the camera works! woo! The output of `lsusb` shows the device as:

Bus 001 Device 006: ID 0c45:62e0 Microdia MSI Starcam Racer

and `dmesg` shows the following:

[22844.064666] uvcvideo: Found UVC 1.00 device USB 2.0 Camera (0c45:62e0)
[22844.080844] input: USB 2.0 Camera as /devices/pci0000:00/0000:00:0b.1/usb1/1-6/1-6:1.0/input/input9

Software
Most video programs will pick up the device, I am opting to use a program called cheese which is awesome not only because of the name but also because of its simplicity.

sudo apt-get install cheese
Screenshot of cheese webcam software in action

Screenshot of cheese webcam software in action

Lens Cap
Remember to take the lens cap off otherwise you will end up focusing on the plastic cap as shown below. It is fairly obvious if this is the problem as moving the microscope will only change the light levels not the image.

Photo of the microscope focussed on its lens cap

Photo of the microscope focussed on its lens cap

Pretty images

200x Microscope image of belly button fluff

200x Microscope image of belly button fluff

Full ~200x zoom microscope image of belly button fluff

Full ~200x zoom microscope image of belly button fluff


200x Microscope image of a £2 coin

200x Microscope image of a £2 coin


Full ~200x zoom magnified section of a £2 coin

Full ~200x zoom magnified section of a £2 coin


200x Microscope image of a custard blob

200x Microscope image of a custard blob


Nonmagnified screenshot of section of screen with the google logo

Nonmagnified screenshot of section of screen with the google logo


200x magnified section of screen with the google logo showing the individual pixels

200x magnified section of screen with the google logo showing the individual pixels


Full ~200x zoom magnified section of screen with the google logo showing the individual pixels

Full ~200x zoom magnified section of screen with the google logo showing the individual pixels


Full ~200x zoom magnified section of my finger

Full ~200x zoom magnified section of my finger


Full ~200x zoom magnified another section of my finger

Full ~200x zoom magnified another section of my finger


Full ~200x zoom magnified section of an LED

Full ~200x zoom magnified section of an LED


Full ~200x zoom magnified section of an LDR

Full ~200x zoom magnified section of an LDR

Any requests for microscope images (within reason) will be considered 🙂

Read More

Python: interfacing with an arduino

So what is an arduino?
An arduino is an open source open hardware programmable controller with several inputs and outputs. The image below shows an Ardunio Dicemella.

Ardunio Dicemella Annotated Photo

Ardunio Dicemella Annotated Photo

It (Arduino Dicemella) has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a reset button. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started.

They are very useful for people who know how to program but have little experience with hardware interaction.

Programming the arduino
This post will not contain in-depth detail on how to program the arduino, instead focussing briefly on setting up serial (over serial or usb cable) communications in order to talk to a python script. The arduino can be programmed via a IDE provided by the creators in a C-style hardware language.

Code example

int ledPin = 13;            // choose the pin for the LED
int inputPin = 2;          // choose the input pin (for a pushbutton)
int val = 0;                // variable for reading the pin status

void setup() {
  pinMode(ledPin, OUTPUT);      // declare LED as output
  pinMode(inputPin, INPUT);     // declare pushbutton as input
}

void loop(){
  val = digitalRead(inputPin);  // read input value
  if (val == HIGH) {            // check if the input is HIGH
    digitalWrite(ledPin, HIGH);  // turn LED ON
  } else {
    digitalWrite(ledPin, LOW); // turn LED OFF
  }
}
Arduino LED switch circuit off

Arduino LED switch circuit off


Arduino LED switch circuit on

Arduino LED switch circuit on

Now we add a few lines to enable the writing of information from our arduino over the serial connection. We first need to set up the transfer speed in our setup (Serial.begin(9600);). Then we can simply send messages over serial using Serial.print(“message\n”);. You can choose between print and println with the difference been that the latter automatically appends the newline char, so we would use the former to write multiple things to the same line. Below is our modified code:

Serial write example

int ledPin = 13;           // choose the pin for the LED
int inputPin = 2;         // choose the input pin (for a pushbutton)
int val = 0;               // variable for reading the pin status

void setup() {
  pinMode(ledPin, OUTPUT);      // declare LED as output
  pinMode(inputPin, INPUT);     // declare pushbutton as input
  Serial.begin(9600);
  Serial.print("Program Initiated\n");  
}

void loop(){
  val = digitalRead(inputPin);  // read input value
  if (val == HIGH) {            // check if the input is HIGH
    digitalWrite(ledPin, HIGH);  // turn LED ON
    Serial.print("LED Activated\n");
  } else {
    digitalWrite(ledPin, LOW); // turn LED OFF
  }
}

We now add into this code the ability to receive information via serial. Below is the modified example which removes the action of the button and replaces it by activating the LED when ‘Y’ is sent via serial.

Serial read example

int ledPin = 13;  // choose the pin for the LED
int val = 0;      // variable for reading the pin status
char msg = '  ';   // variable to hold data from serial


void setup() {
  pinMode(ledPin, OUTPUT);      // declare LED as output
  Serial.begin(9600);
  Serial.print("Program Initiated\n");  
}

void loop(){
        // While data is sent over serial assign it to the msg
	while (Serial.available()>0){ 
		msg=Serial.read();
	}

  // Turn LED on/off if we recieve 'Y'/'N' over serial 
  if (msg=='Y') {            
    digitalWrite(ledPin, HIGH);  // turn LED ON
    Serial.print("LED Activated\n");
    msg=' ';
  } else if (msg=='N') {
    digitalWrite(ledPin, LOW); // turn LED OFF
  }
}

Interaction with python

First we import the serial library to python in order to communicate with the arduino (this includes talking over usb).

import serial

We then attempt to connect to our arduino on /dev/ttyUSB0, using try and except to catch an exception if we are unable to find the arduino on USB0. The 9600 corresponds to the baud rate (speed of communication) that we are using with the arduino and should be the same as set in the program on the arduino otherwise your communication may appear garbled.

try:
	arduino = serial.Serial('/dev/ttyUSB0', 9600)
except:
	print "Failed to connect on /dev/ttyUSB0"

The address will be /dev/ttyUSB# where # is replaced by a number for arduinos connected via usb and /dev/ttyS# where # is replaced by a number for arduinos connected via serial. If you are not sure of the location of your arduino, it can be found in the arduino IDE or you can write some python to scroll through possible locations until a response is found

locations=['/dev/ttyUSB0','/dev/ttyUSB1','/dev/ttyUSB2','/dev/ttyUSB3',
'/dev/ttyS0','/dev/ttyS1','/dev/ttyS2','/dev/ttyS3']

for device in locations:
	try:
		arduino = serial.Serial(device, 9600)
	except:
		print "Failed to connect on",device

You may need to be careful as other devices can be connected. For example if I try to connect to /dev/ttyS0 I will connect to the wacom tablet on my laptop.

Once you have connected to your arduino successfully you can write information to it using write and read information sent from it using read (you will need to import time to use the sleep function). If your arduino does not send any messages via serial then attempting to readline will result in your program hanging until it receives a message.

try:
	arduino.write('Y')
	time.sleep(1)
	print arduino.readline()
except:
	print "Failed to send!"

So the python code should now look like the following and we should be able to control the LED over serial.

import serial
import time

locations=['/dev/ttyUSB0','/dev/ttyUSB1','/dev/ttyUSB2','/dev/ttyUSB3',
'/dev/ttyS0','/dev/ttyS1','/dev/ttyS2','/dev/ttyS3']  
  
for device in locations:  
	try:  
		print "Trying...",device
		arduino = serial.Serial(device, 9600) 
		break
	except:  
		print "Failed to connect on",device   

try:  
    arduino.write('Y')  
    time.sleep(1)
    print arduino.readline()
except:  
    print "Failed to send!" 

The above will send the character ‘Y’ (Y for Yes please turn on the LED) to the arduino wait for 1 second and then read from the arduino which will have hopefully posted a response to our ‘Y’. Using the program on this should turn the LED on, and report LED Activated back via serial to our python program. This should be enough for people to get started with ardunios and communicating with them in python.

References

  • Arduino – The arduino website with everything you are likely to need (programming examples and reference guide, and hardware information)
  • Arduino tutorial – a basic and easy to understand tutorial on programming the arduino
  • Python port of arduino-serial.c – By John Wiseman from which I based my program.
  • original arduino-serial.c – by Tod E. Kurt.
  • Sparkfun – Here is a good place to purchase ardunio and other electronics parts. Try coolcomponents if your from the uk like me
  • Dealextreme – Hong Kong based retailer that sells a lot of cheap DIY electronics and also has worldwide free delivery with no min spend (crazy). Does take about two weeks to arrive though (uk).
Read More