Vous êtes sur la page 1sur 14

SB Demon!

Home

About Me

Search

SB Demon!
Posted on October 21, 2011

Authors
iTheo92

2 Votes

What is SB Demon?
SB Demon, a very confusing name indeed. Some of you may think it as a cousin of Maxwells demon. Some of you may even go further by thinking it as a demon of Stefan-Boltzmann (if Maxwell would have a demon, then, whats wrong with Boltzmann?), a new discovery from some unreleased papers or some secret letters! Let me clarify it: Its NOT so royal thing. SB Demon stands for StefanBoltzmann Law Demonstrator device. Its just a special purpose datalogging system with a built-in USB interface. An amateurs experimental device to have some adventure with Stefan-Boltzmann law, with a flashlight lamp (commonly called a torchlight bulb), a PIC microcontroller, some programming codes and some sort of electrical circuit.

Recent Posts
SB Demon!

Archives
October 2011

Categories
Main Article

Meta
Register Log in Entries RSS Comments RSS WordPress.com

Follow Blog via Email


Enter y our email address to follow this blog and receive notifications of new posts by email.

Background:
There are a number of techniques to support the Stefan-Boltzmann law experimentally and to measure the Stefan-Boltzmann constant apart from theoretical results (i.e. = (2*Pi^5*k^4)/(15*c^2*h^3) ). The simplest procedure is based on an incandescent lamp. The experiment is performed by the undergraduate students of almost all Indian universities. The temperature of the filament is measured by a direct (using an optical pyrometer) or an indirect process (measuring the resistance and comparing it with a reference resistance at known temperature), and the input power is controlled by a variable power supply. For a low power lamp, conduction loss through the leads and convection loss (for gas filled lamps) are ignored and all the input power approximately goes into the radiating channel. Reference-resistance-at-some-known-temperature method is preferred in undergraduate labs. An optical pyrometer or a monochromator with photodiode may be used for more precise temperature measurement but not used in (poor mans) undergraduate labs. The apparatus, used mostly, is just a simple variable power supply with an ammeter and voltmeter, packed in a big box. I tried to do the same using a microcontroller which would
Follow

converted by Web2PDFConvert.com

calculate the exponent and possibly the Stefan-Boltzmann constant with minimal human interaction. The heart of the device is a PIC microcontroller. A low-pass filtered PWM (Pulse Width Modulation, essentially a square wave) output from the microcontroller is passed through some transistors, which forms the variable power supply to drive the lamp. The potential difference across the lamp is sensed by the microcontrollers onboard analog-to-digital converter (ADC), the current through the lamp is sensed by a shunt resistor, amplified by a high-side current sense amplifier and is fed to another ADC channel. Well get back to it in details later.

A look into the device

The device Before going into the details, Here are the outlines first: 1: It saves the calibration data, either from the specified cold resistance or from the draper point as determined by the user. 2: The user enters the number of points to save. 3: The user increases the PWM duty cycle by pressing the INC button, so the power delivered to the lamp increases. The user may use the DEC button to decrease it. 4: Now the user presses the SAVE button to save the values. 5: The user repeats step 3 and 4 until the specified number of points are saved. 6: Finally the device shows the regression results, i.e. the value of the exponent of T and the value of A* *(surface area of the filament times the emissivity of the filament times the Stefan-Boltzmann constant). Now, Lets take a more closer look with the screenshots:

converted by Web2PDFConvert.com

