FR2987927A1 - GPS MOTO DETECTOR - Google Patents
GPS MOTO DETECTOR Download PDFInfo
- Publication number
- FR2987927A1 FR2987927A1 FR1202458A FR1202458A FR2987927A1 FR 2987927 A1 FR2987927 A1 FR 2987927A1 FR 1202458 A FR1202458 A FR 1202458A FR 1202458 A FR1202458 A FR 1202458A FR 2987927 A1 FR2987927 A1 FR 2987927A1
- Authority
- FR
- France
- Prior art keywords
- ping
- trame
- indice
- car
- receiver
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G08—SIGNALLING
- G08G—TRAFFIC CONTROL SYSTEMS
- G08G1/00—Traffic control systems for road vehicles
- G08G1/16—Anti-collision systems
- G08G1/161—Decentralised systems, e.g. inter-vehicle communication
Landscapes
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Mobile Radio Communication Systems (AREA)
Abstract
La présente invention constitue un détecteur GPS de véhicule vulnérable indiquant de manière fiable à un automobiliste qu'un véhicule vulnérable provenant de l'arrière va le dépasser quelques secondes plus tard constituant de ce fait un danger pour les deux véhicules. En couplant différentes données de vitesses, de géolocalisations ainsi que d'orientations, ce détecteur constitué d'un émetteur et d'un récepteur reliés entre eux par fréquence radio fixe et continue à pour but de prévenir les situations de danger potentiel.The present invention is a vulnerable vehicle GPS detector reliably indicating to a motorist that a vulnerable vehicle coming from the rear will overtake it a few seconds later thus constituting a danger for both vehicles. By coupling different velocity, geolocation and orientation data, this detector consists of a transmitter and a receiver connected to each other by radio frequency and continues to aim to prevent situations of potential danger.
Description
DETECTEUR GPS DE VEHICULES VULNERABLES La présente invention concerne un dispositif embarqué dans les véhicules destiné à réduire de façon significative et efficace les risques d'accidents entre automobilistes et véhicules vulnérables, notamment les deux roues. De nombreuses études tendent à prouver que de nombreux accidents de deux roues sont provoqués par une collision avec une voiture. Bien qu'attentif, n'importe quel automobiliste est susceptible de se retrouver impliqué dans une collision avec une moto. En effet, les motards de part leurs moindres tailles et leurs vitesses bien souvent plus élevées constituent un danger permanent sur les routes rendant cette présente invention utile. Les rétroviseurs constituent l'actuel unique dispositif pouvant éviter les collisions avec des motos venant de l'arrière. Néanmoins lorsque l'on sait que l'automobiliste doit à la fois regarder devant lui, son compteur de vitesse et que de surcroît il est susceptible d'allumer une cigarette ou de mettre de la musique, ce seul dispositif s'en trouve fortement diminué dans son efficacité ; la présente invention propose de remédier à ce constat.The present invention relates to a device embedded in vehicles intended to significantly and efficiently reduce the risk of accidents between motorists and vulnerable vehicles, particularly the two wheels. BACKGROUND OF THE INVENTION Numerous studies have shown that many two-wheel crashes are caused by a collision with a car. While caring, any motorist is likely to be involved in a collision with a motorcycle. Indeed, bikers by their smaller sizes and their speeds often higher are a permanent danger on the roads making this present invention useful. Mirrors are the only device that can avoid collisions with motorcycles coming from behind. However, when we know that the driver must both look ahead, his speedometer and moreover it is likely to light a cigarette or put music, this device is greatly diminished in its effectiveness; the present invention proposes to remedy this finding.
En l'état actuel, l'art antérieur ne connaît aucun système semblable. Concernant les deux brevets français FR 2814579 et FR 2928482, il ressort de nos recherches qu'aucune des deux inventions n'utilise la technologie GPS. En outre 25 aucun des deux systèmes n'est capable de détecter avec précision et certitude qu'un véhicule vienne de l'arrière et surtout qu'il constitue un danger potentiel pour lui et pour l'automobiliste. Enfin, aucun des deux systèmes ne se base sur une fonction mathématique utilisant plusieurs données pour calculer selon un différentiel de vitesse un temps de réaction pour l'automobiliste constant et cohérent, à savoir 4 à 5 secondes. 30 Ainsi bien que la finalité de l'invention soit la même, la détection, les moyens mis en ouvres et la pertinence de détection semblent différente à bien des égards. Concernant d'autres éventuelles antériorités sur le plan international, il ressort de nos recherches que sont pertinents notamment les brevets W02004 047047, EP 1 791 35 101, US 6 405 132. Ces derniers utilisent certes la technologie GPS dans le but de permettre la détection par un récepteur d'un émetteur GPS. Néanmoins avec une utilisation large puisque pouvant s'appliquer aux piétons munis de balise (WO 2004 047047), ces inventions nous semblent bien moins pertinentes que celle pour laquelle cette procédure à lieu. Elle n'utilise pas le calcul d'un delta de vitesse entre émetteur et récepteur ne permettant pas une détection optimale des dangers que peuvent représenter les motards, roulant à une vitesse supérieure et venant de l'arrière. Seule notre invention est capable de prendre en compte ces trois facteurs pour le moins essentiels dans l'optique d'une détection cohérente et utile.In the current state, the prior art knows no similar system. Regarding the two French patents FR 2814579 and FR 2928482, it appears from our research that neither of the two inventions uses GPS technology. Furthermore, neither of the two systems is able to detect with precision and certainty that a vehicle is coming from behind and especially that it constitutes a potential danger for him and the motorist. Finally, neither system relies on a mathematical function that uses several data to calculate a reaction time for the constant and consistent motorist according to a speed differential, namely 4 to 5 seconds. Thus, although the purpose of the invention is the same, the detection, the means implemented and the relevance of detection appear to be different in many respects. Regarding other possible prior art on the international level, our research shows that are particularly relevant patents W02004 047047, EP 1 791 35 101, US 6 405 132. They certainly use GPS technology in order to allow detection by a receiver of a GPS transmitter. Nevertheless, with a wide use since it can be applied to pedestrians provided with a beacon (WO 2004 047047), these inventions seem to us much less relevant than that for which this procedure takes place. It does not use the calculation of a delta speed between transmitter and receiver does not allow optimal detection of the dangers that can represent the bikers, traveling at a higher speed and coming from behind. Only our invention is able to take into account these three factors, at least essential for the purpose of coherent and useful detection.
Cf. schémas en dessin 1 Selon l'invention, ce procédé est caractérisé en ce qu'il comprend les éléments suivants - Un émetteur, placé sur la moto. Cet émetteur est d'une part doté d'un dispositif émettant une fréquence radio fixe en continue et d'autre part d'un dispositif GPS extrêmement précis permettant d'indiquer sa position avec une précision de 20 cm.According to the invention, this method is characterized in that it comprises the following elements - A transmitter, placed on the motorcycle. This transmitter is on the one hand endowed with a device transmitting a fixed radio frequency continuously and on the other hand with an extremely precise GPS device making it possible to indicate its position with an accuracy of 20 cm.
L'émetteur est branché soit sur l'alimentation générale de la moto et s'allume dès lors que le contact de la moto est enclenché. - Un récepteur, placé sur la voiture. Ce récepteur est quant à lui capable de détecter l'émission radio provenant de l'émetteur dés lors que celui-ci se trouve à portée. En outre il est lui aussi doté d'un dispositif GPS extrêmement précis lui permettant d'indiquer avec une précision de 20 cm sa position et de connaître avec précision la position GPS de l'émetteur. Cet émetteur est doté d'un interrupteur marche/arrêt et de 8 leds. Une led (verte clignotant indique la bonne réception GPS, une led jaune indique une réception radio, deux leds jaunes, deux leds orange et deux leds rouge indiquent de façon progressive le rapprochement de l'émetteur du récepteur (du jaune au rouge). En outre le récepteur est aussi doté d'un système sonore désactivable et réglable en puissance indiquant au conducteur l'arrivée d'un motard Le récepteur pourra être branché sur l'alimentation générale de la voiture l'embarquant ou sur allume cigare pourvu d'une batterie rechargeable.The transmitter is connected either to the general power supply of the motorcycle and lights up when the contact of the motorcycle is switched on. - A receiver, placed on the car. This receiver is able to detect the radio transmission from the transmitter when it is in range. In addition, it is also equipped with an extremely precise GPS device allowing it to indicate with an accuracy of 20 cm its position and to know precisely the GPS position of the transmitter. This transmitter has an on / off switch and 8 leds. A led (green flashing indicates good GPS reception, a yellow LED indicates a radio reception, two yellow LEDs, two orange LEDs and two red LEDs progressively indicate the approximation of the receiver transmitter (from yellow to red). in addition to the receiver is also equipped with a sound system and power adjustable indicating the driver to the arrival of a rider The receiver can be connected to the general power of the car boarding or cigar lighter provided with a rechargeable battery.
Cf. schéma de fonctionnement dessin 1 Cf. codage en écriture C du boitier moto et voiture respectivement en annexe 1 et 2 Cf. dessin des cartes électroniques et schémas techniques boitier moto et voiture respectivement en dessins Selon l'invention, le procédé fonctionne de la façon suivante: Le dispositif comprend un émetteur, placé sur une moto, qui émet un signal radio de fréquence fixe, ainsi qu'un récepteur installé à bord d'une automobile. Le dispositif récepteur comprend des voyants lumineux et un buzzer pour signaler au conducteur un danger potentiel. Ce procédé possède les caractéristiques suivantes : -utilisation de deux GPS pour mesurer la distance et les vitesses des deux véhicules -transmission de données numériques moyenne portée entre le dispositif émetteur et le dispositif récepteur afin d'améliorer la robustesse. -détection de la provenance de la moto afin de n'avertir le conducteur que dans le cas où la moto va le dépasser. - Le GPS: Le GPS utilisé dans le prototype est un GPS 5HZ " GARMIN " " marque déposée ". Il a l'avantage de donner une position régulièrement et très précise (20cm si réception EGNOSS). De plus, il est très rapide au démarrage rendant le système opérationnel moins d'une minute après la mise sous tension des dispositifs. Le protocole de communication entre le module GPS et les cartes électroniques des dispositifs est de type série RS232 (voir fiche technique du récepteur GPS pour plus de 30 précision). Les données utilisées du récepteur GPS sont la Longitude, la Latitude, et un indicateur de l'exactitude de la donnée. Ces trois valeurs suffisent pour déterminer l'orientation, la position et la vitesse des dispositifs. 35 2 98792 7 4 - La liaison radio : Cf. Dessin 4 La liaison radio est le seul moyen efficace et moyenne portée de faire 5 communiquer les dispositifs entre-eux. En effet, sur autoroute il a été déterminé que la communication doit fonctionner quand les dispositifs sont à au moins 500 m l'un de l'autre. Le trafic routier étant perturbateur, le prototype est muni d'un ensemble émetteur-récepteur d'une portée maximale de 3 km respectant la réglementation en termes de puissance d'émission. 10 Le débit maximal de cette communication est de 10 Kb par secondes. Avec une fréquence de message à envoyer de 2,5 Hz, et un temps démission de 10%, il est obligatoire d'envoyer le minimum de données possibles, sous peine de ne pas respecter la réglementation radio. Seuls les octets de faible poids de la latitude et de la longitude, au format binaire sont 15 envoyés. La fréquence de 869,5 MHz est utilisée comme fréquence radio. Un octet de synchronisation est ajouté pour permettre une communication. En fin de message une somme de contrôle d'un octet permet de vérifier qu'aucune erreur de transmission n'a eu lieu. Le codage Manchester est aussi nécessaire pour garantir une robustesse minimum de la liaison radio. Afin de rendre le dialogue possible en cas de présence de 20 plusieurs motos, un système de multiplexage temporel a été mis en place. En effet il faut garantir qu'au plus un seul boitier émette dans une zone de réception. Les boitiers possédant tous l'heure GPS, ils sont synchronisés et peuvent émettre chacun leur tour suivant la position où ils sont. Les prototypes ont été munis d'une grille très large afin de vérifier le principe. Cette grille assigne à chaque « case » de position Lat/Lon un 25 délai avant émission. Le but est que deux émetteurs ne puissent pas se trouver dans la même case et donc, ne pas émettre simultanément. Le débit de communication des prototypes étant très faible (10kb/s), la taille d'une case reste très grande (plusieurs centaines de mètres). La portée maximale théorique étant de 1km, en estimant un maillage raisonnable à 4m2, et en considérant qu'un message comporte 6 octets, cela nécessite un débit minimum de 15 Mo/secondes ((2000m*2000m)/4m2)*6octets* 2,5 Hz. Ce multiplexage temporel peut être modifié pour utiliser plusieurs fréquences de porteuses (canaux) et ainsi diminuer les débits sur chaque porteuses. Les boitiers peuvent aussi être plus intelligent et écouter le trafic radio pour n'émettre que lorsque les ondes sont disponibles.See diagram of operation drawing 1 Cf. write-code C of the motorcycle and car box respectively in appendix 1 and 2 See drawing of the electronic cards and technical drawings motorcycle and car respectively according to the drawings According to the invention, the method operates from the next: The device comprises a transmitter, placed on a motorcycle, which emits a fixed frequency radio signal, and a receiver installed in an automobile. The receiving device includes indicator lights and a buzzer to alert the driver of potential danger. This method has the following features: - use of two GPS to measure the distance and speeds of the two vehicles - medium-range digital data transmission between the transmitter device and the receiver device to improve the robustness. -detection of the origin of the motorcycle to warn the driver only in case the bike will overtake. - The GPS: The GPS used in the prototype is a GPS 5HZ "GARMIN" "registered trademark". It has the advantage of giving a regular and very precise position (20cm if receiving EGNOSS). In addition, it is very fast at startup, making the system operational less than a minute after the devices are turned on. The communication protocol between the GPS module and the electronic boards of the devices is of the RS232 series type (see technical data sheet of the GPS receiver for more precision). The GPS receiver data used is Longitude, Latitude, and an indicator of the accuracy of the data. These three values are sufficient to determine the orientation, position, and speed of the devices. The radio link is as follows: Drawing 4 The radio link is the only effective and average means of communicating the devices to one another. Indeed, on highway it has been determined that the communication must work when the devices are at least 500 m apart. Since road traffic is disruptive, the prototype is equipped with a transceiver unit with a maximum range of 3 km, complying with the regulations in terms of transmission power. The maximum rate of this communication is 10 Kb per second. With a send message rate of 2.5 Hz, and a 10% timeout, it is mandatory to send the minimum possible data, otherwise the radio regulations will be violated. Only the low weight bytes of latitude and longitude in binary format are sent. The 869.5 MHz frequency is used as a radio frequency. A synchronization byte is added to allow communication. At the end of the message a checksum of one byte makes it possible to check that no transmission error has occurred. Manchester coding is also necessary to ensure minimum robustness of the radio link. In order to make the dialogue possible in the event of the presence of several motorcycles, a temporal multiplexing system has been put in place. Indeed we must ensure that at most a single box emits in a reception area. The boxes all have GPS time, they are synchronized and can each issue their turn according to the position where they are. The prototypes were provided with a very large grid to verify the principle. This grid assigns each "box" of position Lat / Lon a delay before transmission. The goal is that two transmitters can not be in the same box and therefore do not transmit simultaneously. The communication rate of the prototypes being very low (10kb / s), the size of a box remains very large (several hundred meters). The theoretical maximum range is 1km, estimating a reasonable mesh size of 4m2, and considering that a message has 6 bytes, this requires a minimum bit rate of 15MB / seconds ((2000m * 2000m) / 4m2) * 6bytes * 2 , 5 Hz. This time multiplexing can be modified to use several frequencies of carriers (channels) and thus reduce the rates on each carrier. The boxes can also be smarter and listen to the radio traffic to emit only when the waves are available.
Afin d'identifier les motos, un système de tracking est réalisé, les données des motos ne possèdent pas d'identifiant, mais sont mis en correspondance avec une position reçue préalablement à une distance faible. Si cette distance est trop grande, l'algorithme considère qu'il s'agit d'une nouvelle moto. De même, si une même moto n'a plus donné signe de vie, elle est retirée de la liste. - Estimation du danger : Il a été remarqué que le danger n'était pas toujours présent lorsque la moto est proche de la voiture. En effet, lorsque la moto est devant la voiture, le danger est relativement faible car la vision de l'automobiliste est dégagée. De plus, lorsque la moto se déplace à la même vitesse ou à vitesse inférieure, il n'y a pas de danger de collision car ils ne convergent pas l'un vers l'autre. Le seul cas de danger peut être résumé à ces conditions : -la moto est derrière la voiture -la moto se déplace dans la même direction que la voiture -la moto roule plus vite que la voiture Il faut donc déterminer la direction, la position et la distance des deux dispositifs.In order to identify the bikes, a tracking system is made, the data of the motorcycles do not have an identifier, but are mapped to a position previously received at a low distance. If this distance is too great, the algorithm considers that it is a new motorcycle. Similarly, if the same motorcycle has not given any sign of life, it is removed from the list. - Danger rating: It was noticed that the danger was not always present when the bike is close to the car. Indeed, when the bike is in front of the car, the danger is relatively low because the vision of the motorist is clear. In addition, when the bike is moving at the same speed or lower speed, there is no danger of collision because they do not converge towards each other. The only case of danger can be summed up under these conditions: -the motorcycle is behind the car -the motorcycle moves in the same direction as the car -the motorcycle rolls faster than the car It is therefore necessary to determine the direction, the position and the distance of the two devices.
La position est directement récupérée par le module GPS. La distance est calculée par différence entre la position des deux modules (et approximation mathématique des petits angles) La vitesse est mesurée par différence entre deux positions successives d'un même dispositif.The position is directly retrieved by the GPS module. The distance is calculated by difference between the position of the two modules (and mathematical approximation of small angles) The speed is measured by difference between two successive positions of the same device.
La direction est quant à elle déterminée par l'orientation du vecteur vitesse dans le repère géodésique. Le danger peut ensuite être quantifié en fonction du temps restant avant « impact » ou plutôt avant que les deux dispositifs soient au même niveau (dépassement). Un seuil de 30 5 secondes a été déterminé comme danger léger. - Informer l'automobiliste : Le but est d'informer l'automobiliste de façon la plus simple possible pour qu'il puisse 35 rester concentré sur la route et maîtriser son véhicule. C'est pourquoi un signal sonore est très adapté pour capter son attention. Celui-ci est généré quand la moto est à 5 secondes derrière le boîtier récepteur (voiture). Afin de procurer à l'automobiliste une meilleure précision, les voyants lumineux indiquent le temps restant sous forme d'un barre-graph 5 secondes restantes entraînent un seul voyant allumé et 1 seconde restante est indiquée par tout les voyants allumés.The direction is itself determined by the orientation of the velocity vector in the geodesic mark. The danger can then be quantified according to the time remaining before "impact" or rather before the two devices are at the same level (overtaking). A threshold of 30 seconds was determined as a slight danger. - Informing the motorist: The goal is to inform the motorist as simply as possible so that he can stay focused on the road and control his vehicle. This is why a sound signal is very suitable to capture his attention. This is generated when the bike is 5 seconds behind the receiver box (car). In order to provide the motorist with better accuracy, the indicator lights indicate the remaining time in the form of a bar-graph 5 seconds remaining result in a single light on and 1 second remaining is indicated by all the lights on.
De cette façon l'automobiliste pourra être averti en temps utile de l'arrivée d'une moto par derrière et ce, quelque soit la vitesse des véhicules considérés. Grâce à cette détection pertinente, quoi qu'il arrive l'automobiliste sera toujours averti de l'arrivée d'un motard dans un temps utile et raisonnable pour qu'il puisse réagir en temps utile, à savoir environ 5 secondes. De cette manière l'automobiliste peut habillement renforcer sont attention à l'arrivée de la moto. En outre en déchargeant l'automobiliste de cette contrainte, il sera plus vigilant sur sa conduite lui évitant d'être omnibulé par la peur de l'arrivée d'un motard.In this way the motorist can be notified in due time of the arrival of a motorcycle from behind, regardless of the speed of the vehicles considered. With this relevant detection, whatever happens the motorist will always be notified of the arrival of a rider in a timely and reasonable time so that he can react in time, namely about 5 seconds. In this way the motorist can reinforce clothing are attention to the arrival of the motorcycle. In addition by relieving the driver of this constraint, he will be more vigilant about his conduct avoiding him to be omnibulated by the fear of the arrival of a motorcyclist.
Annexe 1: programme moto #include <p30f4012.h> /****************************** * Configuration Bits // FOSC(CSW FSCM OFF & FRC PLL8); /* Fast RC with PLLx8 = 16MIP Clock 10 Mon/Switch OFF *7 FOSC(CSW FSCM OFF & XT PLL8); /* 8MHz Crystal with PLLx8 = 16 MIP */ iWDT(WDT 5FF);- /* Watch dog Timer OFF */ FBORPOR(PBOR OFF & MCLR EN); /* Brown Out OFF, MCLR Enabled 15 */ FGS(CODE PROT OFF); /* Code Protect OFF */ #define MAXSIZEBUFF 40 #define HalfPeriod 2000 20 #define FCY 19660800 // 19 660 800Hz for 19200bps communication #define BaudRate 19200 //for GPS communicatino #define outRadio PORTEbits.RE2 #define ENRadio PORTEbits.RE3 #define RXGPS PORTCbits.RC14 25 #define LEDGPS LATD1 #define NBOCTETRADIO 10 #define DELAY_SEND 1000 #define DELAY EN 900 30 typedef struct{ char trame[90]; char reception; char type; unsigned char indice; 35 unsigned int latDeg; unsigned int latMinEnt; unsigned long latMinDec; unsigned int lonDeg; unsigned int lonMinEnt; 40 unsigned long lonMinDec; } coordonneGPS; typedef struct{ //in 1/100000 minute of degrees (64 unsigned long lat; 45 bits) unsigned long lon; unsigned char trame[200]; int indice; char sended; 50 } coordonneRadio; coordonneGPS ping,pong; coordonneRadio pingR,pongR; 55 char pingW; char modulo; void set Tris(void){ TRISBbits.TRISB0=1; 60 TRISBbits.TRISB1=1; TRISBbits.TRISB2=1; TRISBbits.TRISB3=1; TRISBbits.TRISB4=1; Annexe 1: programme moto TRISBbits.TRISB5=0; TRISCbits.TRISC13=0; TRISCbits.TRISC14=1; TRISDbits.TRISD1=0; //LED TRISEbits.TRISE0=0; TRISEbits.TRISE1=0; TRISEbits.TRISE2=0; TRISEbits.TRISE3=0; TRISEbits.TRISE4=0; TRISEbits.TRISE5=0; TRISEbits.TRISE8=0; /* PCFGO=1; PCFG1=1; PCFG2=1; PCFG3=1; PCFG4=1; PCFG5=1;*/ void set Timers(void){ PRI=2*HalfPeriod; T1CONbits.TCS=0; T1CONbits.TGATE=0; T1CONbits.TCKPS=0; T1CONbits.TON=1; TlIE=1; } void setUart(void){ set Timers(); U1M0DEbits.PDSEL=0; //8 bits No Parity UlMODEbits.USIDL=0; //continue operation in Idle mode UlMODEbits.ALTIO=1; //use UlATX UlMODEbits.WAKE=1; //wake-up enable UlMODEbits.ABAUD=O; //no autoBaud detect UlMODEbits.STSEL=O; 1/1 stopbit U1BRG=127; UlMODEbits.UARTEN=1; U1STAbits.URXISEL=0; U1STAbits.UTXEN=0; //interrput each character received U1RXIF=O; U1RXIE=1; } void loadTrameRadio(coordonneRadio * co){ (co->trame)[0]='$'; /* (co->trame)[1]=((co->lat)&0b11111111000000000000000000000000)>>24; (co->trame)[2]=((co->lat)&0b00000000111111110000000000000000)>>16; (co->trame)[3]=((co->lat)&0b00000000000000001111111100000000)>>8; (co->trame)[4]=((co->lat)&0b00000000000000000000000011111111); (co->trame)[5]=((co->lon)&0b11111111000000000000000000000000)>>24; (co->trame)[6]=((co->lon)&0b00000000111111110000000000000000)>>16; (co->trame)[7]=((co->lon)&0b00000000000000001111111100000000)>>8; (co->trame)[8]=((co->lon)&0b00000000000000000000000011111111);*/ (co->trame)[1]=((co->lat)&0b00000000000000001111111100000000)>>8; Annexe 1: programme moto (co->trame)[2]=((co->lat)&0b00000000000000000000000011111111); (co->trame)[3]=((co->lon)&0b00000000000000001111111100000000)>>8; (co->trame)[4]=((co->lon)&0b00000000000000000000000011111111); //(co->trame)[1]='$';(co->trame)[2]='$';(co->trame)[3]='$';(co->trame)[4] =1$';(co->trame)[5]='$';(co->trame)[6]='$';(co->trame)[7]='$';(co->trame) [8]='$'; //(co->trame)[9]=(unsigned char)((co->trame)[0]+(co->trame)[1]+(co- >trame)[2]+(co->trame)[3]+(co->trame)[4]+(co->trame)[5]+(co->trame)[6]+ (co->trame)[7]+(co->trame)[8]); (co->trame)[5]-(unsigned char)((co->trame)[0]+(co->trame)[1]+(co>trame)[2]+(co->trame)[3]+(co-> trame)[4]); modulo=((co->trame)[1]&0b00000001) + 2*((co->trame)[3]&0b00000001); // à changer pour modulo 9 int charTovalue(char thechar){ switch(thechar){ case 'O': return 0; break; case '1': return 1; break; case '2': return 2; break; case '3': return 3; break; case '4': return 4; break; case '5': return 5; break; case '6': return 6; break; case '7': return 7; break; case '8': return 8; break; case '9': return 9; break; default: return -1; break; 1 ; return -1; void analyseTrame(void){ static int quality,temps=0; static int time=0; static int prevtime=0; if (ping.reception==0){ Annexe 1: programme moto if(ping.trame[0]-='$' && ping.trame[1]=='G' && ping.trame[2]=='P' && ping.trame[3]=='G' && ping.trame[4]=='G' && ping.trame[5]=='A'){ // detect GGA trame ping.indice=0; while(ping.trame[ping.indice]!=',') ping.indice++; ping.indice+=2; while(ping.trame[ping.indice]!=',') ping.indice++; //end <1> time=charTovalue(ping.trame[ping.indice-1]); ping.indice++; if (time!=0) return; // sampling 1HZ //start <2> ping.latDeg=charTovalue(ping.trame[ping.indice++])*10+charTovalue(ping.t rame[ping.indice++]); ping.latMinEnt=charTovalue(ping.trame[ping.indice++])*10+charTovalue(pin g.trame[ping.indice++]); ping.indice++; //jump the '.' ping.latMinDec=0; while(ping.trame[ping.indice]!=',') ping.latMinDec=ping.latMinDec*10+charTovalue(ping.trame[ping.indice++]); //end <2> ping.indice++; //start <3> if (ping.trame[ping.indice++]=='N') ping.latDeg=ping.latDeg; //end <3> ping.indice++; //start <4> ping.lonDeg=charTovalue(ping.trame[ping.indice++])*100+charTovalue(ping. 40 trame[ping.indice++])*10+charTovalue(ping.trame[ping.indice++]); ping.lonMinEnt=charTovalue(ping.trame[ping.indice++])*10+charTova1ue(pin g.trame[ping.indice++]); ping.indice++; //jump the '.' 45 ping.lonMinDec=0; while(ping.trame[ping.indice]!=',') ping.lonMinDec=ping.lonMinDec*10+charTovalue(ping.trame[ping.indice++]); //end <4> 50 ping.indice++; //start <5> if (ping.trame[ping.indice++]=='E') ping.lonDeg=ping.lonDeg; 55 ping.indice=43; quality=charTovalue(ping.trame[ping.indice]); if (quality>1){ LEDGPS=!LEDGPS; 60 1 else if (quality>0){ if (temps==0) LEDGPS=!LEDGPS; temps++; Annexe 1: programme moto if (temps>3) temps=0; 1 else{ LEDGPS=1; ping.reception=2; else ping.reception=3; else{ if(pong.trame[0]=='$' && pong.trame[1]=='G' && pong.trame[2]=='P' && pong.trame[3]=='G' && pong.trame[4]=='G' && pong.trame[5]=='A'){ // detect GGA trame pong.indice=0; while(pong.trame[pong.indice]!=',') pong.indice++; pong.indice++; while(pong.trame[pong.indice]!=',') pong.indice++; //end <1> time=charTovalue(ping.trame[ping.indice-1]); pong.indice++; if (time!=0){ return; // sampling 1HZ //start <2> pong.latDeg=charTovalue(pong.trame[pong.indice++])*10+charTovalue(pong.t 35 rame[pong.indice++]); pong.latMinEnt=charTovalue(pong.trame[pong.indice++])*10+charTovalue(pon g.trame[pong.indice++]); pong.indice++; //jump the '.' 40 pong.latMinDec=0; while(pong.trame[pong.indice]!=',') pong.latMinDec=pong.latMinDec*10+charTovalue(pong.trame[pong.indice++]); //end <2> 45 pong.indice++; //start <3> if (pong.trame[pong.indice++]=='N') pong.latDeg=pong.latDeg; //end <3> 50 pong.indice++; //start <4> pong.lonDeg=charTovalue(pong.trame[pong.indice++])*100+charTovalue(pong. trame[pong.indice++])*10+charTovalue(pong.trame[pong.indice++]); 55 pong.lonMinEnt=charTovalue(pong.trame[pong.indice++])*10+charTovalue(pon g.trame[pong.indice++]); pong.indice++; //jump the '.' pong.lonMinDec=0; 60 while(pong.trame[pong.indice]!=',') pong.lonMinDec=pong.lonMinDec*10+charTovalue(pong.trame[pong.indice++]); //end <4> pong.indice++; 20 25 30 Annexe 1: programme moto //start <5> if (pong.trame[pong.indice++]=='E') pong.lonDeg=pong.lonDeg; pong.indice=43; quality=charTovalue(pong.trame[pong.indice]); if (quality>1){ LEDGPS=!LEDGPS; } else if (quality>0){ if (temps==0) LEDGPS=!LEDGPS; temps++; if (temps>3) temps=0; } else{ LEDGPS=1; } 25 pong.reception=2; } else pong.reception=3; } 30 } int main(void){ LEDGPS=1; 35 int i; OSCCON=0x3300; /* Select Primary Oscillator OSCCONbits.POST=0; while(OSCCONbits.LOCK!=l) {}; ENRadio=1; 40 for (i=0;i<200;i++){ pingR.trame[i]=0;//170; pongR.trame[i]=0;//170; } 45 ping.trame[0]='$'; pingR.trame[1]=11; pingR.trame[2]=12; pingR.trame[3]=13; pingR.trame[4]=14; 50 pingR.trame[5]=15; pingR.trame[6]=16; pingR.trame[7]=17; pingR.trame[8]=18; pingR.trame[9]=19; 55 pingR.trame[10]=20; pingR.trame[11]=21; pingR.trame[12]=22; 60 set_Tris(); setUart(); PEN1L=0; PEN1H=0; PEN2L=0; PEN2H=0; 10 15 20 Annexe 1: programme moto PEN3L=0; PEN3H=0; //h h m m s s . s/10 d d m m m m m m m N/S ,dddmm.mmmmm E/W , 6 , nb Sat , dilution , altitude , //ping.trame={"$","G","P","G","G","A",",","1","2","3","5","1","9",".","1 .,,,,,,,.4.,.8n,.0.,.7.,..,,,.0",,,3",.8.,"2",u5u,",,,,,,N.,,,,,,,n0",up,, uln,u3","in I"..,u3n,u2n,.4",.5flIn8",..,,,,flEu,,,,,,,.1.,,,,,,,,,on,n8",,,,,,,u0",u. u,n9,,,,,,,,,n5,,, "4","5",".","4",",","M",",",13,10,"0","0","0","0","0","0","0","0","0","0", "0" ,"0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0","0"}; 15 ping.trame[0]='$';ping.trame[1]=1G';ping.trame[2]=1P';ping.trame[3]='G'; ping.trame[4]='G';ping.trame[5]='A';ping.trame[6]=','; ping.trame[7]='1';ping.trame[8]=121;ping.trame[9]='3';ping.trame[10]-'4' ;ping.trame[11]=151;ping.trame[12]=16';ping.trame[13]='.';ping.trame[14] ='2'; ping.trame[15]=','; 20 ping.trame[16]=11';ping.trame[17]=11';ping.trame[18]=12';ping.trame[19]= '31;ping.trame[20]='.';ping.trame[21]=',41;ping.trame[22]='5';ping.trame [23]=' 6';ping.trame[24]='7';ping.trame[25]='81;ping.trame[26]=',1;ping.trame[27] ='N ';ping.trame[28]=','; ping.trame[29]-'1';ping.trame[30]='1';ping.trame[31]=121;ping.trame[32]= 25 '3';ping.trame[33]='3';ping.trame[34]='.';ping.trame[35]='4';ping.trame [36]=' 5';ping.trame[37]-'61;ping.trame[38]=17';ping.trame[39]=18';ping.trame[40] =', ';ping.trame[41]='E';ping.trame[42]=','; ping.trame[43]='1';ping.trame[44]=','; ping.trame[45]='0';ping.trame[46]='8';ping.trame[47]=','; 30 ping.trame[48]-'01;ping.trame[49]=1.';ping.trame[50]=19';ping.trame[51]= . , , ping.trame[52]-'5';ping.trame[53]='51;ping.trame[54]='5';ping.trame[55]= '.1;ping.trame[56]='5';ping.trame[57]=','; ping.trame[58]=13;ping.trame[59]=10; 35 ping.reception=0; analyseTrame(); _PTEN=0; ping.reception=4; pong.reception=4; 40 pingR.sended=1; pongR.sended=1; LEDGPS=1; while(1){ 45 // LED=RXGPS; if (ping.reception==0 11 pong.reception==0){ analyseTrame(); } 50 if (ping.reception==2){ //LED=!LED; if (pingR.sended){ 55 pingR.lat=ping.latDeg*6000000+ping.latMinEnt*100000+ping.latMinDec; pingR.lon=ping.lonDeg*6000000+ping.lonMinEnt*100000+ping.lonMinDec; ping.reception=3; loadTrameRadio(&pingR); 60 pingR.indice=0; pingR.sended=0; } else{ 10 Annexe 1: programme moto pongR.lat=ping.latDeg*6000000+ping.latMinEnt*100000+ping.latMinDec; pongR.lon=ping.lonDeg*6000000+ping.lonMinEnt*100000+ping.lonMinDec; ping.reception=3; loadTrameRadio(&pongR); pongR.indice=0; pongR.sended=0; 1 1 if (pong.reception==2){ // LED=!LED; if (pingR.sended){ pingR.lat=pong.latDeg*6000000+pong.latMinEnt*100000+pong.latMinDec; pingR.lon=pong.lonDeg*6000000+pong.lonMinEnt*100000+pong.lonMinDec; pong.reception=3; loadTrameRadio(&pingR); ping.indice=0; pingR.sended=0; } else{ pongR.lat=pong.latDeg*6000000+pong.latMinEnt*100000+pong.latMinDec; pongR.lon=pong.lonDeg*6000000+pong.lonMinEnt*100000+pong.lonMinDec; pong.reception=3; loadTrameRadio(&pongR); pong.indice=0; pongR.sended=0; } } 1 return 0; 1 void attribute ((interrupt, auto_psv)) _U1RXInterrupt(void){ //PING char temps; while(U1STAbits.URXDA){ temps=U1RXREG; if(pingW){ if(ping.reception==3){ ping.reception=1; ping.indice=0; } (ping.trame[ping.indice])=temps; if ((ping.indice>1) && (ping.trame[ping.indice-1]==13) &&(ping.trame[ping.indice]==10)){ //end of sentence detection ping.reception=0; pingW=0; } ping.indice++; } //PONG elsef if(pong.reception==3){ Annexe 1: programme moto pong.reception=1; pong.indice=0; pong.trame[pong.indice]=temps; if ((pong.indice>1) && (pong.trame[pong.indice-1]==13) &&(pong.trame[pong.indice]==10)){ //end of sentence detection pong.reception=0; pingW=1; 1 pong.indice++; 1 U1RXIF=O; //reset Flag void attribute ((interrupt, auto_psv)) Tllnterrupt(void){ //codage menchester static int second=0; static int test=0; static int delay=0; if (pingR.sended==0){ if (pingR.indice>255){ pingR.indice=0; delay=0; } if (delay<(DELAY SEND*modulo)){ delay++; TlIF=0; return; if (delay<(DELAY SEND*modulo+DELAY_EN)){ ENRadio=1; delay++; T1IF=0; return; outRadio=((pingR.trame[pingR.indice/8]>>(pingR.indice%8))+second+1)&1; // LED=((pingR.trame[pingR.indice/8]>>(pingR.indice%8))+second+1)&1; if (second>=1){ pingR.indice++; second=0; } else second++; if(second==0 && pingR.indice==(8*(NBOCTETRADIO+1))){ second=0; pingR.indice=0; outRadio=1; pingR.sended=1; ENRadio=0; else if (pongR.sended==0){ if (pongR.indice>255) pongR.indice=0; delay=0; if (delay<DELAYSEND*modulo){ 5 10 15 25 Annexe 1: programme moto delay++; TlIF=0; return; if (delay<(DELAY SEND*modulo+DELAY EN)){ ENRadio=1; delay++; TlIF=0; return; } outRadio=((pongR.trame[pongR.indice/8]>>(pingR.indice%8))+second+1)&1; // LED=((pongR.trame[pongR.indice/8]>>(pingR.indice%8))+second+1)&1; if (second==1){ pongR.indice++; second=0; el se second++; if(second==1 && pongR.indice==(8*NBOCTETRADIO)){ second=0; pongR.indice=0; pongR.sended=1; ENRadio=0; TlIF =0; 20 30 Annexe 2: programme voiture #include "communication. h" #include "system.h" extern coordonneGPS car; extern vehicule bikes[9]; void analyseTrame(coordonneGPS car, vehicule a_car){ int quality=0; int i; float minRatio=1.0 , ratio=0.0; static int temps=0; if (car.reception==0){ if(car.trame[0]=='$' && car.trame[1]=='G' && car.trame[2]=='P' && car.trame[3]=='G' && car.trame[4]=='G' && car.trame[5]=='A'){ // detect GGA trame car.indice=0; while(car.trame[car.indice]!=',') // car.indice++; car.indice++; //debut <1> while(car.trame[car.indice]!=',') car.indice++; //end <1> car.time=charTovalue(car.trame[car.indice-1]); car.indice++; if (car.time!=0) return; // sampling 1HZ all radio positions must be received (new cycle) for (i=0;i<9;i++) { bikes[i].alive--; if (bikes[i].alive==1) { ratio=isADanger(bikes[i]); if (ratio<minRatio) minRatio=ratio; 1 1 if(minRatio<(1.0/6.0)) LED0=1; else 50 55 60 LED0=0; if(minRatio<(2.0/6.0)) LED1=1; else LED1=0; if(minRatio<(3.0/6.0)) LED2=1; else LED2=0; if(minRatio<(4.0/6.0)) LED3=1; else LED3=0; if(minRatio<(5.0/6.0)) LED4=1; else Annexe 2: programme voiture LED4=0; car.indice=16; //start <2> car.latDeg=charTovalue(car.trame[car.indice++])*10+charTovalue(car.trame [car.indice++]); car.latMinEnt=charTovalue(car.trame[car.indice++])*10+charTovalue(car.tr ame[car.indice++]); car.indice++; //jump the '.' car.latMinDec=O; while(car.trame[car.indice]!=',1) car.latMinDec=car.latMinDec*10+charTovalue(car.trame[car.indice++]); //end <2> car.indice++; //start <3> if (car.trame[car.indice++]=='N') car.latDeg=car.latDeg; //à changer lillitillittliiiiIIIIIII //end <3> car.indice++; //start <4> car.lonDeg=charTovalue(car.trame[car.indice++])*100+charTovalue(car.tram 30 e[car.indice++])*10+charTovalue(car.trame[car.indice++]); car.lonMinEnt=charTovalue(car.trame[car.indice++])*10+charTovalue(car.tr ame[car.indice++]); car.indice++; //jump the '.' 35 car.lonMinDec=0; while(car.trame[car.indice]!=',') car.lonMinDec=car.lonMinDec*10+charTovalue(car.trame[car.indice++]); //end <4> 40 car.indice++; //start <5> if (car.trame[car.indice++]=='E') car.lonDeg=car.lonDeg; //à changerilliiiiiiitilliiiiiiiiittt 45 while(car.trame[car.indice]!=',') car.indice++; car.indice++; //start 6 50 car.indice=43; quality=charTovalue(car.trame[car.indice]); if (quality==2){ LEDGPS=!LEDGPS; } 55 else if (quality>0){ if (temps==0) LEDGPS=!LEDGPS; temps++; 60 if (temps>3) temps=0; 1 aise{ LEDGPS=1; } I 19 Annexe 2: programme voiture acar.lat=car.latDeg*6000000+car.latMinEnt*100000+car.latMinDec; a_car.lon=car.lonDeg*6000000+car.lonMinEnt*100000+car.lonMinDec; // compteurPerteMoto++; car.reception=2; 1 10 else car.reception=3; } } 15 void attribute ((interrupt, auto psv)) U1RXInterrupt(void){ _ //PING _ while(U1STAbits.URXDA){ if(car.reception==3){ car.reception=1; 20 car.indice=0; } (car.trame[car.indice])=U1RXREG; if ((car.indice>1) && (car.trame[car.indice-1]==13) &&(car.trame[car.indice]==10)){ //end of sentence detection 25 car.reception=0; } car.indice++; } U1RXIF=O; //reset Flag 30 } int charTovalue(char thechar) { switch(thechar){ 35 case '0': return 0; break; case '1': return 1; 40 break; case '2': return 2; break; case 1 3 1 : 45 return 3; break; case '4': return 4; break; 50 case '5': return 5; break; case '6': return 6; 55 break; '7': return 7; '8': break; 60 return 8; break; case '9': return 9; break; case case 20 Annexe 2: programme voiture case return break; default: -2; return break; -1; ; -1; return 18 20 25 Annexe 2: programme voiture #include "detection.h" #include "system.h" #include "math.h" extern vehicule a_car; int myatan(double duty){ int signe=l; if (duty<0.0){ duty=-duty; signe=-1; 1 if (duty>11.43) return 90*signe; else if (duty>3.47) return 80*signe; else if (duty>2.145) return 70*signe; else if (duty>1.428) return 60*signe; else if (duty>1.0) return 50*signe; else if (duty>0.7) return 40*signe; else if (duty>0.466) return 30*signe; else if (duty>0.268) return 20*signe; else if (duty>0.087) return 10*signe; else return 0; 1 float computeSpeed(vehicule* a_vehicule){ unsigned long difflat=0; unsigned long difflon=0; unsigned long dist=0; int temp,temp2; if (a_vehicule->lat>a_vehicule->lastlat) difflat=a_vehicule->lat-a_vehicule->lastlat; else difflat=avehicule->lastlat-avehicule->lat; if (a_vehicule->lon>a vehicule->lastlon) difflon=a_vehicile->lon-a_vehicule->lastlon; else difflon=avehicule->lastlon-avehicule->lon; difflat=difflat%50000; difflon=difflon%50000; dist=sqrt((difflon*difflon)+(difflat*difflat)); if (((dist*TOM)*5.0)>2 ){ //vitesse minimale pour calculer l'orientation du véhicule (en m/secondes) (2m/s=> 7.2km/h) temp=(a_vehicule->lon-a_vehicule->lastlon); temp2=a_vehicule->lat-a_vehicule->lastlat; if (temp>0) Annexe 2: programme voiture a_vehicule->angle=myatan(((double)(a_vehicule->lat)- (double)(a_vehicule->lastlat))/((double)(a_vehicule->lon)- (double)(a_vehicule->lastlon))); else if(temp<0) a_vehicule->angle=180+myatan(((double)a_vehicule->lat-(double)avehicule-> lastlat)/((double)a_vehicule->lon-(double)a_vehicule-10 >lastlon)); else if (temp2>0) a_vehicule->angle=90; else a vehicule->angle=-90; 15 if (a_vehicuf;->angle>180) a vehicule->angle-=360; else if (avehicule->angle<=-180) aveFicule->angle+=360; 20 //col->angle=-45; a_vehicule->lastlat=a_vehicule->lat; a_vehicule->lastlon=a vehicule->lon; a vehicule->speed=(dit*TOM)*5.0; return (dist*TOM)*5.0; 25 } float isADanger(vehicule bike) int distance=0; 30 int dSpeed; distance=computeDistance(bike, a_car); dSpeed=bike.speed-a_car.speed; if (dSpeed<0) dSpeed=-dSpeed; 35 //check the time before impact. if it is beetwin 10 an 7, there is a bip. if (distance<=(dSpeed)*10.0 && distance>=(-dSpeed)*7.0 && isBehind(a car,bike) && haveSameDirection(a_car,bike)) 40 BIP(); return ((float)distance)/((float)dSpeed*6.0); 45 void TrackingBike(vehicule bike, vehicule bikes[9]) // after the tracking, do -1 to alive to eliminate old bike! int i,temp,index; int min=1000; 50 for (i=0;i<9;i++) if (bikes[i].alive==1) { temp=computeDistance(bike, bikes[i]); 55 if (temp<min) min=temp; index=i; 60 if(min<TRACKINGDISTANCE) bikes[index]=bike; Annexe 2: programme voiture computeSpeed(&(bikes[index])); if (bikes[index].alive<2) { bikes[index].alive++; //used later to check loose of bike (out of range) } else { i=0; while(i<9 && bikes[i].alive==1); bikes[i]=bike; bikes[i].alive=2; //new bike! bikes[i].speed=0; } int isBehind(vehicule ref,vehicule bike) 1 int temp,temp2; int angle2vehicule,diffangle; temp=bike.lon-ref.lon; temp2=bike.lat-ref.lat; if (temp>0) angle2vehicule=myatan(((double)bike.lat- (double)ref.lat)/((double)bike.lon-(double)ref.lon)); else if (temp<O) angle2vehicule=180+myatan(((double)bike.lat(double)ref.lat)/((double)bike. lon-(double)ref.lon)); else if (temp2>0) angle2vehicule=90; else angle2vehicule=-90; if (angle2vehicule>180); angle2vehicule-=360; diffangle=angle2vehicule-ref.angle; if (diffangle>180) diffangle-=360; else if(diffangle<=-180) diffangle+=360; if (diffangle<=90 && diffangle>=-90) return 0; else return 1; return 0; int haveSameDirection( vehicule vl, vehicule v2) { int diffangle; diffangle=(v1.angle-v2.angle); if (diffangle>180) diffangle-=360; else if (diffangle<=-180) diffangle+=360; if (diffangle<O) diffangle=-diffangle; Annexe 2: programme voiture if (diffangle<60) return 1; else return 0; 1 unsigned int computeDistance( vehicule vl, vehicule v2) { unsigned long difflat=0; unsigned long difflon=0; unsigned long dist=0; if (vl.lat>v2.lat) difflat=v1.1at-v2.1at; else difflat=v2.1at-v1.1at; if (v1.1on>v2.1on) difflon=v1.1on-v2.1on; else difflon=v2.1on-v1.1on; difflat=difflat%50000; //because of modulo (lat and lon just contained the lsb) difflon=difflon%50000; dist=sqrt((difflon*difflon)+(difflat*difflat)); return (dist*TOM); 1 25 Annexe 2: programme voiture #include "system.h" 5 #include "communication.h" #include "detection.h" /****************************** * Configuration Bits 10 ******************************/ // FOSC(CSW FSCM OFF & FRC PLL8); /* Fast RC with PLLx8 = 16MIP Clock Mon/Switch OFF */ FOSC(CSW FSCM OFF & XT PLL8); /* 8MHz Crystal with PLLx8 = 16 MIP -F7WDT(WDT -6FF);- /* Watch dog Timer OFF */ FBORPOR(PBOR OFF & MCLR EN); /* Brown Out OFF, MCLR Enabled *1 20 int lastRadio=1, radioReception=0; int holdLed=O; int countBip=O; coordonneGPS car; 25 vehicule bikes[9], abike, a_car; coordonneRadio radio; int duty=0; 30 int main(void) } ; /* Select Primary Oscillator */ 35 //0SCCONbits.POST=0; //while(OSCCONbits.LOCK!=l) OSCCON=0x3300; set_Tris(); setUart(); LED0=1; LED1=1; LED2=1; LED3=1; LED4=1; LED5=1; LEDGPS=1; 7/ FGS(CODE PROT OFF); /* Code Protect OFF */ // i=computeDistance(bike,car); 50 TMR2=0; BIP(); //interupteur vers le haut pour que ca sonne! while(1) 55 1 radio_bgTask(); return 0; Annexe 2: programme voiture #include "system.h" #include "detection.h" #include "communication. h" extern coordonneRadio radio; extern vehicule a_bike,bikes[9]; extern int duty,countBip; void set Tris(void){ TRSBbits.TRISB0=0;//BUZZER TRISBbits.TRISB1=1; TRISBbits.TRISB2=0; //Enable reception TRISBbits.TRISB3=1; TRISBbits.TRISB4=1; TRISBbits.TRISB5=0; TRISCbits.TRISC13=0; TRISCbits.TRISC14=1; TRISDbits.TRISD1=1; //RXradio TRISEbits.TRISE0=0; //LEDs TRISEbits.TRISE1=0; TRISEbits.TRISE2=0; TRISEbits.TRISE3=0; TRISEbits.TRISE4=0; TRISEbits.TRISE5=0; TRISDbits.TRISDO=0; //LEDGPS TRISEbits.TRISE8=0; PCFG0=1; PCFG1=1; PCFG2=1; PCFG3=1; PCFG4=1; PCFG5=1; void set Timers(void){ PRi=2*HalfPeriod; PR1=2*HalfPeriod; 0C1CONbits.00M=0; INT1IE=0; ilCONbits.TCS=0; T1CONbits.TGATE=0; T1CONbits.TCKPS=0; T1CONbits.TON=1; T1IF=0; TÎIE=1; TlIP=1; Y2CONbits.TCS=0; T2CONbits.TGATE=0; T2CONbits.TCKPS=0; T2CONbits.T32=0; T2CONbits.TON=1; T2IF=0; T2IP=2; T2IE=0; Annexe 2: programme voiture /* // Initialize Capture Module IC1CONbits.ICM= 0; // Disable Input Capture 1 module IC1CONbits.ICTMR= 1; // Select Timer2 as the IC1 Time base IC1CONbits.ICI= 0; // Interrupt on every second capture event IC1CONbits.ICM= 1; // Generate capture event on every Rising edge // Enable Capture Interrupt And Timer2 IC1IP = 7; // Setup IC1 interrupt priority level IC1IF = 1; // Clear IC1 Interrupt Status Flag = 1; // Enable IC1 interrupt*/ } setUart(void){ set Timers(); U1M15DEbits.PDSEL=0; UlMODEbits.USIDL=0; UlMODEbits.ALTIO=1; UlMODEbits.WAKE=1; UlMODEbits.ABAUD=0; UlMODEbits.STSEL=0; U1BRG=127; UlMODEbits.UARTEN=1; //8 bits No Parity void //continue operation in Idle mode //use U1ATX //wake-up enable //no autoBaud detect //1 stopbit U1STAbits.URXISEL=0; U1STAbits.UTXEN=0; U1RXIF=0; //interrput each character received U1RXIP=3; U1RXIE=1; //when void attribute ((interrupt, auto_psv)) _T2Interrupt(void){ interrupt occurs it's the end of a radio message int i=0; int valeur=0; //if nothing append, not receptionning data if (radio.reception==0){ T2IE=0; T2IF=0; return; radio.reception=2; radio.indice=0; i=0; radio.trame[0]=0; for (radio.indicedata=0;radio.indicedata<(NBOCTETRADIO*8);radio.indicedata++){ if (radio.trame[i]==0 && radio.trame[i+1]==0){ radio.data[radio.indicedata]=valeur; i+=2; } else if (radio.trame[i]==1){ radio.data[radio.indicedata]=valeur; valeur=(valeur+1)&1; i+=1; 1 radio.octet[radio.indicedata/8]=0; Annexe 2: programme voiture // converting bits into bytes for (radio.indicedata=0;radio.indicedata<(NBOCTETRADIO*8);radio.indicedata++){ radio.octet[radio.indicedata/8]+=(radio.data[radio.indicedata])<<(radio. indicedata%8); // reconstructing lon and lat from bytes if ((radio.octet[9]==(unsigned char)(radio.octet[0]+radio.octet[1]+radio.octet[2]+radio.octet[3]+radio. octet [4]+radio.octet[5]+radio.octet[6]+radio.octet[7]+radio.octet[8]))&& radio.octet[0]=='$'){ // TO SEE RADIO COMMUNICATION a_bike.lat=((long)radio.octet[1]<<24)+((long)radio.octet[2]<<16)+((long) radio.octet[3]<<8)+(radio.octet[4]); a_bike.lon=((long)radio.octet[5]<<24)+((long)radio.octet[6]<<16)+((long) radio.octet[7]<<8)+(radio.octet[8]); LED5=!LED5; 1 //LED4=!LED4; radio.reception=0; TrackingBike(a_bike,bikes); T2IE=0; T2IF =0; 1 void radio_bgTask(void) { static int lastRadio=1; static int meminRadio; meminRadio=inRadio; if (meminRadio==0 && radio.reception==0){ TMR2=0; T2IF=0; T2IE=1; //LED3=!LED3; radio.reception=1; lastRadio=0; radio.indice=0; radio. indicedata=0; if (meminRadio!=lastRadio && radio.reception==1)I if (HTMR2>LONG)&&(!meminRadio)) II ((TMR2>(ADDLOW+LONG))&&(meminRadio))){ radio.trame[radio.indice]=1; 1 else{ radio.trame[radio.indice]=0; } radio.indice++; TMR2=0; lastRadio=meminRadio; if (radio.indice>500) radio.indice=0; 1 Annexe 2: programme voiture void attribute ((interrupt, auto_psv)) _TlInterrupt(void){ if (duty<O) duty=0; if (countBip<duty){ countBip++; BUZZER=1; } else BUZZER=O; TlIF=0; } void BIP(void){ countBip=O; duty=MAXCOUNTBUZZER; }Appendix 1: motorcycle program #include <p30f4012.h> / ****************************** * Configuration Bits // FOSC ( CSW FSCM OFF & FRC PLL8); / * Fast RC with PLLx8 = 16MIP Clock 10 My / OFF Switch * 7 FOSC (CSW FSCM OFF & XT PLL8); / * 8MHz Crystal with PLLx8 = 16 MIP * / iWDT (WDT 5FF); - / * Watch dog Timer OFF * / FBORPOR (PBOR OFF & MCLR EN); / * Brown Out OFF, MCLR Enabled 15 * / FGS (CODE PROT OFF); / * Code Protect OFF * / #define MAXSIZEBUFF 40 #define HalfPeriod 2000 20 #define FCY 19660800 // 19 660 800Hz for 19200bps communication #define BaudRate 19200 // for GPS communicatino #define outRadio PORTEbits.RE2 #define ENRadio PORTEbits.RE3 # define RXGPS PORTCbits.RC14 25 #define LEDGPS LATD1 #define NBOCTETRADIO 10 #define DELAY_SEND 1000 #define DELAY EN 900 30 typedef struct {frame char [90]; char reception; tank type; unsigned char index; 35 unsigned int latDeg; unsigned int latMinEnt; unsigned long latMinDec; unsigned int lonDeg; unsigned int lonMinEnt; 40 unsigned long lonMinDec; } coordinatesGPS; typedef struct {// in 1/100000 minute of degrees (64 unsigned long lat; 45 bits) unsigned long lon; unsigned char frame [200]; int index; char sended; 50} Radio coordinates; coordinatesGPS ping, pong; coordinatesRadio pingR, pongR; 55 pingW tank; modulo tank; void set Tris (void) {TRISBbits.TRISB0 = 1; TRISBbits.TRISB1 = 1; TRISBbits.TRISB2 = 1; TRISBbits.TRISB3 = 1; TRISBbits.TRISB4 = 1; Appendix 1: motorcycle program TRISBbits.TRISB5 = 0; TRISCbits.TRISC13 = 0; TRISCbits.TRISC14 = 1; TRISDbits.TRISD1 = 0; // LED TRISEbits.TRISE0 = 0; TRISEbits.TRISE1 = 0; TRISEbits.TRISE2 = 0; TRISEbits.TRISE3 = 0; TRISEbits.TRISE4 = 0; TRISEbits.TRISE5 = 0; TRISEbits.TRISE8 = 0; / * PCFGO = 1; PCFG1 = 1; PCFG2 = 1; PCFG3 = 1; PCFG4 = 1; PCFG5 = 1; * / void set Timers (void) {PRI = 2 * HalfPeriod; T1CONbits.TCS = 0; T1CONbits.TGATE = 0; T1CONbits.TCKPS = 0; T1CONbits.TON = 1; Tlie = 1; } void setUart (void) {set Timers (); U1M0DEbits.PDSEL = 0; // 8 bits No Parity ULMODEbits.USIDL = 0; // continue operation in Idle mode UlMODEbits.ALTIO = 1; // use UlATX UlMODEbits.WAKE = 1; // wake-up enable UlMODEbits.ABAUD = O; // no autoBaud detect UlMODEbits.STSEL = O; 1/1 stopbit U1BRG = 127; UlMODEbits.UARTEN = 1; U1STAbits.URXISEL = 0; U1STAbits.UTXEN = 0; // interrupts each character received U1RXIF = O; U1RXIE = 1; } void loadTrameRadio (radioCoordinate * co) {(co-> frame) [0] = '$'; / * (co-> frame) [1] = ((co-> lat) & 0b11111111000000000000000000000000) >> 24; (Co-> frame) [2] = ((co-> lat) & 0b00000000111111110000000000000000) >> 16; (Co-> frame) [3] = ((co-> lat) & 0b00000000000000001111111100000000) >> 8; (Co-> frame) [4] = ((co-> lat) &0b00000000000000000000000011111111); (Co-> frame) [5] = ((co-> lon) & 0b11111111000000000000000000000000) >> 24; (Co-> frame) [6] = ((co-> lon) & 0b00000000111111110000000000000000) >> 16; (Co-> frame) [7] = ((co-> lon) & 0b00000000000000001111111100000000) >> 8; (co-> frame) [8] = ((co-> lon) &0b00000000000000000000000011111111); * / (co-> frame) [1] = ((co-> lat) & 0b00000000000000001111111100000000) >> 8; Appendix 1: motorcycle program (co-> frame) [2] = ((co-> lat) &0b00000000000000000000000011111111); (Co-> frame) [3] = ((co-> lon) & 0b00000000000000001111111100000000) >> 8; (Co-> frame) [4] = ((co-> lon) &0b00000000000000000000000011111111); // (co-> frame) [1] = '$'; (co-> frame) [2] = '$'; (co-> frame) [3] = '$'; (co-> frame) [4] = 1 $ '(co-> frame) [5] =' $ '; (co-> frame) [6] =' $ '; (co-> frame) [7] =' $ '; (co-> frame) [8] = '$'; // (co-> frame) [9] = (unsigned char) ((co-> frame) [0] + (co-> frame) [1] + (co-> frame) [2] + (co-> frame) > frame) [3] + (co-> frame) [4] + (co-> frame) [5] + (co-> frame) [6] + (co-> frame) [7] + (co-> > frame) [8]); (co-> frame) [5] - (unsigned char) ((co-> frame) [0] + (co-> frame) [1] + (co> frame) [2] + (co-> frame) [3] + (co-> frame) [4]); modulo = ((co-> frame) [1] & 0b00000001) + 2 * ((co-> frame) [3] &0b00000001); // to change to modulo 9 int charTovalue (char thechar) {switch (thechar) {case 'O': return 0; break; case '1': return 1; break; case '2': return 2; break; case '3': return 3; break; case '4': return 4; break; case '5': return 5; break; box '6': return 6; break; box '7': return 7; break; case '8': return 8; break; box '9': return 9; break; default: return -1; break; 1; return -1; void analysisField (void) {static int quality, time = 0; static int time = 0; static int prevtime = 0; if (ping.reception == 0) {Appendix 1: motorcycle program if (ping.trame [0] - = '$' && ping.trame [1] == 'G' && ping.trame [2] == ' P '&& ping.trame [3] ==' G '&& ping.trame [4] ==' G '&& ping.trame [5] ==' A ') {// detect GGA frame ping.indice = 0 ; while (ping.trame [ping.indice]! = ',') ping.indice ++; ping.indice + = 2; while (ping.trame [ping.indice]! = ',') ping.indice ++; // end <1> time = charTovalue (ping.trame [ping.indice-1]); ping.indice ++; if (time! = 0) return; // sampling 1HZ // start <2> ping.latDeg = charTovalue (ping.trame [ping.indice ++]) * 10 + charTovalue (ping.t ream [ping.indice ++]); ping.latMinEnt = charTovalue (ping.trame [ping.indice ++]) * 10 + charTovalue (pin g.trame [ping.indice ++]); ping.indice ++; // jump the '.' ping.latMinDec = 0; while (ping.trame [ping.indice]! = ',') ping.latMinDec = ping.latMinDec * 10 + charTovalue (ping.trame [ping.indice ++]); // end <2> ping.indice ++; // start <3> if (ping.trame [ping.indice ++] == 'N') ping.latDeg = ping.latDeg; // end <3> ping.indice ++; // start <4> ping.lonDeg = charTovalue (ping.trame [ping.indice ++]) * 100 + charTovalue (ping 40 frame [ping.indice ++]) * 10 + charTovalue (ping.trame [ping.indice ++]) ; ping.lonMinEnt = charTovalue (ping.trame [ping.indice ++]) * 10 + charTova1ue (pin g.trame [ping.indice ++]); ping.indice ++; // jump the '.' 45 ping.lonMinDec = 0; while (ping.trame [ping.indice]! = ',') ping.lonMinDec = ping.lonMinDec * 10 + charTovalue (ping.trame [ping.indice ++]); // end <4> 50 ping.indice ++; // start <5> if (ping.trame [ping.indice ++] == 'E') ping.lonDeg = ping.lonDeg; 55 ping.indice = 43; quality = charTovalue (ping.trame [ping.indice]); if (quality> 1) {LEDGPS =! LEDGPS; 60 1 else if (quality> 0) {if (time == 0) LEDGPS =! LEDGPS; time ++; Annex 1: moto program if (time> 3) time = 0; 1 else {LEDGPS = 1; ping.reception = 2; else ping.reception = 3; else {if (pong.trame [0] == '$' && pong.trame [1] == 'G' && pong.trame [2] == 'P' && pong.trame [3] == 'G '&& pong.trame [4] ==' G '&& pong.trame [5] ==' A ') {// detect GGA frame pong.indice = 0; while (pong.trame [pong.indice]! = ',') pong.indice ++; pong.indice ++; while (pong.trame [pong.indice]! = ',') pong.indice ++; // end <1> time = charTovalue (ping.trame [ping.indice-1]); pong.indice ++; if (time! = 0) {return; // sampling 1HZ // start <2> pong.latDeg = charTovalue (pong.trame [pong.indice ++]) * 10 + charTovalue (pong.t 35 row [pong.indice ++]); pong.latMinEnt = charTovalue (pong.trame [pong.indice ++]) * 10 + charTovalue (pon g.trame [pong.indice ++]); pong.indice ++; // jump the '.' 40 pong.latMinDec = 0; while (pong.trame [pong.indice]! = ',') pong.latMinDec = pong.latMinDec * 10 + charTovalue (pong.trame [pong.indice ++]); // end <2> 45 pong.indice ++; // start <3> if (pong.trame [pong.indice ++] == 'N') pong.latDeg = pong.latDeg; // end <3> 50 pong.indice ++; // start <4> pong.lonDeg = charTovalue (pong.trame [pong.indice ++]) * 100 + charTovalue (frame pong [pong.indice ++]) * 10 + charTovalue (pong.trame [pong.indice ++]); 55 pong.lonMinEnt = charTovalue (pong.trame [pong.indice ++]) * 10 + charTovalue (pon g.trame [pong.indice ++]); pong.indice ++; // jump the '.' pong.lonMinDec = 0; 60 while (pong.trame [pong.indice]! = ',') Pong.lonMinDec = pong.lonMinDec * 10 + charTovalue (pong.trame [pong.indice ++]); // end <4> pong.indice ++; 20 25 30 Appendix 1: motorcycle program // start <5> if (pong.trame [pong.indice ++] == 'E') pong.lonDeg = pong.lonDeg; pong.indice = 43; quality = charTovalue (pong.trame [pong.indice]); if (quality> 1) {LEDGPS =! LEDGPS; } else if (quality> 0) {if (time == 0) LEDGPS =! LEDGPS; time ++; if (time> 3) time = 0; } else {LEDGPS = 1; } 25 pong.reception = 2; } else pong.reception = 3; } 30} int main (void) {LEDGPS = 1; 35 int i; OSCCON = 0x3300; / * Select Primary Oscillator OSCCONbits.POST = 0; while (OSCCONbits.LOCK! = 1) {}; ENRadio = 1; 40 for (i = 0; i <200; i ++) {pingR.trame [i] = 0; pongR.trame [i] = 0; // 170; } 45 ping.trame [0] = '$'; pingR.trame [1] = 11; pingR.trame [2] = 12; pingR.trame [3] = 13; pingR.trame [4] = 14; 50 pingR.trame [5] = 15; pingR.trame [6] = 16; pingR.trame [7] = 17; pingR.trame [8] = 18; pingR.trame [9] = 19; 55 pingR.trame [10] = 20; pingR.trame [11] = 21; pingR.trame [12] = 22; 60 set_Tris (); setUart (); PEN1L = 0; PEN1H = 0; PEN2L = 0; PEN2H = 0; 10 15 20 Appendix 1: motorcycle program PEN3L = 0; PEN3H = 0; // h h m m s s. s / 10 ddmmmmmmm N / S, dddmm.mmmmm E / W, 6, nb Sat, dilution, altitude, //ping.trame={"$","G","P","G","G " , "A", ",", "1", "2", "3", "5", "1", "9", ".", "1. ,,,,,,,,. , .8n, .0.,. 7., .. ,,,. 0 ",,, 3",. 8., "2", u5u, "N ,,,,,,. ,,,,, ## EQU1 ## ,,,,,,,, one, n8 ",,,,,,, u0" u. u, n, n, n, n, n, n, n, n, n, n, n, n, m "," 0 "," 0 "," 0 "," 0 "," 0 "," 0 "," 0 "," 0 "," 0 "," 0 "," 0 "," 0 ", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0", "0 "," 0 "," 0 "}; 15 ping.trame [0] = '$'; ping.trame [1] = 1G '; ping.trame [2] = 1P'; ping.trame [3] = 'G'; ping.trame [4] = 'G'; ping.trame [5] = 'A'; ping.trame [6] = ''; ping.trame [7] = '1'; ping.trame [8] = 121; ping.trame [9] = '3'; ping.trame [10] - '4'; ping.trame [11] = 151 ; ping.trame [12] = 16 '; ping.trame [13] ='. '; ping.trame [14] =' 2 '; ping.trame [15] = ''; 20 ping.trame [16] = 11 ', ping.trame [17] = 11', ping.trame [18] = 12 ', ping.trame [19] = '31, ping.trame [20] ='. 'ping.trame [21] =', 41; ping.trame [22] = '5'; ping.trame [23] = '6'; ping.trame [24] = '7'; ping.trame [ 25] = '81; ping.trame [26] =', 1; ping.trame [27] = 'N'; ping.trame [28] = ','; ping.trame [29] - '1'; ping.trame [30] = '1'; ping.trame [31] = 121; ping.trame [32] = 25 '3'; ping.trame [33] = '3'; ping.trame [34] = '.'; Ping.trame [35] = '4'; ping.trame [36] = '5'; ping.trame [37] - '61; ping.trame [38] = 17 '; ping.trame [39] = 18'; ping.trame [40] = ','; ping.trame [41] = 'E'; ping.trame [42] = ','; ping.trame [43] = '1'; ping.trame [44] = ''; ping.trame [45] = '0'; ping.trame [46] = '8'; ping.trame [47] = ''; 30 ping.trame [48] - '01; ping.trame [49] = 1.'; Ping.trame [50] = 19 '; ping.trame [51] =. ,, ping.trame [52] - '5', ping.trame [53] = '51, ping.trame [54] =' 5 ', ping.trame [55] =' .1, ping.trame [56] ] = '5'; ping.trame [57] = ''; ping.trame [58] = 13; ping.trame [59] = 10; Ping.reception = 0; analyseTrame (); _PTEN = 0; ping.reception = 4; pong.reception = 4; 40 pingR.sended = 1; pongR.sended = 1; LEDGPS = 1; while (1) {45 // LED = RXGPS; if (ping.reception == 0 11 pong.reception == 0) {scanField (); } 50 if (ping.reception == 2) {// LED =! LED; if (pingR.sended) {55 pingR.lat = ping.latDeg * 6000000 + ping.latMinEnt * 100000 + ping.latMinDec; pingR.lon = ping.lonDeg * 6000000 * 100000 + + ping.lonMinEnt ping.lonMinDec; ping.reception = 3; loadTrameRadio (&pingR); 60 pingR.indice = 0; pingR.sended = 0; } else {10 Appendix 1: motorcycle program pongR.lat = ping.latDeg * 6000000 + ping.latMinEnt * 100000 + ping.latMinDec; pongR.lon = ping.lonDeg * 6000000 * 100000 + + ping.lonMinEnt ping.lonMinDec; ping.reception = 3; loadTrameRadio (&Pongr); pongR.indice = 0; pongR.sended = 0; 1 1 if (pong.reception == 2) {// LED =! LED; if (pingR.sended) {pingR.lat = pong.latDeg * 6000000 + pong.latMinEnt * 100000 + pong.latMinDec; pingR.lon = pong.lonDeg * 6000000 * 100000 + + pong.lonMinEnt pong.lonMinDec; pong.reception = 3; loadTrameRadio (&pingR); ping.indice = 0; pingR.sended = 0; } else {pongR.lat = pong.latDeg * 6000000 + pong.latMinEnt * 100000 + pong.latMinDec; pongR.lon = pong.lonDeg * 6000000 * 100000 + + pong.lonMinEnt pong.lonMinDec; pong.reception = 3; loadTrameRadio (&Pongr); pong.indice = 0; pongR.sended = 0; }} 1 return 0; 1 void attribute ((interrupt, auto_psv)) _U1RXInterrupt (void) {// PING char time; while (U1STAbits.URXDA) {time = U1RXREG; if (pingW) {if (ping.reception == 3) {ping.reception = 1; ping.indice = 0; } (ping.trame [ping.indice]) = time; if ((ping.indice> 1) && (ping.trame [ping.indice-1] == 13) && (ping.trame [ping.indice] == 10)) {// end of sentence detection ping.reception = 0; pingW = 0; } ping.indice ++; } // PONG elsef if (pong.reception == 3) {Appendix 1: moto program pong.reception = 1; pong.indice = 0; pong.trame [pong.indice] = time; if ((pong.indice> 1) && (pong.trame [pong.indice-1] == 13) && (pong.trame [pong.indice] == 10)) {// end of sentence detection pong.reception = 0; pingW = 1; 1 pong.indice ++; 1 U1RXIF = O; // reset Flag void attribute ((interrupt, auto_psv)) Tllnterrupt (void) {// menchester static int int second = 0; static int test = 0; static int delay = 0; if (pingR.sended == 0) {if (pingR.indice> 255) {pingR.indice = 0; delay = 0; } if (delay <(DELAY SEND * modulo)) {delay ++; TLIF = 0; return; if (delay <(DELAY SEND * modulo + DELAY_EN)) {ENRadio = 1; delay ++; T1IF = 0; return; outRadio = ((pingR.trame [pingR.indice / 8] >> (pingR.indice% 8)) + second + 1) + 1; // LED = ((pingR.trame [pingR.indice / 8] >> (pingR.indice% 8)) + second + 1) &1; if (second> = 1) {pingR.indice ++; second = 0; } else second ++; if (second == 0 && pingR.indice == (8 * (NBOCTETRADIO + 1))) {second = 0; pingR.indice = 0; outRadio = 1; pingR.sended = 1; ENRadio = 0; else if (pongR.sended == 0) {if (pongR.indice> 255) pongR.indice = 0; delay = 0; if (delay <DELAYSEND * modulo) {5 10 15 25 Appendix 1: motorcycle delay ++ program; TLIF = 0; return; if (delay <(DELAY SEND * modulo + DELAY EN)) {ENRadio = 1; delay ++; TLIF = 0; return; } outRadio = ((pongR.trame [pongR.indice / 8] >> (pingR.indice% 8)) + second + 1) &1; // LED = ((pongR.trame [pongR.indice / 8] >> (pingR.indice% 8)) + second + 1) &1; if (second == 1) {pongR.indice ++; second = 0; el seconds ++; if (second == 1 && pongR.indice == (8 * NBOCTETRADIO)) {second = 0; pongR.indice = 0; pongR.sended = 1; ENRadio = 0; TlIF = 0; 20 30 Appendix 2: car program #include "communication h" #include "system.h" extern coordonneGPS car; extern vehicle bikes [9]; void scanField (coordinateGPS because, vehicle a_car) {int quality = 0; int i; float minRatio = 1.0, ratio = 0.0; static int time = 0; if (car.reception == 0) {if (car.trame [0] == '$' && car.trame [1] == 'G' && car.trame [2] == 'P' && car. frame [3] == 'G' && car.trame [4] == 'G' && car.trame [5] == 'A') {// detect GGA frame car.indice = 0; while (car.trame [car.indice]! = ',') // car.indice ++; car.indice ++; // start <1> while (car.trame [car.indice]! = ',') car.indice ++; // end <1> car.time = charTovalue (car.trame [car.indice-1]); car.indice ++; if (car.time! = 0) return; // sampling 1HZ all radio positions must be received (new cycle) for (i = 0; i <9; i ++) {bikes [i] .alive--; if (bikes [i] .alive == 1) {ratio = isADanger (bikes [i]); if (ratio <minRatio) minRatio = ratio; 1 1 if (minRatio <(1.0 / 6.0)) LED0 = 1; else 50 55 60 LED0 = 0; if (minRatio <(2.0 / 6.0)) LED1 = 1; else LED1 = 0; if (minRatio <(3.0 / 6.0)) LED2 = 1; else LED2 = 0; if (minRatio <(4.0 / 6.0)) LED3 = 1; else LED3 = 0; if (minRatio <(5.0 / 6.0)) LED4 = 1; else Annex 2: car program LED4 = 0; car.indice = 16; // start <2> car.latDeg = charToval (car.trame [car.indice ++]) * 10 + charTovalue (car.trame [car.indice ++]); car.latMinEnt = charTovalue (car.trame [car.indice ++]) * 10 + charTovalue (car.trame [car.indice ++]); car.indice ++; // jump the '.' car.latMinDec = O; while (car.trame [car.indice]! = ', 1) car.latMinDec = car.latMinDec * 10 + charTovalue (car.trame [car.indice ++]); // end <2> car.indice ++; // start <3> if (car.trame [car.indice ++] == 'N') car.latDeg = car.latDeg; // to change lillitillittliiiiIIIIIII // end <3> car.indice ++; // start <4> car.lonDeg = charTovalue (car.trame [car.indice ++]) * 100 + charTovalue (car.tram 30 e [car.indice ++]) * 10 + charTovalue (car.trame [car.indice ++] ); car.lonMinEnt = charTovalue (car.trame [car.indice ++]) * 10 + charTovalue (car.trame [car.indice ++]); car.indice ++; // jump the '.' 35 car.lonMinDec = 0; while (car.trame [car.indice]! = ',') car.lonMinDec = car.lonMinDec * 10 + charTovalue (car.trame [car.indice ++]); // end <4> 40 car.indice ++; // start <5> if (car.trame [car.indice ++] == 'E') car.lonDeg = car.lonDeg; // to changeilliiiiiiitilliiiiiiiiittt 45 while (car.trame [car.indice]! = ',') car.indice ++; car.indice ++; // start 6 50 car.indice = 43; quality = charTovalue (car.trame [car.indice]); if (quality == 2) {LEDGPS =! LEDGPS; } 55 else if (quality> 0) {if (time == 0) LEDGPS =! LEDGPS; time ++; 60 if (time> 3) time = 0; 1 comfortable {LEDGPS = 1; } I 19 Appendix 2: car program acar.lat = car.latDeg * 6000000 + car.latMinEnt * 100000 + car.latMinDec; a_car.lon = car.lonDeg * 6000000 * 100000 + + car.lonMinEnt car.lonMinDec; // counterMotoPort ++; car.reception = 2; 1 10 else car.reception = 3; }} 15 void attribute ((interrupt, auto psv)) U1RXInterrupt (void) {_ // PING _ while (U1STAbits.URXDA) {if (car.reception == 3) {car.reception = 1; 20 car.indice = 0; } (car.trame [car.indice]) = U1RXREG; if ((car.indice> 1) && (car.trame [car.indice-1] == 13) && (car.trame [car.indice] == 10)) {// end of sentence detection 25 car. reception = 0; } car.indice ++; } U1RXIF = O; // reset Flag 30} int charToval (char thechar) {switch (thechar) {35 case '0': return 0; break; case '1': return 1; 40 break; case '2': return 2; break; box 1 3 1: 45 return 3; break; case '4': return 4; break; 50 box '5': return 5; break; box '6': return 6; 55 break; '7': return 7; '8': break; 60 return 8; break; box '9': return 9; break; case box 20 Appendix 2: car program case return break; default: -2; return break; -1; ; -1; return 18 20 25 Appendix 2: car program #include "detection.h" #include "system.h" #include "math.h" extern vehicle a_car; int myatan (double duty) {int sign = l; if (duty <0.0) {duty = -duty; sign = -1; 1 if (duty> 11.43) return 90 * sign; else if (duty> 3.47) return 80 * sign; else if (duty> 2.145) return 70 * sign; else if (duty> 1.428) return 60 * sign; else if (duty> 1.0) return 50 * sign; else if (duty> 0.7) return 40 * sign; else if (duty> 0.466) return 30 * sign; else if (duty> 0.268) return 20 * sign; else if (duty> 0.087) return 10 * sign; else return 0; 1 float computeSpeed (vehicle * a_vehicule) {unsigned long difflat = 0; unsigned long difflon = 0; unsigned long dist = 0; int temp, temp2; if (a_vehicle-> lat> a_vehicle-> lastlat) difflat = a_vehicle-> lat-a_vehicule-> lastlat; else difflat = avehicle-> lastlat-avehicule-> lat; if (a_vehicule-> lon> a vehicule-> lastlon) difflon = a_vehicile-> lon-a_vehicule-> lastlon; else difflon = avehicule-> lastlon-avehicule-> lon; difflat difflat% = 50000; difflon difflon% = 50000; dist = sqrt ((difflon difflon *) + (difflat difflat *)); if ((dist * TOM) * 5.0)> 2) {// minimum speed to calculate vehicle orientation (in m / seconds) (2m / s => 7.2km / h) temp = (a_vehicle-> lon -a_vehicule-> lastlon); temp2 = a_vehicule-> lat-a_vehicule-> lastlat; if (temp> 0) Appendix 2: car program a_vehicule-> angle = myatan (((double) (a_vehicule-> lat) - (double) (a_vehicule-> lastlat)) / ((double) (a_vehicule-> lon) - (double) (a_vehicule-> lastlon))); else if (temp <0) a_vehicle-> angle = 180 + myatan (((double) a_vehicle-> lat- (double) avehicle-> lastlat) / ((double) a_vehicle-> lon- (double) a_vehicle-10> lastlon)); else if (temp2> 0) a_vehicle-> angle = 90; else a vehicle-> angle = -90; If (a_vehicuf; -> angle> 180) has vehicle-> angle- = 360; else if (avehicle-> angle <= - 180) aveFile-> angle + = 360; 20 // col-> angle = -45; a_vehicule-> lastlat = a_vehicule-> lat; a_vehicule-> lastlon = a vehicule-> lon; a vehicle-> speed = (says * TOM) * 5.0; return (dist * TOM) * 5.0; 25} float isADanger (vehicle bike) int distance = 0; 30 int dSpeed; distance = computeDistance (bike, a_car); dSpeed = bike.speed-a_car.speed; if (dSpeed <0) dSpeed = -dSpeed; 35 // check the time before impact. if it is beetwin 10 year 7, there is a beep. if (distance <= (dSpeed) * 10.0 && distance> = (- dSpeed) * 7.0 && isBehind (a car, bike) && haveSameDirection (a_car, bike)) 40 BIP (); return ((float) distance) / ((float) dSpeed * 6.0); 45 void TrackingBike (vehicle bike, vehicle bikes [9]) // after the tracking, do -1 to alive to eliminate old bike! int i, temp, index; int min = 1000; 50 for (i = 0; i <9; i ++) if (bikes [i] .alive == 1) {temp = computeDistance (bike, bikes [i]); If (temp <min) min = temp; index = i; 60 if (min <TRACKINGDISTANCE) bikes [index] = bike; Appendix 2: car program computeSpeed (& (bikes [index])); if (bikes [index] .alive <2) {bikes [index] .alive ++; // used to check loose of bike (out of range)} else {i = 0; while (i <9 && bikes [i] .alive == 1); bikes [i] = bike; bikes [i] .alive = 2; // new bike! bikes [i] .speed = 0; } int isBehind (vehicle ref, vehicle bike) 1 int temp, temp2; int angle2vehicle, diffangle; temp = bike.lon-ref.lon; temp2 = bike.lat-ref.lat; if (temp> 0) angle2vehicle = myatan (((double) bike.lat- (double) ref.lat) / ((double) bike.lon- (double) ref.lon)); else if (temp <O) angle2vehicle = 180 + myatan (((double) bike.lat (double) ref.lat) / ((double) bike. lon- (double) ref.lon)); else if (temp2> 0) angle2vehicle = 90; else angle2vehicle = -90; if (angle2vehicle> 180); angle2vehicule- = 360; diffangle = angle2vehicule-ref.angle; if (diffangle> 180) diffangle- = 360; else if (diffangle <= - 180) diffangle + = 360; if (diffangle <= 90 && diffangle> = - 90) return 0; else return 1; return 0; int haveSameDirection (vehicle vl, vehicle v2) {int diffangle; diffangle = (v1.angle-v2.angle); if (diffangle> 180) diffangle- = 360; else if (diffangle <= - 180) diffangle + = 360; if (diffangle <O) diffangle = -diffangle; Annex 2: car program if (diffangle <60) return 1; else return 0; 1 unsigned int computeDistance (vehicle v1, vehicle v2) {unsigned long difflat = 0; unsigned long difflon = 0; unsigned long dist = 0; if (vl.lat> v2.lat) difflat = v1.1at-v2.1at; else difflat = v2.1at-v1.1at; if (v1.1on> v2.1on) difflon = v1.1on-v2.1on; else difflon = v2.1on-v1.1on; difflat difflat% = 50000; // because of modulo (lat and lon just contained the lsb) difflon = difflon% 50000; dist = sqrt ((difflon difflon *) + (difflat difflat *)); return (dist * TOM); 1 25 Appendix 2: car program #include "system.h" 5 #include "communication.h" #include "detection.h" / ******************** ********** * Configuration Bits 10 ****************************** / // FOSC (CSW FSCM OFF & FRC PLL8); / * Fast RC with PLLx8 = 16MIP Clock Mon / OFF Switch * / FOSC (CSW FSCM OFF & XT PLL8); / * 8MHz Crystal with PLLx8 = 16 MIP -F7WDT (WDT -6FF); - / * Watch Dog Timer OFF * / FBORPOR (PBOR OFF & MCLR EN); / * Brown Out OFF, MCLR Enabled * 1 20 int lastRadio = 1, radioReception = 0; int holdLed = O; int countBip = O; coordinatesGPS car; 25 bikes vehicle [9], abike, a_car; radio radio coordination; int duty = 0; 30 int main (void)}; / * Select Primary Oscillator * / 35 //0SCCONbits.POST=0; //while(OSCCONbits.LOCK!=l) OSCCON = 0x3300; set_Tris (); setUart (); LED0 = 1; LED1 = 1; LED2 = 1; LED3 = 1; LED4 = 1; LED5 = 1; LEDGPS = 1; 7 / FGS (CODE PROT OFF); / * Code Protect OFF * / // i = computeDistance (bike, car); 50 TMR2 = 0; BEEP(); // switch up to make it sound! while (1) 55 1 radio_bgTask (); return 0; Appendix 2: car program #include "system.h" #include "detection.h" #include "communication.h" extern coordonneRadio radio; extern vehicle a_bike, bikes [9]; extern int duty, countBip; void set Tris (void) {TRSBbits.TRISB0 = 0; // BUZZER TRISBbits.TRISB1 = 1; TRISBbits.TRISB2 = 0; // Enable reception TRISBbits.TRISB3 = 1; TRISBbits.TRISB4 = 1; TRISBbits.TRISB5 = 0; TRISCbits.TRISC13 = 0; TRISCbits.TRISC14 = 1; TRISDbits.TRISD1 = 1; // RXradio TRISEbits.TRISE0 = 0; // LEDs TRISEbits.TRISE1 = 0; TRISEbits.TRISE2 = 0; TRISEbits.TRISE3 = 0; TRISEbits.TRISE4 = 0; TRISEbits.TRISE5 = 0; TRISDbits.TRISDO = 0; // LEDGPS TRISEbits.TRISE8 = 0; PCFG0 = 1; PCFG1 = 1; PCFG2 = 1; PCFG3 = 1; PCFG4 = 1; PCFG5 = 1; void set Timers (void) {PRi = 2 * HalfPeriod; PR1 = 2 * HalfPeriod; 0C1CONbits.00M = 0; INT1IE = 0; ilCONbits.TCS = 0; T1CONbits.TGATE = 0; T1CONbits.TCKPS = 0; T1CONbits.TON = 1; T1IF = 0; TIIE = 1; TlIP = 1; Y2CONbits.TCS = 0; T2CONbits.TGATE = 0; T2CONbits.TCKPS = 0; T2CONbits.T32 = 0; T2CONbits.TON = 1; T2IF = 0; T2IP = 2; T2IE = 0; Appendix 2: car program / * // Initialize Capture Module IC1CONbits.ICM = 0; // Disable Input Capture 1 module IC1CONbits.ICTMR = 1; // Select Timer2 as the IC1 Time base IC1CONbits.ICI = 0; // Interrupt on every second capture event IC1CONbits.ICM = 1; // Generate capture event on every Rising edge // Enable Capture Interrupt And Timer2 IC1IP = 7; // Setup IC1 interrupt priority level IC1IF = 1; // Clear IC1 Interrupt Status Flag = 1; // Enable IC1 interrupt * /} setUart (void) {set Timers (); U1M15DEbits.PDSEL = 0; UlMODEbits.USIDL = 0; UlMODEbits.ALTIO = 1; UlMODEbits.WAKE = 1; UlMODEbits.ABAUD = 0; UlMODEbits.STSEL = 0; U1BRG = 127; UlMODEbits.UARTEN = 1; // 8 bits No Parity void // continue operation in Idle mode // use U1ATX // wake-up enable // no autoBaud detect // 1 stopbit U1STAbits.URXISEL = 0; U1STAbits.UTXEN = 0; U1RXIF = 0; // interrupts each character received U1RXIP = 3; U1RXIE = 1; // when void attribute ((interrupt, auto_psv)) _T2Interrupt (void) {interrupt occurs the end of a radio message int i = 0; int value = 0; // if nothing append, not receptionning data if (radio.reception == 0) {T2IE = 0; T2IF = 0; return; radio.reception = 2; radio.indice = 0; i = 0; radio.trame [0] = 0; for (radio.indicedata = 0; radio.indicedata <(NBOCTETRADIO * 8); radio.indicedata ++) {if (radio.trame [i] == 0 && radio.trame [i + 1] == 0) {radio. data [radio.indicedata] = value; i + = 2; } else if (radio.trame [i] == 1) {radio.data [radio.indicedata] = value; value = (value + 1) + 1; i + = 1; 1 radio.octet [radio.indicedata / 8] = 0; Annex 2: car program // converting bits into bytes for (radio.indicedata = 0; radio.indicedata <(NBOCTETRADIO * 8); radio.indicedata ++) {radio.octet [radio.indicedata / 8] + = (radio.data [radio.indicedata]) << (radio indicedata% 8); // radio.octet [9] == (unsigned char) (radio.octet [0] + radio.octet [1] + radio.octet [2] + radio.octet [3] ] + radio byte [4] + radio.octet [5] + radio.octet [6] + radio.octet [7] + radio.octet [8])) && radio.octet [0] == '$' ) {// TO SEE RADIO COMMUNICATION a_bike.lat = ((long) radio.octet [1] << 24) + ((long) radio.octet [2] << 16) + ((long) radio.octet [ 3] << 8) + (radio.octet [4]); a_bike.lon = ((long) radio.octet [5] << 24) + ((long) radio.octet [6] << 16) + ((long) radio.octet [7] << 8) + ( radio.octet [8]); LED5 = LED5!; 1 // LED4 =! LED4; radio.reception = 0; TrackingBike (a_bike, bikes); T2IE = 0; T2IF = 0; 1 void radio_bgTask (void) {static int lastRadio = 1; static int meminRadio; meminRadio = inRadio; if (meminRadio == 0 && radio.reception == 0) {TMR2 = 0; T2IF = 0; T2IE = 1; // LED 3 = LED3!; radio.reception = 1; lastRadio = 0; radio.indice = 0; radio. indicedata = 0; if (meminRadio! = lastRadio && radio.reception == 1) I if (HTMR2> LONG) && (! meminRadio)) II ((TMR2> (ADDLOW + LONG)) && (meminRadio))) {radio.trame [radio .indice] = 1; 1 else {radio.trame [radio.indice] = 0; } radio.indice ++; TMR2 = 0; lastRadio = meminRadio; if (radio.indice> 500) radio.indice = 0; 1 Appendix 2: car program void attribute ((interrupt, auto_psv)) _TlInterrupt (void) {if (duty <O) duty = 0; if (countBip <duty) {countBip ++; BUZZER = 1; } else BUZZER = O; TLIF = 0; } void BIP (void) {countBip = O; Duty = MAXCOUNTBUZZER; }
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
FR1202458A FR2987927A1 (en) | 2012-03-09 | 2012-09-12 | GPS MOTO DETECTOR |
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
FR1200730A FR2987926A1 (en) | 2012-03-09 | 2012-03-09 | Device i.e. global positioning system detector, for preventing collisions between car motorists and two-wheelers, has transmitter and receiver that are equipped with positioning system devices, where transmitter emits fixed radio frequency |
FR1202458A FR2987927A1 (en) | 2012-03-09 | 2012-09-12 | GPS MOTO DETECTOR |
Publications (1)
Publication Number | Publication Date |
---|---|
FR2987927A1 true FR2987927A1 (en) | 2013-09-13 |
Family
ID=47501315
Family Applications (2)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
FR1200730A Pending FR2987926A1 (en) | 2012-03-09 | 2012-03-09 | Device i.e. global positioning system detector, for preventing collisions between car motorists and two-wheelers, has transmitter and receiver that are equipped with positioning system devices, where transmitter emits fixed radio frequency |
FR1202458A Pending FR2987927A1 (en) | 2012-03-09 | 2012-09-12 | GPS MOTO DETECTOR |
Family Applications Before (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
FR1200730A Pending FR2987926A1 (en) | 2012-03-09 | 2012-03-09 | Device i.e. global positioning system detector, for preventing collisions between car motorists and two-wheelers, has transmitter and receiver that are equipped with positioning system devices, where transmitter emits fixed radio frequency |
Country Status (1)
Country | Link |
---|---|
FR (2) | FR2987926A1 (en) |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2009125399A2 (en) * | 2008-04-07 | 2009-10-15 | Janus Interface Ltd. | Vehicle awareness system |
-
2012
- 2012-03-09 FR FR1200730A patent/FR2987926A1/en active Pending
- 2012-09-12 FR FR1202458A patent/FR2987927A1/en active Pending
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2009125399A2 (en) * | 2008-04-07 | 2009-10-15 | Janus Interface Ltd. | Vehicle awareness system |
Also Published As
Publication number | Publication date |
---|---|
FR2987926A1 (en) | 2013-09-13 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US20230274640A1 (en) | Electrical data processing system for monitoring or affecting movement of a vehicle using a traffic device | |
US20230124092A1 (en) | Electrical data processing system for determining a navigation route based on the location of a vehicle and generating a recommendation for a vehicle maneuver | |
KR102349159B1 (en) | Path providing device and path providing method tehreof | |
EP2452239B1 (en) | Method of controlling a communication system in a motor vehicle | |
KR100513009B1 (en) | Navigation system for providing warning restrictedly, apparatus and method for providing warning restrictedly in navigation system | |
US20170162053A1 (en) | Road safety warning system | |
US20180090005A1 (en) | Method And Apparatus For Vulnerable Road User Incidence Avoidance | |
JP6260912B2 (en) | Device, method, and program for providing traffic location information | |
US20240001952A1 (en) | Systems and methods to issue warnings to enhance the safety of bicyclists, pedestrians, and others | |
WO2012126098A2 (en) | Method and system for preventing automobile accidents caused by the nonobservance of traffic rules, vehicle provided with the system, method for manufacturing the system, and use of the system with vehicles | |
JP2009104531A (en) | Potential hazard point detection device and on-board alert device of a hazard point | |
US11679781B2 (en) | Path providing device and path providing method thereof | |
CN104616516A (en) | Driving safety auxiliary control method and driving safety auxiliary control system | |
JP2004511837A (en) | Communication system between vehicles | |
CN108399774A (en) | A kind of highway low visibility safe driving system for prompting | |
JP2004348254A (en) | On-vehicle device, center device, and preventive safety system using them | |
US12145681B2 (en) | Bicycle visibility system for an electric bicycle | |
CN110415527A (en) | Electric bicycle monitoring method and system based on Beidou ground enhancement technology | |
EP3931070B1 (en) | Grip with retractable direction indicator | |
JP5281431B2 (en) | Vehicle information transmission system | |
FR2987927A1 (en) | GPS MOTO DETECTOR | |
JP2008288855A (en) | Mobil person detection system | |
CN111833652A (en) | Active protection system for children traffic safety based on Bluetooth broadcast | |
CA3211557A1 (en) | Electrical data processing system for determining a navigation route based on the location of a vehicle and generating a recommendation for a vehicle maneuver | |
US20200271459A1 (en) | Path providing device and communication system comprising the same |