„Tutorial - Tiva C (EK-TM4C123GXL)” változatai közötti eltérés

Innen: apaboard
Ugrás a navigációhoz Ugrás a kereséshez
(Új oldal, tartalma: „ === Tutorial === <big>'''Vissza az összesítő oldalra!'''</big> === Analóg jelek 1: TMP35 analóg hőmérő === Mi az '''analóg''' jel?<br /> Hogyan t…”)
 
35. sor: 35. sor:
==== Program ====
==== Program ====
<html>
<html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>/home/bkba/Dropbox/BALINT_share/energia_sketchbook/Tiva_C/Tutorial/TMP35_TivaC_TM4C123_129/TMP35_TivaC_TM4C123_129.ino</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta name="generator" content="Geany 1.24.1" />
<meta name="date" content="2015-08-08T13:05:30+0200" />
<style type="text/css">
body
{
font-family: Monospace, monospace;
font-size: 10pt;
}
.style_1
{
color: #d00000;
background-color: #ffffff;
}
.style_2
{
color: #d00000;
background-color: #ffffff;
}
.style_4
{
color: #007f00;
background-color: #ffffff;
}
.style_5
{
color: #00007f;
background-color: #ffffff;
font-weight: bold;
}
.style_6
{
color: #ff8000;
background-color: #ffffff;
}
.style_10
{
color: #301010;
background-color: #ffffff;
}
.style_11
{
color: #000000;
background-color: #ffffff;
}
</style>
</head>
<body>
<p>
<span class="style_1">/*&nbsp;</span><br />
&nbsp;<span class="style_1">TMP35&nbsp;read&nbsp;data&nbsp;and&nbsp;print&nbsp;to&nbsp;serial&nbsp;monitor&nbsp;in&nbsp;Celsius.</span><br />
&nbsp;<span class="style_1">Balint&nbsp;Kiss;&nbsp;2015.07.09</span><br />
&nbsp;<span class="style_1">eskolar.com</span><br />
&nbsp;<span class="style_1">--------------</span><br />
&nbsp;<br />
&nbsp;<span class="style_1">A&nbsp;TMP35&nbsp;Vout&nbsp;laban&nbsp;10&nbsp;mV&nbsp;1&nbsp;℃-nak&nbsp;felel&nbsp;meg.</span><br />
&nbsp;<span class="style_1">Ahanyszor&nbsp;10&nbsp;mV-unk&nbsp;van,&nbsp;anyi&nbsp;℃&nbsp;a&nbsp;homerseklet.</span><br />
&nbsp;<span class="style_1">Ezt&nbsp;az&nbsp;erteket&nbsp;olvassuk&nbsp;le,&nbsp;utanna&nbsp;a&nbsp;Serial&nbsp;Montor-on</span><br />
&nbsp;<span class="style_1">(soros&nbsp;porton)&nbsp;keresztul&nbsp;kirjuk.</span><br />
&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<span class="style_1">TMP35&nbsp;(front&nbsp;view)</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="style_1">|||</span><br />
&nbsp;<span class="style_1">Vin/&nbsp;|&nbsp;\GND</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="style_1">Vout</span><br />
&nbsp;<span class="style_1">*/</span><br />
<br />
<span class="style_2">//sorozat&nbsp;az&nbsp;E&nbsp;Port&nbsp;inicializalasahoz</span><br />
<span class="style_5">int&nbsp;</span><span class="style_11">E_PORT</span><span class="style_10">[]&nbsp;=&nbsp;{&nbsp;</span><br />
&nbsp;&nbsp;<span class="style_11">PE_0</span><span class="style_10">,&nbsp;</span><span class="style_11">PE_1</span><span class="style_10">,&nbsp;</span><span class="style_11">PE_2</span><span class="style_10">,&nbsp;</span><span class="style_11">PE_3</span><span class="style_10">,&nbsp;</span><span class="style_11">PE_4&nbsp;</span><span class="style_10">};</span><br />
<br />
<span class="style_5">float&nbsp;</span><span class="style_11">TMP35</span><span class="style_10">;&nbsp;</span><span class="style_2">//&nbsp;A&nbsp;szenzor&nbsp;kimente&nbsp;-&gt;&nbsp;lebegopontos&nbsp;leolvasott&nbsp;ertek</span><br />
<span class="style_5">float&nbsp;</span><span class="style_11">temp&nbsp;</span><span class="style_10">=&nbsp;</span><span class="style_4">0</span><span class="style_10">;</span><span class="style_2">//&nbsp;A&nbsp;℃&nbsp;fokba&nbsp;atalakitott&nbsp;ertek</span><br />
<span class="style_5">int&nbsp;</span><span class="style_11">sensor&nbsp;</span><span class="style_10">=&nbsp;</span><span class="style_11">PE_5</span><span class="style_10">;&nbsp;</span><span class="style_2">//leolvasott&nbsp;lab</span><br />
<br />
<span class="style_2">//inditaskor&nbsp;fut&nbsp;le</span><br />
<span class="style_5">void&nbsp;</span><span class="style_11">setup</span><span class="style_10">()&nbsp;{</span><br />
&nbsp;&nbsp;<span class="style_11">Serial</span><span class="style_10">.</span><span class="style_11">begin</span><span class="style_10">(</span><span class="style_4">9600</span><span class="style_10">);&nbsp;</span><span class="style_2">//&nbsp;Soros&nbsp;kapcsolat&nbsp;inditasa,&nbsp;baud&nbsp;rate&nbsp;beallitas</span><br />
&nbsp;&nbsp;<span class="style_11">pinMode&nbsp;</span><span class="style_10">(</span><span class="style_11">sensor</span><span class="style_10">,&nbsp;</span><span class="style_11">INPUT</span><span class="style_10">);&nbsp;</span><span class="style_2">//&nbsp;a&nbsp;leolvasott&nbsp;lab&nbsp;egy&nbsp;bemenet</span><br />
<br />
<br />
&nbsp;&nbsp;<span class="style_2">//Az&nbsp;E&nbsp;portot&nbsp;le&nbsp;kell&nbsp;zarni!</span><br />
&nbsp;&nbsp;<span class="style_2">//Mert&nbsp;PE_3&nbsp;ra&nbsp;bejövő&nbsp;jel&nbsp;(zaj)&nbsp;zavarhatja&nbsp;az&nbsp;E&nbsp;portot!</span><br />
&nbsp;&nbsp;<span class="style_5">for&nbsp;</span><span class="style_10">(</span><span class="style_5">int&nbsp;</span><span class="style_11">thisPin&nbsp;</span><span class="style_10">=&nbsp;</span><span class="style_4">0</span><span class="style_10">;&nbsp;</span><span class="style_11">thisPin&nbsp;</span><span class="style_10">&lt;&nbsp;</span><span class="style_4">5</span><span class="style_10">;&nbsp;</span><span class="style_11">thisPin</span><span class="style_10">++)&nbsp;&nbsp;{</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span class="style_11">pinMode</span><span class="style_10">(</span><span class="style_11">E_PORT</span><span class="style_10">[</span><span class="style_11">thisPin</span><span class="style_10">],&nbsp;</span><span class="style_11">OUTPUT</span><span class="style_10">);&nbsp;&nbsp;</span><br />
&nbsp;&nbsp;&nbsp;&nbsp;<span class="style_11">digitalWrite</span><span class="style_10">(</span><span class="style_11">E_PORT</span><span class="style_10">[</span><span class="style_11">thisPin</span><span class="style_10">],&nbsp;</span><span class="style_11">LOW</span><span class="style_10">);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><br />
&nbsp;&nbsp;<span class="style_10">}</span><br />
<span class="style_10">}</span><br />
<br />
<span class="style_2">//folyamatosan&nbsp;ismetlodik</span><br />
<span class="style_5">void&nbsp;</span><span class="style_11">loop</span><span class="style_10">()&nbsp;{</span><br />
&nbsp;&nbsp;<span class="style_2">//analog&nbsp;leolvasas&nbsp;(TM4C123&nbsp;PE_5&nbsp;=&nbsp;A8)&nbsp;(TM4C129&nbsp;PE_5&nbsp;=&nbsp;A9)&nbsp;&nbsp;</span><br />
&nbsp;&nbsp;<span class="style_11">TMP35&nbsp;</span><span class="style_10">=&nbsp;</span><span class="style_11">analogRead</span><span class="style_10">(</span><span class="style_11">PE_5</span><span class="style_10">);&nbsp;&nbsp;&nbsp;</span><br />
&nbsp;&nbsp;<span class="style_11">temp&nbsp;</span><span class="style_10">=&nbsp;((</span><span class="style_11">TMP35</span><span class="style_10">*</span><span class="style_4">3300</span><span class="style_10">)/</span><span class="style_4">4095</span><span class="style_10">)/</span><span class="style_4">10</span><span class="style_10">;</span><span class="style_2">//&nbsp;konvertalas&nbsp;mV-ba&nbsp;utanna&nbsp;℃-ba</span><br />
<br />
&nbsp;&nbsp;<span class="style_11">Serial</span><span class="style_10">.</span><span class="style_11">print</span><span class="style_10">(</span><span class="style_6">"Analog&nbsp;Read&nbsp;&nbsp;---&gt;&nbsp;&nbsp;"</span><span class="style_10">);</span><br />
&nbsp;&nbsp;<span class="style_11">Serial</span><span class="style_10">.</span><span class="style_11">print</span><span class="style_10">(</span><span class="style_11">TMP35</span><span class="style_10">);&nbsp;</span><span class="style_2">//adatok&nbsp;kiirasa</span><br />
&nbsp;&nbsp;<span class="style_11">Serial</span><span class="style_10">.</span><span class="style_11">print</span><span class="style_10">(</span><span class="style_6">"&nbsp;=&nbsp;"</span><span class="style_10">);</span><br />
&nbsp;&nbsp;<span class="style_11">Serial</span><span class="style_10">.</span><span class="style_11">print</span><span class="style_10">(</span><span class="style_11">temp</span><span class="style_10">);&nbsp;</span><span class="style_2">//adatok&nbsp;kiirasa</span><br />
&nbsp;&nbsp;<span class="style_11">Serial</span><span class="style_10">.</span><span class="style_11">println</span><span class="style_10">(</span><span class="style_6">"&nbsp;C"</span><span class="style_10">);</span><br />
&nbsp;&nbsp;<span class="style_11">delay</span><span class="style_10">(</span><span class="style_4">100</span><span class="style_10">);&nbsp;</span><span class="style_2">//&nbsp;0.1&nbsp;mp&nbsp;szunet</span><br />
<br />
<span class="style_10">}</span><br />
<br />
<br />
<br />
<br />
<br />
</p>
</body>
</html>


