Loop question for lcd

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

 

Hello im trying to make a program that counts speed and kilometers driven from the speed is set and having a problem that i dont know how to refresh lcd or inscrease the valueble by 0.03km every 1 sec. is there a way to increase the valuable by 0.03km every 1 sec? and show it on the lcd? (variable=U3)

 

<

 

 

 

 

 

' Mikrovaldiklio tipas

$regfile = "m8def.dat"

' Taktinis daznis = 4 MHz (vidinis generatorius)

$crystal = 2000000

 

' RS232 baud rate

$baud = 9600

 

' Naudojame I2C magistrale

$lib "i2c_twi.lbx"                                          ' we do not use software emulated I2C but the TWI

Config Scl = Portc.5                                        ' we need to provide the SCL pin name

Config Sda = Portc.4                                        ' we need to provide the SDA pin name

10

 

 

' Tarnybine informacija

$hwstack = 32

$swstack = 8

$framesize = 24

 

 

' Konfiguruojame portu linijas INPUTai/OUTPUTai

Config Portb = Output

Config Portc = Output

Config Portd = Output

 

 

' Rx linija (input)

Config Portd.0 = Input

 

 

 

' Konfiguruojame INPUTus mygtukams

Config Portc.3 = Input

Config Portb.6 = Input

Config Portb.7 = Input

 

' Potenciometrai

Config Portc.0 = Input

Config Portc.1 = Input

 

' Konfiguruojame ADC iejimus

Config Adc = Single , Prescaler = Auto

Start Adc

 

' Du skaiciai po kablelio, realaus kitamuojo formatas

Config Single = Scientific , Digits = 2

 

 

' Nurodome, kurios kojos naudojamos LCD pajungimui

Config Lcdpin = Pin , Db4 = Portb.2 , Db5 = Portb.3 , Db6 = Portb.4 , Db7 = Portb.5 , E = Portb.1 , Rs = Portb.0

' LCD 20 x 4

' Proteus modelis: "LM044L"

Config Lcd = 20 * 4

' Ekranelio inicializacija

Initlcd

' Zymeklis isjungtas ir nemirksi

Cursor Off Noblink

 

 

 

 

 

 

 

 

 

 

 

' Kintamuju paskelbimas

Dim I As Byte

Dim X As Byte

Dim Y As Byte

Dim Sk As Byte

 

Dim U1 As Single

Dim U2 As Single

Dim U3 As Single

Dim U4 As Single

 

Dim Valanda As Byte

Dim Minute As Byte

 

Dim Adc0_value As Word

Dim Adc1_value As Word

 

' Realus skaicius su kableliu

Dim Temp As Single

 

Dim Mas(5) As Byte

 

 

' Simboliniai priskirimai patogumui

Led_r Alias Portd.4

Led_y Alias Portd.5

Led_g Alias Portd.6

 

' Mygtuku simboliniai priskirimai

Myg1 Alias Pinc.3

Myg2 Alias Pinb.6

Myg3 Alias Pinb.7

 

 

 

 

' Pradinis pasisveikinimas

                                             ' dim variable

 

 

 

 

' --------- Testavimas ---------------

 

 

 

 

'-------------------------------------

 

 

 

 

' Amzinas ciklas

Do

 

Debounce Myg1 , 0 , Myg1_pressed , Sub

Debounce Myg2 , 0 , Myg2_pressed , Sub

 

 

   Adc0_value = Getadc(0)

 

   U1 = Adc0_value / 36

   U2 = Adc0_value / 10

   U3 = U1 * 0.001

   U3 = U3 + U3

 

 

 

   Locate 1 , 14

   Lcd "Km " ; U3 ;

 

   Wait 1

 

 

 

  Locate 1 , 1

   Lcd "m/s " ; U1 ;

 

  Locate 2 , 1

   Lcd "km/h " ; U2 ;

 

If U2 = 50.2 Then

Led_g = 1

Led_r = 0

Led_y = 0

End If

 

If U2 >= 50.3 Then

Led_r = 1

Led_g = 0

Led_y = 0

End If

 

If U2 <= 50.1 Then

Led_y = 1

Led_g = 0

Led_r = 0

End If

 

 

 

 

 

'=====================================================================

 

 

 

 

Loop

 

---------------------------------

 

 

 

 

 

 

'===========================================================================

Myg1_pressed:

 

   If Myg1 = 0 Then

  Valanda = Valanda + 1

 

  Locate 4 , 16

  Lcd Valanda

  Waitms 50

  Locate 4 , 18

  Lcd ":"

  End If

 

  If Valanda = 12 Then

  Valanda = 0

  End If

 

Return

'===========================================================================

 

 

'===========================================================================

Myg2_pressed:

 

   If Myg1 = 0 Then

  Minute = Minute + 1

 

  Locate 4 , 19

  Lcd Minute

  Waitms 50

  End If

 

  If Minute = 59 Then

 

  Minute = 00

  End If

 

 

Return

'===========================================================================

 

 

 

 

' pabaiga

End

>

 

Last Edited: Sat. Jan 11, 2020 - 02:51 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

First of all you need to give all the info that you had for example which controller you are using at which clock frequency it's been set to run and of course your problems in details and then what you have done to solve them by yourself..! Give this info I am sure it will make it easier to analyse your problem..Looks to me that you are using Atmega8 at 2MHz frequency, and yes which lcd library you are using make sure that you use some Good ones.

 

 

 

anshumaan kumar

Last Edited: Sun. Jan 26, 2020 - 05:46 AM