Announcement

Collapse
No announcement yet.

Help with serial LCD

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    which serial lcd are you using? how often are you sending stuff to it?
    Epox EP-3VWB+ w/VIA C3 750MHz
    Crystalfontz 632 16x2 LCD
    DWW-7VGA 7" Indash VGA w/Touchscreen
    Garmin GPS 18 USB
    Terk XMD1000 XM Tuner (My VB6 Class)
    Scantool.net ElmScan ISO (My VB6 Class)
    PSK-3100 Traveller Keyboard

    Comment


    • #3
      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.

      Comment


      • #4
        Damn that's a nice display, better than my LCD. Post the project zipped up, I'll give it a look..
        Epox EP-3VWB+ w/VIA C3 750MHz
        Crystalfontz 632 16x2 LCD
        DWW-7VGA 7" Indash VGA w/Touchscreen
        Garmin GPS 18 USB
        Terk XMD1000 XM Tuner (My VB6 Class)
        Scantool.net ElmScan ISO (My VB6 Class)
        PSK-3100 Traveller Keyboard

        Comment


        • #5
          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

          Comment


          • #6
            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.
            Epox EP-3VWB+ w/VIA C3 750MHz
            Crystalfontz 632 16x2 LCD
            DWW-7VGA 7" Indash VGA w/Touchscreen
            Garmin GPS 18 USB
            Terk XMD1000 XM Tuner (My VB6 Class)
            Scantool.net ElmScan ISO (My VB6 Class)
            PSK-3100 Traveller Keyboard

            Comment


            • #7
              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.

              Comment

              Working...
              X