News:

;) This forum is the property of Proton software developers

Main Menu

How to appears my next code with voltage value

Started by swsalun, Jul 29, 2021, 04:07 PM

Previous topic - Next topic

swsalun

Hello members,
I trying to make a volt meter and scrolling text.
My plan are :
   1. First on then text on line 1 appears "Power Supply Unit" with scrolling text.
   2. Then after few second "Power Supply Unit" still scrolling and next go to a volt value
   3. During this period all those working same time, mean is text with Power Supply Unit is running in line 1 and another value with result a voltage in line 3 or 4.
 
My problem is, after text is scrolling and value in volt just appears then gone, mean doesn't stay constant.
Also, when scrolling text "Power Supply Unit" appears, why line 3 also have same text, what I need only line 1.
I used 4x20 LCD Line.
So I need some help how to fix it problem, could be that is simple for you, but not for me, anyway awaiting some advice and suggestion from you here.

Here are my code :

;-------------------------------------------------------------------------------
;**** Added by Fuse Configurator ****
; Use the Fuse Configurator plug-in to change these settings

Device = 16F877A

Config FOSC_XT, WDTE_OFF, PWRTE_OFF, BOREN_ON, LVP_ON, CPD_OFF, WRT_OFF, DEBUG_OFF, CP_OFF

;**** End of Fuse Configurator Settings ****
;-------------------------------------------------------------------------------

All_Digital TRUE             
Xtal=4

Declare LCD_Type 0                 
Declare LCD_DTPin PORTB.4         
Declare LCD_ENPin PORTB.2         
Declare LCD_RSPin PORTB.3         

Declare LCD_Interface 4           
Declare LCD_Lines 4               
Declare Float_Rounding = On
Declare Float_Display_Type = LARGE

TRISA =%00001011                                 
ADCON1=100                                       

Symbol My_Value = 5.0/255                 
Dim My_Input1  As Byte   
Dim My_Result  As Float
Dim x As Byte

 x = 1
  DelayMS 100
 Back:
 Print $fe,1, "Power Supply Unit   "
  Print At 3, 1, ""
    DelayMS 100
 
For x = 0 To 20
   Print $FE,$1E   
     
    DelayMS 150
 Next
 ' GoTo Back
 My_Input1 = ADIn 0              
        My_Result = My_Input1*My_Value              
        Print At 4,1,Dec My_Result   
       
        DelayMS 100
 GoTo Back
     

Thank you so much.
Salun

Yasin

It is normal for the text to appear on the third line. Because the continuation of the first line is the third line.
Probably due to a lack of knowledge about the LCD. Character LCDs have an area of 80 bytes. If the LCD is 2x40, the first 1-40 bytes will appear in the first row and 41-80 bytes in the second row. If the LCD is 4x20;
-first line 1-20 bytes
-second line 41-60 bytes
-third line 21-40 bytes
-fourth line 61-80 bytes.

The other problem is that if you scroll with "Print $FE,$1E" command, all memory will be shift. The ring is formed. Accordingly, if you want a fixed position in the fourth line, you should set the current position accordingly. Or you should not shift the LCD and take the text inside the string and process it.

swsalun

Quote from: Yasin on Jul 29, 2021, 04:53 PMIt is normal for the text to appear on the third line. Because the continuation of the first line is the third line.
Probably due to a lack of knowledge about the LCD. Character LCDs have an area of 80 bytes. If the LCD is 2x40, the first 1-40 bytes will appear in the first row and 41-80 bytes in the second row. If the LCD is 4x20;
-first line 1-20 bytes
-second line 41-60 bytes
-third line 21-40 bytes
-fourth line 61-80 bytes.

The other problem is that if you scroll with "Print $FE,$1E" command, all memory will be shift. The ring is formed. Accordingly, if you want a fixed position in the fourth line, you should set the current position accordingly. Or you should not shift the LCD and take the text inside the string and process it.
Could you give me a sample how to place a text only into first line.

Thanks,
Salun

Yasin

#3
I think you mean in shifting text.

