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.
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.
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.
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.
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!
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
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...
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.
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)
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
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.
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!