Skip to content

Commit

Permalink
More doc cleaning (dotnet#1621)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ellerbach authored Aug 3, 2021
1 parent 148fc42 commit ca63c97
Show file tree
Hide file tree
Showing 95 changed files with 523 additions and 740 deletions.
43 changes: 23 additions & 20 deletions src/System.Device.Gpio.Tests/README.md
Original file line number Diff line number Diff line change
@@ -1,57 +1,62 @@
# How to run the tests

This shows how to run the tests on a Raspberry Pi. On other platforms, things should be similar.
This shows how to run the tests on a Raspberry Pi. On other platforms, things should be similar.

## Building on the desktop PC

(to be extended)

## Building directly on the Pi

First, clone the repository on the pi:

```
```shell
git clone https://github.com/dotnet/iot
cd iot
```

Now you can
- Either download and install the NET Core SDK from https://get.dot.net/ (the Raspberry Pi with the default 32 Bit Raspbian Linux requires the ARM32 version) or
Now you can

- Either download and install the NET Core SDK from <https://get.dot.net/> (the Raspberry Pi with the default 32 Bit Raspbian Linux requires the ARM32 version) or
- run `./build.sh` in the checkout directory. This will install the correct NET Core SDK in the .dotnet subfolder of the working copy.

Build System.Device.Gpio.dll:

```
```shell
cd src/System.Device.Gpio
dotnet build System.Device.Gpio.sln
```

This builds the main System.Device.Gpio assembly together with its test assembly. Before running the tests, you need to:
- Connect BCM Pins 12 and 16 (physical Pins 32 and 36) with a cable. It is suggested to add a 1kΩ to 10kΩ resistor between the pins; this protects the Pi in the case of a misconfiguration (i.e both pins set to Out, one high, the other low).

- Connect BCM Pins 12 and 16 (physical Pins 32 and 36) with a cable. It is suggested to add a 1kΩ to 10kΩ resistor between the pins; this protects the Pi in the case of a misconfiguration (i.e both pins set to Out, one high, the other low).
- Leave BCM Pin 23 (physical Pin 16) open (not connected to anything).

## Raspberry Pi driver tests

After that, you can run the tests with the RaspberryPiDriver (which is the default low-level driver for the Raspberry Pi) like:

```
```shell
dotnet test --filter RaspberryPiDriverTests System.Device.Gpio.sln
```

Depending on the version of the Pi and the installed Linux distribution, it may be required to run the tests as root:

```
```shell
sudo dotnet test --filter RaspberryPiDriverTests System.Device.Gpio.sln
```

If everything went smoothly, the output should end with a success message.
If everything went smoothly, the output should end with a success message.

Alternatively, you can run the tests using the xunit console runner, which allows for better control of what should be executed (see the next section).
Alternatively, you can run the tests using the xunit console runner, which allows for better control of what should be executed (see the next section).

XUnit.console.runner is installed as a nuget package on the system in your home directory during the build. From the root of the project directory, execute:
```

```shell
pi@raspberrypi:~/projects/iot $ dotnet exec ~/.nuget/packages/xunit.runner.console/2.4.1/tools/netcoreapp2.0/xunit.console.dll artifacts/bin/System.Device.Gpio.Tests/Debug/netcoreapp2.1/System.Device.Gpio.Tests.dll -notrait "SkipOnTestRun=Windows_NT" -notrait "feature=i2c"
```
This runs the tests excluding the I2C tests (-notrait "feature-i2c") and excluding the Windows tests (-notrait "SkipOnTestRun=Windows_NT").

This runs the tests excluding the I2C tests (-notrait "feature-i2c") and excluding the Windows tests (-notrait "SkipOnTestRun=Windows_NT").

## Running tests depending on components/requirements

Expand All @@ -67,29 +72,27 @@ Currently the full test suite requires following components, if you don't have o
| configured PWM (overlaps with MCP3008 setting) | `-notrait feature=pwm` |
| root access (overlaps, assumes you use default permissions) | `-notrait requirement=root` |

* Also inputs to ADC are required including one connected to PWM output through low pass filter, please refer to the schematics.


- Also inputs to ADC are required including one connected to PWM output through low pass filter, please refer to the schematics.

## SysFsDriver Tests

You can also run the SysFsDriver Tests (this uses a more generic approach). This driver requires root permissions to run, so you need to `sudo` the command:

```
```shell
sudo dotnet test --filter SysFsDriverTests System.Device.Gpio.sln
```

## LibgpiodDriver Tests

To run the Libgpiod Driver test (a Linux Kernel Driver for the GPIO device), you need to first install the libgpiod package:

```
```shell
sudo apt install -y libgpiod-dev
```

These tests do not require root permissions to run:

```
```shell
dotnet test --filter LibGpiodDriverTests System.Device.Gpio.sln
```

Expand Down Expand Up @@ -126,10 +129,10 @@ All headers are standard 2.54mm headers. Male headers are usually sold longer an

`/boot/config.txt`

```
```text
# Enable I2C, SPI, PWM
dtparam=i2c_arm=on
dtparam=spi=on
dtoverlay=pwm-2chan
```
```
14 changes: 8 additions & 6 deletions src/devices/Ads1115/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

ADS1115 is an Analog-to-Digital converter (ADC) with 16 bits of resolution.

## Documentation
## Documentation

Prodcut datasheet can be found [here](https://cdn-shop.adafruit.com/datasheets/ads1115.pdf)

Expand All @@ -12,7 +12,7 @@ Prodcut datasheet can be found [here](https://cdn-shop.adafruit.com/datasheets/a

## Usage

```C#
```csharp
// set I2C bus ID: 1
// ADS1115 Addr Pin connect to GND
I2cConnectionSettings settings = new I2cConnectionSettings(1, (int)I2cAddress.GND);
Expand All @@ -30,9 +30,9 @@ using (Ads1115 adc = new Ads1115(device, InputMultiplexer.AIN0, MeasuringRange.F
}
```

See the [samples project](https://github.com/dotnet/iot/tree/main/src/devices/Ads1115/samples) for more examples and usage for different applications.
See the [samples project](https://github.com/dotnet/iot/tree/main/src/devices/Ads1115/samples) for more examples and usage for different applications.

If you want to use the interrupt pin, the pulses generated by the ADS1115 might be to short to be properly recognized in the software, i.e. on a Raspberry Pi. The schematic below shows a way of increasing the pulse length so that it is properly recognized (from about 10us to 150us). This uses discrete electronics, but an implementation with an NE555 or equivalent would likely work as well (Just note that you need a type that works at 3.3V).
If you want to use the interrupt pin, the pulses generated by the ADS1115 might be to short to be properly recognized in the software, i.e. on a Raspberry Pi. The schematic below shows a way of increasing the pulse length so that it is properly recognized (from about 10us to 150us). This uses discrete electronics, but an implementation with an NE555 or equivalent would likely work as well (Just note that you need a type that works at 3.3V).

![Pulse_lengthener_schema](Pulse_lengthener_schema.png)

Expand All @@ -49,6 +49,7 @@ If you want to use the interrupt pin, the pulses generated by the ADS1115 might
![circuit](ADS1115_circuit_bb.png)

ADS1115

* ADDR - GND
* SCL - SCL
* SDA - SDA
Expand All @@ -57,13 +58,14 @@ ADS1115
* A0 - Rotary Potentiometer Pin 2

Rotary Potentiometer

* Pin 1 - 5V
* Pin 2 - ADS1115 Pin A0
* Pin 3 - GND

### Code

```C#
```csharp
// set I2C bus ID: 1
// ADS1115 Addr Pin connect to GND
I2cConnectionSettings settings = new I2cConnectionSettings(1, (int)I2cAddress.GND);
Expand Down Expand Up @@ -95,4 +97,4 @@ using (Ads1115 adc = new Ads1115(device, InputMultiplexer.AIN0, MeasuringRange.F
### Results

![run results](RunningResult.jpg)
![interupt result](InterruptResult.png)
![interupt result](InterruptResult.png)
5 changes: 2 additions & 3 deletions src/devices/Adxl345/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ In [Chinese](http://wenku.baidu.com/view/87a1cf5c312b3169a451a47e.html)

In [English](https://www.analog.com/media/en/technical-documentation/data-sheets/ADXL345.pdf)


## Sensor Image

![sensor](sensor.jpg)

## Usage

```C#
```csharp
SpiConnectionSettings settings = new SpiConnectionSettings(0, 0)
{
ClockFrequency = Adxl345.SpiClockFrequency,
Expand Down Expand Up @@ -54,7 +53,7 @@ using (Adxl345 sensor = new Adxl345(device, GravityRange.Range04))

### Code

```C#
```csharp
SpiConnectionSettings settings = new SpiConnectionSettings(0, 0)
{
ClockFrequency = Adxl345.SpiClockFrequency,
Expand Down
2 changes: 1 addition & 1 deletion src/devices/Adxl357/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Product documentation can be found [here](https://www.analog.com/en/products/adx
## Sensor Image

![Source: https://wiki.seeedstudio.com/Grove-3-Axis_Digital_Accelerometer_40g-ADXL357/](sensor.png)
Source: https://wiki.seeedstudio.com/Grove-3-Axis_Digital_Accelerometer_40g-ADXL357/
Source: <https://wiki.seeedstudio.com/Grove-3-Axis_Digital_Accelerometer_40g-ADXL357/>

## Usage

Expand Down
2 changes: 1 addition & 1 deletion src/devices/Ags01db/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ using (Ags01db sensor = new Ags01db(device))

### Result

![running result](RunningResult.jpg)
![running result](RunningResult.jpg)
1 change: 0 additions & 1 deletion src/devices/Ahtxx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ The binding supports the following sensor functions:
* reading status
* issueing calibration and reset commands


### Sensor classes

You need to choose the class depending on the sensor type.
Expand Down
6 changes: 3 additions & 3 deletions src/devices/Ak8963/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Console.WriteLine($"Mag Y = {ak8963.MagnometerBias.Y}");
Console.WriteLine($"Mag Z = {ak8963.MagnometerBias.Z}");
```

You will find a full example on how to extract raw data without calibration on the [MPU9250 sample](../Mpu9250/samples/Mpu9250.sample.cs).
You will find a full example on how to extract raw data without calibration on the [MPU9250 sample](../Mpu9250/samples/Program.cs).

If no calibration is performed, you will get a raw data cloud which looks like this:

Expand All @@ -53,7 +53,7 @@ Running the calibration properly require to **move the sensor in all the possibl

![raw data](./corrcalib.png)

To create those cloud point graphs, every cloud is a coordinate of X-Y, Y-Z and Z-X.
To create those cloud point graphs, every cloud is a coordinate of X-Y, Y-Z and Z-X.

Once the calibration is done, you will be able to read the data with the bias corrected using the ```ReadMagnetometer``` function. You will still be able to read the data without any calibration using the ```ReadMagnetometerWithoutCalibration``` function.

Expand Down Expand Up @@ -129,4 +129,4 @@ Only I2C is supported in this version.
* VCC - 3.3V
* GND - GND

Depending on the version you have, you may have to select I2C over SPI. This is done in different way depending on the board you'll have.
Depending on the version you have, you may have to select I2C over SPI. This is done in different way depending on the board you'll have.
44 changes: 23 additions & 21 deletions src/devices/Amg88xx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ Additionally an interrupt pin can raise an event when any individual pixel goes

![Illustration of thermophile pixel array and heat map](./AMG88xx.png)

*Illustration of thermophile pixel array and heat map*

## Documentation

- Product [homepage](https://industry.panasonic.eu/components/sensors/grid-eye)
Expand Down Expand Up @@ -76,15 +74,16 @@ Property:
public Temperature SensorTemperature
```

**Note**: the thermistor temperature is <u>not</u> equivalent to the
**Note**: the thermistor temperature is **not** equivalent to the

### Operating Mode / Power Control

The sensor supports four operating modes to control power consumption:
* Normal
* Sleep Mode
* Stand-by with 60 seconds intermittence
* Stand-by with 10 seconds intermittence

- Normal
- Sleep Mode
- Stand-by with 60 seconds intermittence
- Stand-by with 10 seconds intermittence

Property:

Expand All @@ -97,8 +96,9 @@ public OperatingMode OperatingMode
### Reset

The sensor supports two types of resets.
* **Reset:** Resets all flags and registers to default values
* **Resetting all flags:** Resets all flags (status register, interrupt flag, interrupt table)

- **Reset:** Resets all flags and registers to default values
- **Resetting all flags:** Resets all flags (status register, interrupt flag, interrupt table)

```csharp
public void Reset()
Expand All @@ -108,6 +108,7 @@ public void ResetAllFlags()
**Note**: resetting the interrupt related flags is only required if you want to clear flags while the readings are still within the hysteresis span. See interrupts section for further details on interrupt behavior.

### Sensor Status

The sensor status indicates if any pixel or the chip internal thermistor overran the upper or lower operating range limit. It also flags on the occurrence of an interrupt. The status can be read out and reset per flag:

```csharp
Expand Down Expand Up @@ -146,14 +147,13 @@ public FrameRate FrameRate
**Default:** off

The sensor supports a moving average mode. In this mode it builds the twice moving average for each pixel.
* If the frame rate is set to 10fps the sensor takes the average of the readings *n* and *n+1* and yields their average as output.
* If the frame rate is set to 1fps the sensor takes the readings of 10 frames (as the sensor runs internally always at 10fps) and builds the average.

- If the frame rate is set to 10fps the sensor takes the average of the readings *n* and *n+1* and yields their average as output.
- If the frame rate is set to 1fps the sensor takes the readings of 10 frames (as the sensor runs internally always at 10fps) and builds the average.
The average of two averages of 10 readings is the resulting output.

![Moving average principle](./AMG88xxAvgMode.svg)

*Moving Average*

The noise per pixel will decrease to 1/sqrt2 when using the moving average mode.

Property:
Expand All @@ -165,6 +165,7 @@ public bool UseMovingAverageMode
***Important***: the reference specification states that the current mode can be read, but it doesn't seem to work at the time being. In this case the property is always read as ```false```.

### Interrupt control, levels and pixel flags

The sensor can raise an interrupt if any pixel passes a given value. The event is signaled by the interrupt flag of the status register. Additionally the INT pin of the sensor can be pulled low.

Properties:
Expand Down Expand Up @@ -194,21 +195,22 @@ public bool[,] GetInterruptFlagTable()

Interrupt levels and hysteresis

**Note**
* be aware that the interrupt flag in the status register is reset automatically if no pixel temperature exceeds the lower or upper threshold. It is <u>not</u> required to reset the flag manually.
* any flag in the interrupt flag table is automatically reset if the corresponding pixel is no long exceed the lower or upper threshold.
* if a hysteresis is applied and the reading of a pixel is not passing the threshold anymore, while at the same time the reading is still within the hysteresis span, the interrupt flag can be cleared by using the ```ResetAllFlags``` method.
Note:

- be aware that the interrupt flag in the status register is reset automatically if no pixel temperature exceeds the lower or upper threshold. It is **not** required to reset the flag manually.
- any flag in the interrupt flag table is automatically reset if the corresponding pixel is no long exceed the lower or upper threshold.
- if a hysteresis is applied and the reading of a pixel is not passing the threshold anymore, while at the same time the reading is still within the hysteresis span, the interrupt flag can be cleared by using the ```ResetAllFlags``` method.

## Example

### Overview

The [sample application](https://github.com/dotnet/iot/tree/main/src/devices/Amg88xx/samples) demonstrates the key functions of the sensor and the binding:

* thermal image readout
* interrupt triggering based on temperature levels incl. hysteresis
* sensor states
* noise reduction by using the sensor's moving average function
- thermal image readout
- interrupt triggering based on temperature levels incl. hysteresis
- sensor states
- noise reduction by using the sensor's moving average function

There are AMG88xx breakout boards available from a variety of vendors. You can use any of them as long as it provides access to the I2C interface of the sensor.

Expand Down
25 changes: 0 additions & 25 deletions src/devices/Amg88xx/samples/README.md

This file was deleted.

Loading

0 comments on commit ca63c97

Please sign in to comment.