Announcement

Collapse
No announcement yet.

Gauge to Slow respond

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

  • Gauge to Slow respond

    I dont know if the problem is the processor speed , or is a problem in the code . I think is the processor is to slow for 6 gauge. I not find how many mhz is this processor. Any help i apreciate.


    #platform "uLCD-43PT_GFX2" // Program Skeleton 1.0 generated 10/19/2012 8:36:21 PM #inherit "4DGL_16bitColours.fnc" #inherit "VisualConst.inc" #inherit "6DOF1Const.inc" func main()// var hstrings ; // Handle to access uSD strings, uncomment if required// var hFontx ; // Handle to access uSD fonts, uncomment if required and change n to font number// Uncomment the following if uSD images, fonts or strings used. putstr("Mounting...\n"); if (!(disk:=file_Mount())) while(!(disk :=file_Mount())) putstr("Drive not mounted..."); pause(200); gfx_Cls(); pause(200); wend endif gfx_TransparentColour(0x0020); gfx_Transparency(ON); // hFontn := file_LoadImageControl("6DOF1.dan", "6DOF1.gcn", 1); // Open handle to access uSD fonts, uncomment if required and change n to font number dropping a and c if > 9// hstrings := file_Open("6DOF1.txf", 'r') ; // Open handle to access uSD strings, uncomment if required hndl := file_LoadImageControl("6DOF1.dat", "6DOF1.gci", 1); gfx_Set(SCREEN_MODE,LANDSCAPE) ; // Form1 1.0 generated 10/24/2012 4:00:53 PM // Homebutton1 1.0 generated 10/24/2012 4:00:53 PM img_SetWord(hndl, iHomebutton1, IMAGE_FLAGS, (img_GetWord(hndl, iHomebutton1, IMAGE_FLAGS) | I_STAYONTOP) & ~I_TOUCH_DISABLE); // set to enable touch, only need to do this once img_Show(hndl, iHomebutton1); // show button, only do this once img_SetWord(hndl, iHomebutton1, IMAGE_INDEX, state); // where state is 0 for up and 1 for down img_Show(hndl,iHomebutton1) ; // Starbutton2 1.0 generated 10/24/2012 4:00:53 PM img_SetWord(hndl, iStarbutton2, IMAGE_FLAGS, (img_GetWord(hndl, iStarbutton2, IMAGE_FLAGS) | I_STAYONTOP) & ~I_TOUCH_DISABLE); // set to enable touch, only need to do this once img_Show(hndl, iStarbutton2); // show button, only do this once img_SetWord(hndl, iStarbutton2, IMAGE_INDEX, state); // where state is 0 for up and 1 for down img_Show(hndl,iStarbutton2) ; // Stopbutton3 1.0 generated 10/24/2012 4:00:53 PM img_SetWord(hndl, iStopbutton3, IMAGE_FLAGS, (img_GetWord(hndl, iStopbutton3, IMAGE_FLAGS) | I_STAYONTOP) & ~I_TOUCH_DISABLE); // set to enable touch, only need to do this once img_Show(hndl, iStopbutton3); // show button, only do this once img_SetWord(hndl, iStopbutton3, IMAGE_INDEX, state); // where state is 0 for up and 1 for down img_Show(hndl,iStopbutton3) ; // Menubutton4 1.0 generated 10/24/2012 4:00:53 PM img_SetWord(hndl, iMenubutton4, IMAGE_FLAGS, (img_GetWord(hndl, iMenubutton4, IMAGE_FLAGS) | I_STAYONTOP) & ~I_TOUCH_DISABLE); // set to enable touch, only need to do this once img_Show(hndl, iMenubutton4); // show button, only do this once img_SetWord(hndl, iMenubutton4, IMAGE_INDEX, state); // where state is 0 for up and 1 for down img_Show(hndl,iMenubutton4) ; // Pausebutton5 1.0 generated 10/24/2012 4:00:53 PM img_SetWord(hndl, iPausebutton5, IMAGE_FLAGS, (img_GetWord(hndl, iPausebutton5, IMAGE_FLAGS) | I_STAYONTOP) & ~I_TOUCH_DISABLE); // set to enable touch, only need to do this once img_Show(hndl, iPausebutton5); // show button, only do this once img_SetWord(hndl, iPausebutton5, IMAGE_INDEX, state); // where state is 0 for up and 1 for down img_Show(hndl,iPausebutton5) ; // Userled1 1.0 generated 10/24/2012 4:00:53 PM img_Show(hndl,iUserled1) ; // show initialy, if required img_SetWord(hndl, iUserled1, IMAGE_INDEX, on) ; // where numx is 0 (Off) or 1 (On) img_Show(hndl,iUserled1) ; // Userled2 1.0 generated 10/24/2012 4:00:53 PM img_Show(hndl,iUserled2) ; // show initialy, if required img_SetWord(hndl, iUserled2, IMAGE_INDEX, on) ; // where numx is 0 (Off) or 1 (On) img_Show(hndl,iUserled2) ; // Userled3 1.0 generated 10/24/2012 4:00:53 PM img_Show(hndl,iUserled3) ; // show initialy, if required img_SetWord(hndl, iUserled3, IMAGE_INDEX, on) ; // where numx is 0 (Off) or 1 (On) img_Show(hndl,iUserled3) ; // Userled4 1.0 generated 10/24/2012 4:00:53 PM img_Show(hndl,iUserled4) ; // show initialy, if required img_SetWord(hndl, iUserled4, IMAGE_INDEX, on) ; // where numx is 0 (Off) or 1 (On) img_Show(hndl,iUserled4) ; // SpLabel 1.0 generated 10/24/2012 4:00:53 PM txt_Width(3) ; txt_Height(2) ; txt_FGcolour(TURQUOISE) ; txt_BGcolour(0x3032) ; gfx_MoveTo(144, 0) ; putstr("Servo Position") ; txt_Width(1) ; txt_Height(1) ; // Gauge1 1.0 generated 10/24/2012 4:00:53 PM img_SetWord(hndl, iGauge1, IMAGE_INDEX, frame) ; // where frame is 0 to 100 (for a displayed 0 to 100) img_Show(hndl,iGauge1) ; // Gauge2 1.0 generated 10/24/2012 4:00:53 PM img_SetWord(hndl, iGauge2, IMAGE_INDEX, frame) ; // where frame is 0 to 100 (for a displayed 0 to 100) img_Show(hndl,iGauge2) ; // Gauge3 1.0 generated 10/24/2012 4:00:53 PM img_SetWord(hndl, iGauge3, IMAGE_INDEX, frame) ; // where frame is 0 to 100 (for a displayed 0 to 100) img_Show(hndl,iGauge3) ; // Gauge4 1.0 generated 10/24/2012 4:00:53 PM img_SetWord(hndl, iGauge4, IMAGE_INDEX, frame) ; // where frame is 0 to 100 (for a displayed 0 to 100) img_Show(hndl,iGauge4) ; // Gauge5 1.0 generated 10/24/2012 4:00:53 PM img_SetWord(hndl, iGauge5, IMAGE_INDEX, frame) ; // where frame is 0 to 100 (for a displayed 0 to 100) img_Show(hndl,iGauge5) ; // Gauge6 1.0 generated 10/24/2012 4:00:53 PM img_SetWord(hndl, iGauge6, IMAGE_INDEX, frame) ; // where frame is 0 to 100 (for a displayed 0 to 100) img_Show(hndl,iGauge6) ; // S1Label 1.0 generated 10/24/2012 4:00:53 PM txt_Height(3) ; txt_FGcolour(0xF642) ; txt_BGcolour(BLACK) ; gfx_MoveTo(256, 40) ; putstr("Servo 1") ; txt_Height(1) ; // S2Label 1.0 generated 10/24/2012 4:00:53 PM txt_Height(3) ; txt_FGcolour(0xF642) ; txt_BGcolour(BLACK) ; gfx_MoveTo(256, 80) ; putstr("Servo 2") ; txt_Height(1) ; // S3Label 1.0 generated 10/24/2012 4:00:53 PM txt_Height(3) ; txt_FGcolour(0xF642) ; txt_BGcolour(BLACK) ; gfx_MoveTo(256, 120) ; putstr("Servo 3") ; txt_Height(1) ; // S4Label 1.0 generated 10/24/2012 4:00:53 PM txt_Height(3) ; txt_FGcolour(0xF642) ; txt_BGcolour(BLACK) ; gfx_MoveTo(256, 160) ; putstr("Servo 4") ; txt_Height(1) ; // S5Label 1.0 generated 10/24/2012 4:00:53 PM txt_Height(3) ; txt_FGcolour(0xF642) ; txt_BGcolour(BLACK) ; gfx_MoveTo(256, 200) ; putstr("Servo 5") ; txt_Height(1) ; // S6Label 1.0 generated 10/24/2012 4:00:53 PM txt_Height(3) ; txt_FGcolour(0xF642) ; txt_BGcolour(BLACK) ; gfx_MoveTo(256, 240) ; putstr("Servo 6") ; txt_Height(1) ; var state,on, on1, on2, frame, n, i, x, y, form2, KbButtons, kbDown, KbHandler, kbUp, ledDigitsDisplay, numx,KbDown; touch_Set(TOUCH_ENABLE); repeat state := touch_Get(TOUCH_STATUS); // get touchscreen status n := img_Touched(hndl,-1) ; frame := frame + 1; //----------------------------------------------------------------------------------------- if(state == TOUCH_PRESSED) // if there's a press x := touch_Get(TOUCH_GETX); y := touch_Get(TOUCH_GETY); if (n == iHomebutton1) img_SetWord(hndl, iHomebutton1, IMAGE_INDEX, 0); // where state is 0 for up and 1 for down img_Show(hndl,iHomebutton1) ; img_SetWord(hndl, iUserled1, IMAGE_INDEX, 0) ; // where numx is 0 (Off) or 1 (On) img_Show(hndl,iUserled1) ; endif if (n == iStarbutton2) img_SetWord(hndl, iStarbutton2, IMAGE_INDEX, 0); // where state is 0 for up and 1 for down img_Show(hndl,iStarbutton2) ; img_SetWord(hndl, iUserled2, IMAGE_INDEX, 0) ; // where numx is 0 (Off) or 1 (On) img_Show(hndl,iUserled2) ; endif if (n == iStopbutton3) img_SetWord(hndl, iStopbutton3, IMAGE_INDEX, 0); // where state is 0 for up and 1 for down img_Show(hndl,iStopbutton3) ; img_SetWord(hndl, iUserled3, IMAGE_INDEX, 0) ; // where numx is 0 (Off) or 1 (On) img_Show(hndl,iUserled3) ; endif if (n == iPausebutton5) img_SetWord(hndl, iPausebutton5, IMAGE_INDEX, 0); // where state is 0 for up and 1 for down img_Show(hndl,iPausebutton5) ; img_SetWord(hndl, iUserled4, IMAGE_INDEX, 0) ; // where numx is 0 (Off) or 1 (On) img_Show(hndl,iUserled4) ; endif if (n == iMenubutton4) img_SetWord(hndl, iMenubutton4, IMAGE_INDEX, 0); // where state is 0 for up and 1 for down img_Show(hndl,iMenubutton4) ; endif endif //----------------------------------------------------------- if(state == TOUCH_RELEASED) // if there's a press if (n == iHomebutton1) img_SetWord(hndl, iHomebutton1, IMAGE_INDEX, 1); // where state is 0 for up and 1 for down img_Show(hndl,iHomebutton1) ; img_SetWord(hndl, iUserled1, IMAGE_INDEX, 1) ; // where numx is 0 (Off) or 1 (On) img_Show(hndl,iUserled1) ; endif if (n == iStarbutton2) img_SetWord(hndl, iStarbutton2, IMAGE_INDEX, 1); // where state is 0 for up and 1 for down img_Show(hndl,iStarbutton2) ; img_SetWord(hndl, iUserled2, IMAGE_INDEX, 1) ; // where numx is 0 (Off) or 1 (On) img_Show(hndl,iUserled2) ; endif if (n == iStopbutton3) img_SetWord(hndl, iStopbutton3, IMAGE_INDEX, 1); // where state is 0 for up and 1 for down img_Show(hndl,iStopbutton3) ; img_SetWord(hndl, iUserled3, IMAGE_INDEX, 1) ; // where numx is 0 (Off) or 1 (On) img_Show(hndl,iUserled3) ; endif if (n == iPausebutton5) img_SetWord(hndl, iPausebutton5, IMAGE_INDEX, 1); // where state is 0 for up and 1 for down img_Show(hndl,iPausebutton5) ; img_SetWord(hndl, iUserled4, IMAGE_INDEX, 1) ; // where numx is 0 (Off) or 1 (On) img_Show(hndl,iUserled4) ; endif if (n == iMenubutton4) img_SetWord(hndl, iMenubutton4, IMAGE_INDEX, 1); // where state is 0 for up and 1 for down img_Show(hndl,iMenubutton4) ; endif endif //----------------------------------------------------------------------------------------- // Gauge1 1.0 generated 10/24/2012 4:00:53 PM img_SetWord(hndl, iGauge1, IMAGE_INDEX, frame) ; // where frame is 0 to 250 (for a displayed 0 to 250) img_Show(hndl,iGauge1) ; // Gauge2 1.0 generated 10/24/2012 4:00:53 PM img_SetWord(hndl, iGauge2, IMAGE_INDEX, frame) ; // where frame is 0 to 250 (for a displayed 0 to 250) img_Show(hndl,iGauge2) ; // Gauge3 1.0 generated 10/24/2012 4:00:53 PM img_SetWord(hndl, iGauge3, IMAGE_INDEX, frame) ; // where frame is 0 to 250 (for a displayed 0 to 250) img_Show(hndl,iGauge3) ; // Gauge4 1.0 generated 10/24/2012 4:00:53 PM img_SetWord(hndl, iGauge4, IMAGE_INDEX, frame) ; // where frame is 0 to 250 (for a displayed 0 to 250) img_Show(hndl,iGauge4) ; // Gauge5 1.0 generated 10/24/2012 4:00:53 PM img_SetWord(hndl, iGauge5, IMAGE_INDEX, frame) ; // where frame is 0 to 250 (for a displayed 0 to 250) img_Show(hndl,iGauge5) ; // Gauge6 1.0 generated 10/24/2012 4:00:53 PM img_SetWord(hndl, iGauge6, IMAGE_INDEX, frame) ; // where frame is 0 to 250 (for a displayed 0 to 250) img_Show(hndl,iGauge6) ; //----------------------------------------------------------------------------------------- if(state == TOUCH_MOVING) // if it's moving x := touch_Get(TOUCH_GETX); y := touch_Get(TOUCH_GETY); endif if(frame >= 250) frame := 0; endif foreverendfunc

  • #2


    You haven't quantified 'slow', you haven't said how big the gauges are, you haven't said how fast you 'need' to update your gauges, you are currently updating all gauges at once, have you tried only updating them when they are changed?

    Do some quick math, work out the area of the gauges you are trying to update, multiply by 2 to get the bytes being sent to the display per update and adjust to a megabytes per second you are updating on the screen, I think you will find it is really anything but slow.
    Mark

    Comment


    • #3


      I am new in lcds, Here is a photo of the screen whit gauges , the gauges height is 40 * 310 . I going to send a 6 bite from the arduino to the LCD like this :âABâ byte1 byte2 byte3 byte4 byte5 byte6 byte7 0x0D. Each byte have a value 0 to 250 , this is for map 6 servo position in the screen. I make this code only for test i think the (frame + 1) in the code going to run a little fast, reading the byte i think he going more slower. I need a real time gauges update , and yes the servos going to move fast. Any help i realy appreciate . And sorry for my english is not realy good . I am almost new whit lcd , sorry if i make a lot of mistake .
      Thanks! Attached files

      Comment


      • #4


        Have you tried it ?

        I think you will find the serial quick - 10 bytes (80 bits not counting start and stop but its only a quick calculation)

        If you use 115200 bits per second that is less than 1 ms

        I believe the refresh rate on servos is normally 20 ms so you should have plenty of time to update your display

        Comment


        • #5


          reading the serial, i need a variable for each servo . Reading the serial + the variable , you think is going to update faster? you think i++ whit only 1 variable is more slow tha reading the serial + the variables?? I not understand realy. I think i loos here. You can help me?? Is realy slow and wen i say slow is realy slow updating each gauge he going 1 by 1.

          Comment


          • #6


            Can you post a short video of it?
            Atilla

            Comment


            • #7


              Yes, i going to make a video tomorow.

              Comment


              • #8
                WOW - see what you mean - just done a gauge on its own 414 width max value 250 and it takes 6 seconds to get to full just incrementing frame in a loop

                #platform "uLCD-43PT_GFX2"
                #inherit "4DGL_16bitColours.fnc"
                #inherit "VisualConst.inc"
                #CONST
                iGauge6
                #END
                func main()
                var disk , hndl , frame ;
                putstr("Mounting...\n");
                if (!(disk:=file_Mount()))
                while(!(disk :=file_Mount()))
                putstr("Drive not mounted...");
                pause(200);
                gfx_Cls();
                pause(200);
                wend
                endif
                hndl := file_LoadImageControl("guage.dat", "guage.gci", 1);
                img_SetWord(hndl, iGauge6, IMAGE_INDEX, frame) ;
                img_Show(hndl,iGauge6);
                repeat
                frame := frame + 1;
                img_SetWord(hndl, iGauge6, IMAGE_INDEX, frame) ;
                img_Show(hndl,iGauge6) ;
                if(frame >= 250)
                frame := 0;

                endif
                forever
                endfunc

                Comment


                • #9


                  Here the video. The buttons have problem too, if you see he stay dim sometime , the leds stay on, its suppose to turn off when i touch other button.

                  http://<div class="videocontainer"> ... </a> </div>

                  Comment


                  • #10


                    Based on a rough calculation using the apparent gauge sizes I estimate you would be able to do about 66 updates/second, if that's all you were doing.

                    Using your 0-250 scale multiplying by 6 gauges that comes out to about 23 seconds to do what your code is doing.

                    In addition your code is also checking for and updating buttons continuously.

                    So, a few points.

                    1. Your sample is not really 'real world'
                    2. Scale your gauges reasonably (i.e. consider the actual range of values, the 'useful' range of values and the resolution of the gauge on the display)
                    3. Only update the gauge if it has actually changed, don't waste time drawing it if it's the same

                    Your touch code, which I presume is based on the sample, only detects 'button up' if you release the touch whilst still on that button. You will need to change your code to detect 'button up' by sliding off a button.
                    Mark

                    Comment


                    • #11


                      0- 250 is 1/4 part of the resolution i need , my servo move 1125 steps in 1/2 turn, And no my platform have 6 servo moving constant all the time. This code or sample have all i need , the only i need to add is the serial read , the variables , and put the value in plase + a serial write for the buttons. Why i going to complet the code if a simple one like this not work????? And yes i need a constant check the button for , STOP, PAUSE, START. I going to see how to do (button up) i think this not going to change my problem but if this consume lees is good , Thanks!!

                      Anyone here know the processing speed of this board???
                      I cant belive this board is in the range of HZ!!!

                      Comment


                      • #12


                        I cant belive this board is in the range of HZ!!!
                        I don't think so, as I said before,

                        Do some quick math, work out the area of the gauges you are trying to update, multiply by 2 to get the bytes being sent to the display per update and adjust to a megabytes per second you are updating on the screen, I think you will find it is really anything but slow.
                        I think you will find you are updating the screen at about 1 megabyte per second.

                        Perhaps you need to rethink just what it is that you are trying to achieve and how you are going about it.
                        Mark

                        Comment


                        • #13


                          I'm glad you brought up

                          MidZamp.

                          That is the same processor at the same speed. It is hamstrung by the fact that it is driven serially, driving it from within the display is much faster.

                          I'll say it one more time, it's the way you do it.

                          Change the gauges to Bevel visible, = no and make them 4 wide. Now try it.

                          Again, you have said you gauge is 170 wide and your scale is 0-250, you can't possibly 'see' 250 graduations it 170 pixels (actually less than that, since the Bevel is using part of it), so reduce the scale to 0-169 and try again.

                          *The processsor speed is not really relevant to the speed of any 'animation' as there are all sorts of other things in play, not to mention that there is really no 1 to 1 relationship anywhere. Anyway, if you search these forums more closely you will find references to 45mhz.
                          Mark

                          Comment


                          • #14


                            how you change the value scale of a gauge?? the one i have is 0 to 250 and i try chaingin the scale and not work.

                            if you have the time , you can make a example that run fast and post here?? 1 gauges is ok and 0 to 100 is ok to.

                            Comment


                            • #15


                              Not sure why changing 250 to 100 didn't work, after all the default is 0-100. Maybe you didn't copy the newly generated image to uSD? That would mean the older scale would still be in effect.

                              I have attached a sample using 1) a 'standard' gauge, 2) a 'minimal' gauge and 3) a 'program drawn' gauge. All are 0-100, but the program drawn one is 200 pixels high 'to make it simple'.

                              I'll put the results obtained here running it on a uLCD-32PT just so we can discuss them, I would expect the results on a 43PT to be fairly similar, unless the sizes are changed.

                              Large Image 159 Val/sec
                              Small Image 346 Val/sec
                              Full Drw 149 Val/sec
                              Smrt Drw 3667 Val/sec
                              Smrt Drw rnd 417 Val/sec

                              Getting rid of the border and making the image narrower more than doubled the values per second rate. You could create a border image and just draw it once (or draw it manually) if you really wanted it.

                              A Full 'program drawn' gauge is slower than the large image, this demontrates the effectiveness of the uSD read 'speed'.

                              A Smart 'program drawn' gauge using incrementing values is ridiculously fast, this is because it is only drawing a single bar until it reverts to 0. The Random Smart 'program drawn' gauge is a truer indication of 'program drawn' speed.

                              Note, however, that it is only about 20% faster than the 'small image', so if you had to scale it in the program to be the size of the 'small image', it would probably slow it down quite a bit with all the extra code.

                              Hopefully that gives you some food for thought. Attached files gauges.zip (2 KB)
                              Mark

                              Comment

                              Working...
                              X