#MAKEWITHMAXIM MAXBOT(A low cost Robotic Kit)

Published by Harish Paul in the blog Harish Paul's blog. Views: 703


Introduction
"MAXBOT" is a low cost Robotic Kit using MAX32630FTHR board has the main Controller Core and is mainly designed to initiate development of Low cost Robotic kit as alternate option to costlier Kits like LEGO Mindstorms NXT & EV3 to ensure avoiding cost as a barrier for learning Robotics.
MAXBOT” will feature interfaces to DC motor, Servo , light sensors, Ultrasonic sensor , Bluetooth connectivity and some additional ports that can be used to interface servo’s/Digital/Analog sensors as per user requirement.
Integrated Peripherals of MAX32630FTHR board like Dual-Mode Bluetooth Module and 6-Axis Accelerometer/Gyro was planned to develop a complete Robotic kit for learning
The main advantage of MAXBOT is, programming part of the robot is ensured to be easy and fun by developing a user friendly library ,which the user can import and straight away go ahead with designing and programming robots as per their creativity, without digging deep into the hardware and software.
Has of now Maxbot library is implemented with functionality for Robot Navigation and light sensor, with which user can design a simple to complex(PID) line following robots.
The library will be updated in future with more functionalities to work with other Sensors,Servos,Dual-Mode Bluetooth Module,6-Axis Accelerometer/Gyro etc in future.

BOM
MAX32630FTHR board 1 NoS
l239D Hbridge 1 Nos
DC Motors 2 Nos
10K Resistor 2 Nos
1K Resistor 2 Nos
IR transmitter Receiver Pair 2 Nos
2000mAh Power Bank - 1 Nos
REES52 KG113 Servo Motor-1 Nos
General Purpose PCB-1 Nos
RMC Connectors(3 Pin,4 Pin & 2 PIN) - 7 Nos
Male and Female Berg Stick -1 Nos
Ultrasonic Sensor(HC-SR-04)- 1 Nos
Schematics


Instructions
Developing Maxbot was really fun and challenging , with the new MAX32630FTHR hardware in hand the startup guide really created a confidence of ease working with the board.
The initial development phase involved writing test codes to check interfaces of Maxbot like DC Motor control using H bridge IC and Light sensors.
Even though had some initial problem ,the support from the mbed developers forum was amazing, it may be a error in code or startup guide for customized library development for Maxbot, the support from mbed team was really excellent.
Finally the test code was modified has a user friendly library and found working as per expections.
Maxbot library requires improvements and updation to explore all feature of it, believe the phase has started with this submission
and will be improved with further support and encouragement from the community.

Below are some images of the developed hardware.
IMG_20170612_221347.jpg IMG_20170612_220540.jpg IMG_20170612_220507.jpg IMG_20170612_220527.jpg IMG_20170612_220344.jpg View attachment 128801
IMG_20170612_221347.jpg IMG_20170612_220540.jpg IMG_20170612_220507.jpg IMG_20170612_220527.jpg





Video


Source Code
Maxbot library

