SpinScope: A Virtual Oscilloscope for the Propeller

Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 21,990
edited March 2015 in Propeller 1 Vote Up0Vote Down
Attached is an installation zip and documentation for a project that's a work in progress but which has reached a usable node. SpinScope is a virtual oscilloscope for the Propeller that monitors selected Propeller pins and displays their states on a two-channel (with separate trigger channel) oscilloscope in a web browser window:

attachment.php?attachmentid=111708&d=1414736422

Future plans include:
1. Add an "analog" scope capability that samples DUTY mode output on a pin over an interval.

2. Add a terminal screen so that regular terminal I/O can occur concurrently with the scope display.

3. Add a graphical I/O instrument that includes switches, lights, sliders, joysticks, etc. At this point the project will be renamed "SpinLab."


Anyway, SpinScope is very easy to use, requiring virtually no additional programming. Here's a quick sample program that was used to create the above image (SpinScope stuff in red):
CON

  _CLKMODE      = XTAL1 + PLL16X
  _XINFREQ      = 5_000_000

OBJ

  [color=red]sco   : "SpinScope"[/color]   'This line and the sco.start line are all that are required to use SpinScope.

PUB start | i

  [color=red]sco.start[/color]
  
  dira[7..0]~~
  i~
  repeat
    outa[7..0] := i++

Enjoy!
-Phil

Addendum: Original download replaced with version 1.1.
“Perfection is achieved not when there is nothing more to add, but when there is nothing left to take away. -Antoine de Saint-Exupery
«13456

