LCDOUT with MPASWIN


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    Sep 2006
    Posts
    747

    Default LCDOUT with MPASWIN

    HI,

    Cant seem to troubleshoot this problem. The LCD is showing random characters, This line
    Lcdout "Right: ", Dec right
    is showing right: XXXX ( The XXX are random characters)
    Also sometime i turn on the circuit I only see the last few characters of the word 'Right' including the random characters...
    Must be a timing, or clocking issue.
    IM using microcode studio with MPASMWIN
    any ideas?

    Ken

    Code:
    INCLUDE "modedefs.bas" 'Includes supoprt for PicBasic language
     
    OSCCON = %01110000 '8 Mhz
    DEFINE OSC 8
    
    CMCON = 7 : ANSEL = 0 : ADCON1 = 7
    DEFINE LCD_DREG PORTB ' Set LCD Data port
    DEFINE LCD_DBIT 4 ' Set starting Data bit (0 or 4) if 4-bit bus
    DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
    DEFINE LCD_RSBIT 1 ' Set LCD Register Select bit
    DEFINE LCD_EREG PORTB ' Set LCD Enable port
    DEFINE LCD_EBIT 0 ' Set LCD Enable bit
    DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
    DEFINE LCD_LINES 2 ' Set number of lines on LCD
    DEFINE LCD_COMMANDUS 2500
    DEFINE LCD_DATAUS 250
    DEFINE CHAR_PACING 1000
    
    ' Define ADCIN parameters
    Define ADC_BITS 10 ' Set number of bits in result
    Define ADC_CLOCK 3 ' Set clock source (3=rc)
    Define ADC_SAMPLEUS 50 ' Set sampling time in uS
    
    ADCON1 = %11000001 ' Set PORTA analog and RIGHT justify result
    ADCON0 = %00000001 ' Configure and turn on A/D Module
    
    TRISB = 0
    TRISA = 1
    
    right var word : oldright var word 
    right = 500
      
    mainloop:
    
    ADCON0.2 = 1 'Start Conversion
    oldright = right 'Pot reading 1
    ADCIN 0, right 'Read channel PORTA.0
    pause 50
    
    right = (right +oldright)/2 'Reducing the fluctuating output by taking an average
    
    
    Lcdout $fe, 1 'Clear screen
    Lcdout "Right: ", Dec right 'Display the decimal value
    pause 100
    
    goto mainloop
    end

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: LCDOUT with MPASWIN

    Hi,
    Verify that the PIC is running at the speed you think it is, otherwise the set timings will be wrong. If it IS running at 8MHz then try increasing the LCD_COMMANDUS and LCD_DATAUS defines.
    I don't think MPASM has anything to do with it.

    /Henrik.

  3. #3
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default Re: LCDOUT with MPASWIN

    HI,
    I changed the values for LCD_COMMANDUS and LCD_DATAUS but that did not change anything. How do I check internal oscillation ??

    I also ADDED hpwm COMMAND and I get the oscillation output wanted, so I guess the clocking is good...

    K
    Last edited by lerameur; - 4th March 2013 at 15:18.

  4. #4
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Default Re: LCDOUT with MPASWIN

    150 ms between readings must be a bit tooshort to see anything clear ...

    also add PAUSE > 700ms before sending the first data stream ( just once @ power up ) to the LCD ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  5. #5
    Join Date
    Sep 2006
    Posts
    747


    Did you find this post helpful? Yes | No

    Default Re: LCDOUT with MPASWIN

    I am down with just the LCDOUT commands:
    still giving awkward letters on the LCD:
    INCLUDE "modedefs.bas" 'Includes supoprt for PicBasic language

    OSCCON = %01110000 '8 Mhz
    DEFINE OSC 8

    '/////////////////////////
    '// LCD configuration //
    '/////////////////////////

    DEFINE LCD_DREG PORTB ' Set LCD Data port
    DEFINE LCD_DBIT 4 ' Set starting Data bit (0 or 4) if 4-bit bus
    DEFINE LCD_RSREG PORTB ' Set LCD Register Select port
    DEFINE LCD_RSBIT 0 ' Set LCD Register Select bit
    DEFINE LCD_EREG PORTB ' Set LCD Enable port
    DEFINE LCD_EBIT 1 ' Set LCD Enable bit
    DEFINE LCD_BITS 4 ' Set LCD bus size (4 or 8 bits)
    DEFINE LCD_LINES 2 ' Set number of lines on LCD
    DEFINE LCD_COMMANDUS 2500
    DEFINE LCD_DATAUS 250
    DEFINE CHAR_PACING 2000
    pause 1000


    Mainloop:

    lcdout $FE,1, " This is a test" '
    lcdout $FE,$C0, "Next or Select" '
    pause 200

    GOTO Mainloop
    End

  6. #6
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,648


    Did you find this post helpful? Yes | No

    Default Re: LCDOUT with MPASWIN

    a scheme would be helpful ... especially to see how contrast and R/W lines are connected ...
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. LCDOUT and 4 *40 displays
    By chips123 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 25th September 2011, 02:44
  2. LCdout
    By lerameur in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd December 2006, 16:14
  3. 8bit LCDout vs 4bit LCDout
    By keithdoxey in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 24th May 2006, 12:16
  4. Lcdout
    By docwisdom in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 11th February 2006, 01:39
  5. LCDOUT help
    By f6ggy in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 6th October 2003, 12:51

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