1 / 17

Bluetooth Auto Projekt

Bluetooth Auto Projekt. 2007 Von: Sascha Tippmann Christian Krieger. Einleitung. Die ersten Schritte Kommunikation und Ansteuerung Schaltplan BT Auto Quellcode Tiny in Bascom Quellcode Windows GUI Abschliessend. Die ersten Schritte. Verständnis der Servos bzw. PWM Signal

venice
Télécharger la présentation

Bluetooth Auto Projekt

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Bluetooth Auto Projekt 2007 Von: Sascha Tippmann Christian Krieger Sascha Tippmann, Christian Krieger

  2. Einleitung • Die ersten Schritte • Kommunikation und Ansteuerung • Schaltplan BT Auto • Quellcode Tiny in Bascom • Quellcode Windows GUI • Abschliessend Sascha Tippmann, Christian Krieger

  3. Die ersten Schritte • Verständnis der Servos bzw. PWM Signal • Signalerzeugung des PWMs, erstes Tiny Programm • Kommunikation mit Serieller Schnittstelle • Ansteuerung mittels Serieller Schnittstelle Sascha Tippmann, Christian Krieger

  4. Kommunikation und Ansteuerung • Verwendete Materialien: - HBX Bonzer (Modellauto) - 2x Tiny 2313 - Bluetooth Adapter - Signalwandler Max232 - Schaltrelais ULN2003A - Gabellichtschranke - etliche elektronische Bauelemente Sascha Tippmann, Christian Krieger

  5. Kommunikation und Ansteuerung • Verwendung einer Windows GUI mit Gamepad • Wichtig! Baudrate , Clockrate , Paraty Bits etc. müssen identisch sein für fehlerfreie Kommunikation • BT Adapter leitet Datenströme an Max weiter • Max wandelt Signale RS232 in TTL-Signal • ULN als Schalter für Lichtanlage etc. Sascha Tippmann, Christian Krieger

  6. Schaltplan BT Auto 1 Sascha Tippmann, Christian Krieger

  7. Schaltplan BT Auto 2 Sascha Tippmann, Christian Krieger

  8. Quellcode Tiny '004.BAS: UART-Empfänger ohne Interrupt 'Hardware: MAX232 an PD0/PD1, Nullmodemkabel zum PC '--------------------------------------------------- $regfile = "ATtiny2313.DAT" 'AT90S2313-Deklarationen $crystal = 8000000 'Quarz: 8MHz $baud = 9600 'Baudrate der UART: 9600 Baud ConfigServos = 2 , Servo1 = Portb.2 , Servo2 = Portb.4 , Reload = 10 ConfigPortb = Output #b-pins als Output Config Pind.3 = Input Enable Interrupts #Aktivierung der Interrupts Servo(1) = 90 'Lenkung Servo(2) = 95 'Gas Dim I As Byte Portd.3 = 1 'Pullup Widerstand einschalten Do If Usr.rxc = 1 Then 'Wenn Byte empfangen... I = Udr If Pind.3 = 0 Then #Falls CD fehlt, -> Mittelstand Servo(1) = 90 Servo(2) = 95 Else Portb.1 = 0 If I < 128 And I > 59 Then Servo(1) = I End If If I > 188 And I < 252 Then I = I - 128 Servo(2) = I End If 'If I = "D" Then ' Servo(2) = 95 ' Servo(1) = 90 ' End If End If Else Usr.rxc = 0 End If Loop End Sascha Tippmann, Christian Krieger

  9. Quellcode Tiny 2 Speed Dim I As Integer Dim C As Byte I = 0 C = 0 Do Loop End Ontimer0: I = I + 1024 If I >= 31250 Then I = 0 Printbin C C = 0 End If Return Isr_von_int1: C = C + 1 'Toggle Led3 Return $regfile = "ATtiny2313.dat" $crystal = 8000000 $hwstack = 28 $swstack = 32 $framesize = 32 Config Portb.1 = Output Portb.1 = 1 Config Pind.3 = Input Led3 Alias Portb.1 Portd.3 = 1 'Internen Pull-up Widerstand einschalten Config Int1 = Rising On Int1 Isr_von_int1 'Interrupt-Routine On Timer0 Ontimer0 Config Timer0 = Timer , Prescale = 1024 , Capture Edge = Rising Enable Timer0 Enable Int1 Enable Interrupts 'Interrupts global Sascha Tippmann, Christian Krieger

  10. Quellcode WinGUI (Ausschnitte) Serielles Interface: hCom = CreateFile(pccom, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); if(INVALID_HANDLE_VALUE == hCom) { //Handle Error return false; } //Get port status portSuccess = GetCommState(hCom, &dcb); if(!portSuccess) { //Handle Error return false; } dcb.BaudRate = CBR_9600; dcb.ByteSize = 8; dcb.Parity = NOPARITY; dcb.StopBits = ONESTOPBIT; portSuccess = SetCommState(hCom, &dcb); if(!portSuccess) { //Handle error return false; } portSuccess = SetCommMask (hCom, EV_RXCHAR); if(!portSuccess) { return false; } SerialReader *p_sread = new SerialReader(); p_sread->Create(getHandle(),frame); p_sread->Run(); return true; Sascha Tippmann, Christian Krieger

  11. Quellcode WinGUI (Ausschnitte) Joystick: while(true) { if(joyGetPosEx(JOYSTICKID1,&joyData) == JOYERR_NOERROR) { Xpos =joyData.dwRpos; Ypos = joyData.dwYpos; Ypos = (Ypos/1092)+60; //Ypos = -Ypos + 308; Ypos = Ypos + 132; Xpos = (Xpos/1092)+67; if(Ypos > 251) Ypos = 251; if(Ypos != Ypos_old || Xpos != Xpos_old) { status = wxString("") << "X = " << Xpos << "\nY = " << Ypos; WriteFile(hCom, &Xpos, sizeof(Xpos), &bytesSent, over); WriteFile(hCom, &Ypos, sizeof(Ypos), &bytesSent, over); } Xpos_old = Xpos; Ypos_old = Ypos; if (joyData.dwButtons & JOY_BUTTON1) { // bt_press = true; // WxButton2->SetLabel("Gamepad an"); } if (joyData.dwButtons & JOY_BUTTON2) { //bt_press = true; } Sascha Tippmann, Christian Krieger

  12. Quellcode WinGUI (Ausschnitte) Reader: voidSerialReader::Create(HANDLE phCom,CarFrm *frm) { hCom = phCom; frame = frm; over = new OVERLAPPED; over->Offset = 0; over->OffsetHigh = 1; over->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL); wxThread::Create(); } void *SerialReader::Entry() { boolbTest = false; DWORD d_size; charr_data; double i = 0.; while(1) { bTest = ReadFile(hCom, &r_data, 1, &d_size, over); while(!bTest) { bTest = GetOverlappedResult(hCom,over, &d_size,false); } i = (double)r_data; i=i*0.38*3.6; //Umdrehungen pro s * U in M * 3.6 = km/h frame->set_kmh(i); } return 0; } Sascha Tippmann, Christian Krieger

  13. Bilder Sascha Tippmann, Christian Krieger

  14. Bilder AVR - Programmer Sascha Tippmann, Christian Krieger

  15. Video Sascha Tippmann, Christian Krieger

  16. Abschliessend • Bluetooth ist kein guter Ersatz was die Reaktionszeit gegenüber Funk betrifft • Bluetooth bietet eine bedeutend höhere Bandbreite als Funk und ist somit multifunktional einsetzbar • Keine Störsignale die das Auto beeinflussen könnten • Eher Drone statt Modellauto Sascha Tippmann, Christian Krieger

  17. ENDE Sascha Tippmann, Christian Krieger

More Related