Skip to content

Commit

Permalink
Merge pull request #678 from WildernessLabs/develop
Browse files Browse the repository at this point in the history
Deploy 2.27.2024
  • Loading branch information
adunndevster2 authored Feb 27, 2024
2 parents c60de8b + 3032f86 commit 3255047
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/Meadow/Meadow.OS/Cellular/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ Settings:

A few things to consider:
* If the carrier numeric operator code (**Operator**) or the network mode is not specified (**Mode**), the module will attempt to automatically determine the optimal network based on the M2M sim card inserted and your location.
* **However, if you encounter any connectivity issues, we recommend to set the operator code and operation mode to the `Operator` and `Mode` properties**. If you don't know this information, you can use the [**Cell Network Scanner**](https://github.com/WildernessLabs/Documentation/blob/cell-docs-updates/docs/Meadow/Meadow.OS/Cellular/index.md#scanning-cell-networks) method that will list nearby networks in the area.
* **However, if you encounter any connectivity issues, we recommend to set the operator code and operation mode to the `Operator` and `Mode` properties**. If you don't know this information, you can use the [**Cell Network Scanner**](#scanning-cell-networks) method that will list nearby networks in the area.
* `TurnOnPin` is a pin used to turn on the module.

## Specify Network Interface and reserved pins
Expand Down
50 changes: 50 additions & 0 deletions docs/Meadow/Meadow_Basics/IO/Analog/High_Speed/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
layout: Meadow
title: High-Speed Analog Input
subtitle: Reading analog data quickly via analog input arrays.
---

You can [consume basic analog input using the `AnalogInputPort` class](../) with a very simple API and useful helper events, as well as using observers that can subscribe to these events and react when they are triggered. This robust API can limit you to a few samples per second, which is often sufficient for most applications, such as reading from a thermistor.

If you need to consume analog data at a much faster rate, you will want to use the `AnalogInputArray` analog input system introduced in Meadow version 1.6. You may require this level of analog data sampling for things such as monitoring power systems, reading vibration sensors, or reading analog audio inputs.

`AnalogInputArray` is a powerful class that allows for high-speed data consumption from multiple analog inputs simultaneously via direct memory access (DMA)s. It's particularly useful in scenarios where you need to monitor or process data froms multiple sensors in real-time. On an F7 Feather v2, for example, across three analog channels you might acheive 37,000 samples per second.

The tradeoff of this level of data sampling is the reduced API, trading events and observables for raw speed.

## Consume high-speed samples from multiple analog inputs

Once you set up an analog input array, you will be able to consume data samples as fast as you call the `Refresh()` method on your `AnalogInputArray` object.

Start by creating your array from your current Meadow F7 device.

```csharp
var array = Device.CreateAnalogInputArray(Device.Pins.A00, Device.Pins.A01, Device.Pins.A02);
```

Then, set up your code to read data from the array in a loop. For example, this will make 1,000 reads per loop as fast as the Meadow can execute the while loop.

```csharp
var readsPerIteration = 1000;
var a0 = new double[readsPerIteration];
var a1 = new double[readsPerIteration];
var a2 = new double[readsPerIteration];

while (true)
{
// read 1k samples as fast as we can
for (var i = 0; i < readsPerIteration; i++)
{
// tell the Array to read all of its inputs
array.Refresh();


// copy the Array data to a local buffer
a0[i] = array.CurrentValues[0];
a1[i] = array.CurrentValues[1];
a2[i] = array.CurrentValues[2];
}
}
```

Substitute your desired analog sensors and their respective analog Meadow pins to be able to collect high-speed readings for your own projects.
6 changes: 5 additions & 1 deletion docs/Meadow/Meadow_Basics/IO/Analog/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ On the Meadow F7 Feather, analog signals are written or read with a 12-bit resol

Meadow has the capabilities to both read and write analog signals, but presently only the input/read functionality is exposed via API.

## Consume higher-speed analog data

Note that analog ports provide a rich system for consuming analog inputs. The data consumed this way can be limited to a few samples per second. You can consume [high-speed analog input data with `AnalogInputArray`](High_Speed/) through a simplified API.

## Samples

For sample Meadow applications that illustrate the usage of analog ports, check out the [IO Sample apps in the Meadow.Core.Samples repo](https://github.com/WildernessLabs/Meadow.Core.Samples/tree/main/Source/IO).
For sample Meadow applications that illustrate both the basic usage of analog ports and high-speed analog data acquisition using an analog input array, check out the [IO Sample apps in the Meadow.Core.Samples repo](https://github.com/WildernessLabs/Meadow.Core.Samples/tree/main/Source/IO).

## Analog Input

Expand Down
12 changes: 11 additions & 1 deletion src/sidebars/meadowOsSidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,17 @@ const meadowOsSidebar = [
id: "Meadow/Meadow_Basics/IO/index",
},
items: [
"Meadow/Meadow_Basics/IO/Analog/index",
{
type: "category",
label: "Analog",
link: {
type: "doc",
id: "Meadow/Meadow_Basics/IO/Analog/index",
},
items: [
"Meadow/Meadow_Basics/IO/Analog/High_Speed/index",
],
},
{
type: "category",
label: "Digital",
Expand Down
2 changes: 2 additions & 0 deletions src/theme/MDXComponents.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// src/theme/MDXComponents.js
import MDXComponents from '@theme-original/MDXComponents';
import Admonition from '@theme/Admonition';
import GettingStarted from '../components/GettingStarted';
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

export default {
...MDXComponents,
Admonition,
GettingStarted,
Tabs,
Expand Down

0 comments on commit 3255047

Please sign in to comment.