nanoFramework.Iot.Device.Tlc1543
1.2.631
Prefix Reserved
See the version list below for details.
dotnet add package nanoFramework.Iot.Device.Tlc1543 --version 1.2.631
NuGet\Install-Package nanoFramework.Iot.Device.Tlc1543 -Version 1.2.631
<PackageReference Include="nanoFramework.Iot.Device.Tlc1543" Version="1.2.631" />
paket add nanoFramework.Iot.Device.Tlc1543 --version 1.2.631
#r "nuget: nanoFramework.Iot.Device.Tlc1543, 1.2.631"
// Install nanoFramework.Iot.Device.Tlc1543 as a Cake Addin #addin nuget:?package=nanoFramework.Iot.Device.Tlc1543&version=1.2.631 // Install nanoFramework.Iot.Device.Tlc1543 as a Cake Tool #tool nuget:?package=nanoFramework.Iot.Device.Tlc1543&version=1.2.631
TLC1543 - 10-bit ADC with 11 input channels
High-speed 10-bit switched-capacitor successive-approximation A/D Converter with 14 channels (11 inputs and 3 self-test channels)
Documentation
- TLC1542/3 Datasheet
Usage
Simple Line finding algorithm with ADC usage
This sample shows how to calculate position of line under matrix of 5 IR sensors with the help of TLC1543 ADC. In this case it's AlphaBot2 Pi from WaveShare with ITR-20001 IR sensors.
Initialization
SpiDevice spi = SpiDevice.Create(new SpiConnectionSettings(1, 5) { DataBitLength = Tlc1543.SpiDataBitLength });
Changing Charge Channel
adc.ReadPreviousAndChargeChannel(channels[0]);
You can set ChargeChannel to one of the Self Test channels (if you really know what you're doing you can also set it to one of the normal channels - but remember that this may amplify noise going from one channel to the other) if you know exactly what range of values you're expecting on polled channels (less interference on channels with fast changing but weak signals). Default set for SelfTest512 as that's the middle of 10 bit range.
Getting data
int values = adc.ReadPreviousAndChargeChannel(channels[0]);
Simple way of reading values into just made list.
Calculating position
for (int i = 0; i < values.Count; i++)
{
if (values[i] < 300)
{
lineAverage += (i - 2);
onLine++;
}
}
To find where under our matrix is line we need to check values given out from sensors depending on where they are pointing.
- Pointing at sky gives us values ranging from 0 to 50
- Keeping it close to white paper gives values bigger than 600
- Placing it pointed at black tape - taped on white paper(for contrast) gives values ranging from 150 to 250 on sensor exactly above line
So to simplfy things we assume that when we run this program we won't be pointing our sensor matrix at the sky and we will keep it at a flat surface.
Next thing is to calculate average from sensors for when there are more than one sensors seeing line.
For example when first and second sensor sees line values will be
- on first loop
lineAverage = -2
andonLine = 1
; - on second loop
lineAverage = -3
andonLine = 2
;
And now with this data we can calculate linePosition
double linePosition = ((double)lineAverage / (double)onLine);
linePosition = -1.5
and we now know that the line is somewhere between first and second sensor. By using (i - 2)
in our loop we moved values that the third sensor now indicates middle of the matrix, values less than zero are left from the middle and values above are on the right side. If we would have seven sensor matrix we would move those values by 3. Nine sensors? Move it by 4 - simple as that.
Binding Notes
Only mode implemented is Fast Mode 1 (10 clocks and !ChipSelect high between conversion cycles). Respective timing diagram can be seen on figure 9 in datasheet.
It is possible to change ADC charge channel.
adc.ReadPreviousAndChargeChannel(channels[0]);
Using EndOfConversion mode is not yet supported.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net is compatible. |
-
- nanoFramework.CoreLibrary (>= 1.15.5)
- nanoFramework.Runtime.Events (>= 1.11.18)
- nanoFramework.Runtime.Native (>= 1.6.12)
- nanoFramework.System.Device.Gpio (>= 1.1.41)
- nanoFramework.System.Device.Spi (>= 1.3.52)
- nanoFramework.System.Diagnostics.Stopwatch (>= 1.2.628)
- nanoFramework.System.Math (>= 1.5.43)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.2.673 | 72 | 10/23/2024 |
1.2.662 | 79 | 10/11/2024 |
1.2.631 | 94 | 8/28/2024 |
1.2.590 | 95 | 7/17/2024 |
1.2.570 | 99 | 6/14/2024 |
1.2.560 | 107 | 5/29/2024 |
1.2.548 | 96 | 5/15/2024 |
1.2.436 | 251 | 11/10/2023 |
1.2.416 | 121 | 11/8/2023 |
1.2.329 | 155 | 5/26/2023 |
1.2.313 | 138 | 5/12/2023 |
1.2.297 | 146 | 5/3/2023 |
1.2.208 | 287 | 1/3/2023 |
1.2.203 | 287 | 12/28/2022 |
1.2.159 | 357 | 11/14/2022 |
1.2.153 | 350 | 11/5/2022 |
1.2.141 | 382 | 10/25/2022 |
1.2.128 | 387 | 10/22/2022 |
1.2.122 | 423 | 10/12/2022 |
1.2.114 | 372 | 10/8/2022 |
1.2.95 | 414 | 9/22/2022 |
1.2.87 | 464 | 9/15/2022 |
1.2.73 | 399 | 9/8/2022 |
1.2.5 | 439 | 7/13/2022 |
1.1.141.41205 | 430 | 7/6/2022 |
1.1.118.19693 | 439 | 6/24/2022 |
1.1.116.8772 | 411 | 6/24/2022 |
1.1.113.2032 | 400 | 6/23/2022 |
1.1.27 | 432 | 4/26/2022 |
1.1.20 | 431 | 4/21/2022 |
1.1.3 | 442 | 4/15/2022 |
1.1.1 | 430 | 4/14/2022 |
1.0.7-preview.114 | 121 | 3/25/2022 |
1.0.7-preview.113 | 123 | 3/25/2022 |
1.0.7-preview.100 | 110 | 3/19/2022 |
1.0.7-preview.99 | 130 | 3/18/2022 |
1.0.7-preview.94 | 121 | 3/15/2022 |
1.0.7-preview.87 | 123 | 3/10/2022 |
1.0.7-preview.73 | 122 | 2/25/2022 |
1.0.7-preview.48 | 129 | 2/4/2022 |
1.0.7-preview.42 | 129 | 1/31/2022 |
1.0.7-preview.41 | 134 | 1/31/2022 |
1.0.7-preview.22 | 127 | 1/27/2022 |
1.0.7-preview.20 | 127 | 1/27/2022 |
1.0.7-preview.18 | 132 | 1/27/2022 |
1.0.1 | 460 | 1/17/2022 |