PAGE 2
© 2012–2017 Opto 22. All rights reserved. Dimensions and specifications are subject to change. Brand or product names used herein are trademarks or registered trademarks of their respective companies or organizations.
Form 2229-170824
Using the SNAP PAC REST API with Excel
You’ll need:
• Microsoft Excel 2007 (or higher) and a basic understanding of how to create, open, and close
worksheets, select cells, and resize columns
• A SNAP PAC Learning Center (or your own SNAP PAC R- or S-series controller and I/O modules)
• PAC Project™ Basic (included with the Learning Center and also available to download for free from the
Opto 22 website) and a good understanding of PAC Manager and PAC Control
• The files in this tutorial’s download file (also available for download from the Opto 22 website)
Summary of topics
To set up the SNAP PAC REST API in your PAC controller, start here:
• Enable Web server feature in a PAC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . page 2
• Create API admin user and authentication keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . page 4
If you just want to learn how to get and use I/O data in Excel, start here:
• Test the REST API . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . page 5
• Read PAC data from a sample Excel worksheet using the tutorial’s sample strategy
(Convenience Store.idb) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . page 8
• Activity: Build a macro-enabled worksheet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . page 9
ENABLE WEB SERVER FEATURE
If you’ve already enabled the Web Server feature in your SNAP PAC controller and created API administrator
credentials and authentication keys, skip to “Test the REST API” on page 5.
Otherwise, follow these steps:
1. Open PAC Manager, and then click Tools > Inspect.
2. In the Inspect Opto 22 Device window, enter the controller’s name or IP address, and then click
Communications > Network Security.
3. In the Value column under WEB SERVER:
a. For TCP Listen Port, type: 80
b. For HTTPS, select: Disabled
Note: Since HTTP is easier to set up, this tutorial will use HTTP.
In production environments, we strongly recommend HTTPS for secure, encrypted access to
your controller.
Files included in the Tutorial Zip Description
Convenience Store Strategy.zip
Strategy used in the tutorial exercises.
Not needed if you plan to modify the tutorial activity to work
with your own strategy and I/O modules.
Convenience_Store_Solution.xlsm Solution code for the tutorial activity.
JsonConverter.bas An open-source third-party tool that parses JSON strings.
Opto22_ReadingWritingSamples.xlsm
A workbook containing sample worksheets that use the
SNAP PAC REST API and the groov API to read and write
data in a SNAP PAC R-series or S-series controller.