<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Kerry D. Wong</title>
	<atom:link href="http://www.kerrywong.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kerrywong.com</link>
	<description></description>
	<lastBuildDate>Sat, 04 Feb 2012 02:10:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Adding Off-Screen Buffer to Serial LCD Display</title>
		<link>http://www.kerrywong.com/2012/02/03/adding-off-screen-buffer-to-serial-lcd-display/</link>
		<comments>http://www.kerrywong.com/2012/02/03/adding-off-screen-buffer-to-serial-lcd-display/#comments</comments>
		<pubDate>Sat, 04 Feb 2012 02:10:53 +0000</pubDate>
		<dc:creator>kwong</dc:creator>
				<category><![CDATA[AVR/Arduino]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Atmega328P]]></category>
		<category><![CDATA[Circular Buffer]]></category>
		<category><![CDATA[FeRAM]]></category>
		<category><![CDATA[Ferroelectric RAM]]></category>
		<category><![CDATA[FM25C160]]></category>
		<category><![CDATA[FRAM]]></category>
		<category><![CDATA[LCD]]></category>
		<category><![CDATA[Off-Screen Buffer]]></category>
		<category><![CDATA[Serial Display]]></category>

		<guid isPermaLink="false">http://www.kerrywong.com/?p=5395</guid>
		<description><![CDATA[Since the current Arduino tools do not support in-circuit debugging, you will have to rely heavily on the serial print outs when tracking down those hard-to-find bugs unless you are one of those few elites whose code just works 100% every time. It is all good when you are doing your development when a computer [...]]]></description>
			<content:encoded><![CDATA[<p>Since the current Arduino tools do not support <a href="http://en.wikipedia.org/wiki/In-circuit_emulator">in-circuit debugging</a>, you will have to rely heavily on the serial print outs when tracking down those hard-to-find bugs unless you are one of those few elites whose code just works 100% every time. It is all good when you are doing your development when a computer is readily available. But what if you need to capture the outputs when you do not have the access to a computer? I found myself running into this situation quite often. <span id="more-5395"></span></p>
<p>One way to solve this problem is to use a serial monitor (like <a href="http://www.kerrywong.com/2011/06/27/building-an-auxiliary-display/">this one</a> I built before) to output the values onto an LCD display. But if your application generates a lot of messages, it would still be hard to spot the relevant information as you can only see the last couple of lines of the data.   </p>
<p>So my solution is to add a none-volatile off-screen buffer to the serial display so that multiple rows of data can be captured during run time and retained for later debugging.</p>
<p>While ATmega328 has built-in EEPROM of 1Kbytes, there is not nearly enough space to store much information for debugging purposes, so clearly some kind of external memory is needed.</p>
<p>For the external memory, I prefer using <a href="http://en.wikipedia.org/wiki/Ferroelectric_RAM">FRAM</a> over <a href="http://en.wikipedia.org/wiki/EEPROM">EEPROM</a> as FRAM can be written to almost instantaneously whereas for EEPROM some delay is required for the write operation. Also, FRAM can handle many more read/write cycles which makes it ideal for this kind of applications in which data needs to be refreshed all the time. In one of my previous blog postings, I wrote about <a href="http://www.kerrywong.com/2012/01/15/using-fram-as-nonvolatile-memory-with-arduino/">how to interface FRAM with Arduino</a>. You can refer to that posting for more details.</p>
<p>In my implementation, I used two <a href="http://www.ramtron.com/files/datasheets/FM25C160B_ds.pdf">Ramtron FM25C160</a>&#8216;s which provide 4 Kbytes of storage space. And I used a standard 16&#215;2 character LCD for display. If we allow each line to contain up to 32 bytes of data (16 bytes will be off screen, but can be viewed via scroll function) we will have 128 lines available to us in the buffer. If this is not sufficient, you can always add more memory chips or choose one that offers bigger storage space.</p>
<div id="attachment_5419" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2012/02/displayboard_1.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2012/02/displayboard_1-300x225.jpg" alt="Board layout" title="Board layout" width="300" height="225" class="size-medium wp-image-5419" /></a><p class="wp-caption-text">Board layout</p></div>
<p>To store the information sent to the serial monitor in the off-screen buffer, a <a href="http://en.wikipedia.org/wiki/Circular_buffer">circular buffer</a> construct is needed. The serial data stream is stored into the circular buffer as it comes in and when the buffer becomes full, the pointer that points to the buffer&#8217;s bottom address is incremented, purging the oldest record in the buffer and making room for another a new row in the mean time. So the circular buffer always contains the latest serial outputs (up to the latest 128 lines in this setup). You can find the implementation details in the full code listing at the end.</p>
<p>To simply the coding a little bit, the values of the pointers for tracking the buffer top, bottom and the current scroll position are kept in volatile memory (RAM), they are flushed to the ATmega&#8217;s EEPROM on demand by pressing the &#8220;save&#8221; button. So if you want to save the data recorded so far (note that the actual data is always stored in the buffer, but without saving the buffer pointers, there is no way to retrieve it), you can press the &#8220;save&#8221; button before powering off the MCU. When the MCU is first powered up, it checks to see whether the buffer location pointers were previously stored, and if so the previously saved values are loaded and the displayed content is scrolled to that position so that user can continue to work on the data in exactly the same state as before. The save button also functions as a &#8220;clear&#8221; button in my implementation. If you hold down the &#8220;save&#8221; button for more than a second, all buffer pointer locations are reset to zero and all information previously stored in the FRAM is cleared. You can examine the source code for more details.</p>
<p>Of course we could have just used a few dedicated locations in the FRAM to store the buffer pointer information on every single buffer write instead of saving this information in EEPROM on the MCU. This alternative approach would probably be a little more convenient as the buffer pointers are always updated and saved automatically each time when a data row is saved. There is no particular reason why I couldn&#8217;t have done that. It is totally up you to decide which is the best method to meet your particular need.</p>
<p>In the picture below you can see the finished serial display. Besides the save/clear button mentioned earlier, there are four additional buttons for scrolling.<br />
<div id="attachment_5420" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2012/02/displayboard_2.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2012/02/displayboard_2-300x225.jpg" alt="LCD with Off-screen FRAM buffer" title="LCD with Off-screen FRAM buffer" width="300" height="225" class="size-medium wp-image-5420" /></a><p class="wp-caption-text">LCD with Off-screen FRAM buffer</p></div></p>
<p>Note that I omitted the UART to RS232 converter chip since most of my debugging are done via UART. But you can easily add one if you intend to use it with RS232 voltage level compatible devices.</p>
<p>Here is a typical usage scenario: connect the serial display to the circuit you are debugging via serial cables (Rx, Tx and Gnd). Make sure that both sides operate at the same baud rate (in this case it&#8217;s 9600 bps). Start your testing. The serial outputs are then stored into the none-volatile memory on the serial display board. When you are done capturing the data, press the save button and you can then power off and disconnect the serial display from your test circuit and analyze the stored information later.</p>
<h4>Download:</h4>
<p> <a href='http://www.kerrywong.com/blog/wp-content/uploads/2012/02/screenbuffer.tar.gz'>screenbuffer.tar.gz</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.kerrywong.com/2012/02/03/adding-off-screen-buffer-to-serial-lcd-display/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Short Guide On Motor Electrical Noise Reduction</title>
		<link>http://www.kerrywong.com/2012/01/26/a-short-guide-on-motor-electrical-noise-reduction/</link>
		<comments>http://www.kerrywong.com/2012/01/26/a-short-guide-on-motor-electrical-noise-reduction/#comments</comments>
		<pubDate>Fri, 27 Jan 2012 01:26:10 +0000</pubDate>
		<dc:creator>kwong</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[Common Mode Interference]]></category>
		<category><![CDATA[Electrical Noise]]></category>
		<category><![CDATA[Ground Loop]]></category>
		<category><![CDATA[Motor]]></category>
		<category><![CDATA[RF Interference]]></category>

		<guid isPermaLink="false">http://www.kerrywong.com/?p=5326</guid>
		<description><![CDATA[This topic is nothing new and there are already quite a few good articles on the web on this. But I thought I would try to provide a more comprehensive view on this issue and give a few concrete examples on how to filter out the electrical noise from motors in your circuits. DC motors, [...]]]></description>
			<content:encoded><![CDATA[<p>This topic is nothing new and there are already quite a few good articles on the web on this. But I thought I would try to provide a more comprehensive view on this issue and give a few concrete examples on how to filter out the <a href="http://en.wikipedia.org/wiki/Electrical_noise">electrical noise</a> from motors in your circuits.<span id="more-5326"></span></p>
<p>DC motors, especially brushed motors tend to generate a lot of noise (both acoustical and electrical), and the electrical noise can interfere with RF circuits and even logic circuits if not isolated properly, leading to erratic behaviors. This kind of noise-induced erratic behavior can sometimes be very hard to trace and debug.</p>
<p>The <a href="http://en.wikipedia.org/wiki/Electrical_noise">electrical noise</a> generated by a DC motor falls into two categories: <a href="http://en.wikipedia.org/wiki/Electromagnetic_interference">Electromagnetic interference</a> (RF interference) and the electrical noise generated on the power rail. </p>
<h3>Suppressing RF interference</h3>
<p>The RF interference can couple into other portions of the circuit and cause circuit malfunction and performance degradation. If your project uses RF data link for instance, the motor induced RF noise can significantly decrease the usable RF range. </p>
<p>The level of RF interference is dependent on a few different factors: for instance, the type of the motor (brushed or brushless), driving waveform and load can all impact the severity of the RF interference. Typically, brushed motors generate more RF interference than their brushless counterparts. But the design of the motor, regardless of the type, also affects the RF leakage greatly. A small cheap toy brushed motor can sometimes generate magnitudes more RF interference than a carefully designed more powerful motor.</p>
<p>To reduce the level of RF interference, motors should be placed as far away from sensitive circuits as physically possible. Motor&#8217;s metal casing typically provides enough shielding capability for reducing the over-the-air RF interference, but an extra metal enclosure should provide much better RF interference reduction capability. It is important that in either case, the metal casing (either the motor casing or the metal enclosure) should be properly grounded (e.g. via ground strap at a single point).</p>
<p>The RF signals generated by the motor can also be coupled into the circuit, which forms what is known as the <a href="http://en.wikipedia.org/wiki/Common-mode_interference">common mode interference</a>. This type of interference cannot be eliminated by shielding, but can be reduced effectively via a simple LC low-pass filter. You can find a couple of examples in the next section.</p>
<h3>Reducing Other Electrical Noises</h3>
<p>Another source of electrical noise comes from the power rail. Since power supply has a none-zero internal resistance, the none constant motor current flow during each rotation period would translate into voltage ripples across the power terminals. The following oscilloscope waveform capture shows the noise at the battery terminal when a small toy motor is powered via 4 AA Ni-Mh batteries with no filter added.</p>
<div id="attachment_5337" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2012/01/motornoise.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2012/01/motornoise-300x219.jpg" alt="Motor Electrical Noise Measured at Power Terminal" title="Motor Electrical Noise Measured at Power Terminal" width="300" height="219" class="size-medium wp-image-5337" /></a><p class="wp-caption-text">Motor Electrical Noise Measured at Power Terminal</p></div>
<p>As you can see, the noise level is quite severe and the noise Vpp reached more than 3 Volts at times, which is more than enough to cause logic gates malfunction. And this kind of noise is likely to affect the performance of Op Amps and other analog circuitry as well.</p>
<p>With a simple LC <a href="http://en.wikipedia.org/wiki/Low-pass_filter">low-pass filter</a> (100nf capacitor, 10mH choke for instance), the waveform improved somewhat, but the noise signal is still noticeable at around 0.5V Vpp:</p>
<div id="attachment_5359" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2012/01/motornoise_lc.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2012/01/motornoise_lc-300x219.jpg" alt="Motor Electrical Noise Measured at Power Terminal (LC Filter)" title="Motor Electrical Noise Measured at Power Terminal (LC Filter)" width="300" height="219" class="size-medium wp-image-5359" /></a><p class="wp-caption-text">Motor Electrical Noise Measured at Power Terminal (LC Filter)</p></div>
<p>Keep in mind that the above captures were taken using newly charged batteries. The noise level will likely be progressive worse as batteries discharge due to the increased internal resistance. </p>
<p>To further reduce the electrical noise, further filtering at the power source is needed. Typically, this is done by adding a larger capacitor (e.g. 1000uF and above) across the power terminals to lower the effective resistance of the power supply and thus improve transient response.</p>
<p>The following schematics show a couple of typical circuits for filtering out motor electrical noise.</p>
<p>The first filtering scheme is suited for uni-directional motor driving circuit. And the second one is suited for bi-directional motor driving circuit.</p>
<div id="attachment_5366" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2012/01/motorwithspeedcontroller.png"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2012/01/motorwithspeedcontroller-300x136.png" alt="Motor with simple Speed Controller" title="Motor with simple Speed Controller" width="300" height="136" class="size-medium wp-image-5366" /></a><p class="wp-caption-text">Motor with simple Speed Controller</p></div>
<p>In bi-directional scenario (e.g. using an H-Bridge), two sets of LC filters should be used as the power to the motor is essentially center tapped.</p>
<div id="attachment_5367" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2012/01/motorwithHbridge.png"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2012/01/motorwithHbridge-300x94.png" alt="Motor with H-Bridge" title="Motor with H-Bridge" width="300" height="94" class="size-medium wp-image-5367" /></a><p class="wp-caption-text">Motor with H-Bridge</p></div>
<p>The values for the inductors and capacitors used in the filters can be varied experimentally to achieve the best results. But in general, the capacitors on the motor side are several hundred nano-farads and the inductors are several milli-heneries. Higher order LC filters can further improve the noise-filtering performance but are rarely necessary.</p>
<h3>Preventing Ground Loop</h3>
<p>In the schematics shown above, please pay special attention to the grounding location. It is important to have the ground tied to a common place which is as close to the power supply source (i.e. the negative terminal of the battery) as possible. This grounding practice is especially important when there are other sensitive electronics component (e.g. MCUs, analog circuits) in your projects as the noise induced  in the <a href="http://en.wikipedia.org/wiki/Ground_loop_(electricity)">ground loop</a> by the ground current can be significant if not taken care of properly.</p>
<p>If it is not possible to ensure a single grounding location, you should at least have the multiple subsystems&#8217; (in this case motor system and the MCU circuits) grounds tied at a single point as close to the negative power terminal as possible. And within each sub system, make sure that the ground plane&#8217;s impedance is as low as possible.</p>
<p>With sufficient shielding, filtering and correct grounding practices the electrical noise generated by an electric motor can be reduced to a level that is low enough for even the most sensitive circuits.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kerrywong.com/2012/01/26/a-short-guide-on-motor-electrical-noise-reduction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My Renesas Demo Boards Arrived</title>
		<link>http://www.kerrywong.com/2012/01/21/my-renesas-demo-boards-arrived/</link>
		<comments>http://www.kerrywong.com/2012/01/21/my-renesas-demo-boards-arrived/#comments</comments>
		<pubDate>Sun, 22 Jan 2012 02:13:17 +0000</pubDate>
		<dc:creator>kwong</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[Renesas]]></category>
		<category><![CDATA[RL78/G13]]></category>
		<category><![CDATA[RX62N]]></category>

		<guid isPermaLink="false">http://www.kerrywong.com/?p=5311</guid>
		<description><![CDATA[Last week, I received two of the demo boards from Renesas. One is a YRPBRL78G13 and the other is a RPBRX62N. The RL78/G13 promotional board features a 64 pin R5F100LEA 16-bit microcontroller, which has 64K flash ROM, 4K data flash and 4K RAM. The RX62N contains a R5F562N8BDFP 32-bit microcontroller, which has 512K ROM, 32K [...]]]></description>
			<content:encoded><![CDATA[<p>Last week, I received two of the demo boards from <a href="http://www.renesas.com">Renesas</a>. One is a <a href="http://am.renesas.com/products/tools/introductory_evaluation_tools/renesas_demo_kits/yrpbrl78g13/index.jsp">YRPBRL78G13</a> and the other is a <a href="http://www.renesas.eu/products/tools/introductory_evaluation_tools/renesas_promotional_boards/RPBRX62N/index.jsp">RPBRX62N</a>. The RL78/G13 promotional board features a 64 pin <a href="http://documentation.renesas.com/doc/products/mpumcu/doc/rl78/r01uh0146ej_rl78g13.pdf">R5F100LEA</a> 16-bit microcontroller, which has 64K flash ROM, 4K data flash and 4K RAM. The RX62N contains a <a href="http://documentation.renesas.com/doc/products/mpumcu/doc/rx_family/r01uh0033ej0130_rx62n.pdf">R5F562N8BDFP</a> 32-bit microcontroller, which has 512K ROM, 32K data flash and 96K RAM<span id="more-5311"></span>.</p>
<div id="attachment_5318" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2012/01/renesasmcus.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2012/01/renesasmcus-300x295.jpg" alt="Renesas MCUs" title="Renesas MCUs" width="300" height="295" class="size-medium wp-image-5318" /></a><p class="wp-caption-text">Renesas MCUs</p></div>
<p>I have not spent too much time playing with them yet. But the latter one (RX62N) definitely looks more interesting to me. On the demo board it features an embedded web server and a VNC server. This type of configuration is very useful in designing networked smart appliances. The included evaluation software (Renesas High Performance Embedded Workshop) is only fully functional for 60 days though, I am not sure if that will be enough time for me to explore.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kerrywong.com/2012/01/21/my-renesas-demo-boards-arrived/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using FRAM as Nonvolatile Memory With Arduino</title>
		<link>http://www.kerrywong.com/2012/01/15/using-fram-as-nonvolatile-memory-with-arduino/</link>
		<comments>http://www.kerrywong.com/2012/01/15/using-fram-as-nonvolatile-memory-with-arduino/#comments</comments>
		<pubDate>Mon, 16 Jan 2012 01:45:04 +0000</pubDate>
		<dc:creator>kwong</dc:creator>
				<category><![CDATA[AVR/Arduino]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Atmega328P]]></category>
		<category><![CDATA[FeRAM]]></category>
		<category><![CDATA[Ferroelectric RAM]]></category>
		<category><![CDATA[FM25C160]]></category>
		<category><![CDATA[FRAM]]></category>

		<guid isPermaLink="false">http://www.kerrywong.com/?p=5275</guid>
		<description><![CDATA[One of the biggest advantages of FRAM (or FeRAM, Ferroelectric RAM) over EEPROM is that FRAM has a much higher write speed and typically can operate at bus speed. This means that no delay instructions are needed when performing write operations, which greatly reduces coding complexity and increases the overall throughput. FRAM is also capable [...]]]></description>
			<content:encoded><![CDATA[<p>One of the biggest advantages of <a href="http://en.wikipedia.org/wiki/Ferroelectric_RAM">FRAM</a> (or FeRAM, Ferroelectric RAM) over <a href="http://en.wikipedia.org/wiki/EEPROM">EEPROM</a> is that FRAM has a much higher write speed and typically can operate at bus speed. This means that no delay instructions are needed when performing write operations, which greatly reduces coding complexity and increases the overall throughput.<span id="more-5275"></span> FRAM is also capable of supporting beyond 10<sup>12</sup> read/write cycles whereas most EEPROM can only handle around 10<sup>6</sup> read/write cycles. These properties make FRAM very attractive for using with microcontrollers where frequent write to nonvolatile memory is needed.</p>
<p>In this blog post I will give an example on interfacing two <a href="http://www.ramtron.com/">Ramtron</a> <a href="http://www.ramtron.com/files/datasheets/FM25C160B_ds.pdf">FM25C160</a> FRAM chips with Arduino. Since the basic operations on an FRAM are very similar to those on a standard EEPROM, I would recommend reading this <a href="http://arduino.cc/en/Tutorial/SPIEEPROM">SPI EEPROM tutorial</a> first if you are not familiar with the protocol. </p>
<p>The main difference between the operation modes of an FM25C160 and a standard EEPROM is that FM25C160 allows multi-byte sequential reads and writes whereas EEPROM typically has a limited write buffer and long writes beyond the buffer length must be broken into multiple writes. We will take advantage of this in our code later.</p>
<p>The following schematic shows the simplest way to interface multiple FRAM (or EEPROM) chips with Arduino.</p>
<div id="attachment_5286" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2012/01/FM25C160.png"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2012/01/FM25C160-300x193.png" alt="Interfacing 2 FM25C160 with Arduino" title="Interfacing 2 FM25C160 with Arduino" width="300" height="193" class="size-medium wp-image-5286" /></a><p class="wp-caption-text">Interfacing 2 FM25C160 with Arduino</p></div>
<p>For our simple implementation, the HOLD and WP pins are disabled (tie to Vcc) and the corresponding data pins (SO, SI and SCK) are connected together. The CS pin of each FRAM is controlled individually by an Arduino IO pin so that each FRAM can be selected and operated on individually.</p>
<p>The following code shows how to access multiple FRAM chips using Arduino. For FM25C160, the maximum address is 0x7FF (since it has 16 Kbits and 2K bytes) so we assume that addresses between 0&#215;800 and 0&#215;1000 belong to the second chip, and addresses beyond 0&#215;1000 are invalid.</p>
<pre class="brush: cpp; title: ; notranslate">
#include &lt;SPI.h&gt;

const byte CMD_WREN = 0x06; //0000 0110 Set Write Enable Latch
const byte CMD_WRDI = 0x04; //0000 0100 Write Disable
const byte CMD_RDSR = 0x05; //0000 0101 Read Status Register
const byte CMD_WRSR = 0x01; //0000 0001 Write Status Register
const byte CMD_READ = 0x03; //0000 0011 Read Memory Data
const byte CMD_WRITE = 0x02; //0000 0010 Write Memory Data

const int FRAM_CS1 = 10; //chip select 1
const int FRAM_CS2 = 9; //chip select 2

/**
 * Write to FRAM (assuming 2 FM25C160 are used)
 * addr: starting address
 * buf: pointer to data
 * count: data length.
 *        If this parameter is omitted, it is defaulted to one byte.
 * returns: 0 operation is successful
 *          1 address out of range
 */
int FRAMWrite(int addr, byte *buf, int count=1)
{
  int cs = 0;

  if (addr &gt; 0x7ff)  {
    addr -=0x800;
    cs = FRAM_CS2;
  } else {
    cs = FRAM_CS1;
  }

  if (addr &gt; 0x7ff) return -1;

  byte addrMSB = (addr &gt;&gt; 8) &amp; 0xff;
  byte addrLSB = addr &amp; 0xff;

  digitalWrite(cs, LOW);
  SPI.transfer(CMD_WREN);  //write enable
  digitalWrite(cs, HIGH);

  digitalWrite(cs, LOW);
  SPI.transfer(CMD_WRITE); //write command
  SPI.transfer(addrMSB);
  SPI.transfer(addrLSB);

  for (int i = 0;i &lt; count;i++) SPI.transfer(buf[i]);

  digitalWrite(cs, HIGH);

  return 0;
}

/**
 * Read from FRAM (assuming 2 FM25C160 are used)
 * addr: starting address
 * buf: pointer to data
 * count: data length.
 *        If this parameter is omitted, it is defaulted to one byte.
 * returns: 0 operation is successful
 *          1 address out of range
 */
int FRAMRead(int addr, byte *buf, int count=1)
{
  int cs = 0;

  if (addr &gt; 0x7ff)  {
    addr -=0x800;
    cs = FRAM_CS2;
  } else {
    cs = FRAM_CS1;
  }

  if (addr &gt; 0x7ff) return -1;

  byte addrMSB = (addr &gt;&gt; 8) &amp; 0xff;
  byte addrLSB = addr &amp; 0xff;

  digitalWrite(cs, LOW);

  SPI.transfer(CMD_READ);
  SPI.transfer(addrMSB);
  SPI.transfer(addrLSB);

  for (int i=0; i &lt; count; i++) buf[i] = SPI.transfer(0x00);

  digitalWrite(cs, HIGH);

  return 0;
}

void setup()
{
  Serial.begin(9600);
  pinMode(FRAM_CS1, OUTPUT);
  digitalWrite(FRAM_CS1, HIGH);
  pinMode(FRAM_CS2, OUTPUT);
  digitalWrite(FRAM_CS2, HIGH);

  //Setting up the SPI bus
  SPI.begin();
  SPI.setDataMode(SPI_MODE0);
  SPI.setBitOrder(MSBFIRST);
  SPI.setClockDivider(SPI_CLOCK_DIV2);

  //Test
  char buf[]=&quot;This is a test&quot;;

  FRAMWrite(1, (byte*) buf, 14);
  FRAMRead(1, (byte*) buf, 14);

  for (int i = 0; i &lt; 14; i++) Serial.print(buf[i]);
}

void loop()
{
}
</pre>
<p>While the above code supports memory spanning multiple chips, each read/write operation is limited within a single chip. This should be sufficient under most scenarios. If reading/writing beyond a single chip&#8217;s boundary is required, logic needs to be added so that when the address wraps around to 0 the CS of the current chip is deselected and the CS of the next chip is selected.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kerrywong.com/2012/01/15/using-fram-as-nonvolatile-memory-with-arduino/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Interfacing MMA8453Q With Arduino</title>
		<link>http://www.kerrywong.com/2012/01/09/interfacing-mma8453q-with-arduino/</link>
		<comments>http://www.kerrywong.com/2012/01/09/interfacing-mma8453q-with-arduino/#comments</comments>
		<pubDate>Mon, 09 Jan 2012 19:14:40 +0000</pubDate>
		<dc:creator>kwong</dc:creator>
				<category><![CDATA[AVR/Arduino]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Atmega328P]]></category>
		<category><![CDATA[AVR]]></category>
		<category><![CDATA[I2C]]></category>
		<category><![CDATA[MMA8450Q]]></category>
		<category><![CDATA[MMA8451Q]]></category>
		<category><![CDATA[MMA8452Q]]></category>
		<category><![CDATA[MMA8453Q]]></category>

		<guid isPermaLink="false">http://www.kerrywong.com/?p=5238</guid>
		<description><![CDATA[MMA8453Q is a rather inexpensive accelerometer. It is significantly cheaper than many other 3-axis accelerometers (such as the popular LIS3LV02DL) and yet it offers a reasonably high 10 bits resolution and packs a rich set of features that simplifies designs and programming in many different applications. In this post, I will show you how to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.freescale.com/files/sensors/doc/data_sheet/MMA8453Q.pdf">MMA8453Q</a> is a rather inexpensive accelerometer. It is significantly cheaper than many other 3-axis accelerometers (such as the popular <a href="http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/DATASHEET/CD00091417.pdf">LIS3LV02DL</a>) and yet it offers a reasonably high 10 bits resolution and packs a rich set of features that simplifies designs and programming in many different applications.<span id="more-5238"></span></p>
<p>In this post, I will show you how to interface it with an ATmega328 MCU using Arduino libraries. Because the operating voltage range for MMA8453Q is  between 1.95V and 3.6V, you will need to either power your MCU using 3.3V or use an I2C voltage level translator (such as TI&#8217;s <a href="http://www.ti.com/lit/ds/symlink/pca9517.pdf">PCA9517 Level-Translating I2C Bus Repeater</a>) so that MMA8453Q can be powered within its specified voltage range.</p>
<p>MMA8453Q uses the <a href="http://en.wikipedia.org/wiki/I%C2%B2C">I2C</a> protocol, so I assumed that I could use the default <a href="www.arduino.cc/en/Reference/Wire">Arduino Wire library</a>. Unfortunately, MMA8453Q uses <a href="http://www.i2c-bus.org/repeated-start-condition/">repeated start condition</a> for the read operations and the default Wire library cannot handle without any modifications. As a result of this, it does not matter which register you try to read from, the returned value is always the content of the status register (at address 0&#215;00) when using the Wire library due to the reset between the write of the register address and the subsequent read. Fortunately, there are alternative I2C libraries available for Arduino that address this issue. And <a href="http://dsscircuits.com/articles/arduino-i2c-master-library.html">the I2C library</a> I used below is from <a href="http://dsscircuits.com/">DSSCircuits</a>.</p>
<p>I mounted my MMA8453Q on a proto-board using <a href="http://www.kerrywong.com/2011/09/25/hand-soldering-fine-pitch-lga-chip/">my favorite hand-soldering method</a>. And connected it to my <a href="http://www.kerrywong.com/2010/09/18/zif-arduino-prototyping-board/">customized Arduino experiment board</a> and set the board voltage to 3.3V instead of the usual 5V. </p>
<div id="attachment_5241" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2012/01/MMA8453QBreakout.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2012/01/MMA8453QBreakout-300x225.jpg" alt="MMA8453Q Breakout Board" title="MMA8453Q Breakout Board" width="300" height="225" class="size-medium wp-image-5241" /></a><p class="wp-caption-text">MMA8453Q Breakout Board</p></div>
<div id="attachment_5240" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2012/01/MMA8453QAVR.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2012/01/MMA8453QAVR-300x225.jpg" alt="MMA8453Q I2C Setup" title="MMA8453Q I2C Setup" width="300" height="225" class="size-medium wp-image-5240" /></a><p class="wp-caption-text">MMA8453Q I2C Setup</p></div>
<p>The following is some sample code. Note that I only provided a few basic functions and not all the register constants are used in the code. But all the remaining functions can be easily implemented using <em>regRead/regWrite</em> functions and the register definitions listed below:</p>
<pre class="brush: cpp; title: ; notranslate">

#include &lt;I2C.h&gt;

const byte REG_STATUS = 0x00; //(R) Real time status
const byte REG_OUT_X_MSB = 0x01; //(R) [7:0] are 8 MSBs of 10-bit sample
const byte REG_OUT_X_LSB = 0x02; //(R) [7:6] are 2 LSBs of 10-bit sample
const byte REG_OUT_Y_MSB = 0x03; //(R) [7:0] are 8 MSBs of 10-bit sample
const byte REG_OUT_Y_LSB = 0x04; //(R) [7:6] are 2 LSBs of 10-bit sample
const byte REG_OUT_Z_MSB = 0x05; //(R) [7:0] are 8 MSBs of 10-bit sample
const byte REG_OUT_Z_LSB = 0x06; //(R) [7:6] are 2 LSBs of 10-bit sample
const byte REG_SYSMOD = 0x0b; //(R) Current system mode
const byte REG_INT_SOURCE = 0x0c; //(R) Interrupt status
const byte REG_WHO_AM_I = 0x0d; //(R) Device ID (0x3A)
const byte REG_XYZ_DATA_CFG = 0xe; //(R/W) Dynamic range settings
const byte REG_HP_FILTER_CUTOFF = 0x0f; //(R/W) cut-off frequency is set to 16Hz @ 800Hz
const byte REG_PL_STATUS = 0x10; //(R) Landscape/Portrait orientation status
const byte REG_PL_CFG = 0x11; //(R/W) Landscape/Portrait configuration
const byte REG_PL_COUNT = 0x12; //(R) Landscape/Portrait debounce counter
const byte REG_PL_BF_ZCOMP = 0x13; //(R) Back-Front, Z-Lock trip threshold
const byte REG_P_L_THS_REG = 0x14; //(R/W) Portrait to Landscape trip angle is 29 degree
const byte REG_FF_MT_CFG = 0x15; //(R/W) Freefall/motion functional block configuration
const byte REG_FF_MT_SRC = 0x16; //(R) Freefall/motion event source register
const byte REG_FF_MT_THS = 0x17; //(R/W) Freefall/motion threshold register
const byte REG_FF_MT_COUNT = 0x18; //(R/W) Freefall/motion debounce counter
const byte REG_TRANSIENT_CFG = 0x1d; //(R/W) Transient functional block configuration
const byte REG_TRANSIENT_SRC = 0x1e; //(R) Transient event status register
const byte REG_TRANSIENT_THS = 0x1f; //(R/W) Transient event threshold
const byte REG_TRANSIENT_COUNT = 0x20; //(R/W) Transient debounce counter
const byte REG_PULSE_CFG = 0x21; //(R/W) ELE, Double_XYZ or Single_XYZ
const byte REG_PULSE_SRC = 0x22; //(R) EA, Double_XYZ or Single_XYZ
const byte REG_PULSE_THSX = 0x23; //(R/W) X pulse threshold
const byte REG_PULSE_THSY = 0x24; //(R/W) Y pulse threshold
const byte REG_PULSE_THSZ = 0x25; //(R/W) Z pulse threshold
const byte REG_PULSE_TMLT = 0x26; //(R/W) Time limit for pulse
const byte REG_PULSE_LTCY = 0x27; //(R/W) Latency time for 2nd pulse
const byte REG_PULSE_WIND = 0x28; //(R/W) Window time for 2nd pulse
const byte REG_ASLP_COUNT = 0x29; //(R/W) Counter setting for auto-sleep
const byte REG_CTRL_REG1 = 0x2a; //(R/W) ODR = 800 Hz, STANDBY mode
const byte REG_CTRL_REG2 = 0x2b; //(R/W) Sleep enable, OS Modes, RST, ST
const byte REG_CTRL_REG3 = 0x2c; //(R/W) Wake from sleep, IPOL, PP_OD
const byte REG_CTRL_REG4 = 0x2d; //(R/W) Interrupt enable register
const byte REG_CTRL_REG5 = 0x2e; //(R/W) Interrupt pin (INT1/INT2) map
const byte REG_OFF_X = 0x2f; //(R/W) X-axis offset adjust
const byte REG_OFF_Y = 0x30; //(R/W) Y-axis offset adjust
const byte REG_OFF_Z = 0x31; //(R/W) Z-axis offset adjust

const byte FULL_SCALE_RANGE_2g = 0x0;
const byte FULL_SCALE_RANGE_4g = 0x1;
const byte FULL_SCALE_RANGE_8g = 0x2;

const byte I2C_ADDR = 0x1c; //SA0=0

/*
  Read register content into buffer.
  The default count is 1 byte. 

  The buffer needs to be pre-allocated
  if count &gt; 1
*/
void regRead(byte reg, byte *buf, byte count = 1)
{
  I2c.write(I2C_ADDR, reg);
  I2c.read(I2C_ADDR, reg, count);

  for (int i = 0; i &lt; count; i++)
    *(buf+i) = I2c.receive();
}

/*
  Write a byte value into a register
*/
void regWrite(byte reg, byte val)
{
  I2c.write(I2C_ADDR, reg, val);
}

/*
  Put MMA8453Q into standby mode
*/
void standbyMode()
{
  byte reg;
  byte activeMask = 0x01;

  regRead(REG_CTRL_REG1, &amp;reg);
  regWrite(REG_CTRL_REG1, reg &amp; ~activeMask);
}

/*
  Put MMA8453Q into active mode
*/
void activeMode()
{
  byte reg;
  byte activeMask = 0x01;

  regRead(REG_CTRL_REG1, &amp;reg);
  regWrite(REG_CTRL_REG1, reg | activeMask);
}

/*
  Use fast mode (low resolution mode)
  The acceleration readings will be
  limited to 8 bits in this mode.
*/
void lowResMode()
{
  byte reg;
  byte fastModeMask = 0x02;

  regRead(REG_CTRL_REG1, &amp;reg);
  regWrite(REG_CTRL_REG1, reg | fastModeMask);
}

/*
  Use default mode (high resolution mode)
  The acceleration readings will be
  10 bits in this mode.
*/
void hiResMode()
{
  byte reg;
  byte fastModeMask = 0x02;

  regRead(REG_CTRL_REG1, &amp;reg);
  regWrite(REG_CTRL_REG1,  reg &amp; ~fastModeMask);
}

/*
  Get accelerometer readings (x, y, z)
  by default, standard 10 bits mode is used.

  This function also convers 2's complement number to
  signed integer result.

  If accelerometer is initialized to use low res mode,
  isHighRes must be passed in as false.
*/
void getAccXYZ(int *x, int *y, int *z, bool isHighRes=true)
{
  byte buf[6];

  if (isHighRes) {
    regRead(REG_OUT_X_MSB, buf, 6);
    *x = buf[0] &lt;&lt; 2 | buf[1] &gt;&gt; 6 &amp; 0x3;
    *y = buf[2] &lt;&lt; 2 | buf[3] &gt;&gt; 6 &amp; 0x3;
    *z = buf[4] &lt;&lt; 2 | buf[5] &gt;&gt; 6 &amp; 0x3;
  }
  else {
    regRead(REG_OUT_X_MSB, buf, 3);
    *x = buf[0] &lt;&lt; 2;
    *y = buf[1] &lt;&lt; 2;
    *z = buf[2] &lt;&lt; 2;
  }

  if (*x &gt; 511) *x = *x - 1024;
  if (*y &gt; 511) *y = *y - 1024 ;
  if (*z &gt; 511) *z = *z - 1024;
}

void setup()
{
  I2c.begin();
  Serial.begin(9600);

  standbyMode(); //register settings must be made in standby mode
  regWrite(REG_XYZ_DATA_CFG, FULL_SCALE_RANGE_2g);
  hiResMode(); //this is the default setting and can be omitted.
  //lowResMode(); //set to low res (fast mode), must use getAccXYZ(,,,false) to retrieve readings.
  activeMode(); 

  byte b;
  regRead(REG_WHO_AM_I, &amp;b);
  Serial.println(b,HEX);
}

void loop()
{
  int x = 0, y = 0, z = 0;

  getAccXYZ(&amp;x, &amp;y, &amp;z); //get accelerometer readings in normal mode (hi res).
  //getAccXYZ(&amp;x, &amp;y, &amp;z, false); //get accelerometer readings in fast mode (low res).
  Serial.print(x);
  Serial.print(&quot; &quot;);
  Serial.print(y);
  Serial.print(&quot; &quot;);
  Serial.print(z);
  Serial.println();

  delay(500);
}
</pre>
<p>With some modification to the getAccXYZ function, similar code can be used with <a href="http://cache.freescale.com/files/sensors/doc/data_sheet/MMA8450Q.pdf">MMA8450Q</a>, <a href="http://cache.freescale.com/files/sensors/doc/data_sheet/MMA8451Q.pdf">MMA8451Q</a> and <a href="http://cache.freescale.com/files/sensors/doc/data_sheet/MMA8452Q.pdf">MMA8452Q</a> as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kerrywong.com/2012/01/09/interfacing-mma8453q-with-arduino/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Insane Packaging</title>
		<link>http://www.kerrywong.com/2012/01/04/insane-packaging/</link>
		<comments>http://www.kerrywong.com/2012/01/04/insane-packaging/#comments</comments>
		<pubDate>Thu, 05 Jan 2012 00:19:19 +0000</pubDate>
		<dc:creator>kwong</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[AVnet]]></category>

		<guid isPermaLink="false">http://www.kerrywong.com/?p=5220</guid>
		<description><![CDATA[AVnet has so far been my most favorite parts supplier and I have used it quite a few times. Not only do they offer a rather comprehensive catalog, their prices are quite competitive as well and their shipping and handling practices are excellent &#8212; sometimes to the extreme. Here are a few photos to prove. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://avnetexpress.avnet.com/">AVnet</a> has so far been my most favorite parts supplier and I have used it quite a few times. Not only do they offer a rather comprehensive catalog, their prices are quite competitive as well and their shipping and handling practices are excellent &#8212; sometimes to the extreme.<span id="more-5220"></span></p>
<p>Here are a few photos to prove. I ordered a few components a couple of weeks ago, and included in my order were two <a href="http://www.freescale.com/files/sensors/doc/data_sheet/MMA8453Q.pdf">MMA8453Q</a> accelerometers.</p>
<p>When I received my order, I found a rather large package inside (the AA battery is shown here to contrast the size of the packaging):<br />
<div id="attachment_5221" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2012/01/packaging1.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2012/01/packaging1-300x225.jpg" alt="Packaging 1" title="Packaging 1" width="300" height="225" class="size-medium wp-image-5221" /></a><p class="wp-caption-text">Packaging 1</p></div></p>
<p>Inside the ESD safe bag is a full QFN tray with moisture absorbing packets and a humidity indicator card wrapped in another layer of protective wrapping. </p>
<p>After opening the QFN tray&#8230; there are the two accelerometers!<br />
<div id="attachment_5222" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2012/01/packaging2.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2012/01/packaging2-300x225.jpg" alt="Packaging 2" title="Packaging 2" width="300" height="225" class="size-medium wp-image-5222" /></a><p class="wp-caption-text">Packaging 2</p></div></p>
<div id="attachment_5223" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2012/01/packaging3.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2012/01/packaging3-300x225.jpg" alt="Packaging 3" title="Packaging 3" width="300" height="225" class="size-medium wp-image-5223" /></a><p class="wp-caption-text">Packaging 3</p></div>
<p>Unbelievable packaging!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kerrywong.com/2012/01/04/insane-packaging/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple Fume Extractor Using Server Blower Fans</title>
		<link>http://www.kerrywong.com/2012/01/01/simple-fume-extractor-using-server-blower-fans/</link>
		<comments>http://www.kerrywong.com/2012/01/01/simple-fume-extractor-using-server-blower-fans/#comments</comments>
		<pubDate>Mon, 02 Jan 2012 00:57:05 +0000</pubDate>
		<dc:creator>kwong</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[Blower Fan]]></category>
		<category><![CDATA[Fume Extractor]]></category>

		<guid isPermaLink="false">http://www.kerrywong.com/?p=5208</guid>
		<description><![CDATA[Breathing in fumes while soldering is not good for your health, so it is recommended that you have a fume extractor in your workshop. A typical fume extractor sucks in air and passes the fumes through layers of active carbon. While effective, it is probably an overkill unless you spend most of your day in [...]]]></description>
			<content:encoded><![CDATA[<p>Breathing in fumes while soldering is not good for your health, so it is recommended that you have a fume extractor in your workshop. A typical fume extractor sucks in air and passes the fumes through layers of active carbon. While effective, it is probably an overkill unless you spend most of your day in your workshop.<span id="more-5208"></span></p>
<p>I have seen some people using small fans to blow air across the work area. This works pretty well as long as you don&#8217;t deal with the <a href="http://en.wikipedia.org/wiki/Surface-mount_technology">SMD</a> stuff. Those small SMD components can be blown away very easily. So my preferred method is still sucking air out of the work area.</p>
<p>So I experimented with a few different methods and found that using server blower fans achieved the best results.</p>
<p>The following is my version of the fume extractor using two 10cm 24V server blower fans.  </p>
<div id="attachment_5209" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2012/01/fumeextractor1.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2012/01/fumeextractor1-300x225.jpg" alt="Fume Extractor" title="Fume Extractor" width="300" height="225" class="size-medium wp-image-5209" /></a><p class="wp-caption-text">Fume Extractor</p></div>
<div id="attachment_5210" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2012/01/fumeextractor2.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2012/01/fumeextractor2-300x225.jpg" alt="Fume Extractor" title="Fume Extractor" width="300" height="225" class="size-medium wp-image-5210" /></a><p class="wp-caption-text">Fume Extractor</p></div>
<p>When powered at the rated voltage (24V), the created suction is effective at least within 2 to 3 feet. This should cover enough area for your soldering work.</p>
<p>A draw back is that this kind of blower fans are very noisy. But they can be operated at lower voltage to reduce the noise (and thus the air flow). You can easily control the air flow with a TRIAC dimmer circuit or using a variable power supply for the blowers.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kerrywong.com/2012/01/01/simple-fume-extractor-using-server-blower-fans/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Makefile for Arduino 1.0</title>
		<link>http://www.kerrywong.com/2011/12/17/makefile-for-arduino-1-0/</link>
		<comments>http://www.kerrywong.com/2011/12/17/makefile-for-arduino-1-0/#comments</comments>
		<pubDate>Sat, 17 Dec 2011 18:13:42 +0000</pubDate>
		<dc:creator>kwong</dc:creator>
				<category><![CDATA[AVR/Arduino]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Makefile]]></category>
		<category><![CDATA[NetBeans]]></category>

		<guid isPermaLink="false">http://www.kerrywong.com/?p=5164</guid>
		<description><![CDATA[A while back, I created an Arduino plugin for NetBeans so that I could use the full-fledged NetBeans IDE for all my Arduino projects. The approach I took was using the NetBeans project sample module method. Under the hood though, it is nothing more than a makefile and an source file template. Since the release [...]]]></description>
			<content:encoded><![CDATA[<p>A while back, I created <a href="http://www.kerrywong.com/2010/05/16/arduino-development-using-netbeans/">an Arduino plugin</a> for <a href="http://netbeans.org/">NetBeans</a> so that I could use the full-fledged NetBeans IDE for all my Arduino projects. The approach I took was using the <a href="http://platform.netbeans.org/tutorials/nbm-projectsamples.html">NetBeans project sample module</a> method. Under the hood though, it is nothing more than a makefile and an source file template.<span id="more-5164"></span></p>
<p>Since the release of Arduino 1.0 a few weeks ago, I have received quite a few inquiries on how to make the plugin work with the new Arduino 1.0. The short answer is you will have to pretty much follow <a href="http://www.kerrywong.com/2010/05/16/arduino-development-using-netbeans/">the steps I mentioned</a> to re-create a project sample module with the up-to-date makefile.</p>
<p>Unfortunately, the original makefile (modified from the one by <a href="http://dam.mhas been changed ellis.org/">Mellis</a> et al. for Arduino 018) is no longer compatible with the latest 1.0 environment due to the many breaking changes introduced in this new Arduino IDE release. </p>
<p>Anyway, I just updated the makefile to make it work with Arduino 1.0, and you can download it towards the end. The new makefile was tested under Ubuntu 10.04 64bit Linux environment. You will most likely need to make some changes to the makefile for it to work under Windows.</p>
<p>Depending on the installation locations and whether additional libraries are used, you may also need to change the following sections in the makefile:</p>
<pre class="brush: bash; title: ; notranslate">
INSTALL_DIR = $(HOME)/arduino-1.0
...
#add your specific c modules at the end
C_MODULES = \
...
#add your specific c++ modules at the end
CXX_MODULES = \
</pre>
<p>Here are a few additional changes: the main code file name is changed from main.pde to main.cpp in the project. The original makefile assembles the main.cpp file behind the scene, in the event there is an compilation error the error shown is from the assembled file not main.pde. This behavior could cause some confusion. In this updated makefile, the compilation is done directly against the code file you are working on so it should be slightly more convenient to use. Also, the include directives are consolidated thanks to the latest Arduino IDE changes. If you are using chips other than ATmega328 though, you will need to change the $VARIANTS variable setting to include the correct pins_arduino.h header file:</p>
<pre class="brush: bash; title: ; notranslate">
VARIANTS = $(INSTALL_DIR)/hardware/arduino/variants/standard
</pre>
<p>Using this makefile, you should be able to configure your favorite IDE (NetBeans, Eclipse, CodeBlocks, KDevelop, etc.) to work with Arduino projects.</p>
<p>You can also download the compiled NetBeans module from below. Just keep in mind that given the nature of this project type, the makefile is static which means you will have to add your own C_MODULES/CXX_MODULES in the makefile if you are using libraries other than those come as default.</p>
<p>The following build targets are available:</p>
<blockquote><p>
all, build, clean, upload
</p></blockquote>
<h3>Downloads</h3>
<p><a href='http://www.kerrywong.com/blog/wp-content/uploads/2011/12/makefile.tar.gz'>Makefile</a> (for Arduino 1.0, tested under Linux)<br />
<a href='http://www.kerrywong.com/blog/wp-content/uploads/2011/12/NetbeansPluginArduino1.0.tar.gz'>NetBeans Plugin for Arduino 1.0</a> (tested under NetBeans 7.0.1)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kerrywong.com/2011/12/17/makefile-for-arduino-1-0/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>X-TRONIC 4040 Hot Air Rework/Soldering Station &#8211; II</title>
		<link>http://www.kerrywong.com/2011/12/07/x-tronic-4040-hot-air-reworksoldering-station-ii/</link>
		<comments>http://www.kerrywong.com/2011/12/07/x-tronic-4040-hot-air-reworksoldering-station-ii/#comments</comments>
		<pubDate>Thu, 08 Dec 2011 00:40:14 +0000</pubDate>
		<dc:creator>kwong</dc:creator>
				<category><![CDATA[Product Reviews]]></category>
		<category><![CDATA[Hot air rework station]]></category>
		<category><![CDATA[Review]]></category>
		<category><![CDATA[X-TRONIC]]></category>
		<category><![CDATA[XTRONIC]]></category>

		<guid isPermaLink="false">http://www.kerrywong.com/?p=5072</guid>
		<description><![CDATA[Last time I did a pretty thorough review of the X-TRONIC 4040 hot air rework/soldering station and shared my own experience with it. Overall, it is a very good entry level rework station. I have been using it intensely for the last week or so and it is holding up extremely well. Now let us [...]]]></description>
			<content:encoded><![CDATA[<p>Last time I did a pretty thorough review of the X-TRONIC 4040 hot air rework/soldering station and shared my own experience with it. Overall, it is a very good entry level rework station. I have been using it intensely for the last week or so and it is holding up extremely well. Now let us take look at what is inside.<span id="more-5072"></span></p>
<p>There is a seal on the back of the unit saying (in Chinese) that warranty would be voided if the seal is broken. But since the seal is just a thin piece of paper, I suspect that it may even break from the unit just being moved around during shipping and handling. In any event, taking the cover off is as simple as just removing eight screws, four on each side. There is not any mechanism to lock the cover in place so putting the cover back requires a little more effort since you have to match the screw holes exactly. </p>
<table width="100%">
<tr>
<td width="50%">
<div id="attachment_5012" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/internal.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/internal-300x225.jpg" alt="Internal layout" title="Internal layout" width="300" height="225" class="size-medium wp-image-5012" /></a><p class="wp-caption-text">Internal layout</p></div>
</td>
<td width="50%">
<div id="attachment_5009" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/diaphragmpump.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/diaphragmpump-300x225.jpg" alt="Diaphragm pump on rubber damper" title="Diaphragm pump on rubber damper" width="300" height="225" class="size-medium wp-image-5009" /></a><p class="wp-caption-text">Diaphragm pump on rubber damper</p></div>
</td>
</tr>
</table>
<p>The first thing I noticed inside once I opened up the case is the Gordak brand marked on the pneumatic pump. Remember I wrote last time that I suspected that the unit was made by Gordak and was simply just re-branded as X-TRONIC? I even more positive this is the case now after seeing this. And if you look at the sticker on top of the transformer, you will also see &#8220;GD-952&#8243; printed on it. Presumably, this X-TRONIC 4040 is just a re-branded Gordak 952 model. In fact, I suspect that all those 952 hot air rework stations (e.g. KADA) are more or less originated from the same design and manufacturer.</p>
<p>As you can see from the pictures above, the internal layout is fairly clean, and all wires are routed neatly. The pneumatic pump is mounted on top of a soft rubber frame to reduce the pump noise and vibration during operation. Also, the case is grounded at two places. </p>
<p>The pump itself is further secured by a few cable ties, and this is again a very typical assembling technique for devices at this price range. </p>
<p>The following YouTube video should give you an idea of what kind of environment this rework station might have been built in. Even though this video is for a different model (KADA 852D+), the actual construction should be more or less the same.</p>
<p><iframe width="320" height="217" src="http://www.youtube.com/embed/quGs3q9nsA8" frameborder="1" allowfullscreen></iframe></p>
<p>Now let us move onto the circuit board. Clearly, in order to reduce assembly cost, all the components used here are through-hole components and are all manually soldered. The PCB is single sided and its quality looks just so so, and the board does not seem to have any solder mask on the trace side. </p>
<p>Ideally, for this kind of circuit board we should really be using double-sided PCBs as there are components mounted on the other side of the board as well. But clearly, to keep the total manufacturing cost down every penny counts.</p>
<p>The two 20-pin ICs are presumably MCUs used to control the hot air, the soldering iron and to drive the two 7-segment displays. The circuitry around the two MCUs are virtually identical so clearly one chip is used for the hot air and the other one is used for the soldering iron. The manufacturer had sanded off the chip markings on the MCUs deliberately to make it harder for other competitors to copy the design.</p>
<table width="100%">
<tr>
<td width="50%">
<div id="attachment_5011" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/mainboard1.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/mainboard1-300x225.jpg" alt="Main circuit board" title="Main circuit board" width="300" height="225" class="size-medium wp-image-5011" /></a><p class="wp-caption-text">Main circuit board</p></div>
</td>
<td width="50%">
<div id="attachment_5010" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/mainboard2.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/mainboard2-300x225.jpg" alt="Main circuit board" title="Main circuit board" width="300" height="225" class="size-medium wp-image-5010" /></a><p class="wp-caption-text">Main circuit board</p></div>
</td>
</tr>
</table>
<p>There are three TRIACs (two <a href="http://www.datasheetcatalog.org/datasheet/philips/BT136_SERIES_E_2.pdf">BT136</a> and one <a href="http://www.datasheetcatalog.org/datasheet/stmicroelectronics/7472.pdf">BTA08-600C</a>) used in the design, I assume that one is used for adjusting the pump speed and the other two are used for adjusting the hot air heater and the soldering temperature.</p>
<p>There are two random phase opt-isolators (<a href="http://pdf1.alldatasheet.com/datasheet-pdf/view/27238/TI/MOC3023/+Q5349UPGZLOEB9tY+/datasheet.pdf">MOC3023</a>) used in conjunction with the two TRIACs to control the heating elements in the hot air wand and the soldering iron. Since the pump itself has no physical contact with anything else, its control circuitry does not have to be isolated. The hot air wand and especially the soldering iron has to be isolated since they come into contact with the components being worked on. The op-amps used for the temperature sensors are <a href="http://www.datasheetcatalog.org/datasheet/HitachiSemiconductor/mXqyszx.pdf">HA17358</a> dual operational amplifiers.</p>
<div id="attachment_5006" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/triacs.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/triacs-300x225.jpg" alt="TRIACs" title="TRIACs" width="300" height="225" class="size-medium wp-image-5006" /></a><p class="wp-caption-text">TRIACs</p></div>
<p>The soldering job quality is really just mediocre , which is more or less expected results from this kind of hand-soldering assembly line. As you can see that the components are not aesthetically aligned, and leads on some of the components soldered on the copper side of the PCB are not all properly trimmed. Look at the LED indicator in the picture below, did they simply just forget to trim the leads after soldering?</p>
<table width="100%">
<tr>
<td width="50%">
<div id="attachment_5008" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/solderingjob.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/solderingjob-300x225.jpg" alt="Soldering job" title="Soldering job" width="300" height="225" class="size-medium wp-image-5008" /></a><p class="wp-caption-text">Soldering job</p></div>
</td>
<td width="50%">
<div id="attachment_5007" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/solderingjob2.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/solderingjob2-300x225.jpg" alt="Soldering job" title="Soldering job" width="300" height="225" class="size-medium wp-image-5007" /></a><p class="wp-caption-text">Soldering job</p></div>
</td>
</tr>
</table>
<p>Also, there seems to be an improperly mounted <a href="http://en.wikipedia.org/wiki/TO-220">TO-220</a> device (see picture to the right), it could be a transistor or a voltage regulator. But in general, TO-220 devices should be mounted on heatsinks which are then secured onto the PCB. But I guess this probably is not a big deal as the rework station is designed for stationary use only. But even so, the vibration from the pneumatic air pump could cause some stress on those soldering points.</p>
<h3>Conclusions</h3>
<p>Even though my review here for the internal construction is not all that rosy, considering the price of this rework station and its excellent performance I mentioned last time, it remains a good choice for engineers and hobbyist alike.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kerrywong.com/2011/12/07/x-tronic-4040-hot-air-reworksoldering-station-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>X-TRONIC 4040 Hot Air Rework/Soldering Station &#8211; I</title>
		<link>http://www.kerrywong.com/2011/12/05/x-tronic-4040-hot-air-reworksoldering-station/</link>
		<comments>http://www.kerrywong.com/2011/12/05/x-tronic-4040-hot-air-reworksoldering-station/#comments</comments>
		<pubDate>Tue, 06 Dec 2011 01:52:50 +0000</pubDate>
		<dc:creator>kwong</dc:creator>
				<category><![CDATA[Product Reviews]]></category>
		<category><![CDATA[Hot air rework station]]></category>
		<category><![CDATA[Review]]></category>
		<category><![CDATA[X-TRONIC]]></category>
		<category><![CDATA[XTRONIC]]></category>

		<guid isPermaLink="false">http://www.kerrywong.com/?p=4991</guid>
		<description><![CDATA[I have used quite a few professional SMD rework stations before, but those professional grade ones tend to be quite pricey. So when I decided to get a hot air rework station for my own personal use, I settled on the cheaply priced X-TRONIC 4040 hot air rework/soldering station combo. In this blog post, I [...]]]></description>
			<content:encoded><![CDATA[<p>I have used quite a few professional SMD rework stations before, but those professional grade ones tend to be quite pricey. So when I decided to get a hot air rework station for my own personal use, I settled on the cheaply priced X-TRONIC 4040 hot air rework/soldering station combo. In this blog post, I will do a detailed review of this rework station and walk you through some of my observations. In the next time I will do a review of its internal construction.<span id="more-4991"></span></p>
<p>For those who are impatient, you can find my review conclusions in the summary section towards the end. </p>
<p>Depending on where you got your unit, this rework station can be had for just above 100 US dollars. For this price range, it is clearly targeted at electronics enthusiasts and hobbyists. </p>
<p>In order to achieve this low price point, there are some design compromises the designers had to make. For instance, the unit does not have an air flow meter, so the speed of the air flow cannot be adjusted precisely and can only be gauged by experience. This should not be an issue for general uses however, as most of the SMD soldering work does not need that level of precision in a non-professional setting. Also, the hot air wand does not turn off automatically when it is in the holder which some might consider it a fire risk. Other slightly more expensive brands typically have magnetic sensors built in and would automatically turn off the heating element once the hot air wand is placed back onto the holder, allowing the unit to properly cool off. In my opinion though, the omission of this feature is actually more convenient as having to wait for the hot air wand to achieve its operation temperature every time can be quite annoying. </p>
<p>It seems that there are two models (X-TRONIC 4040 and X-TRONIC 4000) on the market that are very similar to one another. I am actually not quite sure whether there is any difference between model X-TRONIC 4040 and X-TRONIC 4000.  As far as I can tell, the only difference seems to be that the 4040 model includes a lighted magnifier lamp and the 4000 model does not. But the main units themselves seem to be identical, both have &#8220;X-TRONIC 4000 Series&#8221; printed on them (see picture below).</p>
<div id="attachment_4999" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/hotairironoff.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/hotairironoff-300x225.jpg" alt="Hot air and iron both off" title="Hot air and iron both off" width="300" height="225" class="size-medium wp-image-4999" /></a><p class="wp-caption-text">Hot air and iron both off</p></div>
<p>My unit came with the lighted magnifier lamp. At first I was a little skeptical as the lamp feels pretty cheap and the base is lighter than adequate which means that it can tip over easily if the lamp is leaning too much in one direction. But after I started using it for a while, I found that the magnifier actually worked surprisingly well, presumably due to its large size. Those tiny markings on the SMDs can be easily identified without too much eye strain. It is especially pleasant to use when compared to my small eye loupe I used before. The included fluorescent ring lamp is not particularly bright however and is not useful as a bench light, but it is bright enough for what it does. Finding the replacement bulb could be difficult however, I have not seen any ring shaped fluorescent bulbs of the exact size. But I am not too worried, as the ring lamp can be easily adapted to using LEDs lighting should it break.</p>
<div id="attachment_5046" class="wp-caption aligncenter" style="width: 235px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/magnifierlamp.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/magnifierlamp-225x300.jpg" alt="Lighted magnifier lamp" title="Lighted magnifier lamp" width="225" height="300" class="size-medium wp-image-5046" /></a><p class="wp-caption-text">Lighted magnifier lamp</p></div>
<p>The tubing for the hot air wand comes already attached to the main unit. There are three screws at the bottom of the unit which are used to secure the pneumatic pump during shipping and must be removed prior to turning on for the first time. The only parts that need to be attached are the soldering iron and the holder for the hot air wand. The soldering iron has a keyed 5-pin female plug that plugs firmly into socket on the main unit. The ring outside the plug is threaded and secures tightly onto the socket. </p>
<div id="attachment_5000" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/ironconnector.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/ironconnector-300x225.jpg" alt="Iron connector" title="Iron connector" width="300" height="225" class="size-medium wp-image-5000" /></a><p class="wp-caption-text">Iron connector</p></div>
<p>The metal holder for the hot air wand can be mounted on either side of the unit which is clearly a nice design consideration. But as you can see in the picture below, one of the screws is in the way of the holder when the holder is mounted regardless of which side the holder is on. The protrusion of the screw makes the holder surface not resting flush against the side.  But it really is just a minor annoyance than any real problem. The main unit itself has three mounting holes on each side of the case but only two are needed for the holder included. It is quite possible that the case was designed for multiple brands and different types of holders can be mounted.</p>
<p>The unit comes with four hot air nozzles with the following nozzle sizes: 9.5mm, 6.5mm, 4.5mm and 2.5mm. These sizes should cover a good range of rework tasks. The quality of these nozzles is not all that great though, a couple of the nozzles I received showed sign of rusting inside. But for the price I paid, I really cannot complain too much here. These cosmetic defects are not likely to affect the soldering job nor would they affect the durability of the nozzle anyway.</p>
<table width="100%">
<tr>
<td width="50%">
<div id="attachment_4992" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/hotairwandholder.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/hotairwandholder-300x225.jpg" alt="Hot air wand holder" title="Hot air wand holder" width="300" height="225" class="size-medium wp-image-4992" /></a><p class="wp-caption-text">Hot air wand holder</p></div>
</td>
<td width="50%">
<div id="attachment_4993" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/hotairnozzle.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/hotairnozzle-300x225.jpg" alt="Hot air nozzle" title="Hot air nozzle" width="300" height="225" class="size-medium wp-image-4993" /></a><p class="wp-caption-text">Hot air nozzle</p></div>
</td>
</tr>
</table>
<p>The soldering iron that comes with the X-TRONIC 4040 (or X-TRONIC 4000) is smaller and lighter than a typical 30W soldering iron (see comparison in the picture below), but it grips nicely and holds comfortably in hand. The connection cable is soft and flexible making it less obtrusive when soldering. There are ten assorted soldering tips included in the package: 4 conical tips (<a href="http://www.hakko.com/english/tip_selection/series_t12.html">Hakko</a> shape code I, 0.25mm to 1mm); 4 slanted-cut tips (Hakko shape code BC/C, 1mm to 4mm), 1 screw driver tip (Hakko shape code D, 2mm x 1mm) and 1 knife tip (Hakko shape code K, 7mm x 0.5mm). I am actually not sure whether the Hakko ones would fit properly and the model numbers are included just for reference purposes.</p>
<p>All the tips are coated and presumably offer a longer service life. But from the picture below you can see that the coating is only applied to the very tip of the ironing tip and overall the tip&#8217;s quality does not look as good as other soldering tips that I have used before. While I did not encounter any issues during the past couple of days&#8217; intense use and there is no signs of any premature wear and tear, these tips&#8217; long term performance remains to be seen. But again, there is something to be said about quantity versus quality. Given the number of tips included, you can basically try out a few different ones and settle on the tip you like the best. Should that one wear out you can always buy a higher quality replacement tip of the exact kind.</p>
<p>If you look carefully, you can see the marking on the tips reads &#8220;Gordak&#8221;. I assume that these tips are sourced from <a href="http://jalyou.en.ec21.com/">Gordak Electric Factory</a>. And if you followed the link, you will see that Gordak is specialized in manufacturing SMD rework soldering stations. Browsing through a few of its products, I found that the X-TRONIC 4040 looks strikingly similar to <a href="http://jalyou.en.ec21.com/Single_Digital_Soldering_Station_952B--1880998_2054461.html">Gordak&#8217;s 952B</a> except perhaps that 4040 has a digital temperature readout for the soldering iron but the 952B has  only a temperature labeled dial and a LED indicator for the iron to reduce cost. But if you look at the side panel, there are three mounting holes for the holder, which is exactly the same as the X-TRONIC 4040 I have.</p>
<p>I would not be surprised if X-TRONIC 4040/4000 are actually manufactured by Gordak after all, and they are simply just re-branded as X-TRONIC. This practice is very common in these low-end electronic products. In fact the X-TRONIC 4040 rework station was shipped in generic white boxes with no manual or any manufacturer information &#8211; another tell sign of these re-branded cheap Chinese products.</p>
<table width="100%">
<tr>
<td width="50%">
<div id="attachment_4998" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/ironsize.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/ironsize-300x225.jpg" alt="Iron size" title="Iron size" width="300" height="225" class="size-medium wp-image-4998" /></a><p class="wp-caption-text">Iron size</p></div>
</td>
<td width="50%">
<div id="attachment_4997" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/irontip.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/irontip-300x225.jpg" alt="Iron tip" title="Iron tip" width="300" height="225" class="size-medium wp-image-4997" /></a><p class="wp-caption-text">Iron tip</p></div>
</td>
</tr>
</table>
<p>The hot air wand and the soldering iron can be operated independently (see pictures below). The larger switch and the two knobs to the right control the hot air wand while the smaller switch and the knob towards the bottom middle control the soldering iron. It is clear that the designer had put more emphasis on the hot air portion than the soldering portion as there are two additional LED indicators for the hot air wand control but only a 7-segment display for the soldering iron. </p>
<p>The upper LED indicator seems to be on whenever the hot air wand is turned on and the bottom LED indicates whether the hot air heater is on or not. When the hot air wand reaches the preset temperature, the heater would switch between on and off every few seconds to maintain a steady temperature and you can see this from the flashing of the bottom LED indicator. </p>
<p>It is quite intriguing to me as to why the upper LED was included in the design, as it serves no apparent purpose other then telling you that the hot air unit is on. But you can already tell this via the 7-segment temperature display. So maybe the basic design of this hot air rework station is shared with ones that do not offer the 7-segment display, in which case the LED would be used to indicate whether the hot air unit is on.</p>
<table width="100%">
<tr>
<td width="50%">
<div id="attachment_5003" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/hotaironly2.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/hotaironly2-300x225.jpg" alt="Hot air only  (hot air heater on)" title="Hot air only  (hot air heater on)" width="300" height="225" class="size-medium wp-image-5003" /></a><p class="wp-caption-text">Hot air only  (hot air heater on)</p></div>
</td>
<td width="50%">
<div id="attachment_5004" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/hotaironly1.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/hotaironly1-300x225.jpg" alt="Hot air only  (hot air heater off)" title="Hot air only  (hot air heater off)" width="300" height="225" class="size-medium wp-image-5004" /></a><p class="wp-caption-text">Hot air only  (hot air heater off)</p></div>
</td>
</tr>
<tr>
<td width="50%">
<div id="attachment_5001" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/irononly.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/irononly-300x225.jpg" alt="Soldering iron on only" title="Soldering iron on only" width="300" height="225" class="size-medium wp-image-5001" /></a><p class="wp-caption-text">Soldering iron on only</p></div>
</td>
<td width="50%">
<div id="attachment_5002" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/ironandhotairbothon.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/12/ironandhotairbothon-300x225.jpg" alt="Both soldering iron and hot air on" title="Both soldering iron and hot air on" width="300" height="225" class="size-medium wp-image-5002" /></a><p class="wp-caption-text">Both soldering iron and hot air on</p></div>
</td>
</tr>
</table>
<p>From the pictures above, you can see that the temperature display is in Celsius. Unfortunately, there is no way to change this display setting to Fahrenheit. While I personally do not really care what the temperature unit is in as I could convert them back and forth easily, it is a little disappointing to see that a product sold in North America does not offer Fahrenheit reading as an option.</p>
<p>The hot air wand takes some time to reach the preset temperature. From power up, it takes roughly 45 seconds to reach 350 C (662 F) and it takes an additional 15 seconds if you want to go up to 375 C (707 F). According to the data sheet, the hot air temperature can be adjusted between 150 to 500 Celsius (302 to 932 Fahrenheit) and the air flow can be adjusted from 0.3 to 24 liters per minute. These specifications are quite typical among these entry level rework stations. </p>
<p>The heater for the hot air is specified at 250W, which seems to be a bit under powered (most rework stations in this price range have heaters power rated north of 500W). To be sure, I measured the power consumption of the unit with just the hot air on and the reading came at around 266 W which means that the heater specification is more or less accurate. So maybe by including a beefier heating element the heat up time will be shorter. </p>
<p>But the hot air feels adequate once it reaches operating temperature and I had no trouble de-soldering large components such as a 256 pin TQFP chip and a large BGA chip. While I could not measure the actual air flow volume, it seems that the hot air comes out quite strong when the air flow dial is set to the maximum.</p>
<p>The soldering iron is rated at 60W, but it measures only at about 45W when in use. So the number in the specification is clearly overstated. But even at 45W there is sufficient power for most soldering job. Unlike the hot air wand, the soldering iron heats up very quickly and within 20 seconds after powering on it is ready for use.</p>
<p>When the unit is turned off, it does not power off immediately if the hot air wand was used. Instead, the pneumatic pump will continue to operate until the nozzle temperature drops below 50 degree Celsius (122 F) as a safety measure. One thing to note is that the air flow speed during this cool off period is set according to the dial setting, which means if you accidentally turned down the airflow after shutting down the unit the nozzle temperature would go down very slowly due to the weak air flow. In my opinion during this cool off period the airflow should be automatically increased to the maximum so that the heating element can cool down quickly. </p>
<p>As I mentioned before, there is no auto power-off feature for the hot air wand, this means that the hot air will continue to blow at the set temperature and speed even when the wand is placed back in the holder. This could potentially be a safety issue given the high temperature at the nozzle outlet. But as long as your rework station has enough clearance from everything else, it really poses very little risk as the temperature drops quickly when you move away from the nozzle. </p>
<p>This unit also has no central shut-off switch (i.e. hard-wired on/off switch) since it has to provide power to the pneumatic air pump after the hot air unit is switched off. The standby power consumption is at a reasonable 3W. </p>
<p>One thing I noticed is that when you plugin the unit into an outlet, the 7 segment displays would come on briefly before going into standby mode. Since there is no way to really turn off the unit I am a little skeptical as to whether the unit could somehow be accidentally powered on by itself while the switches are off (which would be a safty risk) so I would strongly recommend only connecting it to an power strip which could be turned off independently and double check to ensure that the power is off when you are done with your work. Thankfully this is not an issue for me as I have a central power switch in my lab. </p>
<p>Despite a few aforementioned shortcomings, X-TRONIC 4040/4000 really gives you plenty of bang for the buck. And it does the job pleasantly well.</p>
<h3>Summary</h3>
<p><strong>Pros:</strong></p>
<ul>
<li>Relatively quiet operation</li>
<li>Hot air wand holder can be placed on either side of the unit</li>
<li>Soldering iron heats up quickly</li>
<li>Flexible tubing and wiring</li>
<li>Replacement heating elements for both the hot air wand and soldering iron included</li>
<li>Includes a magnifier lamp, which is very useful</li>
<li>10 assorted tips included (with one installed)</li>
<li>Iron and hot air wand can be operated independent of each other</li>
<li>Good overall performance</li>
</ul>
<p><strong>Cons:</strong></p>
<ul>
<li>Some cosmetic defects</li>
<li>No air flow meter</li>
<li>Slightly weak heating element for the hot air</li>
<li>No central off switch for the unit (system remains connected to the mains when off)</li>
<li>No auto off capability when hot air wand is placed in holder</li>
<li>Some parts not of top quality</li>
<li>Temperature displays only in Celsius.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.kerrywong.com/2011/12/05/x-tronic-4040-hot-air-reworksoldering-station/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Temperature/Humidity Data Logger &#8212; One Year Worth of Data</title>
		<link>http://www.kerrywong.com/2011/12/01/temperaturehumidity-data-logger-one-year-worth-of-data/</link>
		<comments>http://www.kerrywong.com/2011/12/01/temperaturehumidity-data-logger-one-year-worth-of-data/#comments</comments>
		<pubDate>Fri, 02 Dec 2011 00:37:27 +0000</pubDate>
		<dc:creator>kwong</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[Data Logging]]></category>

		<guid isPermaLink="false">http://www.kerrywong.com/?p=4976</guid>
		<description><![CDATA[I had almost forgotten about the experiment I started late last year using the data logger I built to log the temperature and humidity values in my basement lab for an entire year. The logger worked well during the initial trial run, but having it run continuously for a whole year is another story. Anticipating [...]]]></description>
			<content:encoded><![CDATA[<p>I had almost forgotten about the experiment I started late last year using the <a href="http://www.kerrywong.com/2010/10/02/i2c-data-logger-using-atmega328p-and-ds3232-%E2%80%93-ii/">data logger</a> I built to log the temperature and humidity values in my basement lab for an entire year. The logger worked well during the <a href="http://www.kerrywong.com/2010/11/17/temperaturehumidity-data-logger-trial-run/">initial trial run</a>, but having it run continuously for a whole year is another story.<span id="more-4976"></span></p>
<p>Anticipating possible power glitches and prolonged power outages, I equipped the data logger with rechargeable batteries and a trickle charger, which could provide many days of run time should the power go off. This turned out to be quite useful when the storm hit last month and <a href="http://www.kerrywong.com/2011/11/04/back-online-again-finally/">left me without power for a week</a>.</p>
<p>The data file came in at around 80 MBs. Since the logger was set to log an entry every 10 seconds, the log file grew quite big and it contained over 3,000,000 rows of data. I created a simple program to smooth out the data and reduced the data points to around 15,000 for plotting. And the final graph is shown below:</p>
<div id="attachment_4979" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/11/sensordata_1year.png"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/11/sensordata_1year-300x161.png" alt="Temperature/Humidity Data Over the Past Year" title="Temperature/Humidity Data Over the Past Year" width="300" height="161" class="size-medium wp-image-4979" /></a><p class="wp-caption-text">Temperature/Humidity Data Over the Past Year</p></div>
<p>As for the dip in temperature towards the end? Well, you&#8217;ve guessed it, that was due to the power outage during the Halloween time when the storm hit.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kerrywong.com/2011/12/01/temperaturehumidity-data-logger-one-year-worth-of-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building a Wireless Temperature Sensor</title>
		<link>http://www.kerrywong.com/2011/11/22/building-a-wireless-temperature-sensor/</link>
		<comments>http://www.kerrywong.com/2011/11/22/building-a-wireless-temperature-sensor/#comments</comments>
		<pubDate>Tue, 22 Nov 2011 21:14:58 +0000</pubDate>
		<dc:creator>kwong</dc:creator>
				<category><![CDATA[AVR/Arduino]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[ATMega328]]></category>
		<category><![CDATA[Frequency to Voltage Converter]]></category>
		<category><![CDATA[LM2902]]></category>
		<category><![CDATA[LM324]]></category>
		<category><![CDATA[LM331]]></category>
		<category><![CDATA[LM335]]></category>
		<category><![CDATA[RF Data Link]]></category>
		<category><![CDATA[Temperature Sensor]]></category>
		<category><![CDATA[Thermistor]]></category>
		<category><![CDATA[Voltage to Frequency Converter]]></category>

		<guid isPermaLink="false">http://www.kerrywong.com/?p=4892</guid>
		<description><![CDATA[I have built quite a few (1,2,3) temperature measurement circuits in the past, but none of those has remote sensing capability. So I decided to make a wireless temperature sensor so that temperature measurements can be made anywhere within the range of the transmitter and the receiver. There are many ways to achieve this. One [...]]]></description>
			<content:encoded><![CDATA[<p>I have built quite a few (<a href="http://www.kerrywong.com/2011/05/08/a-dual-temperature-display-with-humidity-measurement/">1</a>,<a href="http://www.kerrywong.com/2011/03/11/interfacing-ds7505/">2</a>,<a href="http://www.kerrywong.com/2010/05/09/working-with-lm19-temperature-sensor/">3</a>) temperature measurement circuits in the past, but none of those has remote sensing capability. So I decided to make a wireless temperature sensor so that temperature measurements can be made anywhere within the range of the transmitter and the receiver.<span id="more-4892"></span></p>
<p>There are many ways to achieve this. One of the simplest ways is to use a voltage to frequency conversion chip along with an analog temperature sensor such as <a href="http://www.national.com/ds/LM/LM135.pdf">LM335</a> or a <a href="http://en.wikipedia.org/wiki/Thermistor">thermistor</a>, and then transmit the modulated frequency signal via an RF data link module. Alternatively, we can use a digital temperature sensor and sending the sensor readings over RF serial data link digitally. In this post I will stick with the first approach.</p>
<p>The following schematic shows my circuit design:</p>
<div id="attachment_4895" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/11/WirelessTemperatureSensor.png"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/11/WirelessTemperatureSensor-300x168.png" alt="Wireless Temperature Sensor" title="Wireless Temperature Sensor" width="300" height="168" class="size-medium wp-image-4895" /></a><p class="wp-caption-text">Wireless Temperature Sensor</p></div>
<p>Here the 1/4 LM324 (or LM2902) forms a <a href="http://en.wikipedia.org/wiki/Buffer_amplifier">voltage follower</a> to buffer the input voltage from the resistor-thermistor voltage divider, and the divider output is fed into an <a href="http://www.national.com/ds/LM/LM231.pdf">LM331</a> voltage to frequency converter. The LM331 portion of the circuit was taken directly from the reference design. </p>
<p>The capacitor at pin 5 needs to be adjusted so that the maximum frequency output from the oscillator is below the maximum bit rates supported by the RF link. The RF data transmitter I used has a maximum bit rate of 2400 bps and thus I used a 47nF capacitor and the oscillation frequency is around 700 Hz under room temperature.</p>
<p>The frequency output from LM331 is again buffered via another 1/4 LM324 (or LM2902) before feeding into the RF data link transmitter. This voltage to frequency circuit is arguably not the most accurate one and you could improve your accuracy by adding an op-amp integrator as illustrated in the datasheet, but for the temperature measurement application we are discussing here, this simple circuit is accurate enough.</p>
<div id="attachment_4900" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/11/temptransmitter.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/11/temptransmitter-300x225.jpg" alt="Transmitter" title="Transmitter" width="300" height="225" class="size-medium wp-image-4900" /></a><p class="wp-caption-text">Transmitter</p></div>
<p>According to the LM331 data sheet, the timing components need to have very high stability in order to achieve a high level of accuracy and minimize frequency drift. The picture above shows the finished transmitter portion of the temperature sensor. Note that the power supply must be regulated in order to obtain accurate readings since it is referenced by the thermistor voltage divider.</p>
<p>I could have built the receiver using another LM331 as a frequency to voltage converter and use the voltage readouts to calculate the temperature readings. But then I would need to use an A/D converter to convert the signal back to digital form in order to perform the calculation. To simplify the design, I used an <a href="http://www.arduino.cc">Arduino</a> MCU (ATmega328) to measure the frequency output from the RF data link receiver directly. The following picture shows the setup on the receiver end.</p>
<div id="attachment_4901" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/11/tempreceiver.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/11/tempreceiver-300x225.jpg" alt="Receiver" title="Receiver" width="300" height="225" class="size-medium wp-image-4901" /></a><p class="wp-caption-text">Receiver</p></div>
<p>The oscilloscope capture below shows the output waveform from the receiver when the transmitter side is under room temperature.<br />
<div id="attachment_4902" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/11/receivedwaveform.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/11/receivedwaveform-300x219.jpg" alt="Receiver Waveform Output" title="Receiver Waveform Output" width="300" height="219" class="size-medium wp-image-4902" /></a><p class="wp-caption-text">Receiver Waveform Output</p></div></p>
<p>With the transmitter and receiver working, now we need to convert the received frequency readings back to the temperature readings. Again, to help you understand how the calculation is done I have included the reference schematic below:</p>
<div id="attachment_4944" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/11/referencedesign.png"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/11/referencedesign-300x228.png" alt="Reference Design" title="Reference Design" width="300" height="228" class="size-medium wp-image-4944" /></a><p class="wp-caption-text">Reference Design</p></div>
<p>We know that the converter&#8217;s output frequency is a linear function of the input voltage at the voltage divider:</p>
<p>\[f=C_0\frac{R_{ntc}}{R_{ntc}+R_0}V_{cc}=C_1\frac{R_{ntc}}{R_{ntc}+R_0}\] </p>
<p>C0 is a constant that can be derived from the following equation according to the datasheet:<br />
\[C_0=\frac{R_s}{2.09*R_L*R_tC_t}\]</p>
<p>Since the temperature is roughly inversely proportional to the thermistor value within a small temperature range:<br />
\[\frac{1}{R_{ntc}}\propto T\]</p>
<p>We can further simplify the frequency output to:<br />
\[f=\frac{C_1}{1+C_2T}\]</p>
<p>And thus we can derive the measured temperature as:<br />
\[T=\frac{C_1}{fC_2} - \frac{1}{C_2}\]</p>
<p>Although the two constants C1 and C2 can be determined by the theoretical values of the components, it is probably simpler to obtain them experimentally by measuring two or more frequencies at different temperature points. </p>
<p>Below is the Arduino code I used. The FreqCounter library I used can be found <a href="http://interface.khm.de/index.php/lab/experiments/arduino-frequency-counter-library/">here</a>.  Note that parameters in the code are tailored specifically for the type of thermistor I used and they are also affected by the transmitter supply voltage (in my case the transmitter operates on 5V). You will need to re-calculate the parameters based on the equations I gave above.  </p>
<pre class="brush: cpp; title: ; notranslate">
#include &lt;FreqCounter.h&gt;

unsigned long frq;

float a = -165.0;
float b = 151735.0;

float GetTemp(float f)
{
  return a + (b/f);
}

void setup()
{
  Serial.begin(9600);
}

void loop()
{
    FreqCounter::f_comp = 106;
    FreqCounter::start(1000);
    while (FreqCounter::f_ready == 0)
        frq = FreqCounter::f_freq;    

    Serial.println(GetTemp(frq));
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.kerrywong.com/2011/11/22/building-a-wireless-temperature-sensor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple Alexa Ranking Script</title>
		<link>http://www.kerrywong.com/2011/11/14/simple-alexa-ranking-script/</link>
		<comments>http://www.kerrywong.com/2011/11/14/simple-alexa-ranking-script/#comments</comments>
		<pubDate>Tue, 15 Nov 2011 01:25:52 +0000</pubDate>
		<dc:creator>kwong</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[Screen Scraping]]></category>
		<category><![CDATA[Search Engine]]></category>
		<category><![CDATA[SEO]]></category>

		<guid isPermaLink="false">http://www.kerrywong.com/?p=4872</guid>
		<description><![CDATA[Alexa is a great tool for gathering your website&#8217;s statistics. Using its traffic rank moving average, you can see how your content affects your site&#8217;s popularity over time. Unfortunately Alexa does not provide detailed history data for sites outside the top 100,000. This makes it slightly more difficult for people running smaller sites to track [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Alexa_Internet">Alexa</a> is a great tool for gathering your website&#8217;s statistics. Using its traffic rank moving average, you can see how your content affects your site&#8217;s popularity over time. <span id="more-4872"></span> </p>
<p>Unfortunately Alexa does not provide detailed history data for sites outside the top 100,000. This makes it slightly more difficult for people running smaller sites to track their trends. Fortunately, we can create a simple script that screen-scrape the traffic ranking information from the HTTP response.</p>
<p>The following shell script illustrates a simple script to parse the traffic ranking information:</p>
<pre class="brush: bash; title: ; notranslate">
#! /bin/sh

wget -SO-  http://www.alexa.com/siteinfo/{site url} 2&gt;&amp;1
| grep -i &quot;alexa traffic rank&quot;  | sed -e 's/.*is ranked number //g'
| sed -e 's/in the world according.*//g'
| sed -e 's/,//g' | grep '^[0-9]*' -o &gt;&gt; {log file name}
</pre>
<p>Note that the <em>wget</em> statement should be kept in a single line. It is broken into multiple lines for legibility.</p>
<p>One challenge is that the returned verbiage changes according to the rough rankings of the sites so you may have to play around with the HTML a little bit to get the parsing working properly for your particular site. But for any given site, the returned HTML should be relatively stable.</p>
<p>If you run the above script as a scheduled job (e.g. through <em>cron</em>), then you will be able to chart your own traffic trend over time.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kerrywong.com/2011/11/14/simple-alexa-ranking-script/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Power is Back</title>
		<link>http://www.kerrywong.com/2011/11/08/power-is-back/</link>
		<comments>http://www.kerrywong.com/2011/11/08/power-is-back/#comments</comments>
		<pubDate>Wed, 09 Nov 2011 00:34:29 +0000</pubDate>
		<dc:creator>kwong</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[Power Outage]]></category>

		<guid isPermaLink="false">http://www.kerrywong.com/?p=4867</guid>
		<description><![CDATA[The power finally came back early this morning. So from last Saturday till today, we have been without power for almost ten days. Well things could have been a lot worse. Thankfully my generator had been working great without a glitch for the last week and half. While the power was out, I received my [...]]]></description>
			<content:encoded><![CDATA[<p>The power finally came back early this morning. So from last Saturday till today, we have been without power for almost ten days. Well things could have been a lot worse. Thankfully my generator had been working great without a glitch for the last week and half.<span id="more-4867"></span></p>
<p>While the power was out, I received my <a href="http://processors.wiki.ti.com/index.php/MSP430_LaunchPad_(MSP-EXP430G2)">TI MSP430 Launchpad</a> and an <a href="http://processors.wiki.ti.com/index.php/EZ430-Chronos?DCMP=Chronos&#038;HQS=Other+OT+chronoswiki">eZ430-Chronos Development Kit</a>. Now that everything is back to normal, I will have time to get busy with my projects again&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kerrywong.com/2011/11/08/power-is-back/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Back Online Again &#8212; Finally!</title>
		<link>http://www.kerrywong.com/2011/11/04/back-online-again-finally/</link>
		<comments>http://www.kerrywong.com/2011/11/04/back-online-again-finally/#comments</comments>
		<pubDate>Fri, 04 Nov 2011 12:51:48 +0000</pubDate>
		<dc:creator>kwong</dc:creator>
				<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[Power Outage]]></category>

		<guid isPermaLink="false">http://www.kerrywong.com/?p=4863</guid>
		<description><![CDATA[The Halloween nor&#8217;easter knocked out power and internet service last Saturday. Even though I have a backup generator, the internet outage caused my site to go dark for the past few days (well almost a whole week). Anyway, the internet service has been restored. Even though main power hasn&#8217;t come back yet, I was able [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://en.wikipedia.org/wiki/2011_Halloween_nor%27easter">Halloween nor&#8217;easter </a> knocked out power and internet service last Saturday. Even though I have a backup generator, the internet outage caused my site to go dark for the past few days (well almost a whole week).<span id="more-4863"></span></p>
<p>Anyway, the internet service has been restored. Even though main power hasn&#8217;t come back yet, I was able to run my servers using the generator.</p>
<p>This is certainly the longest outage that I have seen here in the northeastern part of the US&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kerrywong.com/2011/11/04/back-online-again-finally/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>STM32F4-Discovery Board</title>
		<link>http://www.kerrywong.com/2011/10/22/stm32f4-discovery-board/</link>
		<comments>http://www.kerrywong.com/2011/10/22/stm32f4-discovery-board/#comments</comments>
		<pubDate>Sun, 23 Oct 2011 01:58:12 +0000</pubDate>
		<dc:creator>kwong</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[ARM]]></category>
		<category><![CDATA[MCU]]></category>
		<category><![CDATA[STM32F4]]></category>

		<guid isPermaLink="false">http://www.kerrywong.com/?p=4821</guid>
		<description><![CDATA[I received my STM32F4-Discovery evaluation board last week. So I setup the required development environments and did a quick test. The STM32F4 is an ARM Cortex-M4 processor with DSP and FPU instructions. Since I have not used any ARM MCU before, I decided first to use the recommended tool chain to get myself started. According [...]]]></description>
			<content:encoded><![CDATA[<p>I received my <a href="http://www.st.com/internet/evalboard/product/252419.jsp">STM32F4-Discovery</a> evaluation board last week. So I setup the required development environments and did a quick test.<span id="more-4821"></span></p>
<p>The STM32F4 is an <a href="http://www.arm.com/products/processors/cortex-m/cortex-m4-processor.php">ARM Cortex-M4</a> processor with DSP and FPU instructions. Since I have not used any ARM MCU before, I decided first to use the recommended tool chain to get myself started.</p>
<div id="attachment_4822" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/10/STM32F4Board.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/10/STM32F4Board-300x221.jpg" alt="STM32F4 Board" title="STM32F4 Board" width="300" height="221" class="size-medium wp-image-4822" /></a><p class="wp-caption-text">STM32F4 Board</p></div>
<p>According to the user manual (UM1467), the following IDEs have native support for STM32F4-Discovery board:</p>
<ul>
<li><a href="http://www.iar.com">IAR Embedded Workbench for ARM (EWARM)</a></li>
<li><a href="http://www.keil.com">RealView Microcontroller Development Kit (MDK-ARM)</a></li>
<li><a href="http://www.atollic.com">Atollic TrueSTUDIO for STM32</a>
<li><a href="http://www.tasking.com">Altium TASKING VX-toolset for ARM</a>
</ul>
<p>And it seems that only the Atollic TrueSTUDIO has a <a href="http://atollic.com/index.php/download/downloadstm32">free version (Lite)</a> that does not have any code limitations. So the Atollic IDE is the pretty obvious choice for me.</p>
<p>The IDE is based on the popular open source <a href="http://www.eclipse.org/">Eclipse development environment</a>. Having used it extensively with C++ and Java projects, setting up the demo project is pretty straight forward. Atollic TrueSTUDIO also integrates with ST-Link GDB server, which makes debugging within the IDE very easy (see screenshot below)</p>
<div id="attachment_4829" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/10/STM32F4AtollicDebug.png"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/10/STM32F4AtollicDebug-300x224.png" alt="Debugging STM32F4 Using Atollic" title="Debugging STM32F4 Using Atollic" width="300" height="224" class="size-medium wp-image-4829" /></a><p class="wp-caption-text">Debugging STM32F4 Using Atollic</p></div>
<p>To upload the compiled code onto the STM32F4 board, we will need the <a href="http://www.st.com/internet/evalboard/product/219866.jsp">STM32 ST-LINK utility</a>.</p>
<p>Atollic TrueSTUDIO builds the project target into <a href="http://en.wikipedia.org/wiki/Executable_and_Linkable_Format">ELF format</a> which cannot be uploaded to the development board directly. So we will need to first convert the target from ELF to <a href="http://en.wikipedia.org/wiki/Intel_HEX">Intel HEX</a>. Unfortunately, the lite version does not seem to provide such a conversion utility. </p>
<div id="attachment_4835" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/10/AtollicObjectExplorer.png"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/10/AtollicObjectExplorer-300x270.png" alt="Object Explorer" title="Object Explorer" width="300" height="270" class="size-medium wp-image-4835" /></a><p class="wp-caption-text">Object Explorer</p></div>
<p>After some searching, I found that <a href="http://www.ronetix.at/">Ronetix</a> ARM toolset contains arm-elf-objcopy which can be used for such conversion. The full Ronetix tool chain can be downloaded from <a href="http://download.ronetix.info/toolchains/arm/">here</a>.</p>
<p>To convert the ELF file to HEX, use the command below:</p>
<blockquote><p>
STM32F4-Discovery_FW_V1.0.1\Project\Demonstration\TrueSTUDIO\STM32F4-Discovery_Demo\Debug</p>
<p>arm-elf-objcopy -O ihex RCC.elf RCC.hex
</p></blockquote>
<p>Now we can use the ST-LINK utility to upload the .HEX file onto the STM32F4-Discovery board. Interestingly enough, the converted HEX file is about 17 kB smaller than the pre-compiled project demonstration file in the binary folder. It works without a glitch nevertheless. I suspect that the ST supplied HEX file might have been compiled with more debugging information.</p>
<div id="attachment_4832" class="wp-caption aligncenter" style="width: 265px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/10/STM32STLinkUtility.png"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/10/STM32STLinkUtility-255x300.png" alt="STM32 ST Link Utility" title="STM32STLinkUtility" width="255" height="300" class="size-medium wp-image-4832" /></a><p class="wp-caption-text">STM32 ST Link Utility</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.kerrywong.com/2011/10/22/stm32f4-discovery-board/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Thermistor Parameter Measurement — II</title>
		<link>http://www.kerrywong.com/2011/10/15/thermistor-parameter-measurement-%e2%80%94-ii/</link>
		<comments>http://www.kerrywong.com/2011/10/15/thermistor-parameter-measurement-%e2%80%94-ii/#comments</comments>
		<pubDate>Sat, 15 Oct 2011 15:26:55 +0000</pubDate>
		<dc:creator>kwong</dc:creator>
				<category><![CDATA[AVR/Arduino]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[LM335]]></category>
		<category><![CDATA[MATLAB]]></category>
		<category><![CDATA[Measurement]]></category>
		<category><![CDATA[NTC]]></category>
		<category><![CDATA[Parameter]]></category>
		<category><![CDATA[PTC]]></category>
		<category><![CDATA[Thermistor]]></category>

		<guid isPermaLink="false">http://www.kerrywong.com/?p=4757</guid>
		<description><![CDATA[Last time I showed a simple circuit that can be used to measure unknown thermistor parameters. The circuit is basically just a power MOSFET using a voltage and duty cycle controlled PWM signal to drive the gate and thus generates a temperature reference which is measured by both the unknown thermistor and the precision temperature [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.kerrywong.com/2011/10/09/thermistor-parameter-measurement/">Last time</a> I showed a simple circuit that can be used to measure unknown <a href="http://en.wikipedia.org/wiki/Thermistor">thermistor</a> parameters. The circuit is basically just a power MOSFET using a voltage and duty cycle controlled PWM signal to drive the gate and thus generates a temperature reference which is measured by both the unknown thermistor and the precision temperature sensor <a href="http://www.national.com/ds/LM/LM135.pdf">LM335</a>. By measuring the voltage drop across the thermistor at different temperatures, we can obtain the R-T curve of the thermistor and thus estimate the parameters that define the R-T curve using some known models. <span id="more-4757"></span></p>
<p>Here is the diagram of the measurement circuit again:<br />
<div id="attachment_4794" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/10/ThermistorParameterTracer1.png"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/10/ThermistorParameterTracer1-300x206.png" alt="Thermistor Parameter Tracer" title="Thermistor Parameter Tracer" width="300" height="206" class="size-medium wp-image-4794" /></a><p class="wp-caption-text">Thermistor Parameter Tracer</p></div></p>
<p>The thermistor (R1) is attached directly to the heat sink and close to the LM335 so that we can assume that both the thermistor and the LM335 are measuring the same temperature. The current limiting resistor R2 is chosen so that the voltage resolution is as high as possible (e.g. the voltage change across R1 is maximized over the measured temperature range) and at the same time the self heating effect is negligible.</p>
<p>The picture below shows the three unknown NTCs I used in my test. These three NTCs measure roughly 8K, 10K and 18K under room temperature. And the current limit resistors are chosen after some experiments. For the 8K NTC, I used a 1.783K resistor. For the 10K NTC, I used a 2.643K resistor and for the 18K NTC, I used a 2.164K resistor.</p>
<div id="attachment_4761" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/10/NTCMeasurement3.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/10/NTCMeasurement3-300x225.jpg" alt="NTCs Used in Test" title="NTCs Used in Test" width="300" height="225" class="size-medium wp-image-4761" /></a><p class="wp-caption-text">NTCs Used in Test</p></div>
<p>The PWM signal is supplied via an Arduino board. The reference voltage readings from LM335 and the voltage reading across the unknown NTC are feed to the analog pins of the MCU.</p>
<div id="attachment_4759" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/10/NTCMeasurement1.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/10/NTCMeasurement1-300x225.jpg" alt="Measurement Setup" title="Measurement Setup" width="300" height="225" class="size-medium wp-image-4759" /></a><p class="wp-caption-text">Measurement Setup</p></div>
<p>Here is a close up of the measurement board, you can see that the unknown NTC is clamped onto the heat sink adjacent to the LM335 sensor.</p>
<div id="attachment_4760" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/10/NTCMeasurement2.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/10/NTCMeasurement2-300x225.jpg" alt="Board With Unknown NTC Attached" title="Board With Unknown NTC Attached" width="300" height="225" class="size-medium wp-image-4760" /></a><p class="wp-caption-text">Board With Unknown NTC Attached</p></div>
<p>Depending on the thermal conductivity of the heatsink, it takes time for the heatsink surface to reach a stable temperature. Thus, the temperature must be increased slowly in order to obtain accurate results. One way to control the heatsink temperature is to use a <a href="http://en.wikipedia.org/wiki/PID_controller">PID controller</a> to adjust the pulse width of the driving signal and only measure the NTC readings after the desired temperature is stabilized. This approach can become quite complex as it requires fine tuning of the controller parameters to reduce overshoot and oscillation. </p>
<p>Here we will take a simpler approach by simply increasing the pulse width of the control signal slowly over time. This method works quite well in general. But since the temperature increases faster at higher pulse width, the MOSFET heat-up curve is more exponential than linear. This could introduce some error when the temperature is high since there will be fewer sample points in that range. But for our experiment, this should not be an issue as the A/D converter precision is limited to 10 bits in ATmega328, and the measurement error would largely be coming from A/D conversion resolution than anywhere else.</p>
<p>The following is the code listing:</p>
<pre class="brush: cpp; title: ; notranslate">
//The voltage of the USB power supply to Arduino,
//if higher precision is required, this voltage needs
//to be regulated.
double Vcc = 4.864;
double V = 0;
double TC = 0;
double TK = 0;
double TF = 0;
int tOn = 0; //PWM on time
double val1 = 0;
double val2 = 0;
int refVal = 0; //analog reading from LM335
int measureVal = 0; //analog reading from NTC/PTC

const int refTempPin = 0; //analog pin 0
const int measurePin = 1; //analog pin 1

const int pwmPin = 3; //digital pin 3

void setup()
{
  Serial.begin(9600);
  analogWrite(pwmPin, tOn);
  delay(10000);
}

void loop()
{
  val1 = 0;
  val2 = 0;

  //using average over 10 iterations
  for (int i = 0; i&lt;10; i++) {
    val1 += analogRead(refTempPin);
    delay(20);
    val2 += analogRead(measurePin);
    delay(20);
  }

  refVal = (int) (val1 / 10.0);
  measureVal = (int) (val2 / 10.0);

  V = (double) refVal/ 1024.0 * Vcc; //Measured voltage
  TK = V * 100.0 ; //Kelvin
  TC = TK - 273.0; //Celcius
  TF = 9.0/5.0 * TC + 32.0; //Fahrenheit

  Serial.print(V);
  Serial.print(&quot; &quot;);
  Serial.print(TC);
  Serial.print(&quot; &quot;);
  Serial.print(measureVal);
  Serial.print(&quot; &quot;);
  Serial.println(tOn);

  //The highest temperature is set to be 110 Celcius
  //and the maximum PWM width is set to 100/255
  if (TC &lt; 110 &amp;&amp; tOn &lt; 100) {
    tOn++;
    analogWrite(pwmPin, tOn);
  }  

  //This delay needs to be at least 10 seconds to allow
  //the heat sink to be uniformly heated.
  delay(10000);
}
</pre>
<p>And the measured data is sent via the UART to the computer serial monitor. After the data is collected after each run, the data is processed and then fed into two arrays in MATLAB. From the obtained data we can form two arrays, one is for the LM335 readings and the other is for the thermistor resistance values. We can further estimate the curve parameter values by fitting the measured data to a known model.</p>
<p>A typical NTC thermistor has the following characteristics:<br />
\[R=r_{\infty}e^{\frac{B}{T}}\]</p>
<p>Since MATLAB does not have an out-of-box function for this type of curve fitting, I used an alternative two-term exponential function:<br />
\[f(x)=a*e^{bx}+c*e^{dx}\]</p>
<p>Other forms of functions such as polynomials can also be used and should also give satisfactory results. But since we know the nature of the R-T relationship, the exponential curve fitting should give less error and be applicable over a large temperature range. The following code snippet shows the MATLAB function calls for the curve fitting portion.</p>
<blockquote><p>
f18 = fit(R18Temp&#8217;, R18Val&#8217;, &#8216;exp2&#8242;);<br />
f10 = fit(R10Temp&#8217;, R10Val&#8217;, &#8216;exp2&#8242;);<br />
f8 = fit(R8Temp&#8217;, R8Val&#8217;, &#8216;exp2&#8242;);
</p></blockquote>
<p>And the figures below show the R-T measurements of the three different NTC thermistors with the measured data and fitted curve overlaid.</p>
<div id="attachment_4762" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/10/R8.png"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/10/R8-300x225.png" alt="NTC1 R-T Curve" title="NTC1 R-T Curve" width="300" height="225" class="size-medium wp-image-4762" /></a><p class="wp-caption-text">NTC1 R-T Curve</p></div>
<blockquote><p>
a =  17.94<br />
b = -0.05082<br />
c =  8.424<br />
d = -0.02041
</p></blockquote>
<div id="attachment_4763" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/10/R10.png"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/10/R10-300x225.png" alt="NTC2 R-T Curve" title="NTC2 R-T Curve" width="300" height="225" class="size-medium wp-image-4763" /></a><p class="wp-caption-text">NTC2 R-T Curve</p></div>
<blockquote><p>
a =  28.68<br />
b = -0.04817<br />
c =  2.544<br />
d = -0.02274
</p></blockquote>
<div id="attachment_4764" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/10/R18.png"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/10/R18-300x225.png" alt="NTC3 R-T Curve" title="NTC3 R-T Curve" width="300" height="225" class="size-medium wp-image-4764" /></a><p class="wp-caption-text">NTC3 R-T Curve</p></div>
<blockquote><p>
a =  40<br />
b = -0.04112<br />
c =  4.416<br />
d = -0.01477
</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.kerrywong.com/2011/10/15/thermistor-parameter-measurement-%e2%80%94-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Thermistor Parameter Measurement &#8212; I</title>
		<link>http://www.kerrywong.com/2011/10/09/thermistor-parameter-measurement/</link>
		<comments>http://www.kerrywong.com/2011/10/09/thermistor-parameter-measurement/#comments</comments>
		<pubDate>Mon, 10 Oct 2011 00:50:38 +0000</pubDate>
		<dc:creator>kwong</dc:creator>
				<category><![CDATA[AVR/Arduino]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[LM335]]></category>
		<category><![CDATA[Measurement]]></category>
		<category><![CDATA[NTC]]></category>
		<category><![CDATA[Parameter]]></category>
		<category><![CDATA[PTC]]></category>
		<category><![CDATA[Thermistor]]></category>

		<guid isPermaLink="false">http://www.kerrywong.com/?p=4715</guid>
		<description><![CDATA[Over the years, I have gathered quite a few NTC and PTC thermistors. But most of them are unmarked so it would be difficult to use them in an accurate way without knowing the parameters. So I decided to build a simple circuit that can be used to trace the temperature-resistance curve, and the parameters [...]]]></description>
			<content:encoded><![CDATA[<p>Over the years, I have gathered quite a few NTC and PTC <a href="http://en.wikipedia.org/wiki/Thermistor">thermistors</a>. But most of them are unmarked so it would be difficult to use them in an accurate way without knowing the parameters. So I decided to build a simple circuit that can be used to trace the temperature-resistance curve, and the parameters can then be estimated using the measured data points.<span id="more-4715"></span></p>
<p>Here, I will show you a simple circuit that I designed that can be used as an front end for such measurements. Outputs from this circuit can be inputted into an MCU (such as the popular <a href="http://www.arduino.cc/">Arduino</a>) for further analysis.</p>
<p>The circuit is shown below:</p>
<div id="attachment_4721" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/10/ThermistorParameterTracer.png"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/10/ThermistorParameterTracer-300x206.png" alt="Thermistor Parameter Tracer" title="Thermistor Parameter Tracer" width="300" height="206" class="size-medium wp-image-4721" /></a><p class="wp-caption-text">Thermistor Parameter Tracer</p></div>
<p>Here the MOSFET (<a href="http://www.alldatasheet.com/datasheet-pdf/pdf/96663/IRF/IRFZ22.html">IRFZ22</a>) is used as an active load. The gate voltage is limited to 4.7V by the <a href="http://en.wikipedia.org/wiki/Zener_diode">Zener diode</a> (e.g. 1N4732). This is important as according to IRFZ22&#8242;s datasheet, by limiting the gate voltage to 4.7V, the maximum drain to source current (Ids) is limited to roughly 2 Amp. In principal, pretty much any power MOSFET can be used for this purpose, as long as Vgs is clamped to ensure that the MOSFET operates within the safe limit. A small heat sink is used as the heating surface. A PWM signal is used to control the gate. By adjusting the PWM duty cycle, the thermal dissipation of the MOSFET can be controlled and thus the heatsink temperature can be varied programmatically. </p>
<p>A precision temperature sensor <a href="http://www.national.com/ds/LM/LM135.pdf">LM335</a> is clamped onto the heatsink (see picture below) so the surface temperature can be monitored. When used with a <a href="http://en.wikipedia.org/wiki/Control_theory">closed loop</a> control (e.g. <a href="http://en.wikipedia.org/wiki/PID_controller">PID control</a>) the heatsink surface temperature can be controlled precisely.</p>
<div id="attachment_4731" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/10/ThermistorParameterTracer.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/10/ThermistorParameterTracer-300x225.jpg" alt="Thermistor Parameter Tracer" title="Thermistor Parameter Tracer" width="300" height="225" class="size-medium wp-image-4731" /></a><p class="wp-caption-text">Thermistor Parameter Tracer</p></div>
<p>To measure the parameters of an unknown thermistor (either PTC or NTC), choose an appropriate R2 so that the voltage change across the thermistor under measurement is maximized over the desired temperature range and at the same time the self-heating effect is minimized.</p>
<p>The thermistor temperature-resistance curve can be obtained as follows: </p>
<ul>
<li>Attach the thermistor to be measured near the LM335 sensor. The surface of the thermistor should be firmly attached to the heatsink surface to ensure that the temperature reading from LM335 is the same as the temperature of the thermistor.
<li>
Gradually increase the PWM duty cycle of the control signal so that the temperature reading from LM335 slowly increases (e.g. 1 degree per minute). The temperature has to be changed slowly so that we can ensure that both LM335 and the thermistor are at the same temperature.
</li>
<li>
Record the temperature via Vout1 and the thermistor&#8217;s resistance via Vout2 using an MCU.
</li>
</ul>
<p>Using this circuit, the control temperature can be safely raised to about 250 Fahrenheit (121 Celsius) which should give wide enough of a range for most thermistor measurements.</p>
<p>I will show a few examples in a later post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kerrywong.com/2011/10/09/thermistor-parameter-measurement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Synchronous Camera Flash Trigger Using IGBT</title>
		<link>http://www.kerrywong.com/2011/10/01/synchronous-camera-flash-trigger-using-igbt/</link>
		<comments>http://www.kerrywong.com/2011/10/01/synchronous-camera-flash-trigger-using-igbt/#comments</comments>
		<pubDate>Sun, 02 Oct 2011 00:27:43 +0000</pubDate>
		<dc:creator>kwong</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Camera Flash]]></category>
		<category><![CDATA[GT8G131]]></category>
		<category><![CDATA[IGBT]]></category>
		<category><![CDATA[LM339]]></category>

		<guid isPermaLink="false">http://www.kerrywong.com/?p=4695</guid>
		<description><![CDATA[Typically a synchronous camera flash (e.g. slave flash) is triggered via an SCR. In this blog post, I will show you a circuit that can be used to trigger a secondary camera flash using an IGBT. Using an IGBT for camera flash triggering has several advantages over the traditional SCR triggering mechanism: for instance, the [...]]]></description>
			<content:encoded><![CDATA[<p>Typically a synchronous <a href="http://en.wikipedia.org/wiki/Flashtube">camera flash</a> (e.g. slave flash) is triggered via an <a href="http://en.wikipedia.org/wiki/Silicon-controlled_rectifier">SCR</a>. In this blog post, I will show you a circuit that can be used to trigger a secondary camera flash using an <a href="http://en.wikipedia.org/wiki/IGBT">IGBT</a>. <span id="more-4695"></span></p>
<p>Using an IGBT for camera flash triggering has <a href="http://www.fairchildsemi.com/an/AN/AN-9006.pdf">several advantages</a> over the traditional SCR triggering mechanism: for instance, the width of the triggering pulse can be controlled precisely and thus enabling functions such as red eye prevention that cannot be achieved easily using an SCR triggered circuit.</p>
<p>The following circuit diagram shows a simple IGBT controlled slave camera flash circuit:</p>
<div id="attachment_4697" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/10/SynchronousFlashTrigger.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/10/SynchronousFlashTrigger-300x130.jpg" alt="Synchronous Flash Trigger Using IGBT" title="Synchronous Flash Trigger Using IGBT" width="300" height="130" class="size-medium wp-image-4697" /></a><p class="wp-caption-text">Synchronous Flash Trigger Using IGBT</p></div>
<p>Depending on the camera used, the light sensor can be either a <a href="http://en.wikipedia.org/wiki/Photoresistor">CdS photoresistor </a>, a <a href="http://en.wikipedia.org/wiki/Photoresistor">photodiode</a> or a phototransistor. For many automatic cameras, a photodiode or photo transistor maybe necessary as the shutter speed is typically faster than then reaction time of a CdS sensor. The schematics above also shows how both types of sensors can be used.</p>
<p>Here is how this circuit works. The inverting input of the comparator (LM339) is referenced at roughly Vcc/2. When the CdS sensor detects the primary camera flash, its resistance drops and the voltage at the none-inverting input exceeds the reference voltage. The comparator output a high (e.g. close to Vcc) and thus triggers the IGBT. </p>
<p>The IGBT used here is a Toshiba <a href="http://www.alldatasheet.com/datasheet-pdf/pdf/30939/TOSHIBA/GT8G131.html">GT8G131</a> N Channel IGBT, which is specifically designed for strobe flash applications. It is important to supply a high enough (within safety limit) gate voltage to ensure that the IGBT is fully turned on. Otherwise, the IGBT may not be able to conduct a high enough current to trigger the flash tube. So if you are using other types of IGBT, you may need to adjust the Vcc accordingly.</p>
<p>The following picture shows the finished circuit board used with a Vivitar 2000 camera flash.</p>
<div id="attachment_4698" class="wp-caption aligncenter" style="width: 295px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/10/SynchronousFlashTrigger_1.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/10/SynchronousFlashTrigger_1-285x300.jpg" alt="Synchronous Flash Trigger" title="Synchronous Flash Trigger" width="285" height="300" class="size-medium wp-image-4698" /></a><p class="wp-caption-text">Synchronous Flash Trigger</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.kerrywong.com/2011/10/01/synchronous-camera-flash-trigger-using-igbt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hand Soldering Fine Pitch LGA Chip</title>
		<link>http://www.kerrywong.com/2011/09/25/hand-soldering-fine-pitch-lga-chip/</link>
		<comments>http://www.kerrywong.com/2011/09/25/hand-soldering-fine-pitch-lga-chip/#comments</comments>
		<pubDate>Mon, 26 Sep 2011 00:12:12 +0000</pubDate>
		<dc:creator>kwong</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[Gyroscope]]></category>
		<category><![CDATA[LPY450AL]]></category>
		<category><![CDATA[SMD]]></category>
		<category><![CDATA[Soldering]]></category>

		<guid isPermaLink="false">http://www.kerrywong.com/?p=4607</guid>
		<description><![CDATA[Many of the modern chips such as MEMS accelerometers and gyroscopes only come in surface mount versions and many of them come in fine pitch LGA or QFN packaging. This has created a significant challenge for people who just wanted to experiment with these components. The standard soldering technique for LGA/QFN chips is reflow soldering [...]]]></description>
			<content:encoded><![CDATA[<p>Many of the modern chips such as <a href="http://en.wikipedia.org/wiki/Microelectromechanical_systems">MEMS</a> <a href="http://en.wikipedia.org/wiki/Accelerometer">accelerometers</a> and <a href="http://en.wikipedia.org/wiki/Gyroscope">gyroscopes</a> only come in surface mount versions and many of them come in fine pitch <a href="http://en.wikipedia.org/wiki/Land_grid_array">LGA</a> or <a href="http://en.wikipedia.org/wiki/QFN">QFN</a> packaging. This has created a significant challenge for people who just wanted to experiment with these components. The standard soldering technique for LGA/QFN chips is <a href="http://en.wikipedia.org/wiki/Reflow_soldering">reflow soldering</a> which requires special equipment such as reflow oven and hot air rework station. Special surface mount prototyping <a href="http://en.wikipedia.org/wiki/Printed_circuit_board">PCB</a>s are also needed and these PCBs, depending on the size and complexity can be quite expensive and sometimes are pricier than the components themselves.<span id="more-4607"></span></p>
<p>Luckily, most of these LGA and QFN chips can be prototyped on the typical 2.54 mm drill hole spacing protoboard. In this post, I will use <a href="http://www.st.com/">STMicroelectronics</a>&#8216; <a href="http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/DATASHEET/CD00254143.pdf">LPY450AL</a> dual-axis gyroscope IC as an example to show how to hand solder this kind of fine pitch chips on a protoboard. I have used similar techniques extensively in many of my previous projects (<a href="http://www.kerrywong.com/2010/04/16/interfacing-lis3lv02dl-using-spi-i/">1</a>, <a href="http://www.kerrywong.com/2010/07/16/an-arduino-compatible-using-cp2102/">2</a>, <a href="http://www.kerrywong.com/2010/10/24/rf-data-link-using-si4021-and-si4311/">3</a>). When done properly, this technique can be used in prototyping most lower pin count LGA/QFN chips. Even some chips in the RF range (such as <a href="http://www.silabs.com/Support%20Documents/TechnicalDocs/Si4311.pdf">Si4301</a>) can be prototyped <a href="http://www.kerrywong.com/2010/10/24/rf-data-link-using-si4021-and-si4311/">this way</a>. </p>
<p>LPY450AL comes as a tiny LGA-28 chip measuring at just 4x5x1mm. The pad spacing is very small (0.5 mm). But this chip can be soldered using a standard fine-tip soldering iron with some practice and patience.</p>
<h4>Chip Placement</h4>
<p>Chip should be placed on the component side of the board with pads facing up. Depending on the external components used for your particular circuit, you will need to decide where on the board the chip should be placed. Since LPY450AL requires only a handful of external components, I put it at the center of a small protoboard (see below).</p>
<div id="attachment_4610" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/09/ChipPlacement.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/09/ChipPlacement-300x225.jpg" alt="Chip Placement" title="Chip Placement" width="300" height="225" class="size-medium wp-image-4610" /></a><p class="wp-caption-text">Chip Placement</p></div>
<p>Since the chip is flipped upside down, you will need to pay special attention to the pin numbering. I placed a black mark at the top right corner of the board to indicate the location of pin 1. This chip has a tiny marking near pin 1 as well but not all chips have such identification on the bottom side. Also, the pin ordering would now be clockwise instead of counter clockwise when viewed from the top.</p>
<p>After you are satisfied with the chip placement, use a drop of super glue to glue the chip in place. A pair of tweezers will come in handy for some fine adjustments.</p>
<h4>Tinning The Pads</h4>
<p>You will need to use a soldering iron with a fine tip. If you have a temperature controlled iron, try setting it to the lowest recommended temperature for the type of solder you are using. For Pb-free solder, this temperature should be around  245 degree Celsius and for Sn-Pb solder, the temperature should be around 215 Celsius. If you do not have a temperature controlled soldering iron, you can use a small wattage one (e.g. 15W-25W) attached to a dimmer switch (note, dimmer switch does not regulate the temperature of the iron. Since the pads and wires we are dealing with are very tiny, the temperature change of the iron tip is quite negligible). You can test the iron tip temperature using a thin piece of solder. The temperature should be adjusted such that it is just adequate to melt the solder. Since the pads on these LGA/QFN chips are very fragile, too high of a temperature can result in the detachment of the pads and essentially ruin the chip. You will be warned on this multiple times later.</p>
<p>The picture below shows the soldering iron I used (no temperature control). </p>
<div id="attachment_4611" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/09/SolderingIronUsed.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/09/SolderingIronUsed-300x225.jpg" alt="Fine Tip Soldering Iron" title="Fine Tip Soldering Iron" width="300" height="225" class="size-medium wp-image-4611" /></a><p class="wp-caption-text">Fine Tip Soldering Iron</p></div>
<p>The pads should be tinned first prior to soldering. To tin the pads, first apply some flux on them, and then use the tip of the soldering iron to gently touch each individual pads. Note that the pads on LGA/QFN devices are not designed to withstand excessive force, do not use the tip to drag laterally on the pads as they may come off as a result. Since the surface area of each pad is extremely small, it heats up quickly and usually a pad can be tinned within a second of iron contact.</p>
<p>Here is a picture I took after the pads were tinned. Depending on the type of flux you used, you may or may not need to clean up the flux residue.</p>
<div id="attachment_4612" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/09/TinnedPads.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/09/TinnedPads-300x225.jpg" alt="Tinned Pads" title="Tinned Pads" width="300" height="225" class="size-medium wp-image-4612" /></a><p class="wp-caption-text">Tinned Pads</p></div>
<h4>Soldering</h4>
<p>I would highly recommend using the copper wires within the stranded hookup wire for this task. For each pad, a single strand should be used. Thin magnetic wires could be used as well, but you will need to remove the insulation layer carefully prior to soldering to ensure good connectivity.</p>
<p>Wires should first be soldered onto the pads on the chip and then soldered onto the protoboard. Before soldering on to the pad, the tip of the wire should first be tinned. Then, carefully place the tip of the wire onto the pad. Use the tip of the iron to briefly tap the wire from above. With a little bit of pressure, the wire should bound to the already tinned pad. Again, do not rub the pad with the tip of iron to prevent pad from detaching. After removing the soldering iron, wait for a few seconds for the joint to cool and then gently pull the wire to ensure that it is soldered onto the pad. </p>
<p>Then, the other end of the wire can be soldered on to the protoboard. Since the wire is very thin, you do not have to worry about it coming off the soldering pad as a result of soldering it on to the protoboard.</p>
<div id="attachment_4613" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/09/OnePadSoldered.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/09/OnePadSoldered-300x225.jpg" alt="One Pad Soldered" title="One Pad Soldered" width="300" height="225" class="size-medium wp-image-4613" /></a><p class="wp-caption-text">One Pad Soldered</p></div>
<p>It might be easier to solder all the pads first since it could be a bit more difficult to fix the connections on the pads once the wires are already soldered onto the protoboard. Sometimes the already soldered wire could come off the pad due to the heat generated while soldering on an adjacent pad (use the finest tip you have to avoid this issue). It would be easier to redo the soldering when the other end of the wire is still free.</p>
<p>Try keeping the wires as short as possible to minimize the stray capacitance and inductance, especially when dealing with circuit that runs at higher frequencies. </p>
<p>Again, it is important for the soldering tip not to stay on each pad for too long at any given time. Typically, a couple of seconds should be sufficient to get the job done. If you need to touch up your work, wait till the pads cool down first before trying again. Also, always apply force perpendicular to the pads. All these precautions can greatly reduce the risk of damaging the chip while soldering.</p>
<div id="attachment_4614" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/09/MultiplePadsSoldered.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/09/MultiplePadsSoldered-300x225.jpg" alt="Multiple Pads Soldered" title="Multiple Pads Soldered" width="300" height="225" class="size-medium wp-image-4614" /></a><p class="wp-caption-text">Multiple Pads Soldered</p></div>
<p>Here is the completed LPY450AL experiment board. You can see how tiny the chip is compared to the rest of the circuit components. To put things in scale, the resistors I used are 1/16 watt. </p>
<div id="attachment_4615" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.kerrywong.com/blog/wp-content/uploads/2011/09/LPY450ALBoard.jpg"><img src="http://www.kerrywong.com/blog/wp-content/uploads/2011/09/LPY450ALBoard-300x225.jpg" alt="Finished LPY450AL Board" title="Finished LPY450AL Board" width="300" height="225" class="size-medium wp-image-4615" /></a><p class="wp-caption-text">Finished LPY450AL Board</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.kerrywong.com/2011/09/25/hand-soldering-fine-pitch-lga-chip/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

