Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

LCD and temperature measuring PIC16f887

Status
Not open for further replies.

gojkosisa

Junior Member level 3
Joined
Sep 27, 2012
Messages
31
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,536
Hello,

I'm doing some project where I want to measure temperature but not some simply device. It would have some extra features as entering in sub-menu where you can edit some extra settings. When you click some push button (Ok button) you go from main menu to this menu. In that sub-menu I have another 3 menus where I can set temperature when some alarm will be turned On, temperature when some relay will be energized and menu for calibrating sensor. I have issues with this switching from one menu to another. Basically I use four buttons (Ok, Exit, Up, Down).When press Ok go to menu for settings, with Up, Down choose what you want to change, press Ok to change that parameter and use Up and Down for correct value.When you set value, press Ok or Exit to return.Now use again Up and Down to change another parameter. Ive tried with functions (every menu is separated function) but it didn't work (stack overflow..). Also I use interrupt for blinking text to indicate what value I'm changing.

How to solve this task, is there some extra trick?
 

First you need to tell which microcontroller you use and compiler to get your problem solved.
 

Ok,

I'm using PIC16F887 and mikroC compiler.
 

Are you asking us to design your entire project for you? Do you have a specific question other than "how do I do this?"
 

Hello,

I have issues with this switching from one menu to another.

Hello,

If you are using C then answer is in your question itself.

Use switch case statements. Your problem will be solved.

Hope this will help in getting some hint.
 

No, I'm just asking for idea or reference on some article on this subject. I done almost everything but my code isn't modular. For example when I want to add new menu I have to change all the code.
 

I done almost everything but my code isn't modular. For example when I want to add new menu I have to change all the code.

You mean you want some idea on dynamic menu code ?

If yes again the same answer no big deal.
 

What type of LCD are you utilizing in your design?

Is it a HD44780 compatible or a GLCD variant?


BigDog
 

It is HD44780 16x2 LCD display. With switch statement it wouldn't work.
Isn't so trivial, there are a lot of code behind switching from one menu to another.
More info:
program starts and display Main Menu - sensor reading and information about outputs (alarm, relay)

if Ok button is pressed it displays number of menu and value of alarm temperature

something like this:

1. Alarm temperature
Value: 20


"1" is blinking in the top-left corner to indicate menu number

If you press Ok "1" stop to blink and
Value of alarm temperature is now blinking in the bottom-right corner and using up and down you change temperature value

Press Ok to return in stage when "1" was blinking (now Value stop to blink). Now if you press Exit it will return you to Main Menu
or pressing Up you go to second display for editing relay-temperature

Pressing Up you will have new information on display, something like this:
2. Relay temperature
value: 30


Again "2" is blinking to indicate display number and if Ok is pressed you go to Value and with Up and Down you set desired value
Press Ok or Exit to return in previous stage ("2" is blinking)

If you want to go in third display press Up or to back in first display press Down

Also with Exit button you will return to Main Menu.

This is what I want to implement, I have some ideas but I can't figure out how to make it modular. What I mean is that I currently have 3 parameter but when I want to add new parameter it will change all code.
 

OK

I am sure you must be having a very lengthy code the way you mentioned. Blinking should not be part of menu. Anything which in on the bottom-right that is the last character and anything on the top-left that first character should be in blinking mode if it is in menu mode. So you save some code on blinking. It all depends on how you have coded your menu.

Hope this will give you some idea.

- - - Updated - - -

here is some example how it can be done


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <stdio.h>
 
    main()
    {
        int menu, numb1, numb2, total;
 
        printf("enter in two numbers -->");
        scanf("%d %d", &numb1, &numb2 );
        printf("enter in choice\n");
        printf("1=addition\n");
        printf("2=subtraction\n");
        scanf("%d", &menu );
        switch( menu ) {
            case 1: total = numb1 + numb2; break;
            case 2: total = numb1 - numb2; break;
            default: printf("Invalid option selected\n");
        }
        if( menu == 1 )
            printf("%d plus %d is %d\n", numb1, numb2, total );
        else if( menu == 2 )
            printf("%d minus %d is %d\n", numb1, numb2, total );
    }



Sample Program Output
enter in two numbers --> 37 23
enter in choice
1=addition
2=subtraction
2
37 minus 23 is 14
 
Last edited by a moderator:

I separate blinking in two function, one is for text blink and second is for number blinking. Because when you want to display number on LCD you add 48 to character to get number in ACII format. For blinking I'm using interrupt and timer2. When timer2 is 1, increment blinkVariable. If blinkVariable is less then 10 TEXT is visible and if blinkVariable is grater than 10 TEXT (or number) is invisible.In interrupt function I reset blinkVariable after reaching value grater than 20. With this I have that effect of blinking. There are a lot of functions in my code: display sensor value, display alarm value, relay value, calibrate sensor, check is sensor value equal alarm value, check relay value. My code is doing checking of buttons as you suggested in your example.
But there is a lot of function and after some entering in sub-menus and calling functions I got Recursion error or cross-calling.

I saw a lot of displays with 20 or more sub-menus based on PIC16F887 PIC and I'm asking if someone write similar application to give me advice or method. Some article or code example would be helpful!

Thank you for your helping!
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top