LCD(pic16f688)


Closed Thread
Results 1 to 2 of 2

Thread: LCD(pic16f688)

  1. #1
    tarr's Avatar
    tarr Guest

    Question LCD(pic16f688)

    hey
    i am program pic16f688 to receive signal from the gyro (MG1101). i am using LAB-x4 development board. iam also using pic basic pro compiler. i sucessfully compile my program but not seeing anything thing appear on the LCD. for example i wanted for "gyro ready" or "hold still" to appear. could anyone help me out how to use the SEROUT command to have my pic running.below is my code.

    ************************************************** **************
    '* Name : UNTITLED.BAS *
    '* Author : [benedict tarr] *
    '* Notice : Copyright (c) 2006 [select VIEW...EDITOR OPTIONS] *
    '* : All Rights Reserved *
    '* Date : 3/22/2006 *
    '* Version : 1.0 *
    '* Notes : *
    '* : *
    '************************************************* ***************

    ' Define LCD registers and bits
    include "modedefs.bas"
    Define LCD_DREG PORTA
    Define LCD_DBIT 4
    Define LCD_RSREG PORTA
    Define LCD_RSBIT 0
    Define LCD_EREG PORTB
    Define LCD_EBIT 1

    LCD var PORTA.1

    SCL VAR PORTC.1
    SDA VAR PORTC.0
    ' EEPROM control = $A0
    ' Gyro control = $AE

    address VAR Byte
    x VAR BYTE
    calibration VAR BYTE[16]
    ar VAR WORD
    br VAR WORD

    ar_ave vAR WORD
    br_ave VAR WORD




    ADCON1 = 7 ' Set PORTA and PORTE to digital
    Low PORTB.2 ' LCD R/W line low (W)
    Pause 500 ' Wait for LCD and gyro to start up


    SEROUT LCD, T2400, [$fe, 1] ' Clear screen
    serout LCD, T2400, ["Begin Initialization"] ' Display message

    'Read 15 calibration bytes and control register from EEPROM
    address = 0
    I2CREAD SDA, SCL, $A0, address, [STR calibration\16], i2cerr

    ' Set INIT and Power Mode 001 in control register value
    calibration[$0F] = %01000001

    ' Write 15 calibration bytes and control register to gyro
    I2CWRITE SDA, SCL, $AE, address, [STR calibration\16], i2cerr

    PAUSE 10 ' needed??

    serout LCD, T2400,["Waiting"] ' Message to user
    ' Begin polling GRNR bit
    waitGRNR:
    address = $08
    I2CREAD SDA, SCL, $AE, address, [x], i2cerr
    If x.1 = 1 Then waitGRNR ' If GRNR, continue polling

    ' GRNR is clear, display message and pause to let stabilize
    serout LCD, T2400,["Gyro Ready", $FE, $C0, "Hold Still..."]
    PAUSE 3000

    ' Take an average reading (64 samples) while gyro is motionless
    ar_ave = 0
    br_ave = 0
    address = 0
    For x = 0 to 63
    pause 1
    I2CREAD SDA, SCL, $AE, address, [ar.byte1, ar.byte0, br.byte1, br.byte0], i2cerr
    ar_ave = ar_ave + (ar >> 6)
    br_ave = br_ave + (br >> 6)
    Next x
    ar_ave = (ar_ave >> 6)
    br_ave = (br_ave >> 6)

    LCDOUT $FE, 1 ' Clear the display
    loop:
    ' Get word values from gyro
    I2CREAD SDA, SCL, $AE, address, [ar.byte1, ar.byte0, br.byte1, br.byte0], i2cerr
    ' Scale the values for readability (divide by 64), subtract from average,
    ' and display signed values as yaw and pitch
    serout LCD, T2400,["Yaw: "], SDEC (ar_ave - (ar >> 6)),[" "],_
    serout LCD, T2400,[$FE, $C0, "Pitch: "], SDEC (br_ave - (br >> 6)),[ " "]

    Pause 100 ' Do it ten times a second
    goto loop





    i2cerr:
    serout LCD, T2400,[$FE, 1, "I2C Error"]
    STOP

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hi tarr,

    Couple of possibilities. The 16F688 has comparators, and individually selectable A/D inputs, so you need to ...
    CMCON0 = 7
    ANSEL = 0
    to be able to use PORTA as digital. ADCON1=7 doesn't work here.

    Also, the LAB-X4 has several jumpers, to select whether you are using the Parallel or Serial interface to the LCD.

    For the Serial interface you should have
    JP7-12 Open
    JP3 - Installed
    Once you turn off the analog ports you should also see the data sent to the LCD on the RS-232 port. (If JP13 is installed)

    When using the serial interface, you don't need the LCD DEFINE's.

    HTH,
      Darrel
    Last edited by Darrel Taylor; - 23rd March 2006 at 21:48. Reason: ANSEL

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts