Microcontroller based robot project

Discussion in 'Embedded Systems and Microcontrollers' started by jibinsabu, Feb 18, 2016.

  1. jibinsabu

    Thread Starter New Member

    Feb 18, 2016
    7
    0
    Hi,
    Please help me to solve the issue with my project..i am doing an rf controlled fire fighter robot using AT89S52 microcontroller..all the communications are good..decoder output is good..microcontroller input is ok..but the output have no response. I here upload the circuit and program
    .please help me because it is very urgeng gor me.
    Thanks
     
  2. JohnInTX

    Moderator

    Jun 26, 2012
    2,347
    1,029
    Welcome to AAC!
    To help us help you, please post your code in text using CODE tags (available from the toolbar). Also, post a schematic of your circuit.
    What does 'output have no response' mean? Motors, spray or what?
    How do you know that the RF is working and that communications are good?
    Which compiler and debugger are you using?
     
  3. GopherT

    AAC Fanatic!

    Nov 23, 2012
    6,061
    3,826
    @jibinsabu

    In Rf_process()
    Your "Move backward", you have a single & instead of && like the rest of your logical check

    Also, we need a schematic to really help you because I cannot tell of a Pump=0 is turning the water on or off.
     
    Last edited: Feb 19, 2016
  4. jibinsabu

    Thread Starter New Member

    Feb 18, 2016
    7
    0
    Please tell me a solution..i want to check whether the microcontroller is working.
     
  5. GopherT

    AAC Fanatic!

    Nov 23, 2012
    6,061
    3,826

    This is too difficult.

    You need to copy your code.
    Paste it into a post here.
    Type the phrase CODE inside of square brackets [ ] at the top of your code
    Type the phrase [/CODE] at the bottom of your code

    That way we can read the whole thing.

    Then you need to tell us how you expect this to work with a short text. We cannot see anything about the RF, what exactly is not working, what is working.
    What pins di what.
     
  6. jibinsabu

    Thread Starter New Member

    Feb 18, 2016
    7
    0
    Code (C):
    1.  
    2. ///////////NAVGATION MOTORS DEFINE/////////////
    3. sbit M21=P2^0;
    4. sbit M22=P2^1;
    5.  
    6. sbit M23=P2^2;
    7. sbit M24=P2^3;
    8.  
    9.         ////////ARM MOTORS DEFINE/////////
    10. sbit M11=P2^4;
    11. sbit pump=P2^7;
    12.  
    13. sbit M13=P2^6;
    14. sbit M14=P2^7;
    15.  
    16.         ///////////DATA LINE///////////
    17. sbit D1=P1^0;
    18. sbit D2=P1^1;
    19. sbit D3=P1^2;
    20. sbit D4=P1^3;
    21. sbit VT=P1^4;
    22.  
    23.  
    24. sbit mode_led=P0^1;    // mode indicating led
    25. void rf_process2();
    26. void armcontrole();
    27.  
    28.  
    29. void Delay(int a)
    30. {
    31.     int j;
    32.     int i;
    33.     for(i=0;i<a;i++)
    34.     {
    35.         for(j=0;j<120;j++)
    36.         {
    37.         }
    38.     }
    39. }
    40.  
    41.  
    42.  
    43.  
    44.  
    45.  
    46.  
    47. void main()
    48. {
    49. P1=0XFF;
    50. P2=0X00;
    51. VT=1;
    52. while(1)
    53.     {
    54.         rf_process2();  
    55.         armcontrole();
    56.     }
    57. }
    58. //////////////////////
    59.  
    60.  
    61.  
    62.  
    63. void rf_process2()
    64. { mode_led=1;
    65.     {
    66.  
    67.  
    68. // move the robot forword
    69.      
    70. if(D1==1&&D2==1&&D3==1&&D4==0&&VT==1)
    71.         {
    72.             M21=1;
    73.             M22=0;
    74.             M23=1;
    75.             M24=0;
    76.             }
    77.  
    78. // move the robot backword
    79.     else if(D1==1&&D2==1&D3==0&&D4==1&&VT==1)
    80.         {
    81.             M21=0;
    82.             M22=1;
    83.             M23=0;
    84.             M24=1;  
    85.         }
    86.  
    87. // move the robot right
    88.     else if(D1==0&&D2==1&&D3==1&&D4==1&&VT==1)
    89.         {
    90.             M21=1;
    91.             M22=0;
    92.             M23=0;
    93.             M24=0;
    94.         }
    95.  
    96. // move the robot left
    97.     else if(D1==1&&D2==0&&D3==1&&D4==1&&VT==1)
    98.         {
    99.             M21=0;
    100.             M22=0;
    101.             M23=1;
    102.             M24=0;  
    103.           }
    104.  
    105.  
    106. ///    else stop
    107.     else
    108.         {
    109.             M21=0;
    110.             M22=0;
    111.             M23=0;
    112.             M24=0;
    113.             Delay(200);  
    114.         }
    115.  
    116.  
    117.  
    118. }  
    119. }
    120.  
    121.  
    122. ///// arm control mode
    123.  
    124. void armcontrole()
    125. {
    126.  
    127.     if(D1==0 && D2==0 && D3==1 && D4==1 && VT==1)
    128.         {
    129.         while(D1==0&&D2==0&&D3==0&&D4==1&&VT==1);
    130.         while(1)
    131.         { mode_led=0;
    132.  
    133.  
    134.  
    135. //increase the angle of the arm
    136.      
    137.             if(D1==1&&D2==1&&D3==1&&D4==1&&VT==1)
    138.             {
    139.              M13=1;
    140.              M14=0;
    141.             }
    142.  
    143. //decrease the angle of the arm
    144.  
    145.             else if(D1==1&&D2==1&&D3==1&&D4==1&&VT==1)
    146.             {
    147.              M13=0;
    148.              M14=1
    149.              }
    150. //spray 'on'      
    151.                   else if(D1==1&&D2==0&&D3==1&&D4==1&&VT==1)
    152.             { pump=0;
    153.            
    154.            
    155.                 /////spray off
    156.             }
    157.             else if(D1==0&&D2==0&&D3==1&&D4==1&&VT==1)
    158.             {
    159.              while(D1==0&&D2==0&&D3==1&&D4==1&&VT==1);
    160.            
    161.             }
    162. // stop
    163.                 else
    164.                 {
    165.             M11=0;
    166.             pump=1;
    167.             M13=0;
    168.             M14=0;
    169.             Delay(200);  
    170.         }
    171.      
    172.          }
    173.         }
    174. }
    175.  





    This is the program.

    Thanks.

    This is rf controlled fire fighter robot..we used at89s52 microcontroller..

    MOD note: Added CODE-tags.
     
    Last edited by a moderator: Feb 19, 2016
  7. GopherT

    AAC Fanatic!

    Nov 23, 2012
    6,061
    3,826
    Line 79 above, you are still missing an &
    else if(D1==1&&D2==1&D3==0&&D4==1&&VT==1)

    it should probably be...
    else if(D1==1&&D2==1&&D3==0&&D4==1&&VT==1)


    Also, are you sure you want the
    While(1)
    in line 130 above? What situation will you need it to get caught in that loop forever?
     
  8. jibinsabu

    Thread Starter New Member

    Feb 18, 2016
    7
    0
    Sir,
    I think the program is correct. It is not my program. I bought a programmed microcontroller from a company.
     
  9. GopherT

    AAC Fanatic!

    Nov 23, 2012
    6,061
    3,826
    A combination of bit wise AND (&) and logical AND (&&) in the same statement does not make any sense.
     
  10. jibinsabu

    Thread Starter New Member

    Feb 18, 2016
    7
    0
    Sir,
    What will be the voltages at the port pins of the microcontroller on startup.?
     
  11. jibinsabu

    Thread Starter New Member

    Feb 18, 2016
    7
    0
    Sir,
    These are the critical days of my life that i have only 1 week to submit my project.
    I am doing a project on rf controlled fire fighter robot using 8051.
    But i can't make a good program for my project.
    I will breifly explain my project.
    My project have 2 motors for wheels
    And 1 more motor for controlling the robotic arm.
    Robotic arm is supplied with a pump which can pump water.

    The control is using a remote which consists of 4 push buttons.

    So,
    There is 2 modes: robot navigation mode and arm control mode.

    The transmission is done through rf modules with ht12e and ht12d ics.The rf communication is working.ok

    I will tell the operation,
    Robot navigation mode,
    D4 pushbutton press : robot forward
    D3 : robot backward
    D1 : robot right
    D2 : robot left

    Arm conrol mode.
    There is an led indication for this mode.
    Press D1 and D2 together to switch to this mode.at this time the led must glow.
    (but i dont know the program for return back to navigation mode by pressing the same buttons together.please)

    Then, in this mode,
    D4 : increase arm angle
    D3: decrease arm angle
    D2: spray/pump on

    This is the only requirments.

    I made a program with this requirements , but i am not sure about its accuracy. I am only a begginer of programming.i here include my program and image of proposed project.

    Please tell me if there any errors/ modifications.thanka lot.
    Code (C):
    1.  
    2. [LIST=1]
    3. [*]#include<AT89x52.h>
    4. [*]///////////NAVGATION MOTORS DEFINE/////////////
    5. [*]sbit M21=P2^0;
    6. [*]sbit M22=P2^1;
    7. [*]
    8.  
    9. [*]sbit M23=P2^2;
    10. [*]sbit M24=P2^3;
    11. [*]
    12.  
    13. [*]       ////////ARM MOTORS DEFINE/////////
    14. [*]sbit M11=P2^4;
    15. [*]sbit pump=P2^5;
    16. [*]
    17.  
    18. [*]sbit M13=P2^6;
    19. [*]sbit M14=P2^7;
    20. [*]
    21.  
    22. [*]       ///////////DATA LINE///////////
    23. [*]sbit D1=P1^0;
    24. [*]sbit D2=P1^1;
    25. [*]sbit D3=P1^2;
    26. [*]sbit D4=P1^3;
    27. [*]sbit VT=P1^4;
    28. [*]
    29.  
    30. [*]
    31.  
    32. [*]sbit mode_led=P0^1;   // mode indicating led
    33. [*]void rf_process2();
    34. [*]void armcontrole();
    35. [*]
    36.  
    37. [*]
    38.  
    39. [*]void Delay(int a)
    40. [*]{
    41. [*]   int j;
    42. [*]   int i;
    43. [*]   for(i=0;i<a;i++)
    44. [*]   {
    45. [*]       for(j=0;j<120;j++)
    46. [*]       {
    47. [*]       }
    48. [*]   }
    49. [*]}
    50.  
    51.  
    52. [*]void main()
    53. [*]{
    54. [*]P1=0XFF;
    55. [*]P2=0X00;
    56. [*]VT=1;
    57. [*]while(1)
    58. [*]   {
    59. [*]        rf_process2();
    60. [*]        armcontrole();
    61. [*]   }
    62. [*]}
    63. [*]//////////////////////
    64.  
    65. [*]void rf_process2()
    66. [*]{
    67. [*]mode_led=0;
    68. [*]   {
    69. [*]
    70.  
    71. [*]
    72.  
    73. [*]// move the robot forword
    74. [*]
    75. [*]if(D1==1&&D2==1&&D3==1&&D4==0&&VT==1)
    76. [*]       {
    77. [*]            M21=1;
    78. [*]            M22=0;
    79. [*]            M23=1;
    80. [*]            M24=0;
    81. [*]           }
    82. [*]
    83.  
    84. [*]// move the robot backword
    85. [*]   else if(D1==1&&D2==1&&D3==0&&D4==1&&VT==1)
    86. [*]       {
    87. [*]            M21=0;
    88. [*]            M22=1;
    89. [*]            M23=0;
    90. [*]            M24=1;
    91. [*]       }
    92. [*]
    93.  
    94. [*]// move the robot right
    95. [*]   else if(D1==0&&D2==1&&D3==1&&D4==1&&VT==1)
    96. [*]       {
    97. [*]            M21=1;
    98. [*]            M22=0;
    99. [*]            M23=0;
    100. [*]            M24=0;
    101. [*]       }
    102. [*]
    103.  
    104. [*]// move the robot left
    105. [*]   else if(D1==1&&D2==0&&D3==1&&D4==1&&VT==1)
    106. [*]       {
    107. [*]            M21=0;
    108. [*]            M22=0;
    109. [*]            M23=1;
    110. [*]            M24=0;
    111. [*]         }
    112. [*]
    113.  
    114. [*]
    115.  
    116. [*]///    else stop
    117. [*]   else
    118. [*]       {
    119. [*]            M21=0;
    120. [*]            M22=0;
    121. [*]            M23=0;
    122. [*]            M24=0;
    123. [*]            Delay(200);
    124. [*]       }
    125.  
    126.  
    127. [*]}
    128. [*]}
    129.  
    130. [*]///// arm control mode
    131. [*]
    132.  
    133. [*]void armcontrole()
    134. [*]{
    135. [*]
    136.  
    137. [*]   if(D1==0 && D2==0 && D3==1 && D4==1 && VT==1)
    138. [*]       {
    139. [*]       while(D1==0&&D2==0&&D3==0&&D4==1&&VT==1); // i want to change back to rf_process2 mode here i dont know
    140. [*]       while(1)
    141. [*]         }
    142. [*]       {
    143. [*]mode_led=1;
    144.  
    145.  
    146. [*]//increase the angle of the arm
    147. [*]
    148. [*]           if(D1==1&&D2==1&&D3==1&&D4==0&&VT==1)
    149. [*]           {
    150. [*]             M13=1;
    151. [*]             M14=0;
    152. [*]           }
    153. [*]
    154.  
    155. [*]//decrease the angle of the arm
    156. [*]
    157.  
    158. [*]           else if(D1==1&&D2==1&&D3==0&&D4==1&&VT==1)
    159. [*]           {
    160. [*]             M13=0;
    161. [*]             M14=1
    162. [*]             }
    163. [*]//spray 'on'  
    164. [*]                 else if(D1==1&&D2==0&&D3==1&&D4==1&&VT==1)
    165. [*]           {
    166. [*]pump=1;
    167. [*]   }    
    168. [*]      
    169. [*]          
    170. [*]// stop
    171. [*]               else
    172. [*]               {
    173. [*]            M11=0;
    174. [*]            pump=1;
    175. [*]            M13=0;
    176. [*]            M14=0;
    177. [*]            Delay(200);
    178. [*]       }
    179. [*]
    180. [*]         }
    181. [*]       }
    182. [*]}
    183. [/LIST]
    184.  
    This is the program.

    Thanks.

    Mod edit: added code tags. Moved new thread to here - please do not start more than one thread on the same topic.
     
    Last edited by a moderator: Feb 27, 2016
  12. JohnInTX

    Moderator

    Jun 26, 2012
    2,347
    1,029
    You still haven't told us what it is and is not doing that it should be doing. One thing to do for sure is reorder your tests with parenthesis i.e.

    if(D1==1&&D2==1&&D3==1&&D4==0&&VT==1)
    Should be
    if ( (D1==1) && (D2==1) && (D3==1) && (D4==0) && (VT==1) )

    && has a higher order of precedence than ==. Your test evaluates 1&&D2 instead of testing D2==1 and so on. Not what you want.
     
    Last edited: Feb 27, 2016
  13. jibinsabu

    Thread Starter New Member

    Feb 18, 2016
    7
    0
    Then, is there any corrections? Does this work?
     
  14. JohnInTX

    Moderator

    Jun 26, 2012
    2,347
    1,029
    I don't know. According to Google you are 9444 miles closer to your workbench than I am. The best advice I can give you is to fix up all of those test statements and try it. If it still does not work, break the code into one single small section and get that working then use what you learn from that to apply to the rest of the functions. We can not give you a canned solution based on the info you have provided and likely wouldn't in any case because this is your project. If this is to move to completion, it will be up to you to do it.

    Good luck
     
Loading...