while (1)
{
// Add your application code
printf(“Digital Discovery\r\n”);
__delay_ms(100);
}
The EUSART capture results are displayed by
the Discovery and Waveforms in Screenshot 10.
Who Needs a Microcontroller
The Digital Discovery is not just a multi-function
monitoring instrument. It can also be “programmed”
using JavaScript. This allows the user to generate
waveforms and binary sequences that can be used
to drive an external device such as a
microcontroller.
■ SCREENSHOT 10. Note that the TX and RX
Digital Discovery DIO pins are cross-connected
with the PIC16F18345’s EUSART pins.
The Discovery’s scripting language also can be
used to enable automated data acquisition and
analysis.
Let’s keep is simple. Before we run a script, we
can check for the presence of a Digital Discovery.
Not only can we determine if a Discovery is there,
we can request its vitals. This code will return the
if(Device.isConnected())
{
print(Device.SN);
}
else
{
print(“Digital Discovery Not Found”);
}
We can also use the Discovery’s scripting feature to
set up static I/O switches, buttons, and LEDs. This script
will force the Discovery’s 24-31 DIO positions to switches.
■ SCREENSHOT 11. The Digital Discovery’s scripting
feature is very powerful and provides a means of
programmatically controlling the data acquisition and
analysis process.
It will also configure its 32-39 DIO positions as buttons:
StaticIO.Channel0.Mode.text = “IOs”;
StaticIO.Channel1.Mode.text = “IOs”;
for(var c = 0; c < 8; c++)
{
StaticIO.Channel0.DIO[c].Mode.text = “Switch”;
StaticIO.Channel1.DIO[c].Mode.text = “Button”;
}
We can eliminate the Z position in our set of switches
by executing the following line of script:
StaticIO.Channel0.DIO[0].checked = 1;
StaticIO.Channel0.DIO[0].Switch.text = “PP”;
The resultant configuration of the Discovery’s I/O pins
is shown graphically in Screenshot 11.
PP is short for Push/Pull (1/0). The Z position is
included when the switch is in TS (Three-State 1/Z/0)
mode.
We are not limited to just configuring the static I/O
resources. We can use scripting to manipulate the
switches and buttons as well. This line of script will put the
least significant switch in a logically zero state:
You Need a Digital Discovery
The Digital Discovery is a very powerful little box.
StaticIO.Channel0.DIO[0].checked = 0;
High speed data acquisition and analysis are only part of
the Discovery’s equation. The scripting feature allows you
to use it as a stimulus generator for external circuitry.
Conversely, this line of script will force the same
switch position to a logical high state:
Scripting also enables the automation of some of the
Discovery’s core subsystems.
A Digital Discovery would be a welcome addition to
your Design Cycle. NV
June 2017 51