Go to Post I can neither confirm nor deny that I've worked on alot of pretty cool stuff. - Gary Dillard [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 21-05-2010, 18:47
ASeligman ASeligman is offline
Registered User
AKA: Bytesparks
FRC #3863 (Pantherbotics)
Team Role: Programmer
 
Join Date: May 2010
Rookie Year: 2009
Location: Newbury Park
Posts: 3
ASeligman is an unknown quantity at this point
WPILib & LCD Display

We're trying to use just WPILib to display a character on an LCD screen through a TX port on a Vex processor.

We aren't having too much luck with making it happen with just these functions that WPILib gives us:
Code:
unsigned char ReadSerialPortOne(void);
unsigned char ReadSerialPortTwo(void);
void WriteSerialPortOne(unsigned char byte);
void WriteSerialPortTwo(unsigned char byte);
void OpenSerialPortOne(unsigned baudRate);
void OpenSerialPortTwo(unsigned baudRate);
These are the definitions for the BAUD rates:
Code:
#define BAUD_4800 0x0081
#define BAUD_9600 0x0040
#define BAUD_14400 0x01AD
#define BAUD_19200 0x0181
#define BAUD_28800 0x0156
#define BAUD_38400 0x0140
#define BAUD_57600 0x012A
#define BAUD_115200 0x0115
We tried out Kevin Watson's serial port code, and it works, and we've found out a BAUD of 9600 should be used for an LCD display. Also, his code and the WPILib manual say Port 2 should be used for the LCD display. The only problem is his code has so much more than we need for just this goal.

It seems like there should be a way to use the functions in WPILib to output a character (and later a string of characters) to an LCD display serially. Is it possible?
  #2   Spotlight this post!  
Unread 22-05-2010, 03:57
RyanCahoon's Avatar
RyanCahoon RyanCahoon is offline
Disassembling my prior presumptions
FRC #0766 (M-A Bears)
Team Role: Engineer
 
Join Date: Dec 2007
Rookie Year: 2007
Location: Mountain View
Posts: 689
RyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond reputeRyanCahoon has a reputation beyond repute
Re: WPILib & LCD Display

WriteSerialPortOne and WriteSerialPortTwo should write a single character to the first and second serial ports respectively. To write a null-terminated string to the first serial port, you could use a function such as

Code:
void puts(char *str)
{
   while(*str)
   {
      WriteSerialPortOne(*str++);
   }
}
Of course, make sure you've opened the serial port before trying to read or write with it, and that you pass one of the baudrate constants to the open function; it sounds like you would want something like OpenSerialPortTwo(BAUD_9600);

It seems like you probably could have figured this yourself, though, so let me know if I've misinterpreted your question.

--Ryan
__________________
FRC 2046, 2007-2008, Student member
FRC 1708, 2009-2012, College mentor; 2013-2014, Mentor
FRC 766, 2015-, Mentor
  #3   Spotlight this post!  
Unread 26-05-2010, 19:09
ASeligman ASeligman is offline
Registered User
AKA: Bytesparks
FRC #3863 (Pantherbotics)
Team Role: Programmer
 
Join Date: May 2010
Rookie Year: 2009
Location: Newbury Park
Posts: 3
ASeligman is an unknown quantity at this point
Re: WPILib & LCD Display

Here's the code we had first tried using to output "h" onto the serial lcd display, but we had no luck with it.

Code:
#include "API.h"
#include "BuiltIns.h"

void main(void)
{
OpenSerialPortTwo(BAUD_9600);

while(1){
WriteSerialPortTwo('h');
}

}


Using your suggestion, we've modified the code to the following, but we're still getting nothing. Here is our use of your code (we changed "puts" to "putsd" because of an error message):

Code:
#include "API.h"
#include "BuiltIns.h"

void putsd(char *str)
{
   while(*str)
   {
      WriteSerialPortTwo(*str++);
   }
}

void main(void)
{
OpenSerialPortTwo(BAUD_9600);
putsd('h');
}
We know the display is wired properly because when we use Kevin Watson's serial ports code, it displays correctly. The only problem is his code seems to conflict with WPILib, and we'd like to use the display as well as WPILib.
  #4   Spotlight this post!  
Unread 26-05-2010, 20:16
byteit101's Avatar
byteit101 byteit101 is offline
WPILib maintainer (WPI)
AKA: Patrick Plenefisch
no team (The Cat Attack (Formerly))
Team Role: Programmer
 
Join Date: Jan 2009
Rookie Year: 2009
Location: Worcester
Posts: 699
byteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of lightbyteit101 is a glorious beacon of light
Re: WPILib & LCD Display

Quote:
Originally Posted by ASeligman View Post
Using your suggestion, we've modified the code to the following, but we're still getting nothing. Here is our use of your code (we changed "puts" to "putsd" because of an error message):

Code:
#include "API.h"
#include "BuiltIns.h"

void putsd(char *str)
{
   while(*str)
   {
      WriteSerialPortTwo(*str++);
   }
}

void main(void)
{
OpenSerialPortTwo(BAUD_9600);
putsd('h');
}
We know the display is wired properly because when we use Kevin Watson's serial ports code, it displays correctly. The only problem is his code seems to conflict with WPILib, and we'd like to use the display as well as WPILib.
I don't know much about what you are doing, but I do know you have a error in this code, putsd is expecting a string, not a character, try putsd("h"); (double quote vs single quote) or putsd("h\0");
__________________
Bubble Wrap: programmers rewards
Watchdog.Kill();
printf("Watchdog is Dead, Celebrate!");
How to make a self aware robot: while (∞) cout<<(sqrt(-∞)/-0);
Previously FRC 451 (The Cat Attack)
Now part of the class of 2016 at WPI & helping on WPILib
  #5   Spotlight this post!  
