Announcement

Collapse
No announcement yet.

issue addressing a second gauge

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

  • issue addressing a second gauge

    Hello,

    I've built a project that shows two LED bar graphs on one 128-G2.

    When I try and make it work with serial commander, I can activate one bar graph (the one on the left, address 0X0000, 0X0000) but not the one on the right (address 0X000A, 0XB200).

    When I send the following with serial commander, here is what happens...

    media_Init[FFB1 ] 0.197 (ACK 4 0x0004)
    SSTimeout[000C 0000] 0.022 (ACK)
    media_SetAdd[FFB9 0000 0000] 0.024 (ACK)
    media_VideoFrame[FFBA 0000 0000 0019] 0.032 (ACK)
    media_SetAdd[FFB9 000A B200] 0.023 (ACK)
    media_VideoFrame[FFBA 000A B200 0019] 0.026 (ACK)
    media_VideoFrame[FFBA 0000 0000 0032] 0.043 (ACK)
    media_VideoFrame[FFBA 000A B200 0032] 0.013 (ACK)

    Lines 1 through 4 work fine.
    In line 5 I set the address of the gauge on the right side.
    In line 6 I try and send it a frame, but the display never shows the right side bar graph.
    In line 7 I send a frame to the left side bar graph, works fine.
    In line 8 I try again to send a frame to the right side bar graph, no luck.

    Here are the contents of the inc file showing the addressing I'm using...

    // File generated 3/2/2014 12:08:45 PM
    // Warning! This is a generated file, any manual changes will be
    // lost during the next generation.

    // object indexes for Inputs, Image Addresses + Input Array
    #CONST
    iGauge1H 0x0000
    iGauge1L 0x0000
    iGauge2H 0x000A
    iGauge2L 0xB200
    Inputs 0
    #END

    What am I missing here?

    Thanks,

    John

  • #2


    The second and third parameters are X and Y locations on the screen

    In lines 6 and 8 you have specified the image byte address on the uSD as X + Y

    the image will be there, if your screen was big enough, starting at 10(x), 45568(y).
    Mark

    Comment


    • #3


      Thanks for the quick reply!

      When I convert the iGauge2L address, 0xB200 (which I'm getting from the INC file), to decimal I get 45568.

      If that is incorrect, which seems to be the case, how do I determine the proper x any values of the second gauge?

      Thanks again,

      John

      Comment


      • #4


        The X and Y values are where you placed the object on the screen. (left and top)

        If you use the paste code you will see them, but, really you can see them in the left and top parameters of the object
        Mark

        Comment


        • #5
          Still something not right.

          Here is the code I'm using to make the gauges...

          Code:
          #platform "GOLDELOX"
           
          // Program Skeleton 1.0 generated 3/2/2014 10:41:58 AM
           
          #inherit "4DGL_16bitColours.fnc"
           
          #inherit "VisualConst.inc"
           
          #inherit "dual bar graphsConst.inc"
           
           
          func main()
           
              print("Starting\n") ;
              while(!media_Init())
                  putstr("Drive not mounted...");
                  pause(200);
                  gfx_Cls();
                  pause(200);
              wend
           
              var left := 25;                         // initial value for left gauge
              var right := 75;                        // initial value for right gauge
           
              // Gauge1 1.0 generated 3/2/2014 10:45:04 AM
              media_SetAdd(iGauge1H, iGauge1L) ;      // point to the Gauge1 image
               // Gauge2 1.0 generated 3/2/2014 10:45:13 AM
              media_SetAdd(iGauge2H, iGauge2L) ;      // point to the Gauge2 image
           
              media_VideoFrame(0, 26, 0) ;            // lines 31-56 lines quickly run both gauges
              media_VideoFrame(94, 26, 0) ;           // up and down in increments of 25
              pause (250);
              media_VideoFrame(0, 26, 25) ;
              media_VideoFrame(94, 26, 25) ;
              pause (250) ;
              media_VideoFrame(0, 26, 50) ;
              media_VideoFrame(94, 26, 50) ;
              pause (250) ;
              media_VideoFrame(0, 26, 75) ;
              media_VideoFrame(94, 26, 75) ;
              pause (250) ;
              media_VideoFrame(0, 26, 100) ;
              media_VideoFrame(94, 26, 100) ;
              pause (250) ;
              media_VideoFrame(0, 26, 75) ;
              media_VideoFrame(94, 26, 75) ;
              pause (250) ;
              media_VideoFrame(0, 26, 50) ;
              media_VideoFrame(94, 26, 50) ;
              pause (250);
              media_VideoFrame(0, 26, 25) ;
              media_VideoFrame(94, 26, 25) ;
              pause (250);
              media_VideoFrame(0, 26, 0) ;
              media_VideoFrame(94, 26, 0) ;
           
              pause (1000);
           
              repeat
           
              media_VideoFrame (0, 26, left);        // where left is 0 to 100 (for a displayed 0 to 100)
              media_VideoFrame (94, 26, right);      // where right is 0 to 100 (for a displayed 0 to 100)
              pause (2000);
              media_VideoFrame (0, 26, right);
              media_VideoFrame (94, 26, left);
              pause (2000);
           
              forever
           
          endfunc
          From the above, if I'm understanding correctly, the address of the first gauge is 0x and 26y, and the address of the second gauge is 94x and 26y.

          When I run the above code, everything works great. I see both gauges and they do what I expect them to do.

          But when I do this in serial commander...

          media_Init[FFB1 ] 0.084 (ACK 4 0x0004)
          media_SetAdd[FFB9 0000 001A] 0.024 (ACK)
          media_VideoFrame[FFBA 0000 001A 0032] 0.031 (ACK)
          media_SetAdd[FFB9 005E 001A] 0.016 (ACK)
          media_VideoFrame[FFBA 005E 001A 0032] 0.019 (ACK)

          I can see the left gauge, but never the right one, even though I'm using the same x and y address values that work in the Visi environment.

          Thanks,

          John

          Comment


          • #6


            You Serial Commander code is rather confused...

            In ViSi you have

            media_SetAdd(iGauge1H, iGauge1L) ; // point to the Gauge1 image

            This is the address of gauge image on the uSD card, from what you said earlier this values are

            0x0000, 0x0000 for Gauge 1
            0x000A, 0xB200 for Gauge 2

            So the equivalent Serial Commander commands would be
            media_SetAdd[FFB9 0000 0000]
            and
            media_SetAdd[FFB9 000A B200]

            You then have
            media_VideoFrame(0, 26, 50) ;
            or
            media_VideoFrame(x, y, frame) ;

            Which specifies the frame and where to put it on the display
            media_VideoFrame[FFBA 0000 001A 0032]
            or
            media_VideoFrame[FFBA 005E 001A 0032]
            Mark

            Comment


            • #7


              Ok, got it working, thanks for the help!

              One question though, it works just as well if I don't even put in the media_SedADD command. Is there a good reason to use it even though it works without it?

              Thanks,

              John

              Comment


              • #8


                Errr, Hmmm, maybe because you are displaying the first only? (as the address is initially 0,0)

                It certainly can't reposition 'automagically', it has no idea where the images are.
                Mark

                Comment


                • #9


                  My question was "One question though, it works just as well if I don't even put in the media_SedADD command. Is there a good reason to use it even though it works without it?". That is what I need an answer to.

                  Secondly, when I send the command $FF $E4 $00 $01 $00 $01, I expect that the cursor will go to column 1 line 1, which it does. But it returns F0, and not 06 which the documentation suggests that it should. Why might this be?

                  Thanks,

                  John

                  Comment


                  • #10


                    One possibility is that F0 is the result for the previous command that has not been 'read'.

                    The other is that there is a slight baud rate mismatch.

                    Initially the address media_SedADD is 0, so if you want 0 for the first use then you don't need to set it. But other than that you will need it
                    Mark

                    Comment


                    • #11
                      How would I go about diagnosing a "slight" baud rate mismatch?

                      Thanks,

                      John

                      Comment


                      • #12
                        What baud rate are you talking at and what is your controller?
                        Mark

                        Comment


                        • #13
                          9600 with a Basic Stamp 2e as the controller.

                          I'm now down to just sending serial commands, no graphic or anything fancy. Works fine for 10 or 15 minutes and then it just freezes.

                          In post #10, you said that it's possible that the F0 is a result of a previous command not being "read". What can I do to ensure that all commands are read, or at least have time to be read? Is there some mechanism I can incorporate into my code that halts the program, so to speak, until the previous command has been read and acknowledged?

                          Thanks,

                          John

                          Comment


                          • #14
                            By being read, I mean the previous command had responses in addition to the ACK which you have not read in.

                            Now that you say that it works fine for 10 or 15 minutes I don't think that would be the case.

                            Now that I know what you are using I can see that the baud rate error might be an issue.

                            The BS 2e at 9600 is actually 9615, or 0.16% high, Goldelox at 9600 is actually 9584, or 0.16% low, giving a combined error of 0.32%. Normally I wouldn't thing this would be an issue, but I do not know the sampling rate of the BS, and since the highest baud rate of the BS is quite low I suspect the sampling rate is also low which may be making 0.32% too much.

                            Are you sending data continuously, or are there breaks in transmission? (breaks allow for a slightly higher error %age)

                            Regardless, at 19200 and 38400, both BS 2e and Goldelox are 0.16% high, so there's a chance, if you up the baud rates that your problem will vanish.
                            Mark

                            Comment

                            Working...
                            X