</html>
</html>
=== Digitális jelek 1 ===
=== Digitális jelek 1 ===
==== Video ====
==== Video ====

A lap 2015. augusztus 8., 11:12-kori változata

Tutorial

Vissza az összesítő oldalra!

Analóg jelek 1: TMP35 analóg hőmérő

Mi az analóg jel?
Hogyan tudjuk érzékelni az analóg feszültségváltozást?
A példában egy TMP35 lineáris hő szenzort használtam, hogy megértsük az analóg jeleket, ennek az értékét olvassuk le.
A TMP35 egy lineáris hő szenzor, ahány °C-t mér annyiszor 10 mV-ot kapcsol a 2. lába.
TMP35 datasheet

Video

Kapcsolás

mV to °C
TMP35 + LauchPad
TMP35 TivaC 123.png
TMP35 IC Output Voltage vs. Temperature
TMP35 kivag 02.png
TMP35 Adafruit.png
TMP35 Graph.png

Program

/home/bkba/Dropbox/BALINT_share/energia_sketchbook/Tiva_C/Tutorial/TMP35_TivaC_TM4C123_129/TMP35_TivaC_TM4C123_129.ino

/* 
 TMP35 read data and print to serial monitor in Celsius.
 Balint Kiss; 2015.07.09
 eskolar.com
 --------------
 
 A TMP35 Vout laban 10 mV 1 ℃-nak felel meg.
 Ahanyszor 10 mV-unk van, anyi ℃ a homerseklet.
 Ezt az erteket olvassuk le, utanna a Serial Montor-on
 (soros porton) keresztul kirjuk.
 
    TMP35 (front view)
     |||
 Vin/ | \GND
      Vout
 */

