Testing egg boiled-ness using soundwaves : Experimental results

So I may have gotten a bit carried away before with the whole egg thing. Tried building a working prototype without first doing some experimentation to make sure it is possible to tell how boiled an egg is by using sound waves. I’ve gone back to the basics and done some experimentation. The results are not conclusive really so some further eggsperimentation will be required. I posted about this on reddit and received some great input from several users. One person suggested measuring the time delay between the input and output signal and observing how this changes between boiled and unboiled eggs. In this experiment I measured both amplitude and time lag the results are recorded below.

The experiment:

I bought a six pack of eggs and labelled them individually as seen in this photo:

Individually marked eggs

Individually marked eggs

I made a test rig by mounting two piezos on the end of pens. There is also a place for the egg to sit.
IMG_20150121_154330IMG_20150121_154359

A sine wave with amplitude 9.44V and frequency of 4.46KHz was input into one of the transducers. For this experiment I placed eggs 1-6 in the rig and measured two variables : amplitude ( at receiver piezo ) and the time taken for the sound wave to travel from sender to receiver. This time difference variable will be referred to as delta t in the results. I did this procedure three times for the un-boiled eggs and three times for the boiled eggs. The eggs were boiled for different amounts of time. All of the eggs were placed in one pot, the water was brought to boiling temperature and every two minutes an egg was taken out. So egg 1 was in for 2 mins and egg six was in for a total of 12 mins. Here are some photos of the egg boiling setup:
IMG_20150121_164311IMG_20150121_164505

These are the results from before and after boiling the eggs. The reason I did each test three times was to reduce any errors caused by poor contact between an egg and the transducers and other errors of that nature. Delta T refers to the time lag between the input signal and the output (received) signal it is measured in microseconds. mV refers to the amplitude of the output (received) signal.
g38d34

Taking the difference between each set of numbers gives the following set of data. So to be clear, mV_var refers to the change or variation in output between the unboiled egg and the boiled egg. t_var refers to the change in time lag between the unboiled egg and the boiled egg. T_var is in microseconds still.
g5392

Taking the average of these three tests gives the following results:
g5712

image4369image4358

From the graph on the right, the results looked quite promising up until minute 12 which was egg 6. Egg 6 was the only egg that cracked during boiling. The egg was mostly fine but the reason for the rather low output may be due to the fact that the egg surface had cracks in it. This may be a good reason to repeat this experiment to make sure. Another thing that I’ve noticed is the extremely low amplitude of the received signal, it is normally in the order of tens of milli-volts at best. The piezo transducers used for this experiment are intended for use as speakers presumably for toys and things of that nature. This means that they have a frequency response of only around 1Khz to 7Khz before the sound output drops away to nothing. It may be the case that a higher frequency would pass through an egg much more effectively giving a greater output which would allow for more concrete results. The graph of time lag versus boil time is all over the place, I really don’t know that to make from it. Another thing is that there may be something I’m missing with the data. As in, I’ve graphed change in amplitude and time lag against boil time but this may be the wrong way to think about it. If you have any ideas about this, let me know!

Measuring how boiled an egg is – using sound waves – Attempt #1

Spoiler Alert: This didn’t work out due to the fact that whatever contraption I build tends to fall apart or not work properly when placed in boiling water. I’ll continue to work on the problem. Maybe there is some kind of high temperature, water resistant glue out there that would fit my needs.

The idea is simple. As an egg is boiling it changes from a liquid type state to a more solid type state. Is there a way to represent this change using electricity? Well, maybe. The way I went at the problem was using soundwaves. These soundwaves were generated using these little piezoelectric transducers seen below.

piezo transducers with the back covered with sugru

piezo transducers with the back covered with sugru

The transducers are placed on opposite sides of the egg. One of the transducers is hooked up to a signal generator outputting a sine wave of around 6v and at a frequency somewhere in the 1-5KHz range. This sound wave propogates through the egg and is picked up by the other transducer. The amount of sound energy that reaches the receiving transducer hopefully changes as the egg boils. The amount of sound energy that propagates through will probably either go up or down as the egg boils. At a guess, I would say it would go up because as the egg becomes more solid it can absorb less sound energy meaning more energy passes through to the receiver. This increasing of sound energy reaching the receiver could be measured as an increasing amplitude of the sine wave generated at the receiving piezo. The first rig I built was built just to find out what kind of amplitude might be seen on the receiving end for an un-boiled egg. See below for a picture of the rig:
IMG_1299.JPGIMG_1296.JPG

Oscilloscope output : ch1 is the receiver voltage (approx 30mV) and ch2 is the input

