Making an animated relay in proteus work using pic16f877A

Discussion in 'Embedded Systems and Microcontrollers' started by trinetra31, Jul 12, 2012.

  1. trinetra31

    Thread Starter New Member

    Jul 12, 2012
    1
    0
    Hi all,
    I am trying to make an animated relay work to switch on the bulb in my circuit. When a input is given to the pic16f877A, it is to make the relay on the bulb. I have fixed everything correctly( according to me...). But i can't make the relay work when i execute (F12). The lcd included works well though. Pls help. I will include the coding and the picture of the circuit. Also what do the blue and red square lights that appear in the proteus simulation.
    Pls do help me.
    Thanks
    S.Trinetra

    p.s
    relay is set to 5V. It is still not working.
    Do u notice the power terminal connected to one part of the relay and diode. Must have a certain value? I can't seem to insert any value.
    Do u think that there is something wrong with the code in Mplab?
    Must ac source and bulb be connected to the transistor and ground?

    Code ( (Unknown Language)):
    1.  
    2. #include<htc.h>
    3. #include <pic.h>
    4.  
    5. __CONFIG ( 0x3F32 );
    6.  
    7. #define data                PORTD     //Pins to the LCD D0-D7
    8. #define rs          RC2       //rs of LCD
    9. #define rw          RC0       //rw of LCD
    10. #define en          RC3       //e of LCD
    11. #define in          RE0       //input for RFID
    12.  
    13. // The above pins can be changed according to whicheva u choose
    14.  
    15. void initialize();          
    16. void busy();
    17. void display(unsigned char one[], unsigned char two[]);
    18. void command(unsigned char var);
    19. void send_data(unsigned char var);
    20. void string(unsigned char *var);
    21.  
    22. unsigned char text1[]={"RFID PROJECT"};
    23. unsigned char text2[]={"PLACE YOUR CARD"};
    24. unsigned char text3[]={"CARD ACCEPTED"};
    25. unsigned char text4[]={"CARD REJECTED"};
    26. unsigned char text5[]={"                "};
    27. //Additional text can be placed above. and can be called according to how
    28. //u the calling in the code
    29.  
    30. void main(void)
    31. {
    32. int i, d;
    33. ADCON1 = 0x06;
    34. TRISC=0x00;
    35. TRISD=0X00;
    36. TRISE=0x01;
    37. initialize();
    38. display(text1, text2);
    39. while(1)
    40. {
    41. if (in==1)
    42. {
    43. RC1=1;
    44. display(text3, text5);
    45. busy();
    46.  
    47. }
    48. else
    49. {
    50. RC1=0;
    51. display(text4, text5);
    52. busy();
    53.  
    54. }
    55. }
    56. }
    57.  
    58. void initialize()
    59. {
    60. data=0x38; rs=0; rw=0; en=1; en=0; busy();
    61. data=0x0E; rs=0; rw=0; en=1; en=0; busy();
    62. data=0x01; rs=0; rw=0; en=1; en=0; busy();
    63. data=0x06; rs=0; rw=0; en=1; en=0; busy();
    64. }
    65.  
    66. void busy()
    67. {
    68.  unsigned char i,j;
    69.          for(i=0;i<50;i++)
    70.             for(j=0;j<255;j++);
    71. }
    72.  
    73.  
    74. void command(unsigned char var)
    75. {
    76. data=var; rs=0; rw=0;  en=1; en=0;busy();
    77. }
    78.  
    79. void send_data(unsigned char var)
    80. {
    81.  rs=1;rw=0;  en=1; data=var;  en=0; busy();
    82. }
    83.  
    84. void string(unsigned char *var)
    85. {
    86. while(*var)
    87. send_data(*var++);
    88. }
    89.  
    90. void display(unsigned char one[], unsigned char two[])
    91. {
    92. command(0x80);
    93. string(one);
    94. command(0xC0);
    95. string(two);
    96. busy();
    97. }
    98.  
     
    Last edited by a moderator: Jul 13, 2012
  2. MrChips

    Moderator

    Oct 2, 2009
    12,449
    3,365
    Try lowering the resistance of R2 to about 470Ω.
     
  3. ect_09

    Member

    May 6, 2012
    180
    1
    @trinetra31 can you mail me this schematic on
    abc_ect_09@yahoo.com............
     
  4. absf

    Senior Member

    Dec 29, 2010
    1,493
    372
    In my ISIS simulator there are only 2 relays that allowed me to do animated simulations. The rest of the relays in relay library are only for footprint in PCB making.

    They are namely under "ACTIVE" Library:
    RELAY Animated relay Model
    RELAY2P Animated 2 poles relay Model.

    Allen
     
    Last edited: Jul 13, 2012
Loading...