Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] Simulation problem (gray squares )

Status
Not open for further replies.

SABRAMANSOUR

Junior Member level 2
Joined
Dec 16, 2014
Messages
23
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
127
what's the problem with the gray squares at the pins of PORTB, C, D, E that's my project please help me it's urgent
:cry: :cry: :cry:
111111.png
Code:
void main(){
unsigned int v0,v1,v2,v3,v5;
ADC_Init();  // Initialize ADC module with default set
//CMCON = 0x07; // Disable comparators
ADCON0 = 0x00; // Select ADC channel AN0
ADCON1 = 0x0F; // RA0 as analog input
TRISC = 0x00;
PORTC= 0 ;
PORTA= 0xFF ;
TRISA = 0xFF;
 PORTB= 0 ;
TRISB = 0x00;
 PORTE= 0 ;
TRISE = 0x00;
  PORTD= 0 ;
TRISD = 0x00;

INTCON = 0  ;

  do {

   ADCON0=0b11000101;     // Configure chanal 0

     delay_us(500);
   v0 = ADC_Read(0);   // Get 10-bit results of AD conversion
    delay_us(500);

    ADCON0=0b11001101;     // Configure chanal 1
       delay_us(500);
    v1 = ADC_Read(1);   // Get 10-bit results of AD conversion

    delay_us(500);

    ADCON0=0b11100101;      // Configure chanal 4
      delay_us(500);
    v5 = ADC_Read(5);   // Get 10-bit results of AD conversion
      delay_us(500);
    if ((v0>v5)||(v1>v5));
       {if (v0>v1)                       //  comparaison  des tensions  des capteurs LDR1 et LDR2 si v0>v1
          {
           PORTB.f0=1;             // pour tourné le moteur dans le sens 1 la sortie de pic RB0==1 et RB1==0
           PORTB.f1=0;    // PORTB.1=0;
           delay_us(500);
          }
       else                              // sinon
          {
           PORTB.f0=0;             // pour tourné le moteur dans le sens 1 la sortie de pic RB0==0 et RB1==1
           PORTB.f1=1;    // PORTB.1=0;
           delay_us(500);
          }
       }
    if ((v0<v5)&&(v1<v5));
          {
           PORTB.f0=0;             // pour tourné le moteur dans le sens 1 la sortie de pic RB0==1 et RB1==0
           PORTB.f1=0;    // PORTB.1=0;
           delay_us(500);
          }
     //SENS VERTICALE;

     ADCON0=0b11010101;     // Configure chanal 2
    delay_us(500);
    v2 = ADC_Read(2);   // Get 10-bit results of AD conversion
    delay_us(500);


    ADCON0=0b11011101;     // Configure chanal 3
     delay_us(500);
    v3 = ADC_Read(3);   // Get 10-bit results of AD conversion
     delay_us(500);


    ADCON0=0b11100101;      // Configure chanal 4
     delay_us(500);
    v5 = ADC_Read(5);   // Get 10-bit results of AD conversion
     delay_us(500);

      if ((v2>v5)||(v3>v5));
       {if (v2>v3)                       //  comparaison  des tensions  des capteurs LDR2 et LDR3 si v2>v3
          {
           PORTB.f2=1;             // pour tourné le moteur dans le sens 1 la sortie de pic RB2==1 et RB3==0
           PORTB.f3=0;
           delay_us(500);
          }
       else                              // sinon
          {
           PORTB.f2=0;             // pour tourné le moteur dans le sens 1 la sortie de pic RB0==0 et RB1==1
           PORTB.f3=1;    // PORTB.1=0;
           delay_us(500);
          }
       }
       if ((v2<v5)&(v3<v5));
          {
           PORTB.f2=0;             // pour tourné le moteur dans le sens 1 la sortie de pic RB2==0 et RB3==1
           PORTB.f3=0;
           delay_us(500);
          }

  } while(1);
}
 

Easyrider83

Advanced Member level 5
Joined
Oct 11, 2011
Messages
1,608
Helped
374
Reputation
748
Reaction score
362
Trophy points
1,363
Location
Tallinn, Estonia
Activity points
8,577
Look's like your program even not start. Possible, because MCLR pin used in configuration and connected nowhere. Use pull up resistor at least. For simulation only you can connect MCLR pin to VCC directly. Proteus doesn't simulate startup reset pulse, crystal oscillator, coffe machines and e.t.c. It using SPICE engine whith some primitive microcontrollers options.
 

SABRAMANSOUR

Junior Member level 2
Joined
Dec 16, 2014
Messages
23
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
127
well i used the pull up resistor but the problem doesn't solved
I didn't understant what do you mean by " using SPICE engine whith some primitive microcontrollers options."
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
49,160
Helped
14,392
Reputation
29,048
Reaction score
13,144
Trophy points
1,393
Location
Bochum, Germany
Activity points
283,322
"Grey" designates unknown state, e.g. floating input. If it's observed with pins that should be initialized as outputs, it means that the code isn't executed regulary. To see why, you can load a *.cof instead of *.hex file and trace program execution in Proteus source level debugger.

Although I won't contradict the Proteus qualification by Easyreader83 as "SPICE engine whith some primitive microcontrollers options", even this primitive options can be helpful if used intelligently.
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
49,160
Helped
14,392
Reputation
29,048
Reaction score
13,144
Trophy points
1,393
Location
Bochum, Germany
Activity points
283,322
Binary file 1.hex is missing, you should also attach the debug binary 1.cof to allow code debuuging.
 

milan.rajik

Banned
Joined
Apr 1, 2013
Messages
2,528
Helped
540
Reputation
1,078
Reaction score
524
Trophy points
1,393
Activity points
0
Zip and attach the complete mikroC project. We need to see the configurations you have set.
 
Last edited:

milan.rajik

Banned
Joined
Apr 1, 2013
Messages
2,528
Helped
540
Reputation
1,078
Reaction score
524
Trophy points
1,393
Activity points
0
What are all the semi colons (;) after while(1) and if() conditions ? Proteus 8.1 file attached. Proteus file has been modified.
 

Attachments

  • project_3.rar
    47.7 KB · Views: 7

nagkiller

Full Member level 4
Joined
Jul 9, 2009
Messages
231
Helped
37
Reputation
74
Reaction score
37
Trophy points
1,308
Location
Brazil
Activity points
2,544
There are several errors in the schematic!!!
The diode bridge is connected wrongly, the 12V supply shorted to 5V (all is named as VSS???), the relay coils are without power of 12V, the ULN2003 connected wrongly, etc...

These are my suggestions for the schematic (Proteus 7.10SP0):

Project_4.png

Using only one ULN2003A:

Project_4-B.png
 

Attachments

  • Project_4.zip
    158.5 KB · Views: 12
Last edited:

SABRAMANSOUR

Junior Member level 2
Joined
Dec 16, 2014
Messages
23
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
127
thank you so much
that's my first project it wasnt easy for me
I make stupid mistakes and I'm happy tha I found this forum thanksfor all whoes help me specially " nagkiller "
 

nagkiller

Full Member level 4
Joined
Jul 9, 2009
Messages
231
Helped
37
Reputation
74
Reaction score
37
Trophy points
1,308
Location
Brazil
Activity points
2,544
Special thanks to everyone who contributed!!!

:thumbsup:
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top