Unread 26-05-2010, 20:45
AustinSchuh AustinSchuh is offline
Registered User
FRC #0971 (Spartan Robotics) #254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Feb 2005
Rookie Year: 1999
Location: Los Altos, CA
Posts: 803
AustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond reputeAustinSchuh has a reputation beyond repute
Re: WPILib & LCD Display

Quote:
Originally Posted by byteit101 View Post
I don't know much about what you are doing, but I do know you have a error in this code, putsd is expecting a string, not a character, try putsd("h"); (double quote vs single quote) or putsd("h\0");
\0 is implied by "", so you don't need to put it. "test\0" will double null terminate the string, which isn't necessary.
  #6   Spotlight this post!  
Unread 26-05-2010, 22:15
Tom Bottiglieri Tom Bottiglieri is offline
Registered User
FRC #0254 (The Cheesy Poofs)
Team Role: Engineer
 
Join Date: Jan 2004
Rookie Year: 2003
Location: San Francisco, CA
Posts: 3,187
Tom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond reputeTom Bottiglieri has a reputation beyond repute
Re: WPILib & LCD Display

Are you initializing the LCD driver chip properly? The ones I have used needed to be prodded a bit before they would display characters.
  #7   Spotlight this post!  
Unread 27-05-2010, 02:57
ASeligman ASeligman is offline
Registered User
AKA: Bytesparks
FRC #3863 (Pantherbotics)
Team Role: Programmer
 
Join Date: May 2010
Rookie Year: 2009
Location: Newbury Park
Posts: 3
ASeligman is an unknown quantity at this point
Re: WPILib & LCD Display

Quote:
Originally Posted by byteit101 View Post
I don't know much about what you are doing, but I do know you have a error in this code, putsd is expecting a string, not a character, try putsd("h"); (double quote vs single quote) or putsd("h\0");
We also tried quotes but we didn't try the \0 at all. We'll give that a go tomorrow.


Quote:
Originally Posted by Tom Bottiglieri View Post
Are you initializing the LCD driver chip properly? The ones I have used needed to be prodded a bit before they would display characters.
I'm not quite sure. The only initialization being done is "OpenSerialPortTwo(BAUD_9600);" so it may be that the LCD chip itself is not being initialized. If you're right, how do you think we could properly initialize that LCD chip?
This is the LCD screen we're using, just a standard HD44780 controller.
  #8   Spotlight this post!  
Unread 28-05-2010, 10:48
Robototes2412's Avatar
Robototes2412 Robototes2412 is offline
1 * 4 != 14
FRC #2412 (Robototes)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2007
Location: Bellevue
Posts: 312
Robototes2412 is on a distinguished road
Re: WPILib & LCD Display

CHeck the Arduino source code, they have a library for character LCD's
  #9   Spotlight this post!  
Unread 01-06-2010, 20:09
michael714's Avatar
michael714 michael714 is offline
Registered User
FRC #3863 (Pantherbotics)
Team Role: Teacher
 
Join Date: Apr 2006
Rookie Year: 2007
Location: Newbury Park, CA
Posts: 46
michael714 is on a distinguished road
Re: WPILib & LCD Display

I'm working with aseligman on this issue. We eventually got the WPILib to output display to the SparkFun SerLCD display. We did use OpenSerialPortTwo(BAUD_9600); and then WriteSerialPortTwo('w');

For some reason, it wasn't working with an earlier project. But we noticed that we couldn't get output to go to the terminal either. So, we looked up an old project that did output to the terminal and when we added the above lines of code, we were able to write to the LCD display.

On a side note, we just tried to create a new project and the new project will not printf to the terminal. So, there is still something wrong- maybe with our MPLAB configuration? Project configuration? Not sure. Regardless, our old project is working fine, so we'll try to isolate the problem. Thanks for all the ideas.
  #10   Spotlight this post!  
Unread 02-06-2010, 19:45
michael714's Avatar
michael714 michael714 is offline
Registered User
FRC #3863 (Pantherbotics)
Team Role: Teacher
 
Join Date: Apr 2006
Rookie Year: 2007
Location: Newbury Park, CA
Posts: 46
michael714 is on a distinguished road
Re: serial out and printf with WPILib

Ok, another interesting discovery today. After much trial and error, we figured out why outputting to the serial port only worked sometimes. Actually, we never figured out why, we merely figured out how to get output consistently. For some reason, we had to have some kind of delay at the beginning of our program. This is really strange because we had the output looping and it did not work.

Anyway, by adding a Wait(1000) statement at the beginning of the code, we were able to get printf to the terminal and serial output to the SparkFun SerLCD display consistently. After we discovered this little trick, we then stumbled across a chiefdelphi thread that came to the same conclusion:

http://www.chiefdelphi.com/forums/sh...ad.php?t=62384

Interestingly, the thread also said that they couldn't get printf to work with WPILib when they had a function other than main(). We may experiment with that a bit more another day. However, I'm hoping that this info is helpful to anyone else having problems using printf or serial out with WPILib. Because if you can get it to work, than you can have a nice inexpensive serial LCD display for your vex (http://www.sparkfun.com/commerce/pro...ducts_id=9393).
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Coolest LCD display EVER SuperJake Chit-Chat 7 26-05-2007 16:15
WPILib & Camera colors & data Thanatos Programming 2 19-02-2007 01:15
On robot LCD display David55 Programming 4 24-06-2006 16:12
how to mount a lcd display onto a robot mechanicalbrain Electrical 9 07-09-2005 20:57
LCD display James Crivellone Rules/Strategy 6 06-01-2002 10:22


All times are GMT -5. The time now is 23:20.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi