JavaScript Oscilloscope with MPLAB® Harmony v2

 Objective

This is an example of how to use JavaScript and WebSockets to create an online oscilloscope.

  1. The PIC32MZ2048EFH144 on the Ethernet Starter Kit is acting as a web server.
  2. In the 512 kB MPFS file system of the PIC32 Flash memory, all JavaScript libraries used (~250 kB), are stored compressed.
  3. The software is based on the MPLAB® Harmony 1.07.01 TCPIP example project "web_net_server_nvm_mpfs".
  4. The ADC channel 4 is set up to sample at 2 MHz and 12-bit. Every 100 ms, a measurement is triggered and the DMA collects 1024 sample values in an array.
  5. In the array, a trigger condition is searched to get a stable image.
  6. From the trigger condition, 100 samples are sent to the web browser (client) which displays the value.

Below are the necessary connections:

SK.png

You have direct command line access in a terminal window.

terminal.jpg

Use a signal generator to apply a signal to pin 15 (RB4/AN4).

signal-3.jpg

Enter the URL, 192.168.100.115, into a web browser (as long as it is connected directly).

Click on Realtime Websocket Stream.

startpage.jpg

Enter the correct IP address, and click on Connect.

ip_address.jpg

You should see the signal measured at RB4/AN4 on pin 15 of the board header.

triangle.jpg

Note that when you compare it with a real scope, it looks very much the same.

real_scope.jpg

 Materials

Hardware Tools (Optional)

Tool About Purchase
PIC32MZ-EF-50px.png
PIC32MZ Embedded Connectivity with FPU
Starter Kit

Software Tools

Tool About Installers
Installation
Instructions
Windows Linux Mac OSX
MPLAB® X
Integrated Development Environment
MPLAB® XC32
C/C++ Compiler
MPLAB® Harmony 1.xx
Integrated Software Framework

Exercise Files

File Download
Installation
Instructions
Windows Linux Mac OSX
Project and Source Files

 Procedure

There are two ways to connect the Ethernet Starter Kit (ESKT):

1

Connect to a network switch. The board will attempt to obtain an IP from a DHCP server.
Find the IP adress with the tcpip_discoverer.jar utility from:
c:\microchip\harmony\v1_07_01\utilities\tcpip_discoverer\.

2

Connect the ESKT directly to a PC and set the PC to a fixed IP adress, for example, 192.168.100.120.

Author:

Martin Rupert
Microchip Technology Inc.

© 2024 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.