Shop OBEX P1 Docs P2 Docs Learn Events
SpinScope: A Virtual Oscilloscope for the Propeller — Parallax Forums

SpinScope: A Virtual Oscilloscope for the Propeller

Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
edited 2015-03-06 07:52 in Propeller 1
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.
«13456

Comments

  • ozpropdevozpropdev Posts: 2,791
    edited 2014-10-30 23:43
    Looks great! :)
  • Heater.Heater. Posts: 21,230
    edited 2014-10-30 23:47
    Phil,

    That looks really nice.

    Have you an unpackaged version of it? exe files are no use around here.
  • Heater.Heater. Posts: 21,230
    edited 2014-10-30 23:59
    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: 23,514
    edited 2014-10-31 00:00
    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
  • Heater.Heater. Posts: 21,230
    edited 2014-10-31 00:08
    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: 23,514
    edited 2014-10-31 01:01
    Heater,

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

    -Phil
  • Heater.Heater. Posts: 21,230
    edited 2014-10-31 02:02
    Thanks Phil. Looks good here on Chrome.
  • Heater.Heater. Posts: 21,230
    edited 2014-10-31 06:33
    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: 8,912
    edited 2014-10-31 07:13
    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.
  • PublisonPublison Posts: 12,366
    edited 2014-10-31 07:28
    I am also not to get any traces. I tried Chrome then Firefox.

    Tried another simple program to test, (attached)

    EDIT: Windows 7
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2014-10-31 07:43
    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
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2014-10-31 07:58
    Publison,

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

    attachment.php?attachmentid=111718&d=1414767491

    -Phil
    764 x 562 - 25K
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2014-10-31 08:01
    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
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2014-10-31 08:11
    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
  • PublisonPublison Posts: 12,366
    edited 2014-10-31 08:15
    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
  • PublisonPublison Posts: 12,366
    edited 2014-10-31 08:17
    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.
  • JonnyMacJonnyMac Posts: 8,912
    edited 2014-10-31 08:21
    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?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2014-10-31 08:26
    Thanks, Jon! The whole impetus for doing it has been the Robotics class I'm teaching at the local HS.

    -Phil
  • PublisonPublison Posts: 12,366
    edited 2014-10-31 08:32
    I also restarted my computer. That may be why it worked.
  • Heater.Heater. Posts: 21,230
    edited 2014-11-01 04:31
    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: 12,366
    edited 2014-11-01 05:08
    Looks good here in the US
  • fridafrida Posts: 155
    edited 2014-11-01 05:09
    Awesome it works.
  • RS_JimRS_Jim Posts: 1,751
    edited 2014-11-01 08:18
    I can see it in Arizona on the iPad!
    Jim
  • turbosupraturbosupra Posts: 1,088
    edited 2014-11-01 08:34
    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: 21,230
    edited 2014-11-01 08:41
    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: 21,230
    edited 2014-11-01 08:47
    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: 12,366
    edited 2014-11-01 09:17
    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
  • TorTor Posts: 2,010
    edited 2014-11-01 09:27
    Looks fine in Norway on this Android tablet.
  • Heater.Heater. Posts: 21,230
    edited 2014-11-01 09:30
    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: 21,230
    edited 2014-11-01 09:32
    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.