<?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 19:23:11 -0800</pubDate>
				<lastBuildDate>Thu, 08 Jan 2009 19:23:11 -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>10bit Right justified encoded char</title>
<link>http://www.8051projects.net/forum-t6661.html</link>
<description><![CDATA[hello admin,<br /><br />i have a problem reading the 10-bit right justified 2 byte data from the PIC. i'm using matlab to read the ADC. here is my PIC C code;<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;">main<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><br /><span style="color: #66cc66;">&#123;</span><br />&nbsp; &nbsp;<span style="color: #993333;">long</span> <span style="color: #993333;">int</span> adcValue; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//16-bit A2D reading storage</span><br />&nbsp; &nbsp;<span style="color: #993333;">char</span> adcHI, adcLO; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//8-bit real time frames storage</span><br />&nbsp; &nbsp;setup_adc_ports<span style="color: #66cc66;">&#40;</span>A_ANALOG<span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//set all ADC pins to analog</span><br />&nbsp; &nbsp;setup_adc<span style="color: #66cc66;">&#40;</span>ADC_CLOCK_INTERNAL<span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//enable A2D module</span><br />&nbsp; &nbsp;set_adc_channel<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">//read channel 0</span><br />&nbsp; &nbsp;delay_us<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">20</span><span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">//delay for sampling cap to charge</span><br />&nbsp; &nbsp;<span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">TRUE</span><span style="color: #66cc66;">&#41;</span><br />&nbsp; &nbsp;<span style="color: #66cc66;">&#123;</span><br />&nbsp; &nbsp; &nbsp; adcValue = read_adc<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">//start conversion</span><br />&nbsp; &nbsp; &nbsp; adcHI = <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">char</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>adcValue&gt;&gt;<span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span>& 0x1f<span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">// 0|0|0|d9|d8|d7|d6|d5</span><br />&nbsp; &nbsp; &nbsp; adcLO = <span style="color: #66cc66;">&#40;</span><span style="color: #993333;">char</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>adcValue &amp; 0x1f<span style="color: #66cc66;">&#41;</span>|0x80<span style="color: #66cc66;">&#41;</span>; &nbsp; <span style="color: #808080; font-style: italic;">// 1|0|0|d4|d3|d2|d1|d0</span><br />&nbsp; &nbsp; &nbsp; putc<span style="color: #66cc66;">&#40;</span>adcHI<span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">// Transmit Byte 1 (d9...d5)</span><br />&nbsp; &nbsp; &nbsp; putc<span style="color: #66cc66;">&#40;</span>adcLO<span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #808080; font-style: italic;">// Transmit Byte 2 (d4...d0)</span><br />&nbsp; &nbsp; &nbsp; delay_ms<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">5</span><span style="color: #66cc66;">&#41;</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">//small delay before read</span><br />&nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span><br /><span style="color: #66cc66;">&#125;</span></div></div><br /><br />using hyperterminal and other serial port monitors, i can get the ADC data. but with matlab  it gives me the error: inputBufferSize must be greater than zero which means no data is in the port. <br /><br />initialization of the serial port with the matlab code was made, serial object creation, serial settings; BaudRate @9600 as with the PIC,8bits, Parity=none<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;"> s = serial<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'COM1'</span><span style="color: #66cc66;">&#41;</span>;<br />&nbsp; &nbsp;fopen<span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">&#41;</span>;<br />&nbsp; &nbsp;set <span style="color: #66cc66;">&#40;</span>s, <span style="color: #ff0000;">'BaudRate'</span>, <span style="color: #cc66cc;">9600</span><span style="color: #66cc66;">&#41;</span>;<br />&nbsp; &nbsp;data = fread<span style="color: #66cc66;">&#40;</span>s,s.<span style="color: #202020;">BytesAvailable</span><span style="color: #66cc66;">&#41;</span>;<br />&nbsp; &nbsp;n = length<span style="color: #66cc66;">&#40;</span>data<span style="color: #66cc66;">&#41;</span>;<br />i=<span style="color: #cc66cc;">1</span>;<br />&nbsp; &nbsp;<span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span>i&lt;n/<span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><br />&nbsp; &nbsp;<span style="color: #66cc66;">&#123;</span><br />&nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span><br />&nbsp; &nbsp;end<br />&nbsp; &nbsp;fclose<span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">&#41;</span>;<br />&nbsp; &nbsp;delete<span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">&#41;</span>;<br />&nbsp; &nbsp;clear<span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">&#41;</span>;</div></div><br /><br />how can i decode the 8 bit encoded character send by the pic?]]></description>
<pubDate>Thu, 06 Mar 2008 12:55:10 -0800</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t6661.html</guid>
</item>
						<item>
						<title>Re: 10bit Right justified encoded char</title>
<link>http://www.8051projects.net/forum-t6661.html</link>
<description><![CDATA[You probably need to specify input buffer size.<br />set(s, 'InputBufferSize', 512) ;]]></description>
<author>contact@nospam.com (Ajay Bhargav)</author>
<pubDate>Thu, 06 Mar 2008 21:44:18 -0800</pubDate>
<guid isPermaLink="true">http://www.8051projects.net/forum-t6661.html</guid>
</item>
				</channel>
				</rss>