Pages: [1] 2   Go Down
Author Topic: Serial LCD help - newbie at programming  (Read 2624 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 66
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

On my in-progress robot (more like a go kart but it has robotics components) We're planning to build a Formula-1 style steering wheel with a display and a few buttons. My plan is to use a Parallax Serial 4x20 LCD with i think 2-3 of these little buttons http://www.amazon.com/gp/product/B004RXKWI6/ref=ox_sc_act_title_3?ie=UTF8&smid=A2E0IHQCUI9LTK).

Now on to the part I need help with. We want to have the robot print data like speed of the wheels, battery voltage, temperature inside the hardware case (motor controllers and the arduino) and probably the cooling fan RPMs, and current disable/enable state for drive. So, since i know nothing about code and have been using off the shelf stuff so far, what would a basic program to have the buttons scroll up/down on the LCD data look like?
« Last Edit: November 24, 2012, 12:03:42 am by BurtonCustomX » Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 73
Posts: 7198
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Not an easy job. My phi_prompt library will NOT work with serial displays but someone has made modifications to make it work. Take a look to see if this is what you want.:

http://liudr.wordpress.com/libraries/phi_prompt/
Logged


Offline Offline
Jr. Member
**
Karma: 0
Posts: 66
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So could I use that library to make the screen scroll through data with the buttons?
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 73
Posts: 7198
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

So could I use that library to make the screen scroll through data with the buttons?

Do you have a parallel LCD? If you do, yes you can. If you only have your serial LCD, you need some modification.
Logged


Offline Offline
Jr. Member
**
Karma: 0
Posts: 66
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Nah I don't. I just have my 4x20 serial LCD. So could I just get one of those phi-2 shields? I really don't know much about programming
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 73
Posts: 7198
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Phi-2 shield still needs some programming. If you use your serial lcd, you need very little programming to print to it, although you need quite a bit programming when you add buttons. I tnd to say phi-panel backpacks are the easiest product to do interactions, but again that is my product. I am curious to know what you want with buttons, in details, so I can decide whether phi-panels are a match.
Logged


Offline Offline
Jr. Member
**
Karma: 0
Posts: 66
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well basically, the robot will grab data such as wheel speed (measured by encoders), intake and outtake fan RPMs, current battery voltage, cabin temperature (hardware cabin), robot disable/enable state, and throttle input percentage, and publish it to the LCD. However this is few more things than can be displayed on a 4x20 LCD. The buttons would enable the LCD to scroll through this list both up and down, along with controlling wether the back light is on (for LCD) So i would need 3 buttons in total
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 73
Posts: 7198
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, so you want a long message, which keeps up updating every once in a while to display on a screen and you want to use 2 buttons to scroll the message?
Maybe in the future you want some buttons to make some changes to the setting?
I can see how part one (long message) is done with a serial display and buttons. Here is the version that will work with my phi-panels:

Code:
unsigned long last_update=0;
const int update_period=5000;
const int max_screen_location=3; //You have 3 extra lines that need to scroll since you have 7 pieces of info.

int wheel_speed;
int intake_RPM;
int outtake_RPM;
int battery_voltage;
int cabin_temperature;
int enable_disable_state;
int throttle_input_percentage;
char formatting[][20]={{"Wheel Speed:%4d"},{},{},{},{},{},{}}; // Need to finish

int screen_location=0;
void setup()
{
  Serial.begin(19200);
}

void loop()
{
  if (millis()-last_update>update_period)
  {
    last_update=millis();
    Measure_everything();
    Display_info();
  }
  if (Serial.available())
  {
    byte in_byte=Serial.read();
    switch (in_byte)
    {
      case '1':
      if (screen_location<max_screen_location)
      {
        screen_location++;
        Display_info();
      }
      break;
     
      case '2':
      if (screen_location>0)
      {
        screen_location--;
        Display_info();
      }
      break;
    }
}

Void Measure_everything()
{
  //Please fill this up with code that does all measurements.
}

void Display_info()
{
  for (byte i=screen_location; i<screen_location+4; i++)
  {
    //Render one line at a time and send to screen
  }
}
Logged


Offline Offline
Jr. Member
**
Karma: 0
Posts: 66
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well I kinda want it to update constantly so the speed can be used as a speedometer. So Phi-panel would work for this project?
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 73
Posts: 7198
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well I kinda want it to update constantly so the speed can be used as a speedometer. So Phi-panel would work for this project?
The display can't be updated too quickly. If you do 5 updates a second, that is the limit to human eyes to read numbers. You can keep measuring and only update display 5 times a second. Yes, phi-panel can do that.
Logged


Offline Offline
Jr. Member
**
Karma: 0
Posts: 66
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

5 times a second sounds good. And is the code above good for basic screen display with scrolling? Cause I was thinking about adding a button to disable/enable the robot and for turning backlight on/off
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 73
Posts: 7198
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

5 times a second sounds good. And is the code above good for basic screen display with scrolling? Cause I was thinking about adding a button to disable/enable the robot and for turning backlight on/off
The above code is a framework. You need to fill some details in. I could help if you do your part first. Turning back light on and off is easy too. Just some more code.
Logged


Offline Offline
Jr. Member
**
Karma: 0
Posts: 66
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Alright. So we can assign all these features to buttons on the phi panel? Or could I use the serial LCD with some buttons for the same task?
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 73
Posts: 7198
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Alright. So we can assign all these features to buttons on the phi panel? Or could I use the serial LCD with some buttons for the same task?

Right, you can assign any phi-panel key to any tasks. In that sense, you may assign several buttons to do the same job, or even one button to do different jobs under different situations.
Logged


Offline Offline
Jr. Member
**
Karma: 0
Posts: 66
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So is there any assembly (like soldering) involved with a phi panel? Cause i don't know how to solder. And where do i buy one? if i cant use my lcd and some buttons smiley-razz
Logged

Pages: [1] 2   Go Up
Jump to: