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.
Photo

Communicating with serial 2x16 LCD


  • Please log in to reply
11 replies to this topic

#1 cs0093

cs0093

    New Member

  • Members
  • Pip
  • 4 posts

Posted 18 March 2011 - 02:07 AM

Hi, I have a seetron BPI-216 v1 serial LCD connected to Netduino's com2. I have been trying to get Netduino to print to it unsuccessfully. Would appreciate any help offered to get this going. I have attached the data sheet for the LCD module. Here is a simplified version of the code I am working on: using System; using System.Threading; using System.IO.Ports; using Microsoft.SPOT; using System.Collections; using System.Text; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.Netduino; namespace Netduino_SerialTest { public class Program { private static SerialPort lcd; public static byte[] getBytes(String message) { System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); return encoding.GetBytes(message); } public static void Main() { lcd = new SerialPort(SerialPorts.COM2, 9600, Parity.None, 8, StopBits.One); lcd.ReadTimeout = 10; lcd.Open(); byte[] byteme = getBytes("Welcome to Netduino"); lcd.Write(byteme, 0, byteme.Length); byte[] bytes = new byte[1] { 12 }; lcd.Write(bytes, 0, bytes.Length); while(true){ } } } } I am also attaching an image of what displays on the LCD when I run the code. I apologize for the lousy image. Looks like char 0,0 from the data sheet.

Attached Files



#2 hari

hari

    Advanced Member

  • Members
  • PipPipPip
  • 131 posts

Posted 18 March 2011 - 03:17 AM

I believe that is the same LCD model that I used for my morse code decoder project.
My LCD wanted an inverted rs-232 signal so I used an SN7404 hex inverter to invert the signal out of the Netduino.
You maybe running into the same issue.

#3 cs0093

cs0093

    New Member

  • Members
  • Pip
  • 4 posts

Posted 18 March 2011 - 12:27 PM

hari, thanks for your quick reply. I did go over your example prior to posting my issue. I did notice that your lcd is very similar to mine. I was using this lcd with a basic stamp without any inverters, connected straight to the pins of the stamp II so I figured the same could be done here. It is posible that, with the basic stamp, they are inverting the signal in code. In the serial protocol a 1 is -12v (or < .7v if memory serves me) and 0 is +12v or anything above +2.3v - this may explain why an inverter is needed. One would think the atmel uart would follow this convention though. I dont have a scope so I cant verify any of this. Nice project btw - do you have further plans to develop it or was it just an experiment to learn about the board? I have one of those sharp ir proximity sensors hooked up to my board and want to make the distance readings available on the lcd so it can be used without having to be connected to a pc. Its really convenient as the output of the sensor is 3v max, well within the 3.3v limit of the Atmel ADC. Another great thing about using the netduino is that I can do floating point calculations which makes linearizing the output of the sensor way simpler.

#4 cs0093

cs0093

    New Member

  • Members
  • Pip
  • 4 posts

Posted 19 March 2011 - 04:18 AM

I added the inverter as you suggested and that resloved the issue. BTW - I was able to look at the signal with a scope and saw that the TX pin normally is held high and goes low for ones then high for zero. Thanks for your help again!

#5 hari

hari

    Advanced Member

  • Members
  • PipPipPip
  • 131 posts

Posted 19 March 2011 - 05:28 AM

Cool! Glad to hear you got it to work! The morse decoder was just something I did for fun. Yeah, having floating point is nice. To me, being able to single-step through code running on the microcontroller is the biggest benefit. Also, Visual Studio intellisense rocks! Make sure you post a video on the forum when you got your "electronic ruler" working. Hari

#6 cs0093

cs0093

    New Member

  • Members
  • Pip
  • 4 posts

Posted 20 March 2011 - 04:28 AM

Here is the complete code for the sharp ir distance sensor (GP2Y0A02YK) and the seetron bpi-216 serial lcd screen. The netduino is set to use ADC chanel 1 to read the sensor and COM2 to write to the lcd screen - chage these as necessary for your specific application needs. As mentioned in an earlier post by hari it is necessary to include an inverter between the output of the netduino and the serial input of the LCD screen for things to work right. There is a linearizing function in the code that seems to work well for my sensor - you will have to experiment a bit to get numebers that will work for your specific sensor. You can try mine if you are not in the mood to experiment but your milage may vary. The formula takes the raw ADC data and puts out a value representing the number of inches an object is placed in front of the sensor. The Atmel ADC accepts values from 0 to 3.3 volts - The maximum output from the sensor is 3 volts, this means it can be connected directly to the netduino module, this is how I have mine setup. The sensor has three wires +5, GND and output. You can read up / purchase one from sparkfun.com or acroname. Acroname includes the necessary wiring harness with the sensor, sparkfun does not. The sharp sensor puts out a voltage proportional to the distance an object is from the sensor. Close objects have a higher value than objects further out. I set it up on an arduino proto shield to simplify things. I used an MC4049 as the inverter but a 7404 can also be used as hari did in his project. Here is a link to a data sheet for the 4049 device, these are CMOS devices and sensitive to static electricity - be careful handling them. http://pdf1.alldatas...CS/MMC4049.html As you can see the device has six inverters, you only need one of them for get this project going. Here is a link with info on the sharp ir proximity sensor: http://www.sparkfun.com/products/8958 Here is a link with info on the protoshield: http://www.sparkfun.com/products/7914 A data sheet for the lcd module is attached to the first post in this thread. Use it to see the available commands. The main point of the code is to learn how to use the ADC to read in a value and write it to a serial device, hope you find it useful. enjoy...

Attached Files



#7 don664

don664

    Advanced Member

  • Members
  • PipPipPip
  • 77 posts
  • LocationHillcrest, KZN, South Africa

Posted 19 November 2012 - 12:02 PM

Hi there,

I'm new to the forum and am trying to get my Netduino Plus 2 to send "Hello World" to my Sparkfun Serial LCD (https://www.sparkfun.com/products/9395).

I am able to do this on my Arduino board but have no idea how to use the Melabs SLCD Driver and the Netdunio. I downloaded and added the SLCD_API.cs to my solution as a class but now am not sure how to reference it.

I have the the LCD connected up as follows (LCD to Netduino):
  • RX to Digital I/O 1
  • GND to GND
  • VDD to 5V

Does anyone have an example of how this is done? I have no code to post as my Program.cs file is still empty.

Any help will appreciated :unsure:

Thanks,
Donovan

#8 Coyttl

Coyttl

    Advanced Member

  • Members
  • PipPipPip
  • 61 posts
  • LocationSilver Spring, MD, USA

Posted 19 November 2012 - 08:23 PM

Interesting.. I have that same LCD, but I didn't use anyone's library. I just opened a serial port (COM1) and wrote characters to it, so.. unfortunately, I can't really help you there. :( It never occurred to me that there would even be a library available. D'oh. Depending on how the class is set up, you'd need to include the file in your project, and then reference the class and namespace. (i.e. Some.Namespace.SLCD_API)

#9 don664

don664

    Advanced Member

  • Members
  • PipPipPip
  • 77 posts
  • LocationHillcrest, KZN, South Africa

Posted 19 November 2012 - 08:40 PM

Hi Coyttl, Thanks for replying. I was hoping you could show me the syntax for how you open a com port and write to the lcd... is it kind of like doing a debug.print? Also where do i connect the RX from the lcd onto the plus 2? Thanks, Donovan

#10 carb

carb

    Advanced Member

  • Members
  • PipPipPip
  • 352 posts
  • LocationCrystal River, Florida

Posted 19 November 2012 - 09:07 PM

Hi Coyttl,

Thanks for replying.

I was hoping you could show me the syntax for how you open a com port and write to the lcd... is it kind of like doing a debug.print?

Also where do i connect the RX from the lcd onto the plus 2?

Thanks,
Donovan

Donovan,

Welcome to the Netduino Forum.

For connections on the Netduino Plus 2 see the Steve's Pinout Drawing. Netduino Plus 2 Pinout

As far as setting up serial communications, there are several examples here on the forum, some better than others depending on the task. Just use the search feature in the upper right corner.

Also checkout Stefan's NETMF Toolbox on codeplex. NET Micro Framework Toolbox It has samples and code in C# and Visual Basic plus circuit drawings. Even if you don't find exactly what your looking for you can normally find ideas that will put you on the right track.

Transmitting on serial is fairly easy, receiving is a little harder to get the buffer setup right so as not to lose bytes.

Chuck

#11 don664

don664

    Advanced Member

  • Members
  • PipPipPip
  • 77 posts
  • LocationHillcrest, KZN, South Africa

Posted 20 November 2012 - 08:04 AM

Hi Chuck,

Thanks for the response.

I have figured it and posted my solution here:

Serial LCD and Netduino Plus 2

Thanks again to Coyttl for also taking the time to help out.

Cheers,
Donovan

#12 Coyttl

Coyttl

    Advanced Member

  • Members
  • PipPipPip
  • 61 posts
  • LocationSilver Spring, MD, USA

Posted 20 November 2012 - 05:42 PM

Hi Chuck,

Thanks for the response.

I have figured it and posted my solution here:

Serial LCD and Netduino Plus 2

Thanks again to Coyttl for also taking the time to help out.

Cheers,
Donovan

Well, this is annoying. I went to go pull up my project, and.. can't find it. Grr.. Apparently I forgot to check it into my source control, and .. it's no longer on my hard drive.

I was just going to throw something together, but saw your other post, looks like you got it!

--Mike.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

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.