Results 1 to 7 of 7

Thread: Help with serial LCD

  1. #1
    Variable Bitrate
    Join Date
    Sep 2004
    Posts
    440

    Help with serial LCD

    The crap continues. I have stoped my software from locking up. I had to disconect the CTS line from the lcd. I'm not sure why this would stop it from locking my software up but it dose.

    Now I have a new problem when ever I play a movie (in any player) or there is a flash animation playing the text that is going to the serial lcd gets all messed up. I'm working in vb6 so if any one would like to help me out I will post my project.

  2. #2
    Low Bitrate Erorus's Avatar
    Join Date
    Feb 2005
    Location
    NEPA
    Posts
    100
    which serial lcd are you using? how often are you sending stuff to it?

  3. #3
    Variable Bitrate
    Join Date
    Sep 2004
    Posts
    440
    Noritake 7000 series (vfd but works the same as lcd). I'm trying to send data ever 250ms or every 500ms.

    It is a 4x20 display.

  4. #4
    Low Bitrate Erorus's Avatar
    Join Date
    Feb 2005
    Location
    NEPA
    Posts
    100
    Damn that's a nice display, better than my LCD. Post the project zipped up, I'll give it a look..

  5. #5
    Variable Bitrate
    Join Date
    Sep 2004
    Posts
    440
    Here is the whoal project file. You can just ignore the dll in there.

    The display is nice but it is honestly no good if I can't get this software to work.
    Attached Files Attached Files

  6. #6
    Low Bitrate Erorus's Avatar
    Join Date
    Feb 2005
    Location
    NEPA
    Posts
    100
    I think you're doing way too much in the interval time, slowing your app down. Since you disconnected CTS, the PC will send stuff to the LCD whenever it can, even if the LCD isn't ready for the input, causing corruption.

    Let's take a look at all the function calls you make every 250ms:

    Winamp_gettrackposition calls sendmessage to Winamp, synchronous call
    Winamp_gettracklength calls sendmessage to Winamp, synchronous call
    getwinampsong calls getwindowtext, synchronous call

    compilemessage calls:
    readini 9 times, which calls getprivateprofilestring each time, synchronous call
    hhmmss 8 times,
    total/availphysmem 8 times, which calls globalmemorystatus, synchronous call
    uptime 4 times, which calls gettickcount, synchronous call,
    drawbar 4 times,
    sendmessage 4 times

    on every drawbar call:
    winamp_tracklength twice and winamp_trackposition once, each which call sendmessage to winamp, synchronous call

    on every sendmessage call:
    you loop up to 20 times with (minor) string manipulation
    call sleep for 1ms three times (why?)
    send output to the comm port up to 3 times

    so, in all, every 250ms, you effectively call functions around 68 times.. 36 of which are synchronous calls to the OS/Winamp which may take longer than execution within your program. This allows each function, on average, under 3.7ms. Sure, most of the functions are trivial, but you're definitely chewing up processor time where you don't have to.

    Cache some strings where you can. Once you read the INI file, store the result into a module-level or static variable; there's no need to call readini all the time. Get the gettickcoutn once on startup, and calculate the startup date and store that as a module/global variable. Then do a datediff on that and now to get uptime. Call total/avail phys mem once every 3 seconds, or every 5 or however many you care, and store that in a variable you read on display; that stuff doesn't change so much that you'd care it's off by a few seconds. Don't call each function once per line in your compilemessage sub, call them once per call, store them in strings, and send the strings to sendmessage. Better yet, don't call sendmessage once per line, call it once per 4 lines when you have the whole screen ready to send in one string. Be smart about loops, they're costly when they have to be executed quickly every so often.. replace this:
    Code:
        For x = 1 To maxlength
            If x <= Len(Msg) Then
                tmpMsg = tmpMsg & Mid(Msg, x, 1)
            Else
                tmpMsg = tmpMsg & Chr$(32)
            End If
        Next x
    With this:
    Code:
    tmpmsg = left(msg, maxlength)
    if len(tmpmsg) < maxlength then tmpmsg = tmpmsg & space(maxlength - len(tmpmsg))
    And you just saved yourself hundreds of cycles. In your case, memory is cheap; time is not.

  7. #7
    Variable Bitrate
    Join Date
    Sep 2004
    Posts
    440
    Thats all good points. I planed to cach the ini file at start up to a project wide variable but have not got around to figuring out/making a module to grab settings out of the var yet.

    The problem with compiling the whoal screen at once and then trying to send it is the VFD hates realy big strings. I can only send 15 ascii charectures at a time before it can't handle any more.

    I see were all of this will speed up geting data to the display but I'm not sure how it would be causing it to lock up unless the timer just keeps geting further and further held off by loops in the code tell it breaks.

Similar Threads

  1. Replies: 97
    Last Post: 09-18-2006, 01:56 PM
  2. Wild Things PSone LCD to PC
    By godzi11a in forum LCD/Display
    Replies: 17
    Last Post: 11-22-2005, 07:13 PM
  3. Replies: 4
    Last Post: 12-22-2002, 09:18 PM
  4. lcd datasheet help
    By oddcomp in forum LCD/Display
    Replies: 1
    Last Post: 11-08-2002, 10:24 AM
  5. Matrix Orbital Serial LCD
    By JrFaust in forum General Hardware Discussion
    Replies: 0
    Last Post: 06-24-2000, 11:31 PM

Bookmarks

Posting Permissions

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