Oscilloscope output : ch1 is the receiver voltage (approx 30mV) and ch2 is the input

With an input of around 6.5 volts, only around 30mV makes it to the receiver. This is pretty small but not small enough to be too off putting. If it was micro-volts then there would be a problem!. The first test rig was held together with electrical tape and rubber bands – not very boiling water resistant so I moved onto test rig #2 seen below:
IMG_1303.JPGIMG_1305.JPG

IMG_1306.JPGIMG_1308.JPG

It’s kinda hard to see from these photos but this is just a tin can that I cut in half. The piezos are held on to the can using sugru. For those that haven’t hear of surgru, its basically a rubber that comes in a soft state, once you open the pack it can be shaped as wanted and in 24 hours it will harden. The sugru packaging says that it can withstand up to 180 degrees which I’m going to have to call bullshit on seeing as the whole thing fell apart after about a minute in boiling water. Also a big problem was the thing bouncing around whilst in the water. This caused the received voltage to jump around and the results were totally unusable. For the next rig I tried to make something that weighed a bit more so it wouldn’t bounce around in the boiling water. I used an old speaker frame as the base and this time tried to have the transducers sitting on top of the egg, not actually in the water. The hot glue sticks I use have a max temperature of 120 degrees C so I decided to give that a go to hold everything together. I present to you rig #3 in all of its glory:
2014-12-08 17.29.212014-12-08 17.29.02

It doesn’t look pretty and it didn’t even get the job done. This also fell apart after a minute or two even though everything was raised above the water. The heat of the steam was enough to melt the glue and once again, everything fell apart. At this point I was getting kinda fed up with the whole situation but then I cam across this stuff:
2014-12-10 12.15.27

“AAAWWWWHHHHHH YEAHHH” was my initial reaction upon finding this in woodies diy store for only €7.99 . This stuff comes in a liquid type state and hardens after a few hours. It’s meant for use on things like oven doors etc. perfect for what I wanted (or so I thought at the time). While I was out that day I came across something else I didn’t even know existed but was exactly what I wanted and needed. It was a microwavable egg container. As in you put an egg in this thing, add some water, throw it in the microwave for a few minutes and you have a boiled egg! I wasn’t interested in the microwave part, just the fact that the container was shaped like an egg and had space for two piezo transducers. See below for the egg holder thingy:

2014-12-10 11.38.212014-12-10 11.39.16

2014-12-10 11.50.112014-12-10 12.15.01

The holes were drilled to let the water in. The transducers were put in place and then the sealant stuff was squirted in to hold everything in place. This rig also failed because the sealant isn’t meant for use in water. All of the sealant dissolved in the boiling water leaving everything covered in a grey goo. Oh yeah and everything fell apart. AGAIN. So I’ve had enough eggsperimentation (lol) for a while. If you have any ideas on a better way to do this, please do let me know!

NRF24L01+ development board

This development board is based on the PIC18F45k50 which will communicate with a PC via USB. Example code will be posted in the coming weeks.

bottomtop

Schematic Diagram - Click to enlarge

Schematic Diagram – Click to enlarge

2015-01-06 15.45.462015-01-06 15.48.05

2015-01-06 15.48.312015-01-06 15.45.59

The PICKIT to FFC adapter adapter board artwork and eagle files are available here.

The board artwork and eagle files are available here.

Part
Description
Quantity
Price (per unit in euros)
Source
NCV33375ST3.3T3G3.3V LDO Voltage Regulator10.93http://ie.farnell.com/webapp/wcs/stores/servlet/ProductDisplay?catalogId=15001&langId=353&urlRequestType=Base&partNumber=1924876&storeId=10163
PIC18f45K50Microcontroller12.92http://ie.farnell.com/webapp/wcs/stores/servlet/ProductDisplay?catalogId=15001&langId=353&urlRequestType=Base&partNumber=2305837&storeId=10163
FCI
SFV6R-2STBE9HLF
FFC Connector10.60http://ie.farnell.com/webapp/wcs/stores/servlet/ProductDisplay?catalogId=15001&langId=353&urlRequestType=Base&partNumber=1888056&storeId=10163
CONNECTOR, RECEPTACLE, HV-100, 20WAYFemale pin header12.64http://ie.farnell.com/webapp/wcs/stores/servlet/ProductDisplay?catalogId=15001&langId=353&urlRequestType=Base&partNumber=2311678&storeId=10163
MINI USB B, SMD, 5WAYUSB connector11.11http://ie.farnell.com/global-connector-technology/usb2066-05-rbhm-15-stb-00-00-a/connector-mini-usb-b-smd-5way/dp/2293774
Resistor200Ohm 080530.005
SMD LED080530.05
Capacitor0805 10uF40.010

Tenma 72-7735 DMM: Serial interface with Python

The Tenma 72-7735 is a lower end DMM that comes with quite a few handy features including an opto-isolated serial output. This serial communication is over a cable with a male db-9 rs-232 serial connector on one end and a connector housing a photo-diode that fits into the multimeter on the other end. Here is a picture of the cable:

Multimeter serial cable

Multimeter serial cable

rs232 cable plugged into multimeter

rs232 cable plugged into multimeter

Software is provided by Tenma that offers a gui with that can do things like datalogging, generate graphs and show real time data. The problem is that this program only works on windows and my computer doesn’t have a serial port. Also it would be nice if it was possible to read this serial data using some kind of microcontroller based embedded system and do something cool with it.

First step was to take apart the photodiode housing:

Circuitry inside serial cable

Circuitry inside serial cable

The original idea was to cut off the db-9 connector on the other end of the cable and hook up the wires to the correct voltages to get serial data out. This turned out to be problematic due to that fact that rs232 voltages are bi-polar. See the image of the reverse engineered circuit below:

Reverse engineered circuit diagram

Reverse engineered circuit diagram

These wire were attached to the following rs232 pins:
DCD – yellow
RxD – orange
Txd – white
DTR – brown
RTS – green

This particular cable was missing several components from the internal PCB. It only seemed to have the parts needed to receive data, not send it. The TxD (white) wire is soldered to the PCB but doesn’t seem to be connected to anything. It turns out that it is possible to power very low current (roughly 10mA max) devices over rs-232, some older computer mice would have been powered this way. This is usually done using the RTS and DTR lines to generate +5V and then using the TxD line as the negative voltage. Not wanting to go messing about with negative voltages I tried to get the circuit to work with just ttl voltage levels but it didn’t work out. In the end I just de-soldered the photo-diode from the PCB and made a much simpler circuit that easily works with 5v logic levels. The quick and easy circuit looks like this:

Photodiode circuit diagram

Photodiode circuit diagram


This serial data is sent to a computer via a pl2303 based usb to serial converter.

Here is a picture of the new and improved circuit stuffed inside the housing:

new circuit inside housing

new circuit inside housing

Picture of the output from this circuit on an oscilloscope below. It looks a bit non-square but it didn’t seem to affect the data being read correctly:

Serial data output on a scope

Serial data output on a scope

All that is left now is to read the serial data and do cool things with it. Only problem is the serial protocol is fairly poorly documented. A protocol outline can be found here. Despite the documentation being pretty confusing, the protocol is extremely simple.The serial data sent out is the LCD table which tells us which parts of the LCD are on and which are not. This makes it slightly more difficult to decode the data on the other end than if it just sent values of voltage or current but it’s not that big of a deal. The data is sent out in 14 byte packets ( this means 14 bytes, short pause then another 14 bytes etc). The upper nibble (upper 4 bits) of each byte is the bytes location within the packet. EG the first byte in a packet will be 0001XXXX, the second one 0010XXXX etc. The XXXX’s or the lower nibble of each byte is what we are interested in. There is a table provided in the datasheet that outlines what these lower 4 bits mean.

Serial protocol for multimeter

Serial protocol for multimeter

This table is so unnecessarily confusing. What does COM 1-4 Mean? I still have no idea. The way to look at it is just ignore columns 1-4, just pay attention to the seg colummns (seg1 – seg14). There are 14 seg columns and 14 bytes in a packet. This is because each bytes lower nibble corresponds to the lcd sections in one of those columns. If for example the first byte in a packet was 00010111, the upper nibble is 0001 which means it refers to column seg1. The lower nibble is 0111, each bit of this nibble tells us if that particular symbol is currently showing on the LCD. 1 means on and 0 means off. So for example in this case 0111 means the following

0 – AC OFF
1 – Auto ON
1 – DC ON
1 – RS232 ON

This process repeats for the full 14 byte packet and by knowing which parts of the LCD are on, you can then work out what numbers are being displayed on the screen and so on. See below for a python script I wrote to do this (click to expand):

import serial
import time
import binascii

ser = serial.Serial(
	port='/dev/ttyUSB0',
	baudrate=2400,
	timeout = 0.1,
	stopbits=serial.STOPBITS_ONE,
	bytesize=serial.EIGHTBITS
)

ser.close()
ser.open()

ser.flush()

