SpinScope: A Virtual Oscilloscope for the Propeller

1246

Comments

  • Cluso99Cluso99 Posts: 14,235
    edited November 2014 Vote Up0Vote Down
    Phil,

    Are you willing to post the code that displays on the scope within the browser?

    I have looked at the spinscope html file. I think I can figure how to add some bits but am not sure how this fits together.

    What I am wondering is that since I am saving the full 32 IO pins, I thought it might be nice to add some more channels to the scope (digital only).

    Perhaps I could also add scroll buttons (not scroll bars) that can shift thru the 500 samples while expanding them. Maybe even increase the depth, and select a section of 500 points from that.

    Your thoughts???
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • Heater.Heater. Posts: 21,205
    edited November 2014 Vote Up0Vote Down
    Clusso,

    Everything needed to display the scope is contained in scopespin.html

    What you don't have is the "source" to the background image of the scope on to which the traces are drawn. Phil uses a HTML5 canvas element placed over that image to draw the traces onto. Then there are the other UI elements, buttons etc, just HTML tags laid over the image.

    That image is in the html file as a script tag that uses a base64 encoding of a .png graphic.

    I cut out that base64 and decoded it back into a png the other day. It is attached.

    Just use the base64 command to encode a png and add the -d switch to decode back to a png.


    Edit: Of course that png need not be the "source" so I guess it does not help much if you want to make changes.
    750 x 550 - 6K
  • Cluso99Cluso99 Posts: 14,235
    edited November 2014 Vote Up0Vote Down
    heater,
    Thanks for the info although I am still a bit confused.

    First up I would just like to add another channel trace and I presume that is the html5 canvas you are referring to. So, can I just add to the canvas??? If yes, how???
    I presume this is just changing the html source. I added a 10us timebase option to this although obviously it is not in the .exe compilation. However, if I can at least get this part done and then wait for Phil, at least it would be progress.

    Then, how would I add that into the SpinScope.exe ??? Presume this is at least where I need the source.
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • Cluso99Cluso99 Posts: 14,235
    edited November 2014 Vote Up0Vote Down
    Thanks heater,
    Worked out how to mod the html to add what I want. Still need to figure out compilation etc. But its a good start.
    SpinScope006.jpg


    BTW How did you get the analog data into xxxx to display it???

    spinscope_005_html.zip
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • Heater.Heater. Posts: 21,205
    edited November 2014 Vote Up0Vote Down
    Ah, you worked it out already.

    I was just doing a quick hack to spinscope.html as an example for you. Basically I added a little loop to draw a third trace of. All you have to do is moveTo and line calls on the canvas contect object. So I just added this to the bottom of the drawTraces function
          var i, sample;
          y0 = 300;
          context.moveTo(x0, y0);
          for (i = 0; i < 520; i+=1) {
              sample = Math.sin(8 * Math.PI * i / 520) * 20
              context.lineTo(x0 + i, y0 + sample);
          }
          context.stroke();
    
    You can see it working here: http://the.linuxd.org/lab/

    Anyway, you know that already.
    How did you get the analog data into xxxx to display it???
    spinscope.html makes AJAX requests to the server to get the next batch of samples for the two traces.

    You will see a run() function in there which sets a timer, which when it times out will call loadXMLDoc('trace').
    The loadXMLDoc function calls xmlhttp.open() and xmlhttp.send() to make the request to the server.

    When the reply is received we end up in the xmlhttp.onreadystatechange() function. Which handles all the replies from the server and may well call loadXMLDoc('trace') again if we in the running state. Thus we get continuous updates.

    We can't change any of the server side behaviour until Phil releases his Perl source code.

    How did I get data in there? I wrote a little server of my own in JavaScript using node.js.

    The trace generating part of that looks like this:
    function samples() {
        var samples = [],
        sample,
        i;
        for (i = 0; i < 1040; i += 1) {
            sample = Math.sin(32 * 2 * Math.PI * i / 520);
            sample *= Math.sin(2 * Math.PI * i / 520) * 50;
            sample += Math.random() * 20;
            samples.push(sample);
        }
        return samples;
    }
    
    // Scopes trace request
    app.get('/trace', function (req, res, next) {
        var message = {command: 'T'}; 
        message.trace = samples();
        res.send(message);
    });
    

    JavaScript server code attached. It's very rude and crude and does not handle any anther requests from the scope or communicate with a propeller yet.
  • Cluso99Cluso99 Posts: 14,235
    edited November 2014 Vote Up0Vote Down
    heater,
    Nice sine wave 3rd trace.
    I just updated my previous post with the html file.

    Thanks for the MoveTo info etc. I will take a quick look before I retire. Phil might chime in overnight, depending on how busy he is with his course.

    Of course with a P1V we could do this automatically in the FPGA too;)
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • Heater.Heater. Posts: 21,205
    edited November 2014 Vote Up0Vote Down
    Cluso,

    I just put your version of spinscope onto http://the.linuxd.org/lab/
  • Cluso99Cluso99 Posts: 14,235
    edited November 2014 Vote Up0Vote Down
    Thanks heater - looking good.
    I tried to add the code to the drawTraces function but it didn't display anything. I presume this is where I need the server to display anything?
    Going to retire in a few mins anyway. Thanks again!
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • Dave HeinDave Hein Posts: 5,641
    edited November 2014 Vote Up0Vote Down
    Phil, I tried out SpinAScope and it looks great! I was just curious whether the functionality of SpinScope.exe could be done on the Prop itself. I'm assuming this could be done if the Prop had an ethernet interface, but could it be done over a serial port as well? Can browsers talk to a device over a serial port using the HTTP protocol?
  • Heater.Heater. Posts: 21,205
    edited November 2014 Vote Up0Vote Down
    Dave,

    No. Current browsers cannot talk to serial ports at all. Except....

    The only way I know for a browser to talk over a serial port is to wrap up the HTML, CSS, and JavaScript of a "web app" as an extension to the Chrome browser. Basically making a Chrome Book app out of it.

    I am currently working, slowly, on doing exactly that with SpinScope.

    This is the same problem as getting a Spin WEB IDE talking to and programming a Prop. For example msrobots Editor17.

    Hmmm....thinks...of course if we could get a Prop to talk the slip protocol over a serial link it would show up as a network device, on linux/BSD at least. Then we could have the Prop serve up everything to any browser itself. i doubt we are about to get slip and the IP stack and a web server running on a Prop soon.

    It's IMPOSSIBLE :)
  • Cluso99Cluso99 Posts: 14,235
    edited November 2014 Vote Up0Vote Down
    heater & Dave,
    Perhaps the ESP8266 (Serial to WiFi) could be a cheap way to do the "web app" with a prop ???
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • Heater.Heater. Posts: 21,205
    edited November 2014 Vote Up0Vote Down
    I believe that is what msrobots was doing with his Editor17 IDE. The Propeller was serving up the HTML for the IDE, taking care of source file uploads/downloads. And perhaps some how reprogramming itself. I'm not sure.

    I'm not really into the idea. I want an IDE and tools that works with a naked Propeller over serial as does the Propeller Tool.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 22,093
    edited November 2014 Vote Up0Vote Down
    Dave Hein wrote:
    Can browsers talk to a device over a serial port using the HTTP protocol?
    The short answer is no. It's a security feature of JavaScript that prevents it. That said, howver, there is Google's ChromeApps, which extends the JavaScript paradigm to include things like serial comms and file I/O.

    -Phil
    “Perfection is achieved not when there is nothing more to add, but when there is nothing left to take away. -Antoine de Saint-Exupery
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 22,093
    edited November 2014 Vote Up0Vote Down
    I posted the latest version (1.1) of SpinScope in post #1. Changes:
    1. "Visual time" monitoring of all 32 pins, displayed below the scope face.

    2. Proper start/stop routines in SpinScope.spin.

    3. Install program lets you select the location of the Spin Library (or wherever you want SpinScope.spin to reside).

    Here's an updated screen image:

    attachment.php?attachmentid=111787&d=1415229383

    And the program that generated it:
    CON
    
      _CLKMODE      = XTAL1 + PLL16X
      _XINFREQ      = 5_000_000
    
    OBJ
    
      sco   : "SpinScope"
    
    PUB start | i, j
    
      sco.start
      dira[15..0]~~
      i~
      repeat
        outa[15..0] := i++       
    

    -Phil
    758 x 579 - 34K
    “Perfection is achieved not when there is nothing more to add, but when there is nothing left to take away. -Antoine de Saint-Exupery
  • Cluso99Cluso99 Posts: 14,235
    edited November 2014 Vote Up0Vote Down
    This is really neat !!!
    I posted the latest version (1.1) of SpinScope in post #1. Changes:
    1. "Visual time" monitoring of all 32 pins, displayed below the scope face.

    2. Proper start/stop reoutines in SpinScope.spin.

    3. Install program lets you select the location of the Spin Library (or wherever you want SpinScope.spin to reside).

    .....

    -Phil

    Phil,
    Might you consider posting the source so I can add 7 traces, etc, (see above posts) please ???
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 22,093
    edited November 2014 Vote Up0Vote Down
    Here you go, Ray -- and anyone else who's interested. 'Hope you're not sorry you asked! :)

    Anyway, no support is being offered at this early stage in the game, so use at your own risk!

    -Phil
    “Perfection is achieved not when there is nothing more to add, but when there is nothing left to take away. -Antoine de Saint-Exupery
  • Cluso99Cluso99 Posts: 14,235
    edited November 2014 Vote Up0Vote Down
    Thanks heaps Phil.
    Now off to google how to compile to an exe ;)
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 22,093
    edited November 2014 Vote Up0Vote Down
    Oops! The SpinScope 1.1 installer I uploaded earlier today included the wrong version of SpinScope.spin. Post #1 now contains the correct version.

    -Phil
    “Perfection is achieved not when there is nothing more to add, but when there is nothing left to take away. -Antoine de Saint-Exupery
  • TumblerTumbler Posts: 323
    edited November 2014 Vote Up0Vote Down
    I can see that the prop is connected and i can see that there is activity over com12 at 115200 baud
    but i don't see any highlighted pins in my browser. :(
    firewall rules are correct.
    Tried chrome, firefox and ie
    Downloaded the last installer.

    Any help?
    Tadaaaah!
  • Heater.Heater. Posts: 21,205
    edited November 2014 Vote Up0Vote Down
    Thanks Phil.

    That is wonderfully polyglot. Perl, HTML, CSS, JavaScript all in one file. Oh and I'm going to say that regexps and that base64 encoded image are different languages. That's 6 languages in one file.

    Anyway, you have achieved the impossible Phil. I am now willingly studying a piece of Perl code:)

    I managed to discover how to install www and device-serialport modules for Perl and after a little hack or two it's alive on Debian!
    $ sudo  apt-get install  libwww-perl
    $ apt-get install libdevice-serialport-perl
    ...
    $ perl spinscope.pl 
    The SpinScope server is now listening on localhost:1234.
    Disconnecting.
    Disconnecting.
    Disconnecting.
    Disconnecting.
    Opening port ...
    Can't find Propeller.
    Disconnecting.
    ...
    
    Yep, it serves up the scope page just fine.

    Now I'm stuck, I can't find a single Propeller in the house after a recent enforced tidying session.

    Hacked version of spinscope.pl for Debian attached. You will need to find and edit "/dev/ttyUSB0" in there if your Prop is not on that port.

    Errr...well it would be attached if selecting files for attachment hadn't just mysteriously stopped working on Chrome here. Wait a minute....

    ...it's attached now. That was odd selecting files to attach just refused to work until I restarted Chrome.
  • Cluso99Cluso99 Posts: 14,235
    edited November 2014 Vote Up0Vote Down
    I noticed the latest version seems to hiccup a bit with ~"propeller not found" dialog. Have to go to PropTool and reset the prop with F7 then all recovers.

    Next I noticed that the lower P0-P7 leds are always ON - FYI I presume this would be the persistence of vision for fast pulsing

    BTW Win7 and IE10 do not work but Win7 (32bit) and Firefox does - IIRC Phil mentioned this earlier, but just in case.

    I downloaded Strawberry Perl v5.20.1.1 (32bit for Win7). I also needed cpan Win32:Registry and cpan Win32:SerialPort.
    The serial port installation failed because COM1 is broken - seems a problem nowadays. I managed to move my PropPlug to COM1 (even tho COM1 was in use). Then the SerialPort installation ran fine. Then I reconfigured my PropPlug back to COM8.

    Now I can compile the SpinScope.pl without errors but it fails to find the propeller even tho the DOS window shows it is looking for COM8. SpinScope.exe (v1.1) works fine.
    Hopefully someone else will give it a try and point me in the right direction - I am currently running this unmodified with all v1.1.

    heater,
    cannot believe you can't find a prop in the house!!!
    BTW I have problems under Win7 with IE10 posting code to the forum. Have to use Firefox but then I don't get a cursor :(
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • Cluso99Cluso99 Posts: 14,235
    edited November 2014 Vote Up0Vote Down
    Tumbler wrote: »
    I can see that the prop is connected and i can see that there is activity over com12 at 115200 baud
    but i don't see any highlighted pins in my browser. :(
    firewall rules are correct.
    Tried chrome, firefox and ie
    Downloaded the last installer.

    Any help?
    I think its using an old windows driver and this doesn't recognise serial ports COM 10 and above. Go into System / Devices... and select the USB-Serial device and under the Advanced button you can change the COM port to an unused lower port. Hopefully this will fix it.
    My Prop boards: P8XBlade2, RamBlade, CpuBlade, TriBlade
    Prop OS (also see Sphinx, PropDos, PropCmd, Spinix)
    Website: www.clusos.com
    Prop Tools (Index) , Emulators (Index) , ZiCog (Z80)
  • Heater.Heater. Posts: 21,205
    edited November 2014 Vote Up0Vote Down
    Cluso,
    ...cannot believe you can't find a prop in the house!!!
    It's true. Every few months there is an enforced house tidying session. This generally means I come home to find the whole place ship shape and Bristol fashion. That's very nice but it means all my little projects get tidied away into boxes, stuffed into draws and cupboards. It takes some time to track everything down.

    Most of my Props are at the office. But where is my last remaining Prop-plug?....
  • Dave HeinDave Hein Posts: 5,641
    edited November 2014 Vote Up0Vote Down
    The short answer is no. It's a security feature of JavaScript that prevents it. That said, howver, there is Google's ChromeApps, which extends the JavaScript paradigm to include things like serial comms and file I/O.

    -Phil
    OK, so I can't use serial. However, this could be done entirely in the Prop using a board with an Ethernet interface, such as a Spinneret, right? That would be something interesting -- an oscilloscope/logic analyzer that any web browser could connect to without the need of running an app on my computer.
  • Heater.Heater. Posts: 21,205
    edited November 2014 Vote Up0Vote Down
    Dave,

    Yes, quite so.

    msrobots has openspin.js and the Spin WEB IDE served up from a Propeeller + Spineret.
    http://parallax.msrobots.net/Editor17.htm

    (Not sure if that kink actually is a Spinneret but never mind)

    It would be great to have gadgets like SpinScope included with such a WEB IDE for Spin.
  • PublisonPublison Posts: 10,468
    edited November 2014 Vote Up0Vote Down
    Phil,

    Ver 1.1 looks good!

    When do you start the Kickstarter campaign? :)

    SpinScope_1.1.jpg



    I'm using Tracy's PMW program, and the SpinScope is pretty responsive.

    EDIT: WIN7 and Chrome
    Infernal Machine
  • TumblerTumbler Posts: 323
    edited November 2014 Vote Up0Vote Down
    No succes Cluso99 :(
    Tadaaaah!
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 22,093
    edited November 2014 Vote Up0Vote Down
    Adding the blinkenlights disabled the "Once" mode. That has now been fixed. New install and Perl source is in post #1.
    _____________________

    Tumbler,

    I have no idea why you're not having success with it. The com10+ issue was solved long ago by spec'ing ports as \\.\com12, for example. What does SpinScope.exe's terminal screen show when you cycle the Power button several times?

    -Phil
    “Perfection is achieved not when there is nothing more to add, but when there is nothing left to take away. -Antoine de Saint-Exupery
  • JonnyMacJonnyMac Posts: 6,112
    edited November 2014 Vote Up0Vote Down
    I absolutely love the aesthetic and appreciate the utility of this project, but do sincerely hope it morphs into a stand-alone exe without having to go through a browser -- it seems like I can get things connected, then I change the program for new signals, attempt to re-connect, nada.
    Jon McPhalen
    Hollywood, CA
    It's Jon or JonnyMac -- please do not call me Jonny.
  • TumblerTumbler Posts: 323
    edited November 2014 Vote Up0Vote Down
    Phil

    The SpinScope server is now listening on localhost:1234.
    Disconnecting.
    Disconnecting.
    Disconnecting.
    Opening port ...
    Opening COM2.
    Checking COM2.
    Connected.

    The only thing i can do is clicking the power button to see some activity in the spinscope window and the red led from my propplug
    Tadaaaah!
Sign In or Register to comment.