Comments

  • 157 Comments sorted by Date Added Votes
  • ozpropdevozpropdev Posts: 2,163
    edited October 2014 Vote Up0Vote Down
    Looks great! :)
    Melbourne, Australia
  • Heater.Heater. Posts: 20,948
    edited October 2014 Vote Up0Vote Down
    Phil,

    That looks really nice.

    Have you an unpackaged version of it? exe files are no use around here.
  • Heater.Heater. Posts: 20,948
    edited October 2014 Vote Up0Vote Down
    SpinScope did actually install and runs under wine. Fails to listen as web server though so no go here.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 21,990
    edited October 2014 Vote Up0Vote Down
    Heater,

    Ooh, sorry. The server program itself is an exe that uses Windows API calls. So an unpackaged version would not help you. That said, however, the server is written in Perl, and I will ultimately release the Perl source code for those who might wish to deploy it on Linux or OS/X.

    -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
  • Heater.Heater. Posts: 20,948
    edited October 2014 Vote Up0Vote Down
    Phil,

    Sounds like an excellent plan. You could just stick it into a github repo.

    In the mean time any chance of a zip file of just the bits that get served up to the browser?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 21,990
    edited October 2014 Vote Up0Vote Down
    Heater,

    Attached is a zip with the HTML generated by the server.

    -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
  • Heater.Heater. Posts: 20,948
    edited October 2014 Vote Up0Vote Down
    Thanks Phil. Looks good here on Chrome.
  • Heater.Heater. Posts: 20,948
    edited October 2014 Vote Up0Vote Down
    Yay, also works for analogue !

    attachment.php?attachmentid=111716&d=1414764114

    Well, not really. It's just that I could not resist making a little Node.js web server to serve up spinscope.html and feed it some trace points.
    749 x 546 - 69K
  • JonnyMacJonnyMac Posts: 6,087
    edited October 2014 Vote Up0Vote Down
    I wonder what I'm doing wrong. I'm running Win8.1 and have tried Firefox, Chrome, and Opera with the example code (above), and none of them display traces. Would love to sort this out in the next hour as I have to go to a special effects shop to do some Propeller programming and this could be very helpful today.
    Jon McPhalen
    Hollywood, CA
    It's Jon or JonnyMac -- please do not call me Jonny.
  • PublisonPublison Posts: 10,254
    edited October 2014 Vote Up0Vote Down
    I am also not to get any traces. I tried Chrome then Firefox.

    Tried another simple program to test, (attached)

    EDIT: Windows 7
    Infernal Machine
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 21,990
    edited October 2014 Vote Up0Vote Down
    To get traces:
    1. You have to make sure that you're getting a valid trigger on the trigger channel. In scope parlance, SpinScope operates in "normal" mode only; there's no "auto" mode.

    2. Be sure not to have any serial comms objects running that can interfere with comms on P30/31.

    3. Make sure you have three additional cogs available for SpinScope.spin to run in.

    -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: 21,990
    edited October 2014 Vote Up0Vote Down
    Publison,

    Here's the trace I get from your program on Win7+Firefox:

    attachment.php?attachmentid=111718&d=1414767491

    -Phil
    764 x 562 - 25K
    “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: 21,990
    edited October 2014 Vote Up0Vote Down
    Heater,

    I'm drooling over that image. I really need to take that next step while I've still got my mind wrapped around the JavaScript. The refresh rate will be slower by 8X, however, since the data has to be sent from the Prop as bytes rather than bits. But perhaps I can get by with less horizontal resolution.

    -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: 21,990
    edited October 2014 Vote Up0Vote Down
    Some additional notes:
    1. There propably won't be be any firewall restrictions on localhost, even in Win 7/8; but if there are, they should be removed.

    2. In its current form, SpinScope allows connections from outside the local machine. I should probably not allow that, even though it's kinda cool watching my shop Prop from inside the house.

    3. Having more than one user connected at at time can lead to a battle for control, since both have access to SpinScope's settings. SpinScope is strictly a one-user program since it interfaces to a single Prop.

    -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
  • PublisonPublison Posts: 10,254
    edited October 2014 Vote Up0Vote Down
    Phil,

    Got it working. Here's what I did.

    Start SpinScope.exe
    Start FireFox localhost:1234
    Power On, then Power Off
    Stop SpinScope.exe, the restart SpinScope.exe
    Now it works every time.

    Works in Chrome also.

    Pretty snazzy! Thanks for that!

    Jim
    Infernal Machine
  • PublisonPublison Posts: 10,254
    edited October 2014 Vote Up0Vote Down
    Some additional notes:
    1. There propably won't be be any firewall restrictions on localhost, even in Win 7/8; but if there are, they should be removed.

    2. In its current form, SpinScope allows connections from outside the local machine. I should probably not allow that, even though it's kinda cool watching my shop Prop from inside the house.

    3. Having more than one user connected at at time can lead to a battle for control, since both have access to SpinScope's settings. SpinScope is strictly a one-user program since it interfaces to a single Prop.

    -Phil

    It did complain about firewall restrictions, but I selected internal/private networks were OK.

    Hope Jon gets it working.
    Infernal Machine
  • JonnyMacJonnyMac Posts: 6,087
    edited October 2014 Vote Up0Vote Down
    I shut everything down and restarted it -- now it works. Very neat little tool, Phil. Should be a fun way to introduce youngsters to 'scopes.

    A couple questions about the start-up code in the object:
    VAR
    
      long stack[100]
      long timebase, masktrig, polarity, maskch1, maskch2, newdata, trace[34]
      byte cogno
    
    PUB start | i, r
    
      if ((cogno := cognew(@scope, @timebase)) < 0)
        return false
      if (cognew(xcvr, @stack) < 0)
        return false
      return true
    

    You declare cogno as a byte, yet check for less than 0 -- this should never work, correct? If cognew returns -1, cogno will be truncated to 255.

    If cognew for xcrv fails, should you not add a cogstop for cogno before returning false?
    Jon McPhalen
    Hollywood, CA
    It's Jon or JonnyMac -- please do not call me Jonny.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 21,990
    edited October 2014 Vote Up0Vote Down
    Thanks, Jon! The whole impetus for doing it has been the Robotics class I'm teaching at the local HS.

    -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
  • PublisonPublison Posts: 10,254
    edited October 2014 Vote Up0Vote Down
    I also restarted my computer. That may be why it worked.
    Infernal Machine
  • Heater.Heater. Posts: 20,948
    edited November 2014 Vote Up0Vote Down
    Could somebody point their browser at http://the.linuxd.org/lab/

    It's just spinscope beings served up a noisy signal. None of the setting controls are active.

    Not from a Propeller though because, well i'm not sure I should admit this but I can't for the life of me find a single Propeller in the house today...
  • PublisonPublison Posts: 10,254
    edited November 2014 Vote Up0Vote Down
    Looks good here in the US
    Infernal Machine
  • fridafrida Posts: 124
    edited November 2014 Vote Up0Vote Down
    Awesome it works.
    Yes Frida is my watchdog!
  • RS_JimRS_Jim Posts: 1,234
    edited November 2014 Vote Up0Vote Down
    I can see it in Arizona on the iPad!
    Jim
  • turbosupraturbosupra Posts: 1,088
    edited November 2014 Vote Up0Vote Down
    Nice job Phil. I can see it as well. Win7 64 and Firefox 29.0.1 and IE10.

    One thing that stinks about the propscope is that there is no logging. Will this have the ability to record digital signals as a bit of a data analyzer? It'd be great to be able to record some binary signals and later translate them to hex with this.
  • Heater.Heater. Posts: 20,948
    edited November 2014 Vote Up0Vote Down
    OK, thanks all.

    Only asked because the only way I can view from outside my local network today is via my old Samsung Galaxy S phone where it does not work. Nice to see my setup of multiple layers or routers and nginx proxying is working!

    Seems to be SpinScope should be added to the Editor17 Propeller WEB IDE. Then you could program a Prop and see it's operation all in one web app. Of course Editor17 needs a lot of beautifying first.
  • Heater.Heater. Posts: 20,948
    edited November 2014 Vote Up0Vote Down
    turbosupra,

    Yes, I was thinking it would be cool to be able to decode UART, I2C, SPI signalling. Like you can on real scopes now a days.

    I have no idea what goes on in Phil's server but an issue at the moment it that is that traces are fetched by the browser as and when it has time to. That means batches of samples can be missed.

    I guess that decoding could happen on the server though.

    Surely I won't have time to do anything with this idea.
  • PublisonPublison Posts: 10,254
    edited November 2014 Vote Up0Vote Down
    Heater. wrote: »
    turbosupra,

    Yes, I was thinking it would be cool to be able to decode UART, I2C, SPI signalling. Like you can on real scopes now a days.

    Parallax just ran out of an inexpensive Logic Analyzer from Saleae, that does all that for $149.00 US. Unfortunately, Saleae discontinued that product and came out with a new one that has some analog capabilities at $199.00US. Still not a bad price
    Infernal Machine
  • TorTor Posts: 1,941
    edited November 2014 Vote Up0Vote Down
    Looks fine in Norway on this Android tablet.
  • Heater.Heater. Posts: 20,948
    edited November 2014 Vote Up0Vote Down
    Thanks, that Saleae is a neat device. Even has support for Linux users, amazing. A tad smaller than those huge HP or Philips analysers I used last time I was involved in electronics professionally.

    Today though the latest Rigol 4 channel scopes can be had for about twice as much money. Decisions, decisions.

    Of course what Phil wants to achieve here is a zero cost analyser for us in classes. What better way that have a prop analyse itself?
  • Heater.Heater. Posts: 20,948
    edited November 2014 Vote Up0Vote Down
    Tor and all, thanks.

    I guess my next experiment should be to push the trace data via a web socket connection rather than AJAX requests. In theory we should get a much faster update rate.
Sign In or Register to comment.