<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
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/"
> <channel><title>Comments for Wandering Samurai</title> <atom:link href="http://wanderingsamurai.net/comments/feed" rel="self" type="application/rss+xml" /><link>http://wanderingsamurai.net</link> <description>An Electron In A Sea Of Data</description> <lastBuildDate>Fri, 03 Feb 2012 19:31:08 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=</generator> <item><title>Comment on Serial LCD Backpack (K107) by pixel</title><link>http://wanderingsamurai.net/electronics/serial-lcd-backpack/comment-page-1#comment-1554</link> <dc:creator>pixel</dc:creator> <pubDate>Fri, 03 Feb 2012 19:31:08 +0000</pubDate> <guid
isPermaLink="false">http://wanderingsamurai.net/electronics/serial-lcd-backpack#comment-1554</guid> <description>The LCD geometry is definitely your problem. LCD&#039;s use addresses to reference each character position on the display but the addresses from line to line are not sequential. For example on a 4x16 LCD the addresses work like this:Address
0x00-0x15 - Line 1
0x32-0x47 - Line 2
0x16-0x31 - Line 3
0x48-0x63 - Line 4You will notice that when you reach the end of the line and keep printing characters they start appearing on line 3 NOT line 2 because of how the address space is organized. This also causes all kinds of problems when the K107 thinks it is using a different sized display than it actually is because all the positioning the K107 does is based on these address ranges.Now to actually solve the problem you will need to tell the K107 board that it is driving a 4x20 so that it knows how to &#039;chop up&#039; the address space. For the K107 this is super simple and only needs to be configured once when you plug in a new LCD with a different geometry. It remembers the geometry between disconnects.To set the geometry for your display you need to send the &quot;?G&quot; command (which is explained above) with the number of lines followed by the width of the display (in characters). So for a 4x20 display you would send the string &quot;?G420&quot; at which point you should be all set.Hopefully that should fix things.</description> <content:encoded><![CDATA[<p>The LCD geometry is definitely your problem. LCD&#8217;s use addresses to reference each character position on the display but the addresses from line to line are not sequential. For example on a 4&#215;16 LCD the addresses work like this:</p><p>Address<br
/> 0&#215;00-0&#215;15 &#8211; Line 1<br
/> 0&#215;32-0&#215;47 &#8211; Line 2<br
/> 0&#215;16-0&#215;31 &#8211; Line 3<br
/> 0&#215;48-0&#215;63 &#8211; Line 4</p><p>You will notice that when you reach the end of the line and keep printing characters they start appearing on line 3 NOT line 2 because of how the address space is organized. This also causes all kinds of problems when the K107 thinks it is using a different sized display than it actually is because all the positioning the K107 does is based on these address ranges.</p><p>Now to actually solve the problem you will need to tell the K107 board that it is driving a 4&#215;20 so that it knows how to &#8216;chop up&#8217; the address space. For the K107 this is super simple and only needs to be configured once when you plug in a new LCD with a different geometry. It remembers the geometry between disconnects.</p><p>To set the geometry for your display you need to send the &#8220;?G&#8221; command (which is explained above) with the number of lines followed by the width of the display (in characters). So for a 4&#215;20 display you would send the string &#8220;?G420&#8243; at which point you should be all set.</p><p>Hopefully that should fix things.</p> ]]></content:encoded> </item> <item><title>Comment on Serial LCD Backpack (K107) by Chris</title><link>http://wanderingsamurai.net/electronics/serial-lcd-backpack/comment-page-1#comment-1553</link> <dc:creator>Chris</dc:creator> <pubDate>Fri, 03 Feb 2012 08:23:35 +0000</pubDate> <guid
isPermaLink="false">http://wanderingsamurai.net/electronics/serial-lcd-backpack#comment-1553</guid> <description>Hey, got it working (almost) baud rate was spot on, and I inverted (through jumper on k107) for rs 232 (duh) however, not sure how the code sends commands the the LCD. I am used to sending the commands as strings (ie ?A) as a newbie to C#, obviously the commands are sent as bytes, am I not getting something here.  The LCD (4x20) is writing the first line &quot;FEZ is great&quot; on the first line , but the H in &quot;Hello&quot; is also on the first line with &quot;ello&quot; on line 3.  I get that the code is set up for a 2X16 LCD but how????? thanks so much for the guidance so far :-)</description> <content:encoded><![CDATA[<p>Hey, got it working (almost) baud rate was spot on, and I inverted (through jumper on k107) for rs 232 (duh) however, not sure how the code sends commands the the LCD. I am used to sending the commands as strings (ie ?A) as a newbie to C#, obviously the commands are sent as bytes, am I not getting something here.  The LCD (4&#215;20) is writing the first line &#8220;FEZ is great&#8221; on the first line , but the H in &#8220;Hello&#8221; is also on the first line with &#8220;ello&#8221; on line 3.  I get that the code is set up for a 2X16 LCD but how????? thanks so much for the guidance so far <img
src='http://wanderingsamurai.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /></p> ]]></content:encoded> </item> <item><title>Comment on Serial LCD Backpack (K107) by pixel</title><link>http://wanderingsamurai.net/electronics/serial-lcd-backpack/comment-page-1#comment-1552</link> <dc:creator>pixel</dc:creator> <pubDate>Thu, 02 Feb 2012 21:50:05 +0000</pubDate> <guid
isPermaLink="false">http://wanderingsamurai.net/electronics/serial-lcd-backpack#comment-1552</guid> <description>I don&#039;t see anything particularly wrong in the code snippet. But there are 2 things I noticed that might be causing the problem.1) Make sure your K107 is actually set to work at 9600 baud. I think the newer versions ship with a higher default baud rate (You can check by just using your PICAXE setup to test the LCD).2) I am no expert at C# but I think you need to use a different function in place of Encoding.UTF8.GetBytes(s). The UTF-8 translation is probably messing up the actual bytes being sent across the serial line.Hope that helps with your problem.
Pixel</description> <content:encoded><![CDATA[<p>I don&#8217;t see anything particularly wrong in the code snippet. But there are 2 things I noticed that might be causing the problem.</p><p>1) Make sure your K107 is actually set to work at 9600 baud. I think the newer versions ship with a higher default baud rate (You can check by just using your PICAXE setup to test the LCD).</p><p>2) I am no expert at C# but I think you need to use a different function in place of Encoding.UTF8.GetBytes(s). The UTF-8 translation is probably messing up the actual bytes being sent across the serial line.</p><p>Hope that helps with your problem.<br
/> Pixel</p> ]]></content:encoded> </item> <item><title>Comment on Serial LCD Backpack (K107) by Chris</title><link>http://wanderingsamurai.net/electronics/serial-lcd-backpack/comment-page-1#comment-1551</link> <dc:creator>Chris</dc:creator> <pubDate>Thu, 02 Feb 2012 08:48:56 +0000</pubDate> <guid
isPermaLink="false">http://wanderingsamurai.net/electronics/serial-lcd-backpack#comment-1551</guid> <description>Hi PixelI will cut and paste the code in here.  I have couple of questions... Why can I only find code that sends byte data to the serial port (I am used to SEROUT on a picaxe, so easy) and I would imagine that the commands for the LCD in this code are all byte data, but they should be string data with the K107 commands starting with &quot;?&quot;. So frustrating to not know enough about it.  I hope you can help, and I&#039;m up for &quot;stating the obvious&quot;CheersHere is the code that I like the most.  (there are heaps of examples but this is pretty tight)
(source code or class)
using System;
using System.IO.Ports;
using System.Text;
using System.Threading;
using GHIElectronics.NETMF.FEZ;
namespace LCD
{
public class SerialLCD
{
const byte DISP_ON = 0xC;    //Turn visible LCD on
const byte CLR_DISP = 0x01;      //Clear display
const byte CUR_HOME = 5;      //Move cursor home and clear screen memory
const byte SET_CURSOR = 0x80;   //SET_CURSOR + X : Sets cursor position to X
const byte Move_CURSOR_LEFT = 0x10;
private SerialPort UART = new SerialPort(&quot;COM1&quot;, 9600);
public SerialLCD()
{
UART.Open();
}
public void Print(string s)
{
byte[] buffer = Encoding.UTF8.GetBytes(s);
UART.Write(buffer, 0, buffer.Length);
}public void ClearScreen()
{
SendCommand(CLR_DISP);
}public void CursorHome()
{
SendCommand(CUR_HOME);
}public void SetCursor(byte row, byte col)
{
SendCommand((byte)(SET_CURSOR &#124; row &lt;&lt; 6 &#124; col));
}public void MoveLeft()
{
SendCommand(Move_CURSOR_LEFT);
}private void SendCommand(byte cmd)
{
SendByte(0xFE);
SendByte(cmd);
}private void SendByte(byte cmd)
{
byte[] buffer = new byte[1] { cmd };
UART.Write(buffer, 0, buffer.Length);
}
}
}--------------------------------
execution codeusing System;
using System.IO.Ports;
using System.Text;
using System.Threading;
using GHIElectronics.NETMF.FEZ;
using LCD;namespace FEZ_Domino_Application1
{
public class Program
{
public static void Main()
{
SerialLCD lcd = new SerialLCD();lcd.ClearScreen();
lcd.Print(&quot;FEZ is great&quot;);
lcd.SetCursor(1, 0);
lcd.Print(&quot;Hello&quot;);   // prints on the second row
}}
}-----------------------------------------------------------</description> <content:encoded><![CDATA[<p>Hi Pixel</p><p>I will cut and paste the code in here.  I have couple of questions&#8230; Why can I only find code that sends byte data to the serial port (I am used to SEROUT on a picaxe, so easy) and I would imagine that the commands for the LCD in this code are all byte data, but they should be string data with the K107 commands starting with &#8220;?&#8221;. So frustrating to not know enough about it.  I hope you can help, and I&#8217;m up for &#8220;stating the obvious&#8221;</p><p>Cheers</p><p>Here is the code that I like the most.  (there are heaps of examples but this is pretty tight)<br
/> (source code or class)<br
/> using System;<br
/> using System.IO.Ports;<br
/> using System.Text;<br
/> using System.Threading;<br
/> using GHIElectronics.NETMF.FEZ;</p><p>namespace LCD<br
/> {<br
/> public class SerialLCD<br
/> {<br
/> const byte DISP_ON = 0xC;    //Turn visible LCD on<br
/> const byte CLR_DISP = 0&#215;01;      //Clear display<br
/> const byte CUR_HOME = 5;      //Move cursor home and clear screen memory<br
/> const byte SET_CURSOR = 0&#215;80;   //SET_CURSOR + X : Sets cursor position to X<br
/> const byte Move_CURSOR_LEFT = 0&#215;10;</p><p> private SerialPort UART = new SerialPort(&#8220;COM1&#8243;, 9600);</p><p> public SerialLCD()<br
/> {<br
/> UART.Open();</p><p> }</p><p> public void Print(string s)<br
/> {<br
/> byte[] buffer = Encoding.UTF8.GetBytes(s);<br
/> UART.Write(buffer, 0, buffer.Length);<br
/> }</p><p> public void ClearScreen()<br
/> {<br
/> SendCommand(CLR_DISP);<br
/> }</p><p> public void CursorHome()<br
/> {<br
/> SendCommand(CUR_HOME);<br
/> }</p><p> public void SetCursor(byte row, byte col)<br
/> {<br
/> SendCommand((byte)(SET_CURSOR | row &lt;&lt; 6 | col));<br
/> }</p><p> public void MoveLeft()<br
/> {<br
/> SendCommand(Move_CURSOR_LEFT);<br
/> }</p><p> private void SendCommand(byte cmd)<br
/> {<br
/> SendByte(0xFE);<br
/> SendByte(cmd);<br
/> }</p><p> private void SendByte(byte cmd)<br
/> {<br
/> byte[] buffer = new byte[1] { cmd };<br
/> UART.Write(buffer, 0, buffer.Length);<br
/> }<br
/> }<br
/> }</p><p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br
/> execution code</p><p>using System;<br
/> using System.IO.Ports;<br
/> using System.Text;<br
/> using System.Threading;<br
/> using GHIElectronics.NETMF.FEZ;<br
/> using LCD;</p><p>namespace FEZ_Domino_Application1<br
/> {<br
/> public class Program<br
/> {<br
/> public static void Main()<br
/> {<br
/> SerialLCD lcd = new SerialLCD();</p><p> lcd.ClearScreen();<br
/> lcd.Print(&quot;FEZ is great&quot;);<br
/> lcd.SetCursor(1, 0);<br
/> lcd.Print(&quot;Hello&quot;);   // prints on the second row<br
/> }</p><p> }<br
/> }</p><p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p> ]]></content:encoded> </item> <item><title>Comment on Serial LCD Backpack (K107) by pixel</title><link>http://wanderingsamurai.net/electronics/serial-lcd-backpack/comment-page-1#comment-1550</link> <dc:creator>pixel</dc:creator> <pubDate>Tue, 31 Jan 2012 19:30:25 +0000</pubDate> <guid
isPermaLink="false">http://wanderingsamurai.net/electronics/serial-lcd-backpack#comment-1550</guid> <description>I can take a look for you. I started out with the PICAXE and have used a combination of PICAXE and LCD in several projects. Send me a copy or post it as a comment and I will take a look.</description> <content:encoded><![CDATA[<p>I can take a look for you. I started out with the PICAXE and have used a combination of PICAXE and LCD in several projects. Send me a copy or post it as a comment and I will take a look.</p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching using disk: basic
Object Caching 438/438 objects using disk: basic

Served from: wanderingsamurai.net @ 2012-02-06 21:30:28 -->
