<?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>imsolidstate &#187; LCD</title>
	<atom:link href="http://www.imsolidstate.com/archives/tag/lcd/feed" rel="self" type="application/rss+xml" />
	<link>http://www.imsolidstate.com</link>
	<description>Always improving things...</description>
	<lastBuildDate>Wed, 04 Jan 2012 22:32:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Build a spot welder from a battery charger</title>
		<link>http://www.imsolidstate.com/archives/590</link>
		<comments>http://www.imsolidstate.com/archives/590#comments</comments>
		<pubDate>Thu, 11 Mar 2010 04:53:39 +0000</pubDate>
		<dc:creator>imsolidstate</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[ATMega]]></category>
		<category><![CDATA[AVR]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[Current sense]]></category>
		<category><![CDATA[LCD]]></category>
		<category><![CDATA[PCB]]></category>

		<guid isPermaLink="false">http://www.imsolidstate.com/?p=590</guid>
		<description><![CDATA[I ran across a battery charger a while ago that was collecting dust. I looked inside and saw the transformer, heatsinks, high current bridge rectifier and SCR and knew I could do something with it. So I turned it into a spot welder.

I originally intended this project to weld thin sheetmetal tabs to stuff to [...]]]></description>
			<content:encoded><![CDATA[<p>I ran across a battery charger a while ago that was collecting dust. I looked inside and saw the transformer, heatsinks, high current bridge rectifier and SCR and knew I could do something with it. So I turned it into a spot welder.</p>
<p><img class="size-large wp-image-598 alignnone" title="Spot Welder" src="http://www.imsolidstate.com/wp-content/uploads/2010/03/SpotWelder-028-1024x768.jpg" alt="SpotWelder 028" width="645" height="484" /></p>
<p>I originally intended this project to weld thin sheetmetal tabs to stuff to act as solder tabs. The project has not been as easy as I originally thought though. (It also suffered some scope creep) It&#8217;s my first crack at 5V logic mixed with line AC voltage, and for rolling my own power supply. I used a step-down transformer, bridge regulator and a capacitor to feed an LDO regulator for the control circuit. With the low current draw of the controller, the voltage input to the regulator was relatively free from any ripple thanks to the capacitor.</p>
<p>I ended up frying a processor, LCD, and a couple other components due to a dumb move while troubleshooting the circuit, and overlooking a capacitor&#8217;s voltage rating. 120VAC will eat 5V stuff for lunch.</p>
<p><img class="alignnone size-large wp-image-599" title="Spot Welder guts" src="http://www.imsolidstate.com/wp-content/uploads/2010/03/SpotWelder-030-1024x768.jpg" alt="Spot Welder guts" width="645" height="484" /></p>
<p>The control circuit basically modulates the SCR, which is hooked up to the output of the bridge rectifier after a step-down transformer. The controller allows for adjustment of duration of the weld and amount of the rectified AC phase that is delivered to the workpiece. The controller holds off the SCR until a pre-determined time of each half phase to control power delivery. An analog comparator detects the zero point of the phase for timing purposes, via a seperate bridge rectifier that has it&#8217;s ouput fed through a large resistor to the comparator. A zener clamps the current-limited voltage at 4.8V so as not to damage the micro&#8217;s input. A high-to-low transition on the comparator triggers the zero crossing timer. The threshhold voltage is adjustable by an on-board pot.</p>
<p>I also added an Allegro hall effect current sensor that I had lying around from my <a href="http://www.imsolidstate.com/archives/9">alternator current sense project</a>. It&#8217;s overkill, but it measures the amount of peak current being delivered and displays it on the LCD.</p>
<p><img class="size-medium wp-image-603 alignleft" title="SpotWelder 034" src="http://www.imsolidstate.com/wp-content/uploads/2010/03/SpotWelder-0341-300x225.jpg" alt="SpotWelder 034" width="300" height="225" /></p>
<p>The controller is an ATmega88PA running at 8Mhz. Firmware is written in C with AVRStudio and AVR-GCC. The micro reads the power and duration settings, displays that on the LCD, along with the max current for the last weld cycle and the temperature of the mega&#8217;s on-chip sensor. The controller also handles timing duties, zero crossing detection, and control of the SCR gate. The gate is fired by a P-channel MOSFET, with the FET&#8217;s gate driven by an NPN BJT on one of the micro&#8217;s pins. A footswitch is used as input to the micro to trigger a weld cycle. Both the footswitch input and the zero crossings are buffered by a simple three-sample debouncing routine to prevent erroneous triggers. The system also checks for the footswitch input on power up and after the weld cycle is complete, and waits if the footswitch is down with a message on the LCD to release the footswitch. This allows for safety as well as eliminating any unintended re-triggers at very short durations. Duration is adjustable from roughly one ac cycle to 60 cycles (1 sec). Power control allows from 5% to 95% of each half phase to be delivered to the workpiece.</p>
<p>The SCR&#8217;s cathode voltage is available at PORTC2 as a 10:1 voltage divider, and clamped with a zener to prevent damage to the micro. I didn&#8217;t need it, so it&#8217;s not used in the code.</p>
<p>I&#8217;ve also added a power resistor to the output to limit current. I used carbon-carbon as a power resistor (I work in a carbon plant) since it&#8217;s free and power resistors are expensive. You only need a few tenths of an ohm to limit the current to a level that won&#8217;t destroy the diodes and SCR. I&#8217;m overdriving mine at about 130A maximum. It seems to handle it fine for the short bursts.  [Edit: 130A isn't enough though. I may rewire so the diodes/SCR are on the input side and push the current higher by removing or modifying the resistor. Pressure of the electrodes on the joint is also important, still figuring that out.]</p>
<p>Here&#8217;s some drive waveforms: yellow is the output voltage (it&#8217;s at 50V/div so it looks small), purple is the output current measured by the hall sensor, blue is the FET&#8217;s gate that turns on the SCR, and green is the bridge voltage.</p>
<p><img class="alignnone size-medium wp-image-604" title="Low drive" src="http://www.imsolidstate.com/wp-content/uploads/2010/03/SpotWelder-031-300x225.jpg" alt="Low drive" width="300" height="225" /><img class="alignnone size-medium wp-image-605" title="Medium drive" src="http://www.imsolidstate.com/wp-content/uploads/2010/03/SpotWelder-032-300x225.jpg" alt="Medium drive" width="300" height="225" /></p>
<p>This project has got me thinking about modifying my old &#8221;buzzbox&#8221; AC welder. I&#8217;ve got some big capacitors and IGBTs from a couple old motor drives that could give me a really nice TIG welding power supply. I think I&#8217;ve read you can weld high frequency (1-2kHz?) square-wave without needing any HF section. If I remember right square-wave with a positive DC offset is sort of the ultimate TIG welder. Anybody with comments or information about that feel free to drop me a line.</p>
<p>Continue reading for the schematic, PCB layout, and code.</p>
<p>References: <a href="http://www.millerwelds.com/pdf/Resistance.pdf">Miller Resistance Spot Welding</a></p>
<p><span id="more-590"></span></p>
<p>The schematic: (Click on the picture for full size)</p>
<p><a href="http://www.imsolidstate.com/wp-content/uploads/2010/03/SpotWelderSchem3.png"><img class="alignnone size-large wp-image-659" title="SpotWelder Schematic" src="http://www.imsolidstate.com/wp-content/uploads/2010/03/SpotWelderSchem3-1024x528.png" alt="SpotWelder Schematic" width="645" height="333" /></a></p>
<p>The board: (Click for full-size image)</p>
<p><a href="http://www.imsolidstate.com/wp-content/uploads/2010/03/SpotWelderLayout3.png"><img class="alignnone size-large wp-image-661" title="SpotWelder Layout" src="http://www.imsolidstate.com/wp-content/uploads/2010/03/SpotWelderLayout3-1024x822.png" alt="SpotWelder Layout" width="645" height="518" /></a></p>
<p>And the code. I think it&#8217;s all correct but I had to rewire a couple things on mine so you might do well to doublecheck the I/O is all correct.</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>#include &lt;avr/io.h&gt;<br />
#include &lt;util/delay.h&gt;<br />
#include &lt;avr/interrupt.h&gt;<br />
//#include &lt;avr/wdt.h&gt; // can&#8217;t get the watchdog to work yet</p>
<p>#define F_CPU 8000000; //8MHz</p>
<p>//function declarations<br />
void lcd_write_byte(unsigned char CONTROL, unsigned char DATA);<br />
void initLCD(void);<br />
void updateLCD(void);<br />
void switch_up(void);<br />
void weld_message(void);</p>
<p>//global variables<br />
volatile unsigned int power, duration, temperature;<br />
volatile unsigned char current, max_current;</p>
<p>void main(void)<br />
{<br />
 unsigned int old_power, old_duration= 0; //variables for comparison</p>
<p> PRR &amp;= ~(1&lt;&lt;PRADC);  //disable ADC power reduction<br />
 ADMUX |= (1&lt;&lt;REFS0); //setup VCC as reference<br />
 ADMUX |= (1&lt;&lt;ADLAR); //left adjust result for 8 bit ADC<br />
 ADCSRA |= (1&lt;&lt;ADPS0)|(1&lt;&lt;ADPS1)|(1&lt;&lt;ADPS2); //prescaler clk/64 125kHz @ 8MHz clock<br />
 ADCSRA |= (1&lt;&lt;ADEN); //enable ADC</p>
<p> TCCR1B |= (1&lt;&lt;CS10); //enable timer1, no prescale (clk/1)</p>
<p> ACSR |= (1&lt;&lt;ACIS1); //enable analog comparator falling edge interrupt<br />
 ACSR |= (1&lt;&lt;ACIE); //enable analog comparator interrupt</p>
<p> DDRC |= (1&lt;&lt;PORTC3); //SCR gate drive<br />
 DDRC &amp;= ~((1&lt;&lt;PORTC0)|(1&lt;&lt;PORTC1)|(1&lt;&lt;PORTC2)); //set as input<br />
 PORTC &amp;= ~((1&lt;&lt;PORTC0)|(1&lt;&lt;PORTC1)|(1&lt;&lt;PORTC2)); //PUD</p>
<p> DDRD |= (1&lt;&lt;PORTD0)|(1&lt;&lt;PORTD1)|(1&lt;&lt;PORTD2)|(1&lt;&lt;PORTD3)|(1&lt;&lt;PORTD4)|(1&lt;&lt;PORTD5);<br />
 DDRD &amp;= ~((1&lt;&lt;PORTD6)|(1&lt;&lt;PORTD7)); //set as input<br />
 PORTD &amp;= ~((1&lt;&lt;PORTD6)|(1&lt;&lt;PORTD7)); //PUD</p>
<p> DDRB &amp;= ~(1&lt;&lt;PORTB0);  //footswitch input<br />
 PORTB &amp;= ~(1&lt;&lt;PORTB0);  //PUD</p>
<p> initLCD(); //set up LCD</p>
<p> switch_up(); //check footswitch</p>
<p> max_current= 0&#215;7F;<br />
 updateLCD(); //display settings</p>
<p>// wdt_reset(); //reset the watchdog timer<br />
// WDTCSR |= (1&lt;&lt;WDCE)|(1&lt;&lt;WDE); //clear the system reset/ change enable bits<br />
// WDTCSR |= (1&lt;&lt;WDE)|(1&lt;&lt;WDP0)|(1&lt;&lt;WDP1)|(1&lt;&lt;WDP2); //set new prescaler, 2 seconds</p>
<p> <br />
 while(1)<br />
 {<br />
  old_power= power;  //set up the comparsison value before getting new value<br />
  ADMUX &amp;= ~((1&lt;&lt;MUX0)|(1&lt;&lt;MUX1)|(1&lt;&lt;MUX2)|(1&lt;&lt;MUX3)); //sample ADC0 (power setting)<br />
  ADCSRA |= (1&lt;&lt;ADSC); //start conversion<br />
  while(ADCSRA &amp; (1&lt;&lt;ADSC)){} //wait for conversion<br />
  power= ADCH;<br />
  power*= 234; //scale power for use later: ((2^8)*234)= 59904 max value<br />
      //59904 clk cycles= (1/8000000)*59904= 7.5ms<br />
      //7.5ms= (.0075/(1/120))*100= 90% of one half wave (60Hz)<br />
      //with these values power can be up to 90% of each half wave,<br />
      //which with the 5% coded into the ISR, yields a range of 5%-95%.</p>
<p>  old_duration= duration;  //set up the comparsison value before getting new value<br />
  ADMUX |= (1&lt;&lt;MUX0);  //sample ADC1 (duration setting)<br />
  ADCSRA |= (1&lt;&lt;ADSC); //start conversion<br />
  while(ADCSRA &amp; (1&lt;&lt;ADSC)){} //wait for conversion<br />
  duration= ADCH; <br />
  duration= (duration&gt;&gt;1); //convert to 7-bit number, limits duration to ~1 second<br />
  if(duration&lt;=0&#215;0007) duration= 0&#215;0000;<br />
   else duration-= 0&#215;0007; //subtract 7 so duration can&#8217;t exceed 3 digits (999ms)</p>
<p>  ADMUX &amp;= ~((1&lt;&lt;MUX0)|(1&lt;&lt;MUX1)|(1&lt;&lt;MUX2));  //set up for ADC8 (temp)<br />
  ADMUX |= (1&lt;&lt;MUX3);<br />
  ADMUX |= (1&lt;&lt;REFS0)|(1&lt;&lt;REFS1);  //1.1V ADC reference<br />
  ADMUX &amp;= ~(1&lt;&lt;ADLAR); //undo left adjust result for 8 bit ADC <br />
  ADCSRA |= (1&lt;&lt;ADSC); //start conversion<br />
  while(ADCSRA &amp; (1&lt;&lt;ADSC)){} //wait for conversion<br />
  temperature= ADC;<br />
  temperature/= 12;  //scale temp value to degrees C <br />
  ADMUX |= (1&lt;&lt;ADLAR);  //restore left adjust result <br />
  ADMUX &amp;= ~(1&lt;&lt;REFS1);  //restore VCC ADC reference</p>
<p>  if(power!=old_power) updateLCD(); //update LCD if values changed<br />
  else if(duration!=old_duration) updateLCD();<br />
  if((!(PINB &amp; (1&lt;&lt;PINB0))) &amp; (duration&gt;0)) //check for footswitch input<br />
  {           <br />
   char j= 0;</p>
<p>      for(j= 0;j&lt; 3;)  //three sample noise filter<br />
   {<br />
    if(!(PINB &amp; (1&lt;&lt;PINB0))) j++;  //increment loop value if PORTC2 (fsw) is low<br />
    else j= 4;  //break out of the loop if high<br />
      }  <br />
                        <br />
      if(j==3)  //should only get here if we got three low samples<br />
   {<br />
    weld_message();<br />
    ADMUX |= (1&lt;&lt;MUX0)|(1&lt;&lt;MUX1)|(1&lt;&lt;MUX2); //sample ADC7 (current sensor)<br />
    ADMUX &amp;= ~(1&lt;&lt;MUX3);<br />
    ADCSRA |= (1&lt;&lt;ADATE); //ADC free runnnng mode<br />
    ADCSRA |= (1&lt;&lt;ADSC); //start conversion<br />
    _delay_us(5); //wait for ADC&#8217;s first reading<br />
    max_current= 0&#215;0000;  //reset max current from last cycle<br />
    sei();<br />
    while((!(PINB &amp; (1&lt;&lt;PINB0))) &amp; (duration&gt;0)){}  //wait for zero cross<br />
    cli();<br />
    ADCSRA &amp;= ~(1&lt;&lt;ADATE);  //turn off free running<br />
    switch_up(); //wait for footswitch release<br />
    updateLCD();<br />
   }<br />
  } <br />
 }<br />
}</p>
<p> <br />
ISR (ANALOG_COMP_vect)<br />
{ <br />
 char i= 0;</p>
<p>    for(i= 0;i&lt; 3;)  //three sample noise filter<br />
 {<br />
  if(!(ACSR &amp; (1&lt;&lt;ACO))) i++;  //increment loop value if ACO is low<br />
  else i= 4;  //break out of the loop if high<br />
    }  <br />
                        <br />
    if(i==3)  //should only get here if we got three low samples,  <br />
 {    //which indicates a zero crossing.  <br />
  TCNT1= 0;<br />
  while(TCNT1&lt; power){} //wait for phase rotation<br />
  PORTC |= (1&lt;&lt;PORTC3); //fire SCR<br />
  while(TCNT1&lt; 63333)  //wait for 7.9ms, 95% of one half cycle (60Hz)<br />
  {<br />
   current= ADCH;<br />
   if(current&gt;max_current) max_current= current;  //record the highest value<br />
  } <br />
  PORTC &amp;= ~(1&lt;&lt;PORTC3);  //turn off SCR gate<br />
  duration&#8211;;<br />
 }<br />
}</p>
<p> </p>
<p>void initLCD(void)<br />
{<br />
 _delay_ms(250);  // Wait for HD44780<br />
 PORTD &amp;= ~(1&lt;&lt;PORTD4);<br />
 PORTD |= (1&lt;&lt;PORTD1);<br />
 PORTD |= (1&lt;&lt;PORTD0);  <br />
 PORTD |= (1&lt;&lt;PORTD5); // function set<br />
 _delay_ms(2);<br />
 PORTD &amp;= ~(1&lt;&lt;PORTD5);<br />
 _delay_ms(20);  <br />
 PORTD |= (1&lt;&lt;PORTD5); // function set<br />
 _delay_ms(2);<br />
 PORTD &amp;= ~(1&lt;&lt;PORTD5);<br />
 _delay_ms(10);  <br />
 PORTD |= (1&lt;&lt;PORTD5); // function set<br />
 _delay_ms(2);<br />
 PORTD &amp;= ~(1&lt;&lt;PORTD5);<br />
 _delay_ms(10);<br />
 PORTD &amp;= ~(1&lt;&lt;PORTD0);<br />
 PORTD |= (1&lt;&lt;PORTD5); // initialize to 4 bit<br />
 _delay_ms(2);<br />
 PORTD &amp;= ~(1&lt;&lt;PORTD5);<br />
 _delay_ms(10);</p>
<p> lcd_write_byte(0,0&#215;28);  //set interface width, # of lines, and font size<br />
 lcd_write_byte(0,0&#215;0C);  //display on<br />
 lcd_write_byte(0,0&#215;01);  //clear display<br />
 lcd_write_byte(0,0&#215;06);  //increment address by one, shift cursor at write<br />
}</p>
<p> </p>
<p>void lcd_write_byte(unsigned char CONTROL, unsigned char DATA)<br />
{<br />
 if(CONTROL == 1) PORTD |= (1&lt;&lt;PORTD4); else PORTD &amp;= ~(1&lt;&lt;PORTD4);<br />
 if((DATA &amp; 0&#215;80) == 0&#215;80) PORTD |= (1&lt;&lt;PORTD3); else PORTD &amp;= ~(1&lt;&lt;PORTD3);<br />
 if((DATA &amp; 0&#215;40) == 0&#215;40) PORTD |= (1&lt;&lt;PORTD2); else PORTD &amp;= ~(1&lt;&lt;PORTD2);<br />
 if((DATA &amp; 0&#215;20) == 0&#215;20) PORTD |= (1&lt;&lt;PORTD1); else PORTD &amp;= ~(1&lt;&lt;PORTD1);<br />
 if((DATA &amp; 0&#215;10) == 0&#215;10) PORTD |= (1&lt;&lt;PORTD0); else PORTB &amp;= ~(1&lt;&lt;PORTD0);<br />
 PORTD |= (1&lt;&lt;PORTD5);<br />
 _delay_ms(1);<br />
 PORTD &amp;= ~(1&lt;&lt;PORTD5);</p>
<p> if((DATA &amp; 0&#215;08) == 0&#215;08) PORTD |= (1&lt;&lt;PORTD3); else PORTD &amp;= ~(1&lt;&lt;PORTD3);<br />
 if((DATA &amp; 0&#215;04) == 0&#215;04) PORTD |= (1&lt;&lt;PORTD2); else PORTD &amp;= ~(1&lt;&lt;PORTD2);<br />
 if((DATA &amp; 0&#215;02) == 0&#215;02) PORTD |= (1&lt;&lt;PORTD1); else PORTD &amp;= ~(1&lt;&lt;PORTD1);<br />
 if((DATA &amp; 0&#215;01) == 0&#215;01) PORTD |= (1&lt;&lt;PORTD0); else PORTD &amp;= ~(1&lt;&lt;PORTD0);<br />
 PORTD |= (1&lt;&lt;PORTD5);<br />
 _delay_ms(2);<br />
 PORTD &amp;= ~(1&lt;&lt;PORTD5);<br />
 _delay_ms(10);<br />
}</p>
<p> </p>
<p>void updateLCD(void)<br />
{<br />
 unsigned int temp_duration, temp_power, temp_max_current;<br />
 <br />
 temp_duration= (duration*8); //scale duration for BCD conversion to milliseconds          //<br />
 unsigned int duration_BCD= ((((temp_duration/10)+((temp_duration/100)*6))*16)+(temp_duration%10));<br />
 <br />
 unsigned char ONES= 0&#215;00;<br />
 unsigned char TENS= 0&#215;00;<br />
 unsigned char HUND= 0&#215;00;</p>
<p> if((duration_BCD &amp; 0&#215;0800) == 0&#215;0800) HUND |= 0&#215;08; else HUND &amp;= ~0&#215;08;<br />
 if((duration_BCD &amp; 0&#215;0400) == 0&#215;0400) HUND |= 0&#215;04; else HUND &amp;= ~0&#215;04;<br />
 if((duration_BCD &amp; 0&#215;0200) == 0&#215;0200) HUND |= 0&#215;02; else HUND &amp;= ~0&#215;02;<br />
 if((duration_BCD &amp; 0&#215;0100) == 0&#215;0100) HUND |= 0&#215;01; else HUND &amp;= ~0&#215;01;</p>
<p> if((duration_BCD &amp; 0&#215;0080) == 0&#215;0080) TENS |= 0&#215;08; else TENS &amp;= ~0&#215;08;<br />
 if((duration_BCD &amp; 0&#215;0040) == 0&#215;0040) TENS |= 0&#215;04; else TENS &amp;= ~0&#215;04;<br />
 if((duration_BCD &amp; 0&#215;0020) == 0&#215;0020) TENS |= 0&#215;02; else TENS &amp;= ~0&#215;02;<br />
 if((duration_BCD &amp; 0&#215;0010) == 0&#215;0010) TENS |= 0&#215;01; else TENS &amp;= ~0&#215;01;</p>
<p> if((duration_BCD &amp; 0&#215;0008) == 0&#215;0008) ONES |= 0&#215;08; else ONES &amp;= ~0&#215;08;<br />
 if((duration_BCD &amp; 0&#215;0004) == 0&#215;0004) ONES |= 0&#215;04; else ONES &amp;= ~0&#215;04;<br />
 if((duration_BCD &amp; 0&#215;0002) == 0&#215;0002) ONES |= 0&#215;02; else ONES &amp;= ~0&#215;02;<br />
 if((duration_BCD &amp; 0&#215;0001) == 0&#215;0001) ONES |= 0&#215;01; else ONES &amp;= ~0&#215;01;</p>
<p> ONES |= 0&#215;30;<br />
 TENS |= 0&#215;30;<br />
 HUND |= 0&#215;30;</p>
<p> lcd_write_byte(0&#215;00, 0&#215;01); //clear screen<br />
 lcd_write_byte(0&#215;01, 0&#215;20); //space<br />
 lcd_write_byte(0&#215;01, 0&#215;20); //space<br />
 lcd_write_byte(0&#215;01, 0&#215;20); //space<br />
 lcd_write_byte(0&#215;01, HUND);<br />
 lcd_write_byte(0&#215;01, TENS);<br />
 lcd_write_byte(0&#215;01, ONES);<br />
 lcd_write_byte(0&#215;01, 0&#215;20); //space<br />
 lcd_write_byte(0&#215;01, 0&#215;6D); //&#8217;m&#8217;<br />
 lcd_write_byte(0&#215;01, 0&#215;69); //&#8217;i&#8217;<br />
 lcd_write_byte(0&#215;01, 0&#215;6C); //&#8217;l&#8217;<br />
 lcd_write_byte(0&#215;01, 0&#215;6C); //&#8217;l&#8217;<br />
 lcd_write_byte(0&#215;01, 0&#215;69); //&#8217;i&#8217;<br />
 lcd_write_byte(0&#215;01, 0&#215;73); //&#8217;s&#8217;<br />
 lcd_write_byte(0&#215;01, 0&#215;65); //&#8217;e&#8217;<br />
 lcd_write_byte(0&#215;01, 0&#215;63); //&#8217;c&#8217;<br />
 lcd_write_byte(0&#215;01, 0&#215;6F); //&#8217;o&#8217;<br />
 lcd_write_byte(0&#215;01, 0&#215;6E); //&#8217;n&#8217;<br />
 lcd_write_byte(0&#215;01, 0&#215;64); //&#8217;d&#8217;<br />
 lcd_write_byte(0&#215;01, 0&#215;73); //&#8217;s&#8217;<br />
 temp_power= (power/665);  //scale power for BCD conversion to percent<br />
 temp_power=(95-temp_power);<br />
 unsigned int power_BCD= ((temp_power/10)*16)+(temp_power%10);</p>
<p> ONES= 0&#215;00;<br />
 TENS= 0&#215;00;</p>
<p> if((power_BCD &amp; 0&#215;0080) == 0&#215;0080) TENS |= 0&#215;08; else TENS &amp;= ~0&#215;08;<br />
 if((power_BCD &amp; 0&#215;0040) == 0&#215;0040) TENS |= 0&#215;04; else TENS &amp;= ~0&#215;04;<br />
 if((power_BCD &amp; 0&#215;0020) == 0&#215;0020) TENS |= 0&#215;02; else TENS &amp;= ~0&#215;02;<br />
 if((power_BCD &amp; 0&#215;0010) == 0&#215;0010) TENS |= 0&#215;01; else TENS &amp;= ~0&#215;01;</p>
<p> if((power_BCD &amp; 0&#215;0008) == 0&#215;0008) ONES |= 0&#215;08; else ONES &amp;= ~0&#215;08;<br />
 if((power_BCD &amp; 0&#215;0004) == 0&#215;0004) ONES |= 0&#215;04; else ONES &amp;= ~0&#215;04;<br />
 if((power_BCD &amp; 0&#215;0002) == 0&#215;0002) ONES |= 0&#215;02; else ONES &amp;= ~0&#215;02;<br />
 if((power_BCD &amp; 0&#215;0001) == 0&#215;0001) ONES |= 0&#215;01; else ONES &amp;= ~0&#215;01;</p>
<p> ONES |= 0&#215;30;<br />
 TENS |= 0&#215;30;</p>
<p> lcd_write_byte(0&#215;00, 0xC0); //go to second line<br />
 lcd_write_byte(0&#215;01, 0&#215;20); //space<br />
 lcd_write_byte(0&#215;01, 0&#215;20); //space<br />
 lcd_write_byte(0&#215;01, TENS);<br />
 lcd_write_byte(0&#215;01, ONES);<br />
 lcd_write_byte(0&#215;01, 0&#215;25); //&#8217;%&#8217;<br />
 lcd_write_byte(0&#215;01, 0&#215;20); //space<br />
 lcd_write_byte(0&#215;01, 0&#215;6F); //&#8217;o&#8217;<br />
 lcd_write_byte(0&#215;01, 0&#215;66); //&#8217;f&#8217;<br />
 lcd_write_byte(0&#215;01, 0&#215;20); //space<br />
 lcd_write_byte(0&#215;01, 0&#215;70); //&#8217;p&#8217;<br />
 lcd_write_byte(0&#215;01, 0&#215;68); //&#8217;h&#8217;<br />
 lcd_write_byte(0&#215;01, 0&#215;61); //&#8217;a&#8217;<br />
 lcd_write_byte(0&#215;01, 0&#215;73); //&#8217;s&#8217;<br />
 lcd_write_byte(0&#215;01, 0&#215;65); //&#8217;e&#8217;<br />
 temp_max_current= max_current;<br />
 temp_max_current-= 0&#215;7F;  //remove 2.5V sensor offset<br />
 temp_max_current*= 3; //scaling<br />
 temp_max_current/= 2; //scaling</p>
<p> unsigned int max_current_BCD= ((((temp_max_current/10)+((temp_max_current/100)*6))*16)+(temp_max_current%10));<br />
 <br />
 ONES= 0&#215;00;<br />
 TENS= 0&#215;00;<br />
 HUND= 0&#215;00;</p>
<p> if((max_current_BCD &amp; 0&#215;0800) == 0&#215;0800) HUND |= 0&#215;08; else HUND &amp;= ~0&#215;08;<br />
 if((max_current_BCD &amp; 0&#215;0400) == 0&#215;0400) HUND |= 0&#215;04; else HUND &amp;= ~0&#215;04;<br />
 if((max_current_BCD &amp; 0&#215;0200) == 0&#215;0200) HUND |= 0&#215;02; else HUND &amp;= ~0&#215;02;<br />
 if((max_current_BCD &amp; 0&#215;0100) == 0&#215;0100) HUND |= 0&#215;01; else HUND &amp;= ~0&#215;01;</p>
<p> if((max_current_BCD &amp; 0&#215;0080) == 0&#215;0080) TENS |= 0&#215;08; else TENS &amp;= ~0&#215;08;<br />
 if((max_current_BCD &amp; 0&#215;0040) == 0&#215;0040) TENS |= 0&#215;04; else TENS &amp;= ~0&#215;04;<br />
 if((max_current_BCD &amp; 0&#215;0020) == 0&#215;0020) TENS |= 0&#215;02; else TENS &amp;= ~0&#215;02;<br />
 if((max_current_BCD &amp; 0&#215;0010) == 0&#215;0010) TENS |= 0&#215;01; else TENS &amp;= ~0&#215;01;</p>
<p> if((max_current_BCD &amp; 0&#215;0008) == 0&#215;0008) ONES |= 0&#215;08; else ONES &amp;= ~0&#215;08;<br />
 if((max_current_BCD &amp; 0&#215;0004) == 0&#215;0004) ONES |= 0&#215;04; else ONES &amp;= ~0&#215;04;<br />
 if((max_current_BCD &amp; 0&#215;0002) == 0&#215;0002) ONES |= 0&#215;02; else ONES &amp;= ~0&#215;02;<br />
 if((max_current_BCD &amp; 0&#215;0001) == 0&#215;0001) ONES |= 0&#215;01; else ONES &amp;= ~0&#215;01;</p>
<p> ONES |= 0&#215;30;<br />
 TENS |= 0&#215;30;<br />
 HUND |= 0&#215;30;</p>
<p> lcd_write_byte(0&#215;00, 0&#215;95); //go to third line (DDRAM address 0&#215;15)<br />
 lcd_write_byte(0&#215;01, 0&#215;20); //space<br />
 lcd_write_byte(0&#215;01, HUND);<br />
 lcd_write_byte(0&#215;01, TENS);<br />
 lcd_write_byte(0&#215;01, ONES);<br />
 lcd_write_byte(0&#215;01, 0&#215;20); //space<br />
 lcd_write_byte(0&#215;01, 0&#215;61); //&#8217;a&#8217;<br />
 lcd_write_byte(0&#215;01, 0&#215;6D); //&#8217;m&#8217;<br />
 lcd_write_byte(0&#215;01, 0&#215;70); //&#8217;p&#8217;<br />
 lcd_write_byte(0&#215;01, 0&#215;73); //&#8217;s&#8217;<br />
 lcd_write_byte(0&#215;01, 0&#215;20); //space<br />
 lcd_write_byte(0&#215;01, 0&#215;28); //&#8217;(&#8217;<br />
 lcd_write_byte(0&#215;01, 0&#215;6D); //&#8217;m&#8217;<br />
 lcd_write_byte(0&#215;01, 0&#215;61); //&#8217;a&#8217;<br />
 lcd_write_byte(0&#215;01, 0&#215;78); //&#8217;x&#8217;<br />
 lcd_write_byte(0&#215;01, 0&#215;29); //&#8217;)&#8217;</p>
<p> unsigned int temperature_BCD= ((temperature/10)*16)+(temperature%10);<br />
 <br />
 ONES= 0&#215;00;<br />
 TENS= 0&#215;00;</p>
<p> if((temperature_BCD &amp; 0&#215;0080) == 0&#215;0080) TENS |= 0&#215;08; else TENS &amp;= ~0&#215;08;<br />
 if((temperature_BCD &amp; 0&#215;0040) == 0&#215;0040) TENS |= 0&#215;04; else TENS &amp;= ~0&#215;04;<br />
 if((temperature_BCD &amp; 0&#215;0020) == 0&#215;0020) TENS |= 0&#215;02; else TENS &amp;= ~0&#215;02;<br />
 if((temperature_BCD &amp; 0&#215;0010) == 0&#215;0010) TENS |= 0&#215;01; else TENS &amp;= ~0&#215;01;</p>
<p> if((temperature_BCD &amp; 0&#215;0008) == 0&#215;0008) ONES |= 0&#215;08; else ONES &amp;= ~0&#215;08;<br />
 if((temperature_BCD &amp; 0&#215;0004) == 0&#215;0004) ONES |= 0&#215;04; else ONES &amp;= ~0&#215;04;<br />
 if((temperature_BCD &amp; 0&#215;0002) == 0&#215;0002) ONES |= 0&#215;02; else ONES &amp;= ~0&#215;02;<br />
 if((temperature_BCD &amp; 0&#215;0001) == 0&#215;0001) ONES |= 0&#215;01; else ONES &amp;= ~0&#215;01;</p>
<p> ONES |= 0&#215;30;<br />
 TENS |= 0&#215;30;</p>
<p> lcd_write_byte(0&#215;00, 0xD5); //go to fourth line (DDRAM address 0&#215;55)<br />
 lcd_write_byte(0&#215;01, 0&#215;20); //space<br />
 lcd_write_byte(0&#215;01, TENS);<br />
 lcd_write_byte(0&#215;01, ONES);<br />
 lcd_write_byte(0&#215;01, 0xDF); //degree symbol<br />
 lcd_write_byte(0&#215;01, 0&#215;43); //&#8217;C&#8217;<br />
 lcd_write_byte(0&#215;01, 0&#215;20); //space<br />
 lcd_write_byte(0&#215;01, 0&#215;63); //&#8217;c&#8217;<br />
 lcd_write_byte(0&#215;01, 0&#215;61); //&#8217;a&#8217;<br />
 lcd_write_byte(0&#215;01, 0&#215;73); //&#8217;s&#8217;<br />
 lcd_write_byte(0&#215;01, 0&#215;65); //&#8217;e&#8217;<br />
 lcd_write_byte(0&#215;01, 0&#215;20); //space<br />
 lcd_write_byte(0&#215;01, 0&#215;74); //&#8217;t&#8217;<br />
 lcd_write_byte(0&#215;01, 0&#215;65); //&#8217;e&#8217;<br />
 lcd_write_byte(0&#215;01, 0&#215;6D); //&#8217;m&#8217;<br />
 lcd_write_byte(0&#215;01, 0&#215;70); //&#8217;p&#8217;<br />
}</p>
<p> </p>
<p>void switch_up(void)<br />
{<br />
 if(!(PINB &amp; (1&lt;&lt;PINB0)))<br />
 {<br />
  lcd_write_byte(0&#215;00, 0&#215;01); //clear screen<br />
  lcd_write_byte(0&#215;01, 0&#215;20); //space<br />
  lcd_write_byte(0&#215;01, 0&#215;20); //space<br />
  lcd_write_byte(0&#215;01, 0&#215;72); //&#8217;r&#8217;<br />
  lcd_write_byte(0&#215;01, 0&#215;65); //&#8217;e&#8217;<br />
  lcd_write_byte(0&#215;01, 0&#215;6C); //&#8217;l&#8217;<br />
  lcd_write_byte(0&#215;01, 0&#215;65); //&#8217;e&#8217;<br />
  lcd_write_byte(0&#215;01, 0&#215;61); //&#8217;a&#8217;<br />
  lcd_write_byte(0&#215;01, 0&#215;73); //&#8217;s&#8217;<br />
  lcd_write_byte(0&#215;01, 0&#215;65); //&#8217;e&#8217;<br />
  lcd_write_byte(0&#215;01, 0&#215;20); //space<br />
  lcd_write_byte(0&#215;01, 0&#215;66); //&#8217;f&#8217;<br />
  lcd_write_byte(0&#215;01, 0&#215;6F); //&#8217;o&#8217;<br />
  lcd_write_byte(0&#215;01, 0&#215;6F); //&#8217;o&#8217;<br />
  lcd_write_byte(0&#215;01, 0&#215;74); //&#8217;t&#8217;<br />
  lcd_write_byte(0&#215;01, 0&#215;73); //&#8217;s&#8217;<br />
  lcd_write_byte(0&#215;01, 0&#215;77); //&#8217;w&#8217;<br />
  lcd_write_byte(0&#215;01, 0&#215;69); //&#8217;i&#8217;<br />
  lcd_write_byte(0&#215;01, 0&#215;74); //&#8217;t&#8217;<br />
  lcd_write_byte(0&#215;01, 0&#215;63); //&#8217;c&#8217;<br />
  lcd_write_byte(0&#215;01, 0&#215;68); //&#8217;h&#8217;<br />
  while(!(PINB &amp; (1&lt;&lt;PINB0))){};<br />
 }<br />
}</p>
<p> </p>
<p>void weld_message(void)<br />
{<br />
  lcd_write_byte(0&#215;00, 0&#215;01); //clear screen<br />
  lcd_write_byte(0&#215;01, 0&#215;20); //space<br />
  lcd_write_byte(0&#215;01, 0&#215;20); //space<br />
  lcd_write_byte(0&#215;01, 0&#215;77); //&#8217;w&#8217;<br />
  lcd_write_byte(0&#215;01, 0&#215;65); //&#8217;e&#8217;<br />
  lcd_write_byte(0&#215;01, 0&#215;6C); //&#8217;l&#8217;<br />
  lcd_write_byte(0&#215;01, 0&#215;64); //&#8217;d&#8217;<br />
  lcd_write_byte(0&#215;01, 0&#215;69); //&#8217;i&#8217;<br />
  lcd_write_byte(0&#215;01, 0&#215;6E); //&#8217;n&#8217;<br />
  lcd_write_byte(0&#215;01, 0&#215;67); //&#8217;g&#8217;<br />
  lcd_write_byte(0&#215;01, 0&#215;2E); //&#8217;.&#8217;<br />
  lcd_write_byte(0&#215;01, 0&#215;2E); //&#8217;.&#8217;<br />
  lcd_write_byte(0&#215;01, 0&#215;2E); //&#8217;.&#8217;<br />
}</p>
]]></content:encoded>
			<wfw:commentRss>http://www.imsolidstate.com/archives/590/feed</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Digital RPM indicator</title>
		<link>http://www.imsolidstate.com/archives/104</link>
		<comments>http://www.imsolidstate.com/archives/104#comments</comments>
		<pubDate>Wed, 26 Aug 2009 17:40:42 +0000</pubDate>
		<dc:creator>imsolidstate</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[ATtiny]]></category>
		<category><![CDATA[AVR]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[LCD]]></category>
		<category><![CDATA[RPM]]></category>

		<guid isPermaLink="false">http://www.imsolidstate.com/?p=104</guid>
		<description><![CDATA[
I made a circuit for RPM measurement based on an Atmel ATtiny24 to drive a Hitachi 44780 parallel interface character LCD. It uses an external interrupt request and INT0 to calculate the elapsed time between high/low transitions on the INT0 pin. The elapsed time is then converted to RPM and sent to the LCD. The [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignnone size-large wp-image-110" title="LCD RPM indicator" src="http://www.imsolidstate.com/wp-content/uploads/2009/08/IMAG0008-1024x768.jpg" alt="IMAG0008" width="614" height="461" /></p>
<p>I made a circuit for RPM measurement based on an Atmel ATtiny24 to drive a Hitachi 44780 parallel interface character LCD. It uses an external interrupt request and INT0 to calculate the elapsed time between high/low transitions on the INT0 pin. The elapsed time is then converted to RPM and sent to the LCD. The code will work from RPM values up to 999, and a variable timeout is used for a low cutoff to display 0RPM. The RPM range could be extended to 9,999 or higher by modifying the decimal to BCD routine at the end of the program.</p>
<p><img class="alignnone size-large wp-image-111" title="ATtiny24 interface PCB" src="http://www.imsolidstate.com/wp-content/uploads/2009/08/Sony-016-1024x768.jpg" alt="Sony 016" width="614" height="461" /></p>
<p>Here is the source code, it compiles with AVR Studio and AVR-GCC. <span id="more-104"></span><br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</p>
<pre>#include &lt;avr/io.h&gt;
#include &lt;avr/interrupt.h&gt;
#include &lt;util/delay.h&gt;

#define F_CPU 	1000000;	// 1MHz

volatile unsigned long RPM=0;	// Global RPM variable

void initLCD(void);
void lcd_write_byte(unsigned int CONTROL, unsigned int DATA);
void updateLCD(unsigned long RPM_OLD);
void check_BF(void);

void main(void)
{
TCCR1B=(1&lt;&lt;CS10)|(1&lt;&lt;CS12);	// Set up prescaler for CLK/1024
GIMSK=(1&lt;&lt;INT0);		// Enable external interrupt INT0
MCUCR=(1&lt;&lt;ISC00)|(1&lt;&lt;ISC01);    // Setup INT0 for rising edge detection

unsigned long RPM_OLD=1;	// Internal loop RPM variable

DDRB=0x00;			// Set PB2 for input

initLCD();			// Initialize the LCD

sei();				// Enable interrupts

while(1)
{
if((RPM != RPM_OLD) &amp; (TCNT1 &lt; 4000))
{
RPM_OLD=RPM;		// If new updated RPM value is not the same
updateLCD(RPM_OLD);	// as the one inside the loop, update the LCD.
}

if(TCNT1 &gt;= 4000)	// If it's been longer than 4 seconds, RPM=0.
{
RPM=0;
if (RPM != RPM_OLD)
{
RPM_OLD=RPM;		// If new updated RPM value is not the same
updateLCD(RPM_OLD);	// as the one inside the loop, update the LCD.
}
}
}
}

ISR(EXT_INT0_vect)	// External interrupt on PB2
{
unsigned long ELAPSED;

if(TCNT1 &lt; 4000)	// If Timer1 value is valid:
{
ELAPSED=TCNT1;		// Get Timer1 value before it changes much
TCNT1=0;		// Reset Timer1
RPM=(58594/ELAPSED);	// Calculate RPM based on Timer1 elapsed time
}

if(TCNT1 &gt;= 4000)	// If Timer1 overflowed, value is no good.
{
TCNT1=0;		// Reset Timer1
}
}

void initLCD()
{
DDRA=0xFF;			// Set PortA for output
_delay_ms(250);			// Wait for HD44780
PORTA=0x04;			// Intialize to 4 Bit, one line
PORTA |= 0x10;
_delay_ms(1);
PORTA &amp;= ~0x10;
_delay_ms(10);			// Intialize to 4 Bit, one line
PORTA |= 0x10;
_delay_ms(1);
PORTA &amp;= ~0x10;
_delay_ms(10);			// Intialize to 4 Bit, one line
PORTA |= 0x10;
_delay_ms(1);
PORTA &amp;= ~0x10;
_delay_ms(10);
lcd_write_byte(0,0x0C);		// Turn on display
lcd_write_byte(0,0x06);		// Increment by one after write

}

void lcd_write_byte(unsigned int CONTROL, unsigned int DATA)
{
// check_BF();

if(CONTROL == 1) PORTA |= 0x20; else PORTA &amp;= ~0x20;
if((DATA &amp; 0x80) == 0x80) PORTA |= 0x01; else PORTA &amp;= ~0x01;
if((DATA &amp; 0x40) == 0x40) PORTA |= 0x02; else PORTA &amp;= ~0x02;
if((DATA &amp; 0x20) == 0x20) PORTA |= 0x04; else PORTA &amp;= ~0x04;
if((DATA &amp; 0x10) == 0x10) PORTA |= 0x08; else PORTA &amp;= ~0x08;
PORTA |= 0x10;
_delay_us(1);
PORTA &amp;= ~0x10;

if((DATA &amp; 0x08) == 0x08) PORTA |= 0x01; else PORTA &amp;= ~0x01;
if((DATA &amp; 0x04) == 0x04) PORTA |= 0x02; else PORTA &amp;= ~0x02;
if((DATA &amp; 0x02) == 0x02) PORTA |= 0x04; else PORTA &amp;= ~0x04;
if((DATA &amp; 0x01) == 0x01) PORTA |= 0x08; else PORTA &amp;= ~0x08;
PORTA |= 0x10;
_delay_us(1);
PORTA &amp;= ~0x10;
_delay_ms(4);
}

void updateLCD(unsigned long RPM_OLD)
{
unsigned long RPM_BCD=((((RPM_OLD/10)+((RPM_OLD/100)*6))*16)+(RPM_OLD%10));

unsigned int ONES = 0x00;
unsigned int TENS = 0x00;
unsigned int HUND = 0x00;

if((RPM_BCD &amp; 0x0800) == 0x0800) HUND |= 0x08; else HUND &amp;= ~0x08;
if((RPM_BCD &amp; 0x0400) == 0x0400) HUND |= 0x04; else HUND &amp;= ~0x04;
if((RPM_BCD &amp; 0x0200) == 0x0200) HUND |= 0x02; else HUND &amp;= ~0x02;
if((RPM_BCD &amp; 0x0100) == 0x0100) HUND |= 0x01; else HUND &amp;= ~0x01;

if((RPM_BCD &amp; 0x0080) == 0x0080) TENS |= 0x08; else TENS &amp;= ~0x08;
if((RPM_BCD &amp; 0x0040) == 0x0040) TENS |= 0x04; else TENS &amp;= ~0x04;
if((RPM_BCD &amp; 0x0020) == 0x0020) TENS |= 0x02; else TENS &amp;= ~0x02;
if((RPM_BCD &amp; 0x0010) == 0x0010) TENS |= 0x01; else TENS &amp;= ~0x01;

if((RPM_BCD &amp; 0x0008) == 0x0008) ONES |= 0x08; else ONES &amp;= ~0x08;
if((RPM_BCD &amp; 0x0004) == 0x0004) ONES |= 0x04; else ONES &amp;= ~0x04;
if((RPM_BCD &amp; 0x0002) == 0x0002) ONES |= 0x02; else ONES &amp;= ~0x02;
if((RPM_BCD &amp; 0x0001) == 0x0001) ONES |= 0x01; else ONES &amp;= ~0x01;

ONES |= 0x30;
TENS |= 0x30;
HUND |= 0x30;

lcd_write_byte(0x00, 0x01);
lcd_write_byte(0x01, 0x20);
lcd_write_byte(0x01, HUND);
lcd_write_byte(0x01, TENS);
lcd_write_byte(0x01, ONES);
lcd_write_byte(0x01, 0x20);
lcd_write_byte(0x01, 0x52);
lcd_write_byte(0x01, 0x50);
lcd_write_byte(0x01, 0x4D);

}

void check_BF(void)
{
DDRA = 0xF0;  // Set PortA 4-7 (R/W, RS, E) to output, 0-3 (DBx) for input
PORTA &amp;= ~0x20;			// Clear register select
PORTA |= 0x40;			// Set read
PORTA |= 0x10;			// Set enable
_delay_us(1);

while((PA0 &amp; 0x01) == 0x01)	// Read DB7 of LCD (busy flag)
{
PORTA &amp;= ~0x10;			// Clear enable
_delay_us(1);
PORTA |= 0x10;			// Set enable
_delay_us(1);
PORTA &amp;= ~0x10;			// Clear enable
_delay_us(1);
PORTA |= 0x10;			// Set enable
_delay_us(1);
}

PORTA &amp;= ~0x10;			// Clear enable
_delay_us(1);
PORTA |= 0x10;			// Set enable
_delay_us(1);
PORTA &amp;= ~0x10;			// Clear enable
PORTA &amp;= ~0x40;			// Clear read
DDRA = 0xFF;			// Set for output

}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.imsolidstate.com/archives/104/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