hex_vals = []
temp_str = ''
bin_vals = []
dmm_data = ''
lower_nibbles = []
for i in range (0, 14):       # make lists to store hex and binary values
	hex_vals.append('0')
	bin_vals.append(0)
	lower_nibbles.append(0)
	
	
def get_lower_nibbles(bin_vals):            # only keep the lower part of nibble
	for i in range(0, len(bin_vals)):
		temp_str = str(bin_vals[i])
		lower_nibbles[i] = str(temp_str[4:8])
	
	return(lower_nibbles)

a=[]
b=[]
c=[]
d=[]
digit = 0

for h in range(8):  # make a list for each digit to record which parts of seven segment are on or off
	a.append('0')
	b.append('0')
	c.append('0')
	d.append('0')
	
def lcd_get_num(lcd_array):                 ##  each digit corresponds to certain parts of seven segment display being on
	digit = 0
	if lcd_array == '1010000' : digit = 1
	if lcd_array =='1101101' : digit = 2
	if lcd_array == '1111001' : digit = 3
	if lcd_array == '0110011' : digit = 4
	if lcd_array == '1011011' : digit = 5
	if lcd_array == '1011111' : digit = 6
	if lcd_array == '1110000' : digit = 7
	if lcd_array == '1111111' : digit = 8
	if lcd_array == '1111011' : digit = 9
	if lcd_array == '1111110' : digit = 0
	
	return str(digit)
	
	
def decode_data(lower_nibbles):             #this function works out what numbers are being displated based on 
	for i in range(1, len(lower_nibbles)):  # which parts of each seven segment digit are turned on
		temp_reg = lower_nibbles[i]
	#	print temp_reg
	#	print len(a)
		if (i==1):         ## first digit
			#print temp_reg[3]
			a[1] = temp_reg[3]
			a[6] = temp_reg[2]
			a[5] = temp_reg[1]
		if (i==2):
			a[2] = temp_reg[3]
			a[7] = temp_reg[2]
			a[3] = temp_reg[1]
			a[4] = temp_reg[0]
			
		if (i==3):
			b[1] = temp_reg[3]
			b[6] = temp_reg[2]
			b[5] = temp_reg[1]
			
		if (i==4):
			b[2] = temp_reg[3]
			b[7] = temp_reg[2]
			b[3] = temp_reg[1]
			b[4] = temp_reg[0]
			
		if (i==5):
			c[1] = temp_reg[3]
			c[6] = temp_reg[2]
			c[5] = temp_reg[1]
		
		if (i==6):
			c[2] = temp_reg[3]
			c[7] = temp_reg[2]
			c[3] = temp_reg[1]
			c[4] = temp_reg[0]
		
		if (i==7):
			d[1] = temp_reg[3]
			d[6] = temp_reg[2]
			d[5] = temp_reg[1]
		
		if (i==8):
			d[2] = temp_reg[3]
			d[7] = temp_reg[2]
			d[3] = temp_reg[1]
			d[4] = temp_reg[0]
	a.pop(0)
	b.pop(0)
	c.pop(0)
	d.pop(0)
	achar = ''.join(a)
	bchar = ''.join(b)
	cchar = ''.join(c)
	dchar = ''.join(d)	
	a.append('0')	
	b.append('0')
	c.append('0')              # this terrible piece of code would probably make                          
	d.append('0')             # Guido van Rossum cry  
	
	d1 = lcd_get_num(achar)
	d2 = lcd_get_num(bchar)
	d3 = lcd_get_num(cchar)
	d4 = lcd_get_num(dchar)
	print d1+d2+d3+d4              #print numbers displayed on LCD screen
	
	return(achar, bchar, cchar, dchar)
		
			
		
dmm_data = ""

while True:
	dmm_data = ""
	ser.flush()
	while dmm_data == "":                                #wait for a packet
		dmm_data = str(binascii.hexlify(ser.read(14)))


	g = 0                                               # concert hex values into binary
	for i in range(0, len(dmm_data), 2):
		bin_vals[g] = str( bin(int(dmm_data[i:i+2], 16))[2:].zfill(8)) 
		g=g+1

	#print bin_vals

	get_lower_nibbles(bin_vals)                       # only interested in lower nibble of each byte
	#print lower_nibbles

	decode_data(lower_nibbles)                        # from this data work out what numbers are displayed on screen
	time.sleep(0.5)                               

Table outlining how to work out what digit is being displayed

Table outlining how to work out what digit is being displayed

The output from the Python script at the moment is just the numbers currently being displayed on the multimeter. This is a work in progress, data logging with a microcontroller is something to try out in the future.

Python script output

Python script output