//sorozat az E Port inicializalasahoz
int E_PORT[] = { 
  PE_0PE_1PE_2PE_3PE_4 };

float TMP35// A szenzor kimente -> lebegopontos leolvasott ertek
float temp 0;// A ℃ fokba atalakitott ertek
int sensor PE_5//leolvasott lab

//inditaskor fut le
void setup() {
  Serial.begin(9600); // Soros kapcsolat inditasa, baud rate beallitas
  pinMode (sensorINPUT); // a leolvasott lab egy bemenet


  //Az E portot le kell zarni!
  //Mert PE_3 ra bejövő jel (zaj) zavarhatja az E portot!
  for (int thisPin 0thisPin 5thisPin++)  {
    pinMode(E_PORT[thisPin], OUTPUT);  
    digitalWrite(E_PORT[thisPin], LOW);      
  }
}

//folyamatosan ismetlodik
void loop() {
  //analog leolvasas (TM4C123 PE_5 = A8) (TM4C129 PE_5 = A9)  
  TMP35 analogRead(PE_5);   
  temp = ((TMP35*3300)/4095)/10;// konvertalas mV-ba utanna ℃-ba

  Serial.print("Analog Read  --->  ");
  Serial.print(TMP35); //adatok kiirasa
  Serial.print(" = ");
  Serial.print(temp); //adatok kiirasa
  Serial.println(" C");
  delay(100); // 0.1 mp szunet

}





</html>

Digitális jelek 1

Video