Maxbot.cpp file
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Code (Text):
  1.  
  2. #include "Maxbot.h"
  3. #include "mbed.h"
  4. #include "max32630fthr.h"
  5. MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
  6. DigitalOut M1A(P5_0);
  7. DigitalOut M1B(P5_1);
  8. DigitalOut M2A(P5_6);
  9. DigitalOut M2B(P5_5);
  10. PwmOut Enable(P4_0);
  11. AnalogIn   LIGHTSENA(AIN_4);
  12. AnalogIn   LIGHTSENB(AIN_5);
  13. float sensoravalue;
  14. float sensorbvalue;
  15. float PWMPERIOD=0.1;
  16. void move(int direction,float speed,float time)/*Function for Robot Navigation*/
  17. {
  18. speed = speedmap(speed, 10, 100, 0.05, 0.1);
  19. if(direction==FORWARD)
  20. forward(speed,time);
  21. else if(direction==BACKWARD)
  22. backward(speed,time);
  23. else if(direction==LEFTTURN)
  24. leftTurn(speed,time);
  25. else if(direction==POINTLEFTTURN)
  26. pointleftTurn(speed,time);
  27. else if(direction==RIGHTTURN)
  28. rightTurn(speed,time);
  29. else if(direction==POINTRIGHTTURN)
  30. pointrightTurn(speed,time);
  31. }
  32. void forward(float speed,float time)/*Function definition to move forward*/
  33. {
  34. M1A = 1;
  35. M1B = 0;
  36. M2A = 1;
  37. M2B = 0;
  38. Enable.period(PWMPERIOD);
  39. Enable.pulsewidth(speed);
  40. wait(time);
  41. void stop();
  42. }
  43. void backward(float speed,float time)/*Function definition to move backward*/
  44. {
  45. M1A = 0;
  46. M1B = 1;
  47. M2A = 0;
  48. M2B = 1;
  49. Enable.period(PWMPERIOD);
  50. Enable.pulsewidth(speed);
  51. wait(time);
  52. void stop();
  53. }
  54. void leftTurn(float speed,float time)/*Function definition to move leftTurn*/
  55. {
  56. M1A = 0;
  57. M1B = 1;
  58. M2A = 1;
  59. M2B = 0;
  60. Enable.period(PWMPERIOD);
  61. Enable.pulsewidth(speed);
  62. wait(time);
  63. void stop();
  64. }
  65. void pointleftTurn(float speed,float time)/*Function definition to move pointleftTurn*/
  66. {
  67. M1A = 0;
  68. M1B = 0;
  69. M2A = 1;
  70. M2B = 0;
  71. Enable.period(PWMPERIOD);
  72. Enable.pulsewidth(speed);
  73. wait(time);
  74. void stop();
  75. }
  76.  
  77. void rightTurn(float speed,float time)/*Function definition to move rightTurn*/
  78. {
  79. M1A = 1;
  80. M1B = 0;
  81. M2A = 0;
  82. M2B = 1;
  83. Enable.period(PWMPERIOD);
  84. Enable.pulsewidth(speed);
  85. wait(time);
  86. void stop();
  87. }
  88.  
  89. void pointrightTurn(float speed,float time)/*Function definition to move pointrightTurn*/
  90. {
  91. M1A = 1;
  92. M1B = 0;
  93. M2A = 0;
  94. M2B = 0;
  95. Enable.period(PWMPERIOD);
  96. Enable.pulsewidth(speed);
  97. wait(time);
  98. void stop();
  99. }
  100.  
  101. void stop()/*Function definition to stop*/
  102. {
  103. M1A = 0;
  104. M1B = 0;
  105. M2A = 0;
  106. M2B = 0;
  107. Enable.period(PWMPERIOD);
  108. Enable.pulsewidth(0.00f);
  109. }
  110. float speedmap(float in, float inMin, float inMax, float outMin, float outMax)
  111. {
  112.   // check it's within the range
  113.   if (inMin<inMax) {
  114.     if (in <= inMin)
  115.       return outMin;
  116.     if (in >= inMax)
  117.       return outMax;
  118.   } else {  // cope with input range being backwards.
  119.     if (in >= inMin)
  120.       return outMin;
  121.     if (in <= inMax)
  122.       return outMax;
  123.   }
  124.   // calculate how far into the range we are
  125.   float scale = (in-inMin)/(inMax-inMin);
  126.   // calculate the output.
  127.   return outMin + scale*(outMax-outMin);
  128. }
  129.  
  130. float lightSensoranalog(int port) /*function definition for light sensor*/
  131. {
  132. if(port==PORTA)
  133. {
  134. float analogvaluea=analogmap(LIGHTSENA.read(),0.0,1.0,0,100);
  135. return analogvaluea;
  136. }
  137. if(port==PORTB)
  138. {
  139. float analogvalueb=analogmap(LIGHTSENB.read(),0.0,1.0,0,100);
  140. return analogvalueb;
  141. }
  142. }
  143. int lightSensordigital(int port,float value,int condition) /*function definition for light sensor*/
  144. {
  145. if(port==PORTA)
  146. {
  147. float analogvaluea=analogmap(LIGHTSENA.read(),0.0,1.0,0,100);
  148. if(condition==GREATER)
  149. {
  150. printf("light sensor value digital:%f \n",analogvaluea);
  151. if(value>analogvaluea)
  152. return 1;
  153. else
  154. return 0;
  155. }
  156. else if(condition==LESSER)
  157. {
  158. printf("light sensor value digital:%f \n",analogvaluea);
  159. if(value<analogvaluea)
  160. return 1;
  161. else
  162. return 0;
  163. }}
  164. else if(port==PORTB)
  165. {
  166. float analogvalueb=analogmap(LIGHTSENB.read(),0.0,1.0,0,100);
  167. if(condition==GREATER)
  168. {
  169. printf("light sensor value digital:%f \n",analogvalueb);
  170. if(value>analogvalueb)
  171. return 1;
  172. else
  173. return 0;
  174. }
  175. else if(condition==LESSER)
  176. {
  177. printf("light sensor value digital:%f \n",analogvalueb);
  178. if(value<analogvalueb)
  179. return 1;
  180. else
  181. return 0;
  182. }}}
  183. float analogmap(float in, float inMin, float inMax, float outMin, float outMax)
  184. {
  185.   // check it's within the range
  186.   if (inMin<inMax) {
  187.     if (in <= inMin)
  188.       return outMin;
  189.     if (in >= inMax)
  190.       return outMax;
  191.   } else {  // cope with input range being backwards.
  192.     if (in >= inMin)
  193.       return outMin;
  194.     if (in <= inMax)
  195.       return outMax;
  196.   }
  197.   // calculate how far into the range we are
  198.   float scale = (in-inMin)/(inMax-inMin);
  199.   // calculate the output.
  200.   return outMin + scale*(outMax-outMin);
  201. }
  202.  
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Maxbot.h File
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Code (Text):
  1.  
  2. #ifndef Maxbot_h
  3. #define Maxbot_h
  4. #include "mbed.h"
  5. #include "max32630fthr.h"
  6. #define FORWARD 0x1
  7. #define BACKWARD 0x2
  8. #define LEFTTURN 0x3
  9. #define POINTLEFTTURN 0x4
  10. #define RIGHTTURN 0x5
  11. #define POINTRIGHTTURN 0x6
  12. #define PORTA 0x7
  13. #define PORTB 0x8
  14. #define GREATER 0x9
  15. #define LESSER 0x0A
  16. void move(int,float,float);
  17. void forward(float,float);
  18. void backward(float,float);
  19. void leftTurn(float,float);
  20. void pointleftTurn(float,float);
  21. void rightTurn(float,float);
  22. void pointrightTurn(float,float);
  23. float speedmap(float,float,float,float,float);
  24. void stop();
  25. int lightSensordigital(int,float,int);
  26. float lightSensoranalog(int);
  27. float analogmap(float,float,float,float,float);
  28. #endif
  29.  
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Example program demonstrating various robot navigations possible by Maxbot with simple in build functions
Code (Text):
  1.  
  2. #include "Maxbot.h"
  3. void main()
  4. {
  5. move(FORWARD,100,2);   //move(direction,speed(0-100),time(sec))
  6. wait(1);
  7. move(RIGHTTURN,20,3);
  8. wait(1);
  9. move(LEFTTURN,60,4);
  10. wait(1);
  11. move(BACKWARD,90,2);
  12. wait(1);
  13. move(POINTRIGHTTURN,60,2);
  14. wait(1);
  15. move(POINTLEFTTURN,70,1);
  16. wait(1);
  17. stop();
  18. }
  19.  
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Example program demonstrating line following robot using Maxbot with simple in build functions
Code (Text):
  1.  
  2. #include "Maxbot.h"
  3. void main()
  4. {
  5. while(true)
  6. {
  7. int val1=lightSensordigital(PORTA,30,GREATER); //Read's sensor value from Light Sensor connected to PortA
  8. int val2=lightSensordigital(PORTB,30,GREATER); //Read's sensor value from Light Sensor connected to PortB
  9. printf("READNG:%f \n",val1);
  10. printf("READNG:%f \n",val2);
  11. if(val1==1&&val2==1)//Moves Forward when both light sensors are on white area
  12. move(FORWARD,50,.05);
  13. else if(val1==0&&val2==1)//Moves towards Left when Right Light sensors is on black area
  14. move(POINTLEFTTURN,40,.05);
  15. else if(val1==1&&val2==0)//Moves towards Right when Left Light sensors is on black area
  16. move(POINTRIGHTTURN,40,.05);
  17. else if(val1==0&&val2==0)//Moves Forward when both light sensors are on Black area
  18. move(FORWARD,50,.05);
  19. wait(0.1);
  20. }
  21. }
  22.  
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
CAD Files
Attach or link to any CAD files if relevant to your project.
You need to be logged in to comment