LCD typescripts After a quick splash screen (see SS1) the device asks for the mode of operation. Two modes are available (see SS2). In the first mode, DP or draper point, the user carefully sets the point where the lamp just begins to glow (i.e. the filament temperature is about 800K), so that the device get calibrated. In CR or cold resistance mode, the user specifies the of CR, which is the resistance of the filament at about 300K. So far, SB Demon cant determine the CR by itself, the user must measure it by an accurate measuring device (essentially, a device capable of measuring low resistances like any digital meter specialized for this purpose or a bridge, general purpose multimeters are not capable of it). I didnt measure the CR of the lamp because I dont have enough precision instruments. Though, the CR mode with an accurately measured CR would produce more accurate results than the DP. Now the user presses the INC/DEC button to increase/decrease the voltage until the the draper point arrives (see SS3). At that point the user presses the OK button so that the point is saved. For CR mode the user sets the cold resistance of the lamp (as measured by some external instrument) by the INC/DEC button. In the next step it asks for the number of points to save (see SS5) . We can select 5 to 30 points, the default is 12. Next, it shows the voltage, current, resistance and the estimated temperature values (see SS6). You can increase/decrease the voltage by pressing the INC/DEC button. By default the data acquisition occurs after a delay of 100ms whenever the INC/DEC button is pressed. The 100ms delay is to ensure that the data acquisition takes place in steady state only, and not in transient state. Though a continuous read mode can be enabled by pressing the OPTIONS button, in this mode data acquisition occurs at every 10mS. The user saves the desired values by pressing the SAVE button. And finally, after saving all the points, it shows the regression results (see SS7). Ill post a video of it later.

converted by Web2PDFConvert.com

False colour of thermal emission detected by CCD This is not only a beautiful photograph, notice the blue tint of IR emission, the false colour, as detected by my digicams CCD sensor. Heres another example.

Another example of false colour detection

Whats inside?
Take a look at the schematic first:

The schematic (click to enlarge) If youre one from the newbie league, then Im explaining a little for you. But if you are someone from the experts community, then please comment me your suggestion(s). See there, the PWM duty cycle is varied (increases at INC and decreases at DEC) by the microcontroller firmware. And the PWM signal is filtered by a second order low pass filter. Then an NPN transistors inverts the filtered signal and sends it to a PNP power transistor. Which powers up the lamp through a 100 milliohm current-sense resistor (R4). The small potential drop across the resistor is amplified by a high side current sense amplifier (called a high side CSA) MAX4372. And the voltage across the lamp is divided one-third by a resistive voltage divider (R2, R3). Both of them goes to two ADC channels of the microcontroller. MAX873T provides 2.5V reference voltage to the ADC module through the VREF+ pin for accurate ADC results.
converted by Web2PDFConvert.com

Inner view of the box This looks messy, I know, cluttered with wires and hot glue! But anyway its working. That surprises me how this mess closes a full path for the free electrons to walk, run, twist, spin through the wires and finally die at GND!!! I soldered-desoldered-resoldered the perfboard, for more than 20 times at some places. MAX4372 and MAX873 are SMD components, I made a small PCB (see the above image, Ref/CSA PCB) to solder them. A single PCB would clear up the mess to a beautiful electronic landscape.

Photograph of some pre-prototype.

converted by Web2PDFConvert.com

Programming the PIC microcontroller


So far, in my 3 years of PIC programming career, Ive used many compilers for writing codes. Ive used Microchips C along with their MPLAB IDE, MikroElektronikas MikroC and MikroBasic, PICC compiler, Proton IDE, Swordfish Basic etc. C has the most powerful and compact instruction set, I swear, but for writing such a long and complex code like this, I chose Swordfish Basic because of its highly structured and modular nature. Its a fairly long code, consuming 770 lines in the IDE and filling 65.45% of the PICs program memory (i.e. ~20.9KB out of 32KB). Previously Ive written many codes for PICs (the most interesting among them was my first line following robot), but Ive never written such a long code like it. After many faults, compilation errors, culprit LCD scripts (mainly the custom symbols like ), PWM issues, unrecognized USB device error due to incorrect interrupt and PLL settings and many other known-unknown hassles (some of them are still unknown to me, trial-n-error based on a little guess-work was the only option to tackle them), finally I came up with the final code after working patiently for more than four months, programming-reprogramming the microcontroller over 500 times! The hardware was fairly complex for any simulation software (like Proteus VSM) to handle efficiently and in near-real-time. I tried them; they worked great for simple codes with simple hardware setup but for this device, the simulations were painfully slow on my old Pentium 4 based PC. So I quitted simulation and started with a breadboard and some passives from the junk-boxes.

