lazertu
Messages postés3Date d'inscriptionjeudi 12 juin 2014StatutMembreDernière intervention18 juin 2014
-
12 juin 2014 à 09:55
Bonjour,
je voudrais faire un conteur de passage avec trois modules
--->Module 'Entré'Composer d'un détecteur de passage en entrée, un PIC et un module RF TX/RX.
--->Module 'Sortie' Composer d'un détecteur de passage en sortie, un PIC et un module RF TX/RX.
--->Module 'Central' Composer d'un module RF TX/RX un PIC et un afficher LCD 2*16.
Le principe un que le module "Central'" demande ( un part un à un intervalle régulier) aux autres modules (Entré & Sortie) de lui envoyer le nombre de passes qui a comptabilisé et enregistré puis le module "Central'" fait le calcule [entré - sortie] et affiche sur le LCD le nombre de personnes entré et sortie plus le nombre de personnes à l'intérieur.
Donc pour communiqué autre les module j'utilise le code Manchester le problème c'est que j'ai baux être en 1er année de BTS SE (systèmes électroniques)
j'ai découvert le code Manchester il n'y a que 2 semaines donc pour faire mon projet de prendre comme basse un code qui était déjà fait dans la librairie du compilateur "mikroC PRO for PIC" que j'ai copier copié ci-dessous et voici un doc pour mieux comprendre le code
// Manchester module connections
sbit MANRXPIN at RC0_bit;
sbit MANRXPIN_Direction at TRISC0_bit;
sbit MANTXPIN at RC1_bit;
sbit MANTXPIN_Direction at TRISC1_bit;
// End Manchester module connections
char index, character;
char s1[] = "mikroElektronika";
void main() {
ANSEL = 0; // Configure AN pins as digital I/O
ANSELH = 0;
C1ON_bit = 0; // Disable comparators
C2ON_bit = 0;
Man_Send_Init(); // Initialize transmitter
while (1) { // Endless loop
Man_Send(0x0B); // Send "start" byte
Delay_ms(100); // Wait for a while
character = s1[0]; // Take first char from string
index = 0; // Initialize index variable
while (character) { // String ends with zero
Man_Send(character); // Send character
Delay_ms(90); // Wait for a while
index++; // Increment index variable
character = s1[index]; // Take next char from string
}
Man_Send(0x0E); // Send "end" byte
Delay_ms(1000);
}
}
RX
// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
// Manchester module connections
sbit MANRXPIN at RC0_bit;
sbit MANRXPIN_Direction at TRISC0_bit;
sbit MANTXPIN at RC1_bit;
sbit MANTXPIN_Direction at TRISC1_bit;
// End Manchester module connections
char error, ErrorCount, temp;
void main() {
ErrorCount = 0;
ANSEL = 0; // Configure AN pins as digital I/O
ANSELH = 0;
C1ON_bit = 0; // Disable comparators
C2ON_bit = 0;
TRISC.F5 = 0;
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear LCD display
Man_Receive_Init(); // Initialize Receiver
while (1) { // Endless loop
Lcd_Cmd(_LCD_FIRST_ROW); // Move cursor to the 1st row
while (1) { // Wait for the "start" byte
temp = Man_Receive(&error); // Attempt byte receive
if (temp == 0x0B) // "Start" byte, see Transmitter example
break; // We got the starting sequence
if (error) // Exit so we do not loop forever
break;
}
do
{
temp = Man_Receive(&error); // Attempt byte receive
if (error) { // If error occured
Lcd_Chr_CP('?'); // Write question mark on LCD
ErrorCount++; // Update error counter
if (ErrorCount > 20) { // In case of multiple errors
temp = Man_Synchro(); // Try to synchronize again
//Man_Receive_Init(); // Alternative, try to Initialize Receiver again
ErrorCount = 0; // Reset error counter
}
}
else { // No error occured
if (temp != 0x0E) // If "End" byte was received(see Transmitter example)
Lcd_Chr_CP(temp); // do not write received byte on LCD
}
Delay_ms(25);
}
while (temp != 0x0E) ; // If "End" byte was received exit do loop
}
}
Dans cette configuration sa fonctionne
Le problème est que se code ne correspondant pas aux attentes de mon projet!
Le premier souci c'est que je ne peux pas envoyer un nombre (de type: hex...binaire...décimale...etc...) sur 'Man_Send' mais qu'un caractère alfa-numérique POURQUOI ?
Donc pour réussir mon projet je vous demande de l'aide pour codé c'est trois pic (côté compteur et affichage sur le lcd je c fait, mais côté communication là entre les module !!!).