View
0
Download
0
Category
Preview:
Citation preview
1. Project title : Sport Car Circuit Timer
Iosub Iulia Buleev Ghennadi Zugravu Valentin
valentinzug@gmail.com iulia.iosub@gmail.com ghennadibuleev@gmail.com
2. Abstract
XMC4500 poate fi folosit intr-o varietate mare de proiecte, deoarece are o gama mare de componente ce pot fi
folosite in diferite scopuri.
Am ales sa folosim comunicarea prin bluetooth pentru transmiterea datelor, deoarece se poate seta simplu si eficient.
Proiectul poate fi utilizat in multe domenii ce tin de curse auto. Este complet autonom, nu necesita monitorizarea de catre
utilizator, acesta la randul lui poate doar colecta datele necesare ulterior.
3. Introduction, project aims and objectives
Proiectul isi propune realizarea unui sistem de monitorizare a unei piste de circuit. Timpii obtinuti prin masurare vor fi afisati
pe o aplicatie grafica in C# prin intermediul protocolului UART. Din punct de vedere functional, sistemul conceput trebuie sa
permita obtinerea timpilor chiar daca in acelasi timp prin punctul de start trec simultan doua masini. Sistemul de
recunoastere a masinii ce trece prin punctul de start trebuie sa fie cat mai independent de functionarea acesteia, astfel
circuitul aditional creat are ca scop doar de a notifica circuitul de receptie. Totodata toate subcircuitele realizate in vederea
monitorizarii au alimentare proprie.
Prin aceasta functionare independenta a subcircuitelor se contureaza caracteristica principala a acestor sisteme, si aceea de a
fi "embedded".
4. System overview
Din punct de vedere structural si functional, proiectul poate fi impartit in trei sisteme:
a). Aplicatia Windows
b). Modulul de receptie IR
c). Modulul de transmisie IR
1. Windows application
Since the XMC4500 is in charge with sending the data about the circuit state, meaning the car number and the time
for each car, there is a need for this data to be processed and displayed. The windows application is the one that does that.
This interface allows the connection to a serial port in order to receive the information. The data will be ordered by seconds
and displayed in the application , and the user will be able to see the cars ranking.
2. Modulul de receptie IR
Pentru realizarea acestui modul s-au folosit urmatoareale componente:
- 2 circuite TSOP1738
- 2 circuite TSOP1736
- 4 circuite IC555
- 4 capacitori 0.01uF
- un filtru trece jos
- LM7805cv
- un comutator
- pini tata
- baterie 9V
Circuitul de receptie functioneaza pe baza schemei din Figura 1. Circuitul din acea figura este multiplicat de patru
ori. Astfel se contureaza 3 circuite
aditionale, redundante, menite sa capteze semnalul IR. In momentul in care se trigger-eaza un semnal IR, decizia transmiterii
timpului mai departe la modulul de aplicatie C# se ia in functie de toate cele 4 transceivere. Identificatorul unic prin care este
recunoscuta masina este duty cycle-ul PWM-ului ce este transmis prin intermediul ledului IR amplasat pe automobil. Decizia
de a automobilului se ia in functie de logica majoritara de pe receptorii IR. Daca cel putin 2 receptori dau un ID unic, atunci
informatia este valida si va fi transmis mai departe catre aplicatia C# timpul care a trecut de la ultima masurare a acelui
automobil.
Figura.1
c) Modulul de transmisie IR
Datele receptionate sunt transmise de catre masinile care au cate un transmitter infrared pe ele. Acestea au fost realizate prin
setarea unui semnal PWM de pe platforma FRDMKL25Z, deoarece este un instrument puternic in care se poate seta cu
acuratete un semnal PWM. Masinile reprezinta un led IR de un PWM cu o anumita frecventa si duty cycle. Platforma
XMC4500 comunica cu computerul printr-un modul Bluetooth conectat la pinii setati pentru seriala in mod crossover. In
programul main.c au fost adaugate functiile pentru comunicare in mod full duplex. Datele de la platforma se transmit catre
computer si sunt preluate de o interfata implementata in C#. Conexiunea este realizata printr-un port virtual pe care se
receptioneaza informatia.
5. Schematics and components
Modulul de receptie IR
6. Software
• Receiver module software:
struct{
int ir_1;
int ir_2;
int ir_3;
int ir_4;
}typedef IR_inputs;
static IR_inputs IR_Receivers;
int main(void)
{
DAVE_STATUS_t status;
int button_stats;
int counter = 0;
int seconds = 0;
status = DAVE_Init(); /* Initialization of DAVE APPs */
if(status == DAVE_STATUS_FAILURE)
{
/* Placeholder for error handler code. The while loop below canbe replaced with an user error handler. */
XMC_DEBUG("DAVE APPs initialization failed\n");
while(1U)
{
}
}
/* Placeholder for user application code. The while loop below can be replaced with user application code. */
while(1U)
{
IR_Receivers.ir_1 = DIGITAL_IO_GetInput(&BUTTON2);
IR_Receivers.ir_2 = DIGITAL_IO_GetInput(&IR_1);
IR_Receivers.ir_3 = DIGITAL_IO_GetInput(&IR_2);
IR_Receivers.ir_4 = DIGITAL_IO_GetInput(&IR_3);
if(IR_Receivers.ir_1 == 0 && IR_Receivers.ir_2 == 0 &&
IR_Receivers.ir_3 == 0 && IR_Receivers.ir_4 == 0)
{
if(counter == 1000)
{
counter = 0;
++seconds;
}
++counter;
}
else
{
// write to serial
UART_Transmit(&UART_0,seconds, sizeof(seconds));
seconds = 0 ;
counter = 0 ;
}
}
}
void toggle_led(void) {
DIGITAL_IO_ToggleOutput(&LED2);
UART_Transmit(&UART_0,send_data, sizeof(send_data));
}
• Windows application
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ProiectCI
{
public partial class Form1 : Form
{
private SerialPort serialPort;
private Dictionary<int,int> _clasament;
public Form1()
{
InitializeComponent();
stopListening.Enabled = false;
_clasament = new Dictionary<int,int>();
}
private void Form1_Load(object sender, EventArgs e)
{
string[] ports = SerialPort.GetPortNames();
foreach (string port in ports)
{
portName.Items.Add(port);
}
//Default values
boudRate.SelectedIndex = boudRate.Items.IndexOf("9600");
dataBits.SelectedIndex = dataBits.Items.IndexOf("8");
parity.SelectedIndex = parity.Items.IndexOf("None");
stopBits.SelectedIndex = stopBits.Items.IndexOf("1");
}
private void updateClasament()
{
int i = 1;
clasament.Rows.Clear();
var list = _clasament.Keys.ToList();
list.Sort();
foreach(var elem in list)
{
int rowNum = clasament.Rows.Add();
clasament.Rows[rowNum].Cells[0].Value = "Locul "+i;
clasament.Rows[rowNum].Cells[1].Value = _clasament[elem];
TimeSpan time = TimeSpan.FromSeconds(elem);
string str = time.ToString(@"hh\:mm\:ss");
clasament.Rows[rowNum].Cells[2].Value = str;
i++;
}
}
private void startListening_Click(object sender, EventArgs e)
{
if (serialPort != null && serialPort.IsOpen)
{
serialPort.Close();
}
Parity pari = Parity.None;
StopBits stopb = StopBits.None;
switch(parity.Text.ToString())
{
case "Odd":
{
pari = Parity.Odd;
break;
}
case "Even":
{
pari = Parity.Even;
break;
}
case "Mark":
{
pari = Parity.Mark;
break;
}
case "Space":
{
pari = Parity.Space;
break;
}
default:
{
break;
}
}
switch(stopBits.Text.ToString())
{
case "1":
{
stopb = StopBits.One;
break;
}
case "1.5":
{
stopb = StopBits.OnePointFive;
break;
}
case "2":
{
stopb = StopBits.Two;
break;
}
default:
{
break;
}
}
serialPort = new SerialPort(portName.Text.ToString(), Convert.ToInt32(boudRate.Text), pari,
Convert.ToInt32(dataBits.Text), stopb);
// Subscribe to event and open serial port for data
serialPort.DataReceived += new SerialDataReceivedEventHandler(serialPort_DataReceived);
serialPort.Open();
startListening.Enabled = false;
stopListening.Enabled = true;
}
private void serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
int dataLength = serialPort.BytesToRead;
byte[] data = new byte[dataLength];
int nbrDataRead = serialPort.Read(data, 0, dataLength);
if (nbrDataRead == 0)
return;
string dataS = System.Text.Encoding.Default.GetString(data);
int seconds = getSeconds(dataS);
int car = getCarNumber(dataS);
if (!_clasament.ContainsValue(car))
{
_clasament.Add(seconds, car);
}
else
{
if(seconds < _clasament.FirstOrDefault(x => x.Value.Equals(car)).Key )
{
_clasament.Remove(_clasament.FirstOrDefault(x => x.Value.Equals(car)).Key);
_clasament.Add(seconds, car);
}
}
}
private int getSeconds(string message)
{
StringBuilder s = new StringBuilder();
for (int i = 0; i < message.Length - 1;i++ )
{
if (message[i] == 's')
{
break ;
}
s.Append(message[i]);
}
return int.Parse(s.ToString());
}
private int getCarNumber(string message)
{
StringBuilder s = new StringBuilder();
for (int i = message.Length - 2; i >= 0;i--)
{
if (message[i] == 's')
{
break;
}
s.Append(message[i]);
}
return int.Parse(s.ToString());
}
private void toHMinSec(int seconds)
{
}
private void stopListening_Click(object sender, EventArgs e)
{
serialPort.Close();
startListening.Enabled = true;
stopListening.Enabled = false;
}
private void update_Click(object sender, EventArgs e)
{
updateClasament();
}
}
}
7. Project results & applications
8. Reference
http://embedac.ro/Infineon/index.html
http://www.infineon.com/
TSOP1738 Datasheet
IC555 Datasheet
Recommended