Go Down

Topic: Serial LCD help - newbie at programming (Read 2969 times) previous topic - next topic

BurtonCustomX

Nov 23, 2012, 06:05 am Last Edit: Nov 24, 2012, 06:03 am by BurtonCustomX Reason: 1
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?

liudr

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/

BurtonCustomX

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

liudr


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.

BurtonCustomX

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

liudr

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.

BurtonCustomX

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

liudr

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: [Select]
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
  }
}

BurtonCustomX

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?

liudr


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.

BurtonCustomX

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

liudr


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.

BurtonCustomX

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?

liudr


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.

BurtonCustomX

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 :P

Go Up