Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.

waxie

Member Since 09 Aug 2011
Offline Last Active Sep 12 2011 02:51 PM
-----

Posts I've Made

In Topic: Help with Serial LCD displaying gobbly-de-gop!

04 September 2011 - 06:45 AM

Hi there.

Okay so I tried your special characters using this code:

string text = "àèìòù€äöüñ"; // "Starting Up!";
buffer = Encoding.UTF8.GetBytes(text);
sPort.Write(buffer, 0, buffer.Length); // Write to LCD

and it produces klingon!!!! :) It doesnt like those special characters.

Here is a screenshot

In Topic: Help with Serial LCD displaying gobbly-de-gop!

02 September 2011 - 09:20 AM

Hello waxie! I am happy that you resolved your problem.
Just for curiosity and completeness, what do you see if you try to write a text containing "special" characters, like the extended alphabet, for instance?
You may try to write the following string:

Cheers


Hi Mario.

I am at work at the moment but when I get back home tonight I will test your sample chracters and see what is displayed on the LCD and report back.

In Topic: Help with Serial LCD displaying gobbly-de-gop!

02 September 2011 - 06:17 AM

Just for completness here is my code now which fully works! Thanks again.

using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoPlus;
using System.IO.Ports;
using System.Text;

namespace NetduinoPlusApplicationLCDTest4
{
    public class Program
    {
        public static void Main()
        {
            // write your code here
            SerialPort sPort = new SerialPort(SerialPorts.COM1, 9600, Parity.None, 8, StopBits.One);
            sPort.Open();

            byte[] buffer = null;

            string text = "Starting Up!";
            buffer = Encoding.UTF8.GetBytes(text);
            sPort.Write(buffer, 0, buffer.Length); // Write to LCD

            Thread.Sleep(3000);

            // Now lets clear display!
            sPort.Write(new byte[] { 0x00FE, 0x01 }, 0, 2); // Write to LCD

            while (true)
            {
                text = "hello ";
                buffer = Encoding.UTF8.GetBytes(text);
                sPort.Write(buffer, 0, buffer.Length); // Write to LCD

                Thread.Sleep(500);

                text = "Netduino";
                buffer = Encoding.UTF8.GetBytes(text);
                sPort.Write(buffer, 0, buffer.Length); // Write to LCD

                Thread.Sleep(500);

                // Now lets clear display!
                sPort.Write(new byte[] { 0x00FE, 0x01 }, 0, 2); // Write to LCD

                Thread.Sleep(500);

            }

            Thread.Sleep(Timeout.Infinite);


        }

    }
}

In Topic: Help with Serial LCD displaying gobbly-de-gop!

01 September 2011 - 10:38 AM

The term/suffix "port" is abstract: it would mean "a point where the data flows".
With that term the designers of software uses to describe a variety of different forms to exchange data. Now, even a "data" is an abstract term.
An InputPort is a "port" that allows input (only) of data of type "Boolean", thus false or true.
Similarly, the OutputPort is the symmetric form for the same kind of data (Boolean).
A SerialPort is a "port" which allows the exchange of "stream" of byte, or -if you like- byte array.

When you design a class/component which gives the user a "door" to something else (typically hardware), it is a best practice to add the suffix "Port". At a first glance anyone may understand what's the basic purpose of that class/component.
To tell the truth, I would have named the SPI class differently, just because it is another kind of port. Why not "SpiPort"?

Cheers


Thanks for this info Mario and thanks for helping me with my problem.

In Topic: Help with Serial LCD displaying gobbly-de-gop!

01 September 2011 - 09:17 AM

You totally messed up the hardware, the tutorial and the software. Sorry, waxie!
Your module is "smarter" than the depicted one in the tutorial. It embeds a tiny microcontroller acting as interface serial UART --> parallel LCD.
The tutorial assumes you're having a normal parallel LCD, and instructs how to interface it directly to the Nteduino using a shift-register and the SPI.

Your case is dramatically simpler.
According with the module specs, you should connect only three wires: ground, +5V and "signal". This "signal" can be connected to the Netduino's I/O #3, which is the UART transmit line (TXD).
That's all about the hardware.

For the software side, you should only configure the serial UART as the specs say: 9600,N,8,1 as default.
Try this:

public static void Main()
{
       SerialPort sPort = new SerialPort(SerialPorts.COM1, 9600, Parity.None, 8, StopBits.One);
       sPort.Open();

       byte[] buffer = //set-up the byte stream to be sent (see module specs)
       sPort.Write(buffer, 0, buffer.Length);
       Thread.Sleep(Timeout.Infinite);
}
Cheers.


Oh fiddlesticks!! Ive spent ages rubbing my noggin on this and your code looks ever so simple! Thank you for pointing me in the right direction. Like I say I am new to all of this and so its all one big learning curve. I will have to check this out when I get home tonight.

While I have got your ear can I ask you a question about the digital ports. I thought that these ports could only be used to send/recieve a 1 or a 0. (true/false) but in this example you are able to use Digital Input port 0 and write characters to it. Is this because you are using the SerialPort class instead of the OutputPort/InputPort classes?

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.