Announcement

Collapse
No announcement yet.

Use of Flags command

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Use of Flags command

    Hi to all

    Using PBP3 for a simple LCD display. The pic here shows the result using a 16F887.
    Works very well with a DO loop in which all the values are updated from switches with ADC inputs for
    the volume controls.

    Here is the problem. I don't want this display on all the time so arranged with a switch to turn off power
    to both the LCD and back light. Great. But when I tried to turn it back on no go. So added as the first line
    in the main loop before LCDOUT for the first display line the suggested FLAGS=0.

    And now it works. Every time. Only trouble is the last line displaying the temperature has gone. The
    routine for the temp is from the MeLabs site called TEMP_DS1822.pbp. Never would have worked out the
    timing in a million years so thanks to all there. That temp code is the last in the loop and the FLAGS=0 is
    the first.

    Out of my depth with flags here so hope for some help and if possible an explanation of what's
    happening.

    thanks and regards
    Dave.

  • #2
    Usually the first reply with a post like yours is, "Please post your code so we know what you're doing".
    We can crack this cotton PIC'n thang!

    Comment


    • #3
      How long after power is applied are you waiting to send the FLAG=0 command?
      Dave Purola,
      N8NTA
      EN82fn

      Comment


      • #4
        Delay is about 30 seconds.
        Before the main do loop containing the Flags=0 line there is another loop to allow pre-amp tubes to warm up before output is switched on.

        Dave.

        Comment


        • #5
          Are you sending any initial setup commands to the display before it's use? I always send them initially and in instances where I disable the display, I just re-send the commands and away I go. I have never used the FLAGS command. OR maybe instead of powering down the entire display, just disconnect the backlight and send blank characters to all lines of the display. There may be a command for the display to clear the entire screen.
          Dave Purola,
          N8NTA
          EN82fn

          Comment


          • #6
            Thanks Dave.
            That sounds like a great idea.
            As I said earlier this is very much simple boilerplate code.
            So no need boring people to death by publishing 300 lines they have seen many times before.
            Will give it a try and get back to you.

            In the meantime the PCB used was made in China.
            Have 3 spare if you want one.
            tks again Dave.

            Comment


            • #7
              "FLAGS" isn't really a command, it's a system variable that PBP uses to track things that get initialized only once when the program starts. When you write "FLAGS = 0", you're fooling the program into thinking that the LCD hasn't been initialized yet. When any LCDOUT command is next executed, it will send the init sequence to the LCD and set a bit in FLAGS to record that the LCD has been initialized. Subsequent LCDOUT commands won't waist time initializing because they see that FLAGS holds a value.
              Charles Leo
              ME Labs, Inc.
              http://melabs.com

              Comment


              • #8
                I started manually controlling LCD displays. I found an initialization sequence in one of the Hitachi data sheets that fixed a problem nothing else would. I now use it on every LCD project.

                [CODE}
                ;This code is from a Hitachi data sheet to initialize an LCD. This version
                ; uses an entire PORTB for parallel data transmission.

                Init_LCD:
                low RS ;A PORT pin is assigned as OUTPUT and aliased as RS for Register Select
                PORTB = $30
                high En ;A PORT pin is assigned as OUTPUT and aliased as En for ENABLE
                pauseus 4
                low En
                pause 5
                PORTB = $30
                high En
                pauseus 4
                low En
                pauseus 160
                PORTB = $30
                high En
                pauseus 4
                low En
                pauseus 160
                PORTB = $38
                gosub Send
                PORTB = $10
                gosub Send
                PORTB = $0C
                gosub Send
                PORTB = $06
                gosub Send
                PORTB = 1
                gosub Send
                high RS
                ;At this point the LCD is initialized. The following loads Line 1.
                for b0 = 0 to 15
                lookup b0, [" Randy's "], b1
                PORTB = b1
                gosub Send
                next b0
                low RS
                pause 1
                PORTB = $C0
                gosub Send
                high RS
                pause 1
                ; Continue adding screen lines until your screen is loaded with the data you want.
                [/CODE]
                We can crack this cotton PIC'n thang!

                Comment


                • #9
                  I normally use a routine like this:
                  ' ********************************************************************
                  INITLCD: 'INITIALIZE LCD DISPLAY
                  ' ********************************************************************
                  PAUSE 500
                  LCDOUT $fe,$30 'FUNCTION SET COMMAND 8 BIT INTERFACE
                  PAUSE 15
                  LCDOUT $fe,$30 'FUNCTION SET COMMAND 8 BIT INTERFACE
                  PAUSE 15
                  LCDOUT $fe,$20 'SET 4 BIT MODE
                  PAUSEUS 100
                  LCDOUT $fe,$28 'SET 2 FOR LINES
                  PAUSEUS 100
                  LCDOUT $fe,$08 'SET DISPLAY OFF
                  PAUSEUS 100
                  LCDOUT $fe,$01 'CLEAR DISPLAY
                  PAUSEUS 15000
                  LCDOUT $fe,$06 'INCREMENT ADDRESS/NO DISPLAY SHIFT
                  PAUSEUS 100
                  LCDOUT $fe,$0C 'DISPLAY ON/ CURSOR OFF/ BLINK OFF
                  PAUSEUS 100
                  RETURN
                  I am not sure if PBP send's all of these commands as they are different for each unique display.

                  I hope this helps....
                  Dave Purola,
                  N8NTA
                  EN82fn

                  Comment


                  • #10
                    Well I tried this in various places and it's the same result. Thank you to all for the suggestions.
                    However, to re-state: use of the Flags statement does work all the time in a loop.
                    Whenever the power is cut to the LCD then restored the LCD comes back on.

                    But the temperature display on line 4 is blank. If I comment out the Flags line temperature line comes back.
                    But then, the LCD will not come back on.

                    So the real problem seems to be why the following code from the MeLabs site examples page does not display when Flags=0 is active.
                    Here is the code which is in the loop with the Flags statement.

                    Code:
                    ' ======== RETRIEVE AND PROCESS SENSOR TEMPERATURE ===============
                    OWOUT DQ, 1, [$CC, $44] ' Start temperature conversion
                    pause 2000
                    OWOUT DQ, 1, [$CC, $BE]  ' Read the temperature
                    OWIN DQ, 0, [temperature.LOWBYTE, temperature.HIGHBYTE]
                    ' Calculate temperature in degrees C - no decimal places
                    temperature = temperature */ 1600
                    '
                    lcdout $fe,$D4,"Heatsink Temp:",DEC (temperature/100),"  C"
                    Dave.

                    Comment


                    • #11
                      dave
                      the problem is not in the snippet you have posted , its in the code you did not post or in the way the pic is connected to the display [so far not revealed].
                      I would suggest a schematic of your setup and a complete compliable code [including config word] demonstrating the issue to be the best way forward


                      Comment


                      • #12
                        If you are updating the LCD rapidly, it's possible that you ARE sending line 4, but before it has a chance to load you are updating the screen again. Line 4 may never get to load before you are updating it again. I had a situation where line 4 was barely legible. I slowed down the reload and it came out clear.
                        We can crack this cotton PIC'n thang!

                        Comment


                        • #13
                          Thanks Richard.

                          Agree it could be hardware so let's start there.
                          Full schematic attached.

                          Any comments appreciated.

                          regards
                          Dave.

                          Comment


                          • #14
                            dave

                            the unused data pins 0-3 of the lcd are floating , that is not good they should be grounded .

                            you infer that the lcd power is being switched the schematic does not show that happening at all.

                            richard

                            Comment


                            • #15
                              just worked out the lcd power , its ok plus the disp1-3 signals can let the pic know the display has been repowered
                              should be workable

                              Comment

                              Working...
                              X