-
Notifications
You must be signed in to change notification settings - Fork 594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation changes (second half): Use only a single README.md per device #1610
Changes from 1 commit
9a2217b
5950f5f
0b46db2
5b9eb3f
e73955e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,108 @@ LSM9DS1 internally uses 2 buses: | |
|
||
and therefore functionality has been split into 2 classes which allows using them independently. | ||
|
||
See [samples](samples/README.md) for information about usage. | ||
|
||
## References | ||
## Documentation | ||
|
||
- https://www.st.com/resource/en/datasheet/lsm9ds1.pdf | ||
|
||
## Usage | ||
|
||
### Accelerometer and gyroscope | ||
|
||
```csharp | ||
class Program | ||
{ | ||
public const int I2cAddress = 0x6A; | ||
|
||
static void Main(string[] args) | ||
{ | ||
using (var ag = new Lsm9Ds1AccelerometerAndGyroscope(CreateI2cDevice())) | ||
{ | ||
while (true) | ||
{ | ||
Console.WriteLine($"Acceleration={ag.Acceleration}"); | ||
Console.WriteLine($"AngularRate={ag.AngularRate}"); | ||
Thread.Sleep(100); | ||
} | ||
} | ||
} | ||
|
||
private static I2cDevice CreateI2cDevice() | ||
{ | ||
var settings = new I2cConnectionSettings(1, I2cAddress); | ||
return I2cDevice.Create(settings); | ||
} | ||
} | ||
``` | ||
|
||
### Magnetometer | ||
|
||
```csharp | ||
class Magnetometer | ||
{ | ||
public const int I2cAddress = 0x1C; | ||
|
||
public static void Run() | ||
{ | ||
using (var m = new Lsm9Ds1Magnetometer(CreateI2cDevice())) | ||
{ | ||
Console.WriteLine("Calibrating..."); | ||
Console.WriteLine("Move the sensor around Z for the next 20 seconds, try covering every angle"); | ||
Stopwatch sw = Stopwatch.StartNew(); | ||
Vector3 min = m.MagneticInduction; | ||
Vector3 max = m.MagneticInduction; | ||
while (sw.ElapsedMilliseconds < 20 * 1000) | ||
{ | ||
Vector3 sample = m.MagneticInduction; | ||
min = Vector3.Min(min, sample); | ||
max = Vector3.Max(max, sample); | ||
Thread.Sleep(50); | ||
} | ||
Console.WriteLine("Stop moving for some time..."); | ||
Thread.Sleep(3000); | ||
const int intervals = 32; | ||
bool[,] data = new bool[32,32]; | ||
Vector3 size = max - min; | ||
int n = 0; | ||
while (true) | ||
{ | ||
n++; | ||
Vector3 sample = m.MagneticInduction; | ||
Vector3 pos = Vector3.Divide(Vector3.Multiply((sample - min), intervals - 1), size); | ||
int x = Math.Clamp((int)pos.X, 0, intervals - 1); | ||
int y = Math.Clamp((int)pos.Y, 0, intervals - 1); | ||
data[x, y] = true; | ||
if (n % 10 == 0) | ||
{ | ||
Console.Clear(); | ||
Console.WriteLine("Now move the sensor around again but slower..."); | ||
for (int i = 0; i < intervals; i++) | ||
{ | ||
for (int j = 0; j < intervals; j++) | ||
{ | ||
if (i == x && y == j) | ||
{ | ||
Console.ForegroundColor = ConsoleColor.Red; | ||
Console.Write('#'); | ||
Console.ResetColor(); | ||
} | ||
else | ||
{ | ||
Console.Write(data[i, j] ? '#' : ' '); | ||
} | ||
} | ||
Console.WriteLine(); | ||
} | ||
} | ||
Thread.Sleep(50); | ||
} | ||
} | ||
} | ||
|
||
private static I2cDevice CreateI2cDevice() | ||
{ | ||
var settings = new I2cConnectionSettings(1, I2cAddress); | ||
return I2cDevice.Create(settings); | ||
} | ||
} | ||
``` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Markdown tip: you need to finish the file with an empty line, so adding an extra enter There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See the other Markdown tips left there and there :-) the enum at the beginning of the file is not correct as it should havre an empty line before also reinforce by the fact you have a title. |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,42 @@ | ||
# Max31856 - cold-junction compensated thermocouple to digital converter | ||
|
||
## Summary | ||
The Max31856 device is a SPI interface cold-junction compensated thermocouple to digital converter. | ||
|
||
## Sensor Image | ||
 | ||
|
||
**Note:** _ThermocoupleType.K is configured for a K type thermocouple if you want to use a B,E,J,K,N,R,S, or T simply change the K to the thermocouple type of your choosing._ | ||
|
||
## References | ||
## Documentation | ||
|
||
**Max31856** [datasheet](https://datasheets.maximintegrated.com/en/ds/Max31856.pdf) | ||
|
||
## Usage | ||
The Max31856.samples file contains a sample usage of the device. Note that this reads two temperatures. One is a connected thermocouple reading which can be read using the ```TryGetTemperature``` command and the other is the temperature of the device itself which can be read using the ```GetColdJunctionTemperature``` command. The Cold Junction Temperature is used internally to increase the accuracy of the thermocouple but can also be read if you find a use for it. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Marktdown tips:
|
||
|
||
Create a new ```SpiConnectionSettings``` Class if using a Raspberry Pi do not change these settings. | ||
|
||
```csharp | ||
SpiConnectionSettings settings = new(0, 0) | ||
{ | ||
ClockFrequency = Max31856.SpiClockFrequency, | ||
Mode = Max31856.SpiMode, | ||
DataFlow = 0 | ||
}; | ||
``` | ||
|
||
Create a new ```SpiDevice``` with the settings from above. Then create a new Max31856 device with the ```SpiDevice``` as well as the correct ```ThermocoupleType``` (see note below) | ||
```csharp | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so here you miss an enter before the code block |
||
using SpiDevice device = SpiDevice.Create(settings); | ||
using Max31856 sensor = new(device, ThermocoupleType.K); | ||
``` | ||
|
||
Now read the temperature from the device. Using the UnitsNet nuget you can see the units of your choosing. In this example you chan change```DegreesFahrenheit``` to ```DegreesCelsius``` or any other unit by changing ```.GetTemperature().DegreesFahrenheit``` to another unit of your choice. | ||
|
||
```csharp | ||
while (true) | ||
{ | ||
Temperature tempColdJunction = sensor.GetColdJunctionTemperature(); | ||
Console.WriteLine($"Temperature: {tempColdJunction} ℃"); | ||
Thread.Sleep(2000); | ||
} | ||
``` |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while you are at adjusting those elements, make it with the proper pattern so something like:
I've tried to adjust all those URLs as well