Announcement

Collapse
No announcement yet.

Scope Functions

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

  • Scope Functions

    Hello, I have played around with the scope widget and it is great and easy to use.

    However i was wondering is it possible to start plotting the graph from left hand side instead of right hand side ?

    Is it possible to change the scope properties when plotting the graph simultaneously ? I want to be able to auto zoom the graph upon reaching certain X or Y values.

    Finally, I to confirm the properties of the scope Xmag and Yamp.

    Xmag means jumping the X-scale by x times ? lets say i put in a value of 10. Means every refresh increment, it will jump by 10 pixels ?

    Yamp has the value of 100. I see from the application note about the explanation is not very clear. So what does a value of 200 means ? Divide by 2 ?

    Regards,
    Adrian


  • #2
    Most of what you want can be done, but you will need to use Genie Magic, or ViSi to access that level of functionality.

    Have a look at the File, Samples, Diablo Designer, Scope demo to see how the Xmag and Yamp values can be used dynamically. Note that that sample requires "gfx2demo.dat" and "gfx2demo.gci" from the C:\Users\Public\Documents\4D Labs\RESOURCES\GC FILES folder to be on the uSD.

    Xmag can expand or compress the X axis 0 is 1 point = 1 pixel, positive expands, -ve compresses.

    Yamp is Y amplification with 100 being unity, i.e. a value in of 100 is 100 pixels high. 200 will make 100 show as 200 pixels high, 50 will make 100 show as 50 pixels high.

    Can take quite some time to get your head around it, that's for sure.

    Mark

    Comment


    • #3
      Thanks Mark. I saw the demo codes and it is an interesting project. I am new to 4DGL code and i am confused and do not know where to start. Can this code be copy and paste to the Genie Magic ? I have a pro version of the workshop.

      My intention is to plot the graph from the scope 0,0 axis which is on the left hand side of the graph. The input signal will come from Arduino every second up to about 100 seconds. I need the auto zoom function to fill up the scope screen as it takes 100 seconds, hence breakdown the scope graph plot maybe every 20 seconds or so.

      Not sure how to start the 4DGL coding on the Genie Magic, could you give a hand ?

      Comment


      • #4
        Hi Adrian,

        For adding Magic Objects to ViSi-Genie projects, you might want to see the application note:

        ViSi-Genie How to Add Magic Objects http://www.4dsystems.com.au/appnote/4D-AN-00182/

        and the manual

        ViSi-Genie User Reference Manual

        http://www.4dsystems.com.au/product/..._IDE/downloads


        For studying 4DGL it is best to start with the Designer or ViSi environment. Besides the example projects in Workshop, you might find the application notes helpful:

        http://www.4dsystems.com.au/appnotes

        Choose your processor and environment accordingly and click on the search button. All relevant application notes will be displayed by order of increasing difficulty. You may then use the order by which the results are displayed as a guide. You may read the most basic Designer app notes first.

        To display all app notes related to Genie Magic, choose "genie-magic" in the sub-category column.

        Next week I will try to find the time to create a basic scope application in ViSi-Genie Magic. But I trust that after going thru the app notes and the scope example projects in Worskhop, you will have no difficulty writing 4DGL codes for Magic Objects on your own.

        We also have several examples with videos here:

        http://forum.4dsystems.com.au/forum/...elp-or-inspire

        Hope this helps and regards.
        Doff

        Comment


        • #5
          Hello Doff,

          I had done some reading on the 4DGL coding and still lost on plotting the graph from left to right hand side. I see there is a library for the scope in Visi, the "gfx_Scope", which can offset the Y axis either top, bottom or middle but not for X-axis. How do I make the graph starts from bottom left hand side ?

          Could I use Visi Genie Magic and insert the scope widget and use this code together to manipulate the scope functions ? Does it work that way ?

          One idea that came up is upon showing up the form, I initialise or sending "0" in the X-axis to make it go to the left position then I send my values thereafter. Means I send "0"s according to the width of the scope.

          Do help me out.

          Adrian

          Comment


          • #6
            Hi Adrian,

            How do I make the graph starts from bottom left hand side ?
            Attached are project files showing one way of this in ViSi. Have a look and tell me what you think.

            Regards.
            Attached Files
            Doff

            Comment


            • Daniel.Herrera
              Daniel.Herrera commented
              Editing a comment
              Hello, it's very practical yours answers. But i have a problem, in every forum when i try to download the attached archives, appears a white web site and never downlad this files. Please help me with that

          • #7
            Hello Doff,

            Appreciate your help so much. I have seen your code and it is straightforward and can be use for my next phase of my project. Next phase means i store the values from Arduino into the memory card and restore it to the scope function, This will work beautifully.

            But for the first phase of my project it will not work that way. It is because the data and the scope shown have to be in real time or almost real time. I could not wait until the data fill up the width of the scope and then reverse and plot the graph.

            I was thinking to use the line function to draw this scope. I guess it is more straightforward. What do you think ?

            Best regards,
            Adrian




            Comment


            • #8
              Hi Adrian,

              In the demo code, the variable "k" dictates how often the scope is updated. If k = 5, for example, the five left-most elements in the scope are filled with new values, the entire scope is updated, all contents are shifted 5 pixels to the right, and the process is repeated.


              I could not wait until the data fill up the width of the scope and then reverse and plot the graph.
              In the demo code, the scope is initially filled up with values of a sine wave. This is optional. You can bypass this and start plotting immediately. Note that the values of the array elements are zero by default after powering up the display, so you would get a zero line initially.

              In your case, you could let k = 1, such that the scope is updated every pixel. You could then replace

              Code:
              new_y1[i] := SIN(m);
              with

              Code:
              new_y1[i] := getDataFromTheSerialPort(...);

              where getDataFromTheSerialPort(...) is some theoretical function that returns the correct byte from the serial port. You could also integrate the demo code to a ViSi-Genie magic project.


              I was thinking to use the line function to draw this scope. I guess it is more straightforward. What do you think ?
              Yes that is also possible. If you look inside the function "gfx_Scope(...)", you will see lots of functions for drawing lines.

              Were you able to play with the widgets under the Genie Magic pane? You will find links to helpful docs/projects in post # 4 above.

              I will try to integrate the demo code in post # 6 above to a Genie Magic project. If you could kindly wait until until tomorrow or early morning on Monday, I will post the project here. If you were requesting for a normal "right-to-left" scope, then the demo project "MagicScope" would have been the right demo for you.

              File - Samples - ViSi Genie Magic (Picaso/Diablo16) - MagicScope


              The implementation of a left-to-right scope in ViSi-Genie requires the use of two magic objects - the magic code and the magic object.

              Regards.

              Doff

              Comment


              • #9
                Hi Adrian,

                Please see the attached files for the codebase example "ViSi-Genie Magic Left-to-Right Scope with a Host".

                Also, you might want to go ahead and do an advanced reading of the Arduino sketches of the following codebase examples.

                4D-CD-00005 ViSi-Genie Magic Arduino Spectrum

                4D-CD-00004 ViSi-Genie Magic Arduino 32bit LED Digits

                4D-CD-00029 ViSi-Genie Magic Arduino 32bit LED Digits 2

                The Arduino sketch for this codebase example will be very similar to those of the above.

                Hope this helps and regards.
                Attached Files
                Doff

                Comment


                • #10
                  Hello Doff,

                  Thanks for the example. It was helpful. Very well documented as well. I will try out the code and modify it with Arduino.

                  Just a question, I see that you use 4DGL code and insert it into Visi-Genie-Magic. Its there another way of doing it ? Means I layout the scope with the widget then I use the code in the background ? Cause with your design, the scope is not visible on the screen, it will be visible only when it is running on the actual LCD.

                  How did you paste the scope code to the Visi Genie ? I guess you use Visi environment, then copy the whole code and paste it into Visi Genie ?

                  Thanks again for the examples.

                  Regards,
                  Adrian

                  Comment


                  • #11
                    Hi Adrian,

                    How did you paste the scope code to the Visi Genie ? I guess you use Visi environment, then copy the whole code and paste it into Visi Genie ?
                    Yes, that's exactly how I did it. I copied the code for the scope widget in
                    4D-CD-00047 ViSi Displaying a Sine Wave using the Scope Widget
                    and pasted it inside a magic code object in
                    4D-CD-00048 ViSi-Genie Magic Left-to-Right Scope with a Host.
                    That's why 4D-CD-00047 is a pre-requisite of 4D-CD-00048.

                    You can also the same - design a scope widget in a ViSi project (to help you visualize the area to be occupied by the scope in the WYSIWYG screen), copy its code, and paste it inside a magic code object in a ViSi-Genie project.

                    It is also possible for you to use the gfx_Scope(...) function directly inside a magic code object. However, this requires you to manually assign the values of the parameters for gfx_Scope(...). If you use ViSi, Workshop will do this for you.


                    Just a question, I see that you use 4DGL code and insert it into Visi-Genie-Magic. Its there another way of doing it ? Means I layout the scope with the widget then I use the code in the background ?
                    For now this is the only way, that I can think of, of implementing a special left-to-right scope in a ViSi-Genie Magic project. If it were a normal right-to-left scope, you could simply add a scope widget to the WYSIWYG screen and use some Genie Magic callable functions to drive the scope widget. See the example project "MagicScope" in
                    Workshop - File - Samples - ViSi Genie Magic (Picaso/Diablo16) - MagicScope
                    You can also implement everything in ViSi, but you will have to write the code for the serial comms. As a consequence, you may have to create your own communication protocol and your own Arduino library, etc.

                    Hope this helps and regards.
                    Doff

                    Comment


                    • #12
                      In all my 40 years of data acquisition experience a "scope" runs left to right. A right to left drawing mode is known as a "chart recorder", like an EKG. This confuses conversation considerably.

                      Comment


                      • Doff
                        Doff commented
                        Editing a comment
                        Thanks for the information Jblack.

                        BR,
                        Doff
                    Working...
                    X