"MakerBot Replicator" 3D printer is the next step in MiniSumo category:
Strong structured ABS plastics and unordinary design, more design, more solidworks, less makeshift engineerings.
This blog is a full specification of a Mini Sumo Robot with everyday updates and upgrades. The most of the blog is a student engineering skills.
/*IDLE RUN STATE*/ void idleRunUpdate(){ //Conditions for transition to a Line Avoid State if((sensorSum>=16 && sensorSum<=63)||(sensorSum>=80 && sensorSum<=127)||(sensorSum>=208 && sensorSum<=255)){ stateMachine.transitionTo(lineAvoidState); } //Conditions for transition to a Attack State if(sensorSum==2||sensorSum==4||sensorSum==6||sensorSum==7||sensorSum==14){ stateMachine.transitionTo(attackState); } //Conditions for transition to a Spin State if(sensorSum==1||sensorSum==3||sensorSum==8||sensorSum==12){ stateMachine.transitionTo(spinState); } //Conditions for transition to a Overfall Avoid State if((sensorSum>=64 && sensorSum<=79)||(sensorSum>=128 && sensorSum<=143)||(sensorSum>=192 && sensorSum<=207)){ stateMachine.transitionTo(overfallAvoidState); } }
/*IDLE RUN STATE*/ void idleRunUpdate(){ // Serial.println("idleRunUpdate"); switch(sensorSum){ //Conditions for transition to a Line Avoid State case 16 ... 63: case 80 ... 127: case 208 ... 255: stateMachine.transitionTo(lineAvoidState); break; //Conditions for transition to a Attack State case 2: case 4: case 6: case 7: case 14: stateMachine.transitionTo(attackState); break; //Conditions for transition to a Spin State case 1: case 3: case 8: case 12: stateMachine.transitionTo(spinState); break; //Conditions for transition to a Overfall Avoid State case 64 ... 79: case 128 ... 143: case 192 ... 207: stateMachine.transitionTo(overfallAvoidState); break; } }The result has saved 12 bytes of memory
Depth: 495 mm (19.5 in.)PDF product sheet:
Height: 508 mm (20 in.)
Width: 515 mm (20.3 in.)
Weight 25 kg (55 lb)
A resistor ladder is an electrical circuit made of repeating units of resistors. Cited: Wikipedia "Resistor Ladder"
Vout
|
S1
|
S0
|
10bit value
|
0
|
0
|
0
|
0
|
1.25
|
0
|
1
|
256
|
2.50
|
1
|
0
|
512
|
3.75
|
1
|
1
|
768
|
const byte microswitch[]={0, 64, 128, 192};
/*SWITCH DETECT*/ byte Switch(){ int switchVal=analogRead(SWITCH); if(switchVal==0) return 3; if(switchVal>200 && switchVal<300) return 2; if(switchVal>400 && switchVal<600) return 1; if(switchVal>700 && switchVal<800) return 0; }
/*SENSOR DATABYTE*/ void SensorSum(){ sensorSum = sharp_sl[digitalRead(SHARP_SL)] + sharp_fl[digitalRead(SHARP_FL)] + sharp_fr[digitalRead(SHARP_FR)] + sharp_sr[digitalRead(SHARP_SR)] + vishay_l[digitalRead( TCRT_L )] + vishay_r[digitalRead( TCRT_R )] + microswitch[Switch()]; }
Serial.println("{FB_L,T," + String(analogRead(FB_L))+'}'); Serial.println("{FB_R,T," + String(analogRead(FB_R))+'}');
//http://www.arduino.cc/playground/uploads/Code/FSM_1-6.zip #include <FiniteStateMachine.h>Added some more states:
The data sum of 8 sensors might have the result from 0~255 as a byte, so it is not efficient to write a switch-case for that. In order to find all combinations, use windows calc.exe in programmer mode for 1 byte in decimal units. Click "+", "1" and keep clicking "=" to increment the value, check the binary code while clicking.State idleRunState = State(idleRunEnter, idleRunUpdate, NULL); State spinState = State(spinEnter, spinUpdate, spinExit); State lineAvoidState = State(lineAvoidEnter, lineAvoidUpdate, NULL); State attackState = State(attackEnter, attackUpdate, NULL); State overfallAvoidState = State(overfallAvoidEnter, overfallAvoidUpdate, NULL); FiniteStateMachine stateMachine = FiniteStateMachine(idleRunState);
/*IDLE RUN STATE*/ void idleRunEnter(){ motor(50, 50); }Update it with continuous sensor readings, several if's will do the transitions.
(Update 2012.12.14 17:57): Fixed the condition for attackState, was the same as spinState's, in result robot runs stright forward as forever in idleEnter function, no line detection.
void idleRunUpdate(){ SensorSum(); if(sensorSum==1||sensorSum==3||sensorSum==8||sensorSum==12){ stateMachine.transitionTo(spinState); } if((sensorSum>=16 && sensorSum<=63)||(sensorSum>=208 && sensorSum<=255)){ stateMachine.transitionTo(lineAvoidState); } if(sensorSum==2||sensorSum==4||sensorSum==6||sensorSum==7||sensorSum==14){ stateMachine.transitionTo(attackState); } if((sensorSum>=64 && sensorSum<=79)||(sensorSum>=128 && sensorSum<=143)||(sensorSum>=192 && sensorSum<=207)){ stateMachine.transitionTo(overfallAvoidState); } }Under line avoid state are some setups on the enter: a timer, mask, a switch. 2 line sensors are used, so there is 3 combinations of them: left, right and both. Each result drives the system accordingly.
/*LINE AVOID STATE*/void lineAvoidEnter(){ timeOld=millis(); sensorMask=!(sensorSum & 48); switch(sensorSum & 48){ case 16: timer=600; motor( 0, -50); break; case 32: timer=600; motor(-50, 0); break; case 48: timer=1000; motor(-50, -50); break; } }While avoiding the line, scan the sensor readings for a change and ignore the previous sensor, while in state in order not to tristate the state. The state will transit back if timer is out or there is a positive sensor result. But there is a condition for both activated line sensors, it will transit to spin state if no sensor was found after timeout.
Analogical situation in the spin state.void lineAvoidUpdate(){ SensorSum(); if(sensorSum & sensorMask > 0 || millis()-timeOld >=timer*8){ if(sensorMask==!48 && millis()-timeOld>=timer*8){ timeOld=millis(); stateMachine.immediateTransitionTo(spinState); } stateMachine.immediateTransitionTo(idleRunState); } }
Functions not programmed yet./*SPIN STATE*/void spinEnter(){ timeOld=millis(); sensorMask=!(sensorSum & 9); switch(sensorSum & 9){ case 0: timer=1000; motor(-50, +50); break; case 1: timer=1000; motor(-50, +50); break; case 8: timer=1000; motor(+50, -50); break; } } void spinUpdate(){ SensorSum(); if(sensorSum & sensorMask > 0 || millis()-timeOld >=timer*8){ stateMachine.immediateTransitionTo(idleRunState); } } void spinExit(){ }
void attackEnter(){ } void attackUpdate(){ } void attackExit(){ } void overfallAvoidEnter(){ } void overfallAvoidUpdate(){ } void overfallAvoidExit(){ }