<?xml version="1.0" encoding="utf-8"?>
				<!-- generator="e107" -->
				<!-- content type="Forum / topic" -->
				<rss  version="2.0">
				<channel>
				<title>8051 Microcontroller Projects AVR PIC Projects Tutorials Ebooks Libraries codes : Forum / topic</title>
				<link>http://www.8051projects.net/</link>
				<description>Learn to make simple microcontroller projects, pic, 8051, avr and arm projects. download 8051 projects, tutorials, libraries, sample codes. join the microcontroller discussion forum and ask doubts regarding electronics. the best source for 8051 over internet.</description>

<language>en-gb</language>
				<copyright>2008 Rickey's World</copyright>
				<managingEditor>contact@nospam.com (Ajay Bhargav)</managingEditor>
				<webMaster>contact@nospam.com (Ajay Bhargav)</webMaster>
				<pubDate>Thu, 08 Jan 2009 20:28:50 -0800</pubDate>
				<lastBuildDate>Thu, 08 Jan 2009 20:28:50 -0800</lastBuildDate>
				<docs>http://backend.userland.com/rss</docs>
				<generator>e107 (http://e107.org)</generator>
				<ttl>60</ttl>
				<textInput>
				<title>Search</title>
				<description>Search 8051 Microcontroller Projects AVR PIC Projects Tutorials Ebooks Libraries codes</description>
				<name>query</name>
				<link>http://www.8051projects.net/search.php</link>
				</textInput>
						<item>
						<title>how to join the low byte nd high byte</title>
<link>http://www.8051projects.net/forum-t6697.html</link>
<description><![CDATA[im using vb program in reading the data send by my pic16f877 and im getting results alternately.. is it because of the low byt and high byte that is being write in my usart? please help???<br /><br /><div class='code_box'>CODE:</div><div class='code_highlight' style='unicode-bidi: embed; direction: ltr'><div class="c" style="font-family: monospace;"><span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> adc_val;<br /><span style="color: #993333;">unsigned</span> <span style="color: #993333;">char</span> low_byte,hi_byte;<br /><span style="color: #993333;">void</span> main<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br /><span style="color: #66cc66;">&#123;</span><br />USART_Init<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">9600</span><span style="color: #66cc66;">&#41;</span>;<br />ADCON0 = <span style="color: #cc66cc;">0</span>;<br />ADCON0.<span style="color: #202020;">ADON</span> = <span style="color: #cc66cc;">1</span>;<br />TRISA = 0xFF;<br />TRISB = <span style="color: #cc66cc;">0</span>; &nbsp;<br />PORTB = <span style="color: #cc66cc;">0</span>;<br /><br /><span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><br /><span style="color: #66cc66;">&#123;</span><br />&nbsp; ADCON0.<span style="color: #202020;">GO</span> = <span style="color: #cc66cc;">1</span><br />adc_val = ADC_Read<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;<br />low_byte = adc_val;<br />hi_byte = adc_val &gt;&gt; <span style="color: #cc66cc;">8</span>;<br />USART_Write<span style="color: #66cc66;">&#40;</span>low_byte<span style="color: #66cc66;">&#41;</span>;<br />USART_Write<span style="color: #66cc66;">&#40;</span>hi_byte<span style="color: #66cc66;">&#41;</span>;<br />low_byte =USART_Read<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />high_byte =USART_Read<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br /><span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>adc_val==<span style="color: #cc66cc;">511</span><span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">//if ADC value read in is 511 </span><br /><span style="color: #66cc66;">&#123;</span>PORTB = 0xFF;<span style="color: #66cc66;">&#125;</span> <span style="color: #808080; font-style: italic;">//display some LED's on PORTB</span><br />....<br />....<br />.<br /><span style="color: #66cc66;">&#125;</span><br /><span style="color: #66cc66;">&#125;</span></div></div><br /><br /><br />for my vb prog:<br /><br /><div class='code_box'>CODE:</div><div class='code_highlight' style='unicode-bidi: embed; direction: ltr'><div class="vb" style="font-family: monospace;"><span style="color: #b1b100;">Private</span> <span style="color: #b1b100;">Sub</span> CmdExit_Click<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />&nbsp; &nbsp; <span style="color: #b1b100;">If</span> MSComm1.<span style="color: #66cc66;">PortOpen</span> = <span style="color: #b1b100;">True</span> <span style="color: #b1b100;">Then</span><br />&nbsp; &nbsp; MSComm1.<span style="color: #66cc66;">PortOpen</span> = <span style="color: #b1b100;">False</span><br />&nbsp; &nbsp; <span style="color: #b1b100;">End</span> <span style="color: #b1b100;">If</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">End</span><br /><span style="color: #b1b100;">End</span> <span style="color: #b1b100;">Sub</span><br /><span style="color: #b1b100;">Private</span> <span style="color: #b1b100;">Sub</span> Form_Load<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />&nbsp; &nbsp; MSComm1.<span style="color: #66cc66;">InputLen</span> = <span style="color: #cc66cc;">0</span><br />&nbsp; &nbsp; MSComm1.<span style="color: #66cc66;">CommPort</span> = <span style="color: #cc66cc;">2</span><br />&nbsp; &nbsp; MSComm1.<span style="color: #66cc66;">Settings</span> = <span style="color: #ff0000;">&quot;9600,N,8,1&quot;</span><br /><span style="color: #b1b100;">End</span> <span style="color: #b1b100;">Sub</span><br /><span style="color: #b1b100;">Private</span> <span style="color: #b1b100;">Sub</span> Timer1_Timer<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />&nbsp; &nbsp; <span style="color: #b1b100;">Dim</span> BytesToRead <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Integer</span><br />&nbsp; &nbsp; <span style="color: #b1b100;">Dim</span> sData <span style="color: #b1b100;">As</span> Variant<br />&nbsp; &nbsp; MSComm1.<span style="color: #66cc66;">PortOpen</span> = <span style="color: #b1b100;">True</span><br />&nbsp; &nbsp; BytesToRead = <span style="color: #cc66cc;">1</span><br />&nbsp; &nbsp; <span style="color: #b1b100;">Do</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">DoEvents</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">Loop</span> Until MSComm1.<span style="color: #66cc66;">InBufferCount</span> = BytesToRead<br />&nbsp; &nbsp; &nbsp; &nbsp; sData= MSComm1.<span style="color: #b1b100;">Input</span><br />&nbsp; &nbsp; &nbsp; &nbsp; Text1.<span style="color: #66cc66;">Text</span> = <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">Asc</span><span style="color: #66cc66;">&#40;</span>sData<span style="color: #66cc66;">&#41;</span> * <span style="color: #cc66cc;">0.00489</span><span style="color: #66cc66;">&#41;</span> &nbsp;&amp; <span style="color: #ff0000;">&quot; Volts DC&quot;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; MSComm1.<span style="color: #66cc66;">PortOpen</span> = <span style="color: #b1b100;">False</span><br /><span style="color: #b1b100;">End</span> <span style="color: #b1b100;">Sub</span></div></div><br /><br />how am i going to read the low and high byte since im only using sData as input]]></description>
<pubDate>Fri, 07 Mar 2008 20:58:49 -0800</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t6697.html</guid>
</item>
						<item>
						<title>Re: how to join the low byte nd high byte</title>
<link>http://www.8051projects.net/forum-t6697.html</link>
<description><![CDATA[in C you can combine something like this..<br /><div class='code_box'>CODE:</div><div class='code_highlight' style='unicode-bidi: embed; direction: ltr'><div class="c" style="font-family: monospace;"><br /><span style="color: #993333;">int</span> combined;<br /><span style="color: #993333;">char</span> adcHI, adcLOW;<br /><br />combined = adcHI;<br />combined = <span style="color: #66cc66;">&#40;</span>combined &lt;&lt; <span style="color: #cc66cc;">8</span><span style="color: #66cc66;">&#41;</span> | adcLOW;<br /><span style="color: #808080; font-style: italic;">//now combined is 16-bit value.</span><br />&nbsp;</div></div>]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Fri, 07 Mar 2008 21:54:00 -0800</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t6697.html</guid>
</item>
						<item>
						<title>Re: how to join the low byte nd high byte</title>
<link>http://www.8051projects.net/forum-t6697.html</link>
<description><![CDATA[thanks ajay... does this dont mess up with the readings ill be getting in my vb program? ill be using this code as this<br /><br />unsigned int adc_val;<br />int combined <br />char adcHI, adcLOW;;<br />void main()<br />{<br />USART_Init(9600);<br />ADCON0 = 0;<br />ADCON0.ADON = 1;<br />TRISA = 0xFF;<br />TRISB = 0;  <br />PORTB = 0;<br /><br />while (1)<br />{<br />  ADCON0.GO = 1<br />adc_val = ADC_Read(0);<br />adcLOW = adc_val;<br />adcHigh= adc_val >> 8;<br />combined = adcHI;<br />combined = (combined &lt;&lt;8) | adcLOW<br />USART_Write(combined)<br />combined = USART_Read();<br /><br /><br />do i need to delete the low_byte and high_byte thing?<br /><br />]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Sat, 08 Mar 2008 06:15:18 -0800</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t6697.html</guid>
</item>
						<item>
						<title>Re: how to join the low byte nd high byte</title>
<link>http://www.8051projects.net/forum-t6697.html</link>
<description><![CDATA[Hi.....<br />First of all you need to understand what you are doing.Let me explain.....<br />You are reading the adc value and storing it in adc_val which is an int type ie 2-bytes.<br />When you send data to the PC through the PIC's USART,you can send only 1 byte at a time.Therefore you cannot send adc_val through the USART at once(since it's 2-bytes).So what you do is split the adc_val into two separate bytes ie. hi_byte and low_byte.Now send one byte first(say lo_byte) through USART,then the next(hi_byte).<br />Now in your VB program you receive these 2 bytes and then recombine them into the original integer  adc_val,using the logic depicted above by Ajay(you have to do this in your VB program and not PIC)..<br /><br /> <div class='indent'>low_byte =USART_Read();<br />high_byte =USART_Read()</div> <br />In your PIC program what is this for? Can you explain?]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Sat, 08 Mar 2008 10:00:30 -0800</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t6697.html</guid>
</item>
						<item>
						<title>Re: how to join the low byte nd high byte</title>
<link>http://www.8051projects.net/forum-t6697.html</link>
<description><![CDATA[You cannot send variable combine to UART directly, coz its a 16-bit variable and UART is capable of sending 8-bit.<br /><br />in your first post you are doing right.. i means sending first byte and then second byte. Now you need to do the combining thing in VB.. you can do it something like this<br /><br /><div class='code_box'>CODE:</div><div class='code_highlight' style='unicode-bidi: embed; direction: ltr'><div class="vb" style="font-family: monospace;"><span style="color: #b1b100;">Dim</span> Value <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Integer</span> = <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">CInt</span><span style="color: #66cc66;">&#40;</span>FirstByte<span style="color: #66cc66;">&#41;</span> &lt;&lt; <span style="color: #cc66cc;">8</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">Or</span> SecondByte<br />&nbsp;</div></div>]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Sun, 09 Mar 2008 07:07:47 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t6697.html</guid>
</item>
						<item>
						<title>Re: how to join the low byte nd high byte</title>
<link>http://www.8051projects.net/forum-t6697.html</link>
<description><![CDATA[ah ok.thanks...  can u give me some info on how i am going to combine this? i've tried but not that succesfull.]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Sat, 08 Mar 2008 22:09:34 -0800</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t6697.html</guid>
</item>
						<item>
						<title>Re: how to join the low byte nd high byte</title>
<link>http://www.8051projects.net/forum-t6697.html</link>
<description><![CDATA[where i am going to insert the code uve given? <br />this is my code:<br /><div class='code_box'>CODE:</div><div class='code_highlight' style='unicode-bidi: embed; direction: ltr'><div class="vb" style="font-family: monospace;"><span style="color: #b1b100;">Private</span> <span style="color: #b1b100;">Sub</span> CmdExit_Click<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />&nbsp; &nbsp; <span style="color: #b1b100;">If</span> MSComm1.<span style="color: #66cc66;">PortOpen</span> = <span style="color: #b1b100;">True</span> <span style="color: #b1b100;">Then</span><br />&nbsp; &nbsp; MSComm1.<span style="color: #66cc66;">PortOpen</span> = <span style="color: #b1b100;">False</span><br />&nbsp; &nbsp; <span style="color: #b1b100;">End</span> <span style="color: #b1b100;">If</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">End</span><br /><span style="color: #b1b100;">End</span> <span style="color: #b1b100;">Sub</span><br /><span style="color: #b1b100;">Private</span> <span style="color: #b1b100;">Sub</span> Form_Load<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />&nbsp; &nbsp; MSComm1.<span style="color: #66cc66;">InputLen</span> = <span style="color: #cc66cc;">0</span><br />&nbsp; &nbsp; MSComm1.<span style="color: #66cc66;">CommPort</span> = <span style="color: #cc66cc;">2</span><br />&nbsp; &nbsp; MSComm1.<span style="color: #66cc66;">Settings</span> = <span style="color: #ff0000;">&quot;9600,N,8,1&quot;</span><br /><span style="color: #b1b100;">End</span> <span style="color: #b1b100;">Sub</span><br /><span style="color: #b1b100;">Private</span> <span style="color: #b1b100;">Sub</span> Timer1_Timer<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br />&nbsp; &nbsp; <span style="color: #b1b100;">Dim</span> BytesToRead <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Integer</span><br />&nbsp; &nbsp; <span style="color: #b1b100;">Dim</span> sData <span style="color: #b1b100;">as</span> Variant<br />&nbsp; &nbsp; MSComm1.<span style="color: #66cc66;">PortOpen</span> = <span style="color: #b1b100;">True</span><br />&nbsp; &nbsp; BytesToRead = <span style="color: #cc66cc;">1</span><br />&nbsp; &nbsp; <span style="color: #b1b100;">Do</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">DoEvents</span><br />&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">Loop</span> Until MSComm1.<span style="color: #66cc66;">InBufferCount</span> = BytesToRead<br />&nbsp; &nbsp; &nbsp; &nbsp; sData= MSComm1.<span style="color: #b1b100;">Input</span><br />&nbsp; &nbsp; &nbsp; &nbsp; Text1.<span style="color: #66cc66;">Text</span> = <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">Asc</span><span style="color: #66cc66;">&#40;</span>sData<span style="color: #66cc66;">&#41;</span> * <span style="color: #cc66cc;">0.00489</span><span style="color: #66cc66;">&#41;</span> &nbsp;&amp; <span style="color: #ff0000;">&quot; Volts DC&quot;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; MSComm1.<span style="color: #66cc66;">PortOpen</span> = <span style="color: #b1b100;">False</span><br /><span style="color: #b1b100;">End</span> <span style="color: #b1b100;">Sub</span><br />&nbsp;</div></div>]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Sun, 09 Mar 2008 22:06:40 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t6697.html</guid>
</item>
						<item>
						<title>Re: how to join the low byte nd high byte</title>
<link>http://www.8051projects.net/forum-t6697.html</link>
<description><![CDATA[i donno much about VB coding and stuff.. only thing i can tell you is.. you need to read two bytes as sent by controller.<br /><br />Lets say you are sending high byte first and then low byte..<br />so you need to read them separately one by one.. and store them in two variables and then combine both of them as mentioned above.<br /><br />e.g.<br /><div class='code_box'>CODE:</div><div class='code_highlight' style='unicode-bidi: embed; direction: ltr'><div class="vb" style="font-family: monospace;"><br />FirstByte= MSComm1.<span style="color: #b1b100;">Input</span><br />SecondByte = MSComm1.<span style="color: #b1b100;">Input</span><br /><br />Combined = <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">CInt</span><span style="color: #66cc66;">&#40;</span>FirstByte<span style="color: #66cc66;">&#41;</span> &lt;&lt; <span style="color: #cc66cc;">8</span><span style="color: #66cc66;">&#41;</span> <span style="color: #b1b100;">Or</span> SecondByte<br />&nbsp;</div></div>]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Mon, 10 Mar 2008 06:02:06 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t6697.html</guid>
</item>
						<item>
						<title>Re: how to join the low byte nd high byte</title>
<link>http://www.8051projects.net/forum-t6697.html</link>
<description><![CDATA[Ajay, thank you very much for the help, i've tried using ur code but when im in the Combine = (CInt(FirstByte)&lt;&lt;8) Or Secondbyte the "&lt;&lt;" gives an error, i can only use one &lt;, isn't it a c code "&lt;&lt;"? ...  and when i tried checking the value send by the microcontroller the reading was at 255 and changes to 239, is there something wrong with my code?]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Tue, 11 Mar 2008 00:06:58 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t6697.html</guid>
</item>
						<item>
						<title>Re: how to join the low byte nd high byte</title>
<link>http://www.8051projects.net/forum-t6697.html</link>
<description><![CDATA[Try this.....<br />Combined = CInt(Firstbyte * (2^8)) OR Secondbyte]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Tue, 11 Mar 2008 10:03:21 -0700</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t6697.html</guid>
</item>
				</channel>
				</rss>