;**** Added by Fuse Configurator ****
; Use the Fuse Configurator plug-in to change these settings

Device = 16F877A

Config FOSC_XT, WDTE_OFF, PWRTE_OFF, BOREN_ON, LVP_ON, CPD_OFF, WRT_OFF, DEBUG_OFF, CP_OFF

;**** End of Fuse Configurator Settings ****
;-------------------------------------------------------------------------------

All_Digital TRUE             
Xtal=4

Declare LCD_Type 0                 
Declare LCD_DTPin PORTB.4         
Declare LCD_ENPin PORTB.2         
Declare LCD_RSPin PORTB.3         

Declare LCD_Interface 4           
Declare LCD_Lines 4               
Declare Float_Rounding = On
Declare Float_Display_Type = LARGE

TRISA =%00001011                                 
ADCON1=100                                       

Symbol My_Value = 5.0/255                 

Dim FirstLineStr[20] As Byte
Dim My_Input1  As Byte   
Dim My_Result  As Float
Dim x As Byte

DelayMS 100
x = 1
Print $FE,1
Back:
    FirstLineStr[20-x] = 0
    If x = 1 Then
        StrN FirstLineStr = " Power Supply Unit"
    ElseIf x > 19 Then
        x = 0
    Else
        Print At 1,x,Str FirstLineStr
    EndIf
    Inc x
    My_Input1 = ADIn 0              
    My_Result = My_Input1*My_Value              
    Print At 4,1,Dec My_Result   
    DelayMS 100
    GoTo Back
    End

swsalun

Quote from: swsalun on Jul 29, 2021, 04:07 PMHello members,
I trying to make a volt meter and scrolling text.
My plan are :
   1. First on then text on line 1 appears "Power Supply Unit" with scrolling text.
   2. Then after few second "Power Supply Unit" still scrolling and next go to a volt value
   3. During this period all those working same time, mean is text with Power Supply Unit is running in line 1 and another value with result a voltage in line 3 or 4.
 
My problem is, after text is scrolling and value in volt just appears then gone, mean doesn't stay constant.
Also, when scrolling text "Power Supply Unit" appears, why line 3 also have same text, what I need only line 1.
I used 4x20 LCD Line.
So I need some help how to fix it problem, could be that is simple for you, but not for me, anyway awaiting some advice and suggestion from you here.

Here are my code :

;-------------------------------------------------------------------------------
;**** Added by Fuse Configurator ****
; Use the Fuse Configurator plug-in to change these settings

Device = 16F877A

Config FOSC_XT, WDTE_OFF, PWRTE_OFF, BOREN_ON, LVP_ON, CPD_OFF, WRT_OFF, DEBUG_OFF, CP_OFF

;**** End of Fuse Configurator Settings ****
;-------------------------------------------------------------------------------

All_Digital TRUE             
Xtal=4

Declare LCD_Type 0                 
Declare LCD_DTPin PORTB.4         
Declare LCD_ENPin PORTB.2         
Declare LCD_RSPin PORTB.3         

Declare LCD_Interface 4           
Declare LCD_Lines 4               
Declare Float_Rounding = On
Declare Float_Display_Type = LARGE

TRISA =%00001011                                 
ADCON1=100                                       

Symbol My_Value = 5.0/255                 
Dim My_Input1  As Byte   
Dim My_Result  As Float
Dim x As Byte

 x = 1
  DelayMS 100
 Back:
 Print $fe,1, "Power Supply Unit   "
  Print At 3, 1, ""
    DelayMS 100
 
For x = 0 To 20
   Print $FE,$1E   
     
    DelayMS 150
 Next
 ' GoTo Back
 My_Input1 = ADIn 0              
        My_Result = My_Input1*My_Value              
        Print At 4,1,Dec My_Result   
       
        DelayMS 100
 GoTo Back
     

Thank you so much.
Salun
Yassin,
That revision code by you is working fine, but that text start from third character and is not to start from first character, and also how to make it speed more slower.

Thanks.
Salun