Screenshot of the Swordfish IDE Im not going into detailed discussion on the code here, if you know the basic syntaxes of Swordfish IDE, you could mean the code patiently. If you are not a PIC geek, just skip this coding part and continue.

See the DIY PICKit2 programmer I used my DIY PICKit2 programmer to program the microcontroller. PICKit2 is a standard tool from Microchip. But I built it myself (with so much memories of my class xi days embedded in it!)

converted by Web2PDFConvert.com

The USB functionality For more adventure


First thing to mention that the SB Demon is a USB device of HID (Human Interface Device) class, its not a CDC (Communication Device Class) device. CDC is simple to manipulate in a microcontroller based system (or using a very popular FT232 to create a CDC interface from basic USART), also needs little or no PC side programming, as it renders itself as a virtual serial (or COM) port. It is generally interfaced via any terminal application (like the Hyperterminal on Windows XP). Its easy to use but not so reliable and strongly outdated. Even Windows Vista and 7 dont have inbuilt driver for CDC devices. So, I chose the HID. Which needs a sophisticated programming on both sides. I played a lot with the codes for it, and finally succeeded. Now, Ive a fully working USB HID datalogging system. This special purpose datalogger can be modified to suit with all datalogging applications.

A closer look to the interface Here is a closer look to the interface software. My goal was to setup a USB HID class host software and to integrate with Wolfram Mathematica, my most favourite computational software. I wrote this in Microsoft Visual Basic 2010 using an USB HID template. The interface is mostly self explanatory. The + and buttons are to increase/ decrease the PWM duty cycle. The end button turns the lamp off and ends data logging. The Save Log button exports the log in .txt format. The To Mathematica button exports the data in a mathematica notebook (.nb) file. Which opens a new room for analysis of the data. Undoubtedly, this is the most interesting part of the project to bring a real world data directly to a computational software. Well take a part-by-part look towards it. The exported mathematica file contains 5 matrices containing the saved values of voltage, power, current, resistance and temperature (V, P, I, R, T).

converted by Web2PDFConvert.com

For Stefan-Boltzmann law, were interested in T and P. Now well construct two matrices. One with P and T (TP) for non linear regression and another one with logP and logT (lTP) for linear regression.

Performing the linear regression first:

Then the nonlinear regression: note that without the MaxIteration > 200 (the default is 100) option, the NonLinearModelFit will fail to converge to the required accuracy. Itll generate an error NonlinearModelFit::cvmit: Failed to converge to the requested accuracy or precision within 100 iterations..

converted by Web2PDFConvert.com

See the PDF file for the complete notebook.

The .txt log file in notepad The above image is a cropped screenshot of my desktop showing the log text file in notepad. You probably have recognized the brilliant face of Anne Frank right next to the notepad window. I wonder did she ever dream that her letters to Kitty would be so celebrated worldwide, when she was killed in a 1945 Nazi concentration camp? She logged her days and nights, which now stands as an immortal description of that days of the boys in the striped pajamas. Find the full image here

Problems and improvement options


However, there are some problems (mainly with the power supply) associated with the design, which I uncovered later. The PWM scheme used here might be good enough for controlling brightness of an array of LEDs to create stunning lighting effects or to generate a thousand of colours using a RGB LED. But it is not enough for precision measurement. An NPN transistor inverts the filtered PWM signal (its a dc, not actually a signal) and then passes it to the lamp through a PNP pass transistor BD140. Id liked to use a P-channel MOSFET instead, but a logic level MOSFET was not available in my area. The device is neither a true constant voltage source nor a true constant current source. As the lamp glows on the voltage slowly increases as the resistance of the lamp decreases. Though, the deviation is so small that it can almost be neglected. But truly, this is an unwanted effect.

converted by Web2PDFConvert.com

LTSpice simulation of the PSU (Note that this is not the real scenario where filament resistance R_Load increases as the voltage increases, in that case the transistor stays active from 10% to 60% duty cycle, i.e. nearly 0.6V to 3V.) However, this effect might have a little negative impact on the overall performance, but this is a major design fault of the power supply section, which I uncovered later. I liked to use a MOSFET which is easier to design, has better efficiency (than BJTs). Modern power MOSFETs have very low on resistance RDS(ON) that reduces the voltage dropouts. But I was forced to use a power transistor instead of it because of availability. At that time (about a year ago from now), I didnt know the mathematics behind biasing of a transistor (now I know how simple it is). Hence, the transistor in the design is not biased properly to stay in active region throughout the entire range of the PWM duty cycle. The transistor stays in active region in between 16% to 63% duty cycle. Beyond of which the transistor gets cut-off or saturated. Though the BD140 can handle a maximum collector current of 1.5A, but even at 500mA it becomes very hot (almost impossible to touch, maybe a better heatsink was needed), tends to shift up the operating point and gets saturated at 63% duty cycle. . This faulty biasing effectively reduces the voltage resolution Another unwanted issue! But truly I wanted a MOSFET, so badly a MOSFET! After investigating into the power supply for more faults, I found the output gets noisy while the duty cycle is changed. As a remedy, I used a second order low pass filter instead of a first order one and increased the PWM base frequency to 48KHz from 10KHz. Now, there is no audible noise, the output dc remains enough clean, though I didnt check it with an oscilloscope, so I cant tell you how clean it is! But all the problems have a very simple solution. To replace the whole power supply section with a voltage controlled current source (VCCS). The VCCS would operate in two modes. In first mode, itll give a full range output current of 0-50 uA, to determine the cold resistance of the filament accurately (it is not possible with PWM + pass transistor). In the second mode, itd give a full range current of 0-2A. The maximum current depends on the MOSFET (see the schematic below) and the power supply voltage. In the quick simulation, Ive used a 20V power supply to the VCSS, just enough to power up a 12V automotive lamp.

Rough simulation of a VCSS in NI Multisim The control voltage of the VCCS would be controlled by a digital potentiometer. We all have used a rotary potentiometer. Digital potentiometer is simply a digital version of it where
converted by Web2PDFConvert.com

the knob is rotated by some digital signals (SPI or I2C) from the microcontroller instead of our fingers. Through which more precision control over the power supply would be achieved.

If I had a hammer
If I had a hammer/ Id hammer in the morning/ Id hammer in the evening/ All over this land /Id hammer out danger/ Id hammer out a warning/ Id hammer out love between my brothers and my sisters/ All over this land A great song by Pete Seeger. Here Im going to tell you I could do better if I had some more instruments (i.e. some hammers) and access to some electronics and scientific stores. The local electronics stores are awful, really awful. They dont stock any components other than passives and some very basic transistors and ICs. Probably they never heard of PIC microcontrollers. SMDs are not available. Precision resistors (5% or 1% tolerance) are not available. My BOM (bill of materials) was always a bomb to them! Though some of the greatest Indian electronics stores are there at online. Like element14 (formerly Farnell), onlineTPS, rhydolabz, kitsnspares etc. But I dont have any credit card or netbanking facility to buy from them. Check/DDs are outdated and many of the stores dont accept it. And who accepts, takes more than one and half months to proceed due to banking lags. So online stores are not worthy to me for now. Maxim semiconductors provided me some samples of MAX4372 and MAX873. Oh! thanks a lot. Now professionals will laugh aloud: I used five pieces of 1 ohm resistor (10% tolerance) in series as the 100 milliohm current sense resistor. This has to be precision for accurate results. Fortunately, five resistors of 10% tolerance will constitute a maximum 2% tolerance when connected in series. Resistors specially made for current sensing have very low tolerance values, like 0.1% or 0.01%. A real current sense resistor will greatly improve the overall accuracy. I dont have access to an oscilloscope so that I couldnt analyze some part of the circuit (e.g. the low pass filter characteristics). I used a tiny speaker to listen to the waveform! A dc sounds a little transient bump and any other waveform sounds continuously. So, I could at least distinguish between a dc and some wavy variations. It was fine when the PWM base frequency was 10KHz. Later I changed it to 48KHz. Phew aint no bat to listen to ultrasonics! I had an idea to use a IR photodiode to measure the filament temperature from its IR emission. Well, sounds nice. I tried using a standard IR photodiode with various bias levels to cover the entire 300K to 2500K temperature range. Obviously failed every time. After some tryouts, I understood, Im actually going to make an optical pyrometer from scratch! Later I studied the details of a pyrometer and figured how foolish I was. It would need very complex mechanism; collimator, optical chopping, sensitive pyro element, precision amplifier etc etc. So I abandoned my idea soon. Pasco scientific ltd, a leading scientific instrument maker from US, has a so called Stefan-Boltzmann Lamp. They claim that it closely resembles a blackbody characteristics. I liked to do some experiment with it. But unfortunately Pasco dont have any reseller/distributor in India.

converted by Web2PDFConvert.com

The Stefan-Boltzmann Lamp

Helping hands
The list of helping hands is not too long. This is not because people are unhelpful. Actually, I didnt sought help from anybody. How would you expect to get others hand without spreading out your own? Probably you have guessed that its a completely DIY project and what Ive learned so far in electronics and programming are all in do-it-yourself way. But, the first one I should mention as a helping hand is Partha Chakraborti. I learnt numerous things from him, from PCB etching to C# code snippets! Also happily burnt our times in gossiping from so-hatedpolitics to so-beloved-love-stories! Interestingly, he is my net-friend, not anyone from the world of reality. I swear, whenever my DIY world fell into an abyss, I always got his virtual hands. And most likely, without it, I couldnt have become what now I am. My two priceless friends from real world, Anjan and Prantik, did help me too. Anjan brought me some components and I had a long discussion about various properties of linear and non linear regression with Prantik.

References
PIC Programming Note that, I didnt learn PIC programming from any real person, but the followings are not less than a real person anyway (what would philosophers call it: postmodern revolution!). http://digital-diy.com (Im grateful to them, what Ive learnt so far in PIC programming are mostly from them) Documentations/ examples of Swordfish IDE (http://www.sfcompiler.com) Various application notes from Microchip (http://www.microchip.com) Countless threads/posts from http://www.electro-tech-online.com Journal articles Here are the journal articles which I followed. http://journal.lapen.org.mx/jan10/LAJPE_332_Ahmad_preprint_corr_f.pdf : Just a general article employing traditional methods, but it widened my general idea of the problem. http://journal.lapen.org.mx/jan09/LAJPE%20217%20Agrawal%20preprint%20f.pdf : A nice set of exponent rules. I didnt understood it fully as I dont have access to the main IEEE article. It needs a subscription which can be made through credit card only. I dont have it. http://my.ece.ucsb.edu/Bobsclass/134/Handouts/ej1413.pdf : Wow! I was surprised at first sight. What an innovative idea. The topics is not directly related to mine, but I learnt a lot from it. http://advlabs.aapt.org/tcal/Detail.cfm?id=2605 : Very nice explanation. Noted a few

converted by Web2PDFConvert.com

things from it. It uses advanced instruments, like photodiodes, monochromator (with HeNe laser to calibrate it), precision multimeters and bench meters. I dont have them, even my college lab doesnt stock them all! http://journal.lapen.org.mx/jan10/LAJPE_324_Agrawal_preprint_corr_f.pdf : Many of us perform physical experiments without caring the errors and limitations of accuracy of the reading. This is a so nicely written article, must read for every amateur experimenters. http://articles.adsabs.harvard.edu/full/1925ApJ.61..146F : An article on various properties of tungsten. Published in 1916. http://www.phys.ksu.edu/personal/rprice/BB.pdf : It also deals with an incandescent lamp, lot like my topics. http://www3.wooster.edu/physics/jris/Files/Carter.pdf : This is so well written, a lot better than traditional textbooks, helped me a lot. This is not a complete list though. I went through almost all the search results. My files The PDF export of the Mathematica notebook file: log6.pdf The .bas file from Swordfish IDE: sb_demon -bas. doc (change the extension to .bas ) If you are curious about something more, then you can ask me for some more files (e. g. Swordfish libraries, compiled hex file, USB interface installation files, its source files or any other file). WordPress doesnt allow this type of files to be attached. But feel free to ask me for them, Ill mail it to you.

The last thing on my mind


Are you going away with no word of farewell?/ Will there be not a trace left behind?/ Well, I could have loved you better, /Didnt mean to be unkind./ You know that was the last thing on my mind Another great song by Tom Paxton. After more than 8 years with DIY electronics, microcontrollers, bucketful of junk electronic lilliputs and programming codes; with failures, sudden victories and helplessness Dont know why Ive become so romantic, so addicted about DIY stuffs. Ive done so much for it; explored a lot, neglected my academic studies, skipped from being an academic scholar to a casual 80 percenter. Now Im an undergraduate student of physics. Ive seen a few real teachers who tries to uncover the facts rather than throwing them into a mess of equations. Physics is all about nature, and its beautiful. And it becomes easy/simple when the aesthetic is well understood. The simplicity is often neglected in academic studies. As a bookworm of popular science books (namely, started off with Parthasarathi Chakraborti, Shyamal Chakraborti and authors from Mir publication of former USSR; later introduced to Feynman, George Gamow, John Gribbin, Roger Penrose, Paul J Nahin, Michio Kaku, G. Venkataraman, Jayanta Basu, John A Adam and lot more), I found the world of mystery beauty and surprises, lot more surprises, which I rarely found in texts (I swear, there are a few textbooks which explores the topic, revealing the beauty in it). At this point, I should mention my parents, specially my father, who is an art-critic. His livelong passion is to collect and read books. Ive over five thousand books (and counting!) mostly on art and literature in my very cluttered house. We often have discussions how to relate arts and sciences just like an unification. So far, the greatest DIY people, I know, is Michio Kaku. The whole world knows him as a leading theoretical physicist in the field of string field theory. Since, at least for now, I dont have not enough courage to venture into this, he is a God of DIY-ing to me. He made a
converted by Web2PDFConvert.com

particle accelerator (betatron) at home! Can you believe it, a school-going-kid makes a particle accelerator at his parents garage for a science fair project!!! Is not it like dreaming? Also, the book, Hyperspace, where he told it, is one of my very best read. Here is a glimpses of the dream (for you who missed it, page no 6-7): Hyperspace: a scientific odyssey through parallel universes, time warps, and By Michio Kaku And the very last thing is Prof. Walter Lewin, who changed my understanding of physics (specially electromagnetism) through his lectures, now available to everyone through MIT OpenCourseWare. This is a classic lecture series, I admire his interactive and demonstrative method of teaching. Im eagerly waiting for his book, For the Love of Physics to become available in India. If you have considered reading so far, then Id recommend you to watch this 5:46 min course introduction video, youll never forget it (specially the last part, from 2:44 min), Im sure.

Course Introduction | MIT 8.02 Electricity and Magnetism, Spring 2002

And thats all, the last thing on my mind


Posted in Main Article | Tagged blackbody radiation, electronics, HID, lamp, mathematica, pic microcontroller, stefanboltazmann law , USB| 3 Comments

SB Demon!

Theme: Twenty Ten

Blog at WordPress.com.

converted by Web2PDFConvert.com

Vous aimerez peut-être aussi