caramoan tour package

caramoan tour package

Author Topic: P-Bot Official Thread  (Read 16196 times)

Offline nokia3310

  • CR2032 Battery
  • **
  • Posts: 42
  • Pogi/Ganda Points: 1
Re: P-Bot Official Thread
« Reply #380 on: March 15, 2012, 11:32:22 AM »
mali pa rin kuya eh...
Code: [Select]
digitalRead(Lin_Sen[0] == HIGH)
dapat ganito
Code: [Select]
digitalRead(Lin_Sen[0]) == HIGH
yung result ang ikocompare sa HIGH na constant...

for some programmers it is safer to write it this way para maiwasan ang typo...
Code: [Select]
(HIGH == digitalRead(Lin_Sen[0]))
and enclosed palagi sa parenthesis kung ia-AND sa ibang conditions....

rationale, example isang = lang ang nailagay mo
eto ay di magcocompile so mapupuna mo agad ang mali, dun sa isang case kapag isang = lang ang inilagay mo eh maaring issign nya ang HIGH na value sa variable at magcompile ng tama pero mali ang response.



ok na sir,.. ehehe salamat.. kaya pala.. tnx sa sagot sir..,ung assign sa HIGH and LOW sa M1Run,M2Run, M1Dir at M2Dir medjo titingnan ko pang mabuti kasi sayaw ng sayaw ung pbot :D :D.. ahaha tnx sir,, ;D

Philippine Electronics Forum

Re: P-Bot Official Thread
« Reply #380 on: March 15, 2012, 11:32:22 AM »

Offline nokia3310

  • CR2032 Battery
  • **
  • Posts: 42
  • Pogi/Ganda Points: 1
Re: P-Bot Official Thread
« Reply #381 on: March 15, 2012, 11:34:17 AM »
ako po si TS, nyahahaha,

Natry na ni sir nokia s using PBot library, baka nageexplore lang sya kung paano gawin sa low level,

kahit ako kapag nagcocode ng madalian eh inilalagay ko muna sa surrogate function then kapag gumagana na eh saka ko inililipat sa sarili nyang function. ;D ;D ;D

anong meaning ng TS?.. hehe

Philippine Electronics Forum

Re: P-Bot Official Thread
« Reply #381 on: March 15, 2012, 11:34:17 AM »

Offline glutnix_neo

  • Technical People
  • Nuclear Reactor
  • *****
  • Posts: 4161
  • Pogi/Ganda Points: 166
  • Gender: Female
  • A journey to a thousand lines begins w/ LED Blink
    • Underground Workbench
Re: P-Bot Official Thread
« Reply #382 on: March 15, 2012, 12:27:27 PM »
anong meaning ng TS?.. hehe


Thread Starter
If we hear,we forget;if we see, we remember;if we do,we understand.
Let's support the use of free and open source softwares...
http://UndergroundWorkbench.wordpress.com

Philippine Electronics Forum

Re: P-Bot Official Thread
« Reply #382 on: March 15, 2012, 12:27:27 PM »

Offline nokia3310

  • CR2032 Battery
  • **
  • Posts: 42
  • Pogi/Ganda Points: 1
Re: P-Bot Official Thread
« Reply #383 on: March 16, 2012, 07:54:29 PM »
sir, umugung ung bot pag nkadetect ng obstacle.. dahil po sa nkadetect xa ng line at the same time nkadetect sya ng obstacle..may conflict sa output..ill try to code na indi magconflict..ano po kaya ang mali dito?
. ito po ung code..
Code: [Select]
const int Col_Sen[3] = {2,3,4};
const int Lin_Sen[3] = {5,6,7};
const int M1Dir = 8;
const int M1Run = 9;
const int M2Run = 10;
const int M2Dir = 11;

void setup()
{
  for(int i=0;i<3;i++)
  {
    pinMode(Col_Sen[i],INPUT);
    pinMode(Lin_Sen[i],INPUT);
  }
  
  pinMode(M1Run,OUTPUT);
  pinMode(M2Run,OUTPUT);
  pinMode(M1Dir,OUTPUT);
  pinMode(M2Dir,OUTPUT);
  
  digitalWrite(M1Run,HIGH);
  digitalWrite(M1Dir,HIGH);
}

void loop()
{
  if (digitalRead(Lin_Sen[0]) == LOW && digitalRead (Lin_Sen[1]) == LOW && digitalRead(Lin_Sen[2]) == LOW)//all sensors
  {
    analogWrite(M1Run,75);
    analogWrite(M2Run,75);
    digitalWrite(M1Dir,HIGH);
    digitalWrite(M2Dir,HIGH);
  }
  else if (digitalRead(Lin_Sen[0]) == HIGH && digitalRead(Lin_Sen[1]) == LOW && digitalRead(Lin_Sen[2]) == HIGH)//center snesor
  {
    analogWrite(M1Run,75);
    analogWrite(M2Run,75);
    digitalWrite(M1Dir,HIGH);
    digitalWrite(M2Dir,HIGH);
  }
  else if (digitalRead(Lin_Sen[0]) == LOW && digitalRead(Lin_Sen[1]) == LOW && digitalRead(Lin_Sen[2]) == HIGH)//left center snesor
  {
    analogWrite(M1Run,100);
    analogWrite(M2Run,100);
    digitalWrite(M1Dir,HIGH);
    digitalWrite(M2Dir,LOW);
  }
  else if (digitalRead(Lin_Sen[0]) == HIGH && digitalRead(Lin_Sen[1]) == LOW && digitalRead(Lin_Sen[2]) == LOW)//right center snesor
  {
    analogWrite(M1Run,100);
    analogWrite(M2Run,100);
    digitalWrite(M1Dir,LOW);
    digitalWrite(M2Dir,HIGH);
  }
  else if (digitalRead(Lin_Sen[0]) == LOW && digitalRead(Lin_Sen[1]) == HIGH && digitalRead(Lin_Sen[2]) == HIGH)//left  snesor
  {
    analogWrite(M1Run,100);
    analogWrite(M2Run,100);
    digitalWrite(M1Dir,HIGH);
    digitalWrite(M2Dir,LOW);
  }
  else if (digitalRead(Lin_Sen[0]) == HIGH && digitalRead(Lin_Sen[1]) == HIGH && digitalRead(Lin_Sen[2]) == LOW)//right center snesor
  {
    analogWrite(M1Run,100);
    analogWrite(M2Run,100);
    digitalWrite(M1Dir,LOW);
    digitalWrite(M2Dir,HIGH);
  }
  else if (digitalRead(Lin_Sen[0]) == HIGH && digitalRead(Lin_Sen[1]) == HIGH && digitalRead(Lin_Sen[2]) == HIGH)//no snesor
  {
    analogWrite(M1Run,0);
    analogWrite(M2Run,0);
    digitalWrite(M1Dir,HIGH);
    digitalWrite(M2Dir,HIGH);
  }
  
  if (digitalRead(Col_Sen[0]) == LOW || digitalRead(Col_Sen[1]) == LOW || digitalRead(Col_Sen[2]) == LOW || digitalRead(Lin_Sen[0]) == LOW || digitalRead (Lin_Sen[1]) == LOW || digitalRead(Lin_Sen[2]) == LOW) //must correct the conflicts
  {
    analogWrite(M1Run,0);
    analogWrite(M2Run,0);
    digitalWrite(M1Dir,HIGH);
    digitalWrite(M2Dir,HIGH);
  }
  else
  {
  
  }
  
}

Philippine Electronics Forum

Re: P-Bot Official Thread
« Reply #383 on: March 16, 2012, 07:54:29 PM »

Offline glutnix_neo

  • Technical People
  • Nuclear Reactor
  • *****
  • Posts: 4161
  • Pogi/Ganda Points: 166
  • Gender: Female
  • A journey to a thousand lines begins w/ LED Blink
    • Underground Workbench
Re: P-Bot Official Thread
« Reply #384 on: March 16, 2012, 09:25:17 PM »
eto hinala ko, nagfoforward sya ng saglit bago nagstop then sa next loop ganun na naman...
If we hear,we forget;if we see, we remember;if we do,we understand.
Let's support the use of free and open source softwares...
http://UndergroundWorkbench.wordpress.com

Philippine Electronics Forum

Re: P-Bot Official Thread
« Reply #384 on: March 16, 2012, 09:25:17 PM »

Offline nokia3310

  • CR2032 Battery
  • **
  • Posts: 42
  • Pogi/Ganda Points: 1
Re: P-Bot Official Thread
« Reply #385 on: March 16, 2012, 10:05:19 PM »
eto hinala ko, nagfoforward sya ng saglit bago nagstop then sa next loop ganun na naman...

inilipat ko sa taas ang code na to
Code: [Select]
if (digitalRead(Col_Sen[0]) == LOW || digitalRead(Col_Sen[1]) == LOW || digitalRead(Col_Sen[2]) == LOW || digitalRead(Lin_Sen[0]) == LOW || digitalRead (Lin_Sen[1]) == LOW || digitalRead(Lin_Sen[2]) == LOW) //must correct the conflicts
  {
    analogWrite(M1Run,0);
    analogWrite(M2Run,0);
    digitalWrite(M1Dir,HIGH);
    digitalWrite(M2Dir,HIGH);
  }
bago ito
Code: [Select]
if (digitalRead(Lin_Sen[0]) == LOW && digitalRead (Lin_Sen[1]) == LOW && digitalRead(Lin_Sen[2]) == LOW)//all line sensors


  {
    analogWrite(M1Run,75);
    analogWrite(M2Run,75);
    digitalWrite(M1Dir,HIGH);
    digitalWrite(M2Dir,HIGH);
  }

ganun pa din.. nkaloop kasi.. ano ba mas mainam na code para dito sir?

Offline glutnix_neo

  • Technical People
  • Nuclear Reactor
  • *****
  • Posts: 4161
  • Pogi/Ganda Points: 166
  • Gender: Female
  • A journey to a thousand lines begins w/ LED Blink
    • Underground Workbench
Re: P-Bot Official Thread
« Reply #386 on: March 16, 2012, 10:32:25 PM »
hindi magwowork yan, same pa rin ng dati, this time naooff muna bago magon,

ilagay mo sya sa itaas as "if", then naka else yung rest...
If we hear,we forget;if we see, we remember;if we do,we understand.
Let's support the use of free and open source softwares...
http://UndergroundWorkbench.wordpress.com

Offline glutnix_neo

  • Technical People
  • Nuclear Reactor
  • *****
  • Posts: 4161
  • Pogi/Ganda Points: 166
  • Gender: Female
  • A journey to a thousand lines begins w/ LED Blink
    • Underground Workbench
Re: P-Bot Official Thread
« Reply #387 on: March 17, 2012, 12:11:48 PM »
Napagtripan ko lang...


Code: [Select]
#include <PBot.h>

PBotClass  RoomRover;

#define K_FULL_ROTATE_PERIOD      3000      // 3 Seconds
#define K_BACKOFF_PERIOD          3000      // 3 Seconds
#define K_MAXIDLDE_PERIOD         15000     // No Wall Detected for 15 Seconds, could stucked somewhere

unsigned long ulIdlePeriod;

void setup()
{
  RoomRover.begin(SUMO,WHITE,BLACK,0,9600);
  ulIdlePeriod = millis();
}

void loop()
{
  int iWallState;
 
  iWallState = RoomRover.detectObstacle();
 
  if(iWallState == NO_OBSTACLE)
  {
    if((millis()-ulIdlePeriod) > K_MAXIDLDE_PERIOD)
    {
      ulIdlePeriod = millis();
      PerformManeuver();
    }
    else
    {
      //RoomRover.moveForward(FULLSPEED); 
      RoomRover.turnLeft(20);  // my bias kasi sa right ang PBot ko...
    }
  }
  else
  {
    ulIdlePeriod = millis();
   
    /* Obstacle on left */
    if(iWallState == OBJECT_LEFT)
    {
      RoomRover.turnRight(FULLSPEED);
    }
    /* Obstacle on right */
    else if(iWallState == OBJECT_RIGHT)
    {
      RoomRover.turnLeft(FULLSPEED);
    }
    /* Obstacle on left-center */
    else if(iWallState == OBJECT_LEFTCENTER)
    {
      RoomRover.rotateRight(FULLSPEED);
    }
    /* Obstacle on right-center */
    else if(iWallState == OBJECT_RIGHTCENTER)
    {
      RoomRover.rotateLeft(FULLSPEED);
    }
    else
    {
      PerformManeuver();
    }
  }
}


#define KBL_TURNLEFT        false
#define KBL_TURNRIGHT       true

void PerformManeuver(void)
{
  bool           blTurnDirection = KBL_TURNLEFT;
  unsigned long  ulMotionTimer;
 
  ulMotionTimer = millis();
   
  /* Move Backward for 3Sec */
  while((millis()-ulMotionTimer) < K_BACKOFF_PERIOD)
  {
    RoomRover.moveBackward(FULLSPEED);
  }
 
  if(random(0, 255) < 128)
  {
    blTurnDirection = KBL_TURNLEFT;
  }
  else
  {
    blTurnDirection = KBL_TURNRIGHT;
  }
 
  ulMotionTimer = millis();
  /* Rotate for 5Sec */
  while((millis()-ulMotionTimer) < K_FULL_ROTATE_PERIOD)
  {
    if(KBL_TURNRIGHT == blTurnDirection)
    {
      RoomRover.rotateRight(FULLSPEED);
    }
    else
    {
      RoomRover.rotateLeft(FULLSPEED);
    }
  }
 
  ulIdlePeriod = millis();
}

eto namamasyal si PBot sa kwarto ko,hehehe
If we hear,we forget;if we see, we remember;if we do,we understand.
Let's support the use of free and open source softwares...
http://UndergroundWorkbench.wordpress.com

Offline nokia3310

  • CR2032 Battery
  • **
  • Posts: 42
  • Pogi/Ganda Points: 1
Re: P-Bot Official Thread
« Reply #388 on: March 18, 2012, 10:50:01 PM »
hindi magwowork yan, same pa rin ng dati, this time naooff muna bago magon,

ilagay mo sya sa itaas as "if", then naka else yung rest...
ok sir... indi na xa umuugong... ehehe tnx sir..

Offline nokia3310

  • CR2032 Battery
  • **
  • Posts: 42
  • Pogi/Ganda Points: 1
Re: P-Bot Official Thread
« Reply #389 on: March 25, 2012, 06:26:59 AM »
Napagtripan ko lang...


Code: [Select]
#include <PBot.h>

PBotClass  RoomRover;

#define K_FULL_ROTATE_PERIOD      3000      // 3 Seconds
#define K_BACKOFF_PERIOD          3000      // 3 Seconds
#define K_MAXIDLDE_PERIOD         15000     // No Wall Detected for 15 Seconds, could stucked somewhere

unsigned long ulIdlePeriod;

void setup()
{
  RoomRover.begin(SUMO,WHITE,BLACK,0,9600);
  ulIdlePeriod = millis();
}

void loop()
{
  int iWallState;
 
  iWallState = RoomRover.detectObstacle();
 
  if(iWallState == NO_OBSTACLE)
  {
    if((millis()-ulIdlePeriod) > K_MAXIDLDE_PERIOD)
    {
      ulIdlePeriod = millis();
      PerformManeuver();
    }
    else
    {
      //RoomRover.moveForward(FULLSPEED); 
      RoomRover.turnLeft(20);  // my bias kasi sa right ang PBot ko...
    }
  }
  else
  {
    ulIdlePeriod = millis();
   
    /* Obstacle on left */
    if(iWallState == OBJECT_LEFT)
    {
      RoomRover.turnRight(FULLSPEED);
    }
    /* Obstacle on right */
    else if(iWallState == OBJECT_RIGHT)
    {
      RoomRover.turnLeft(FULLSPEED);
    }
    /* Obstacle on left-center */
    else if(iWallState == OBJECT_LEFTCENTER)
    {
      RoomRover.rotateRight(FULLSPEED);
    }
    /* Obstacle on right-center */
    else if(iWallState == OBJECT_RIGHTCENTER)
    {
      RoomRover.rotateLeft(FULLSPEED);
    }
    else
    {
      PerformManeuver();
    }
  }
}


#define KBL_TURNLEFT        false
#define KBL_TURNRIGHT       true

void PerformManeuver(void)
{
  bool           blTurnDirection = KBL_TURNLEFT;
  unsigned long  ulMotionTimer;
 
  ulMotionTimer = millis();
   
  /* Move Backward for 3Sec */
  while((millis()-ulMotionTimer) < K_BACKOFF_PERIOD)
  {
    RoomRover.moveBackward(FULLSPEED);
  }
 
  if(random(0, 255) < 128)
  {
    blTurnDirection = KBL_TURNLEFT;
  }
  else
  {
    blTurnDirection = KBL_TURNRIGHT;
  }
 
  ulMotionTimer = millis();
  /* Rotate for 5Sec */
  while((millis()-ulMotionTimer) < K_FULL_ROTATE_PERIOD)
  {
    if(KBL_TURNRIGHT == blTurnDirection)
    {
      RoomRover.rotateRight(FULLSPEED);
    }
    else
    {
      RoomRover.rotateLeft(FULLSPEED);
    }
  }
 
  ulIdlePeriod = millis();
}

eto namamasyal si PBot sa kwarto ko,hehehe


sir, pwede bang eparallel ang v2238 na ir sensor sa collision sensor?.. eattach ko ung sensor sa lower front ng pbot para makadetect din xa ng obstacle sa baba.. eparallel connection ko ung bagong ir sensor sa collsion sensor.. pwede po ba un?,

Offline glutnix_neo

  • Technical People
  • Nuclear Reactor
  • *****
  • Posts: 4161
  • Pogi/Ganda Points: 166
  • Gender: Female
  • A journey to a thousand lines begins w/ LED Blink
    • Underground Workbench
Re: P-Bot Official Thread
« Reply #390 on: March 25, 2012, 10:17:30 AM »
paano madidifferentiate ng arduino kung wall sensor sa front  wall sensor sa baba yung nasense nya?

pwede siguro magdagdag ka na lang ng circuit para sa bakanteng input ng arduino.
If we hear,we forget;if we see, we remember;if we do,we understand.
Let's support the use of free and open source softwares...
http://UndergroundWorkbench.wordpress.com

Offline nokia3310

  • CR2032 Battery
  • **
  • Posts: 42
  • Pogi/Ganda Points: 1
Re: P-Bot Official Thread
« Reply #391 on: March 25, 2012, 10:43:06 AM »
paano madidifferentiate ng arduino kung wall sensor sa front  wall sensor sa baba yung nasense nya?

pwede siguro magdagdag ka na lang ng circuit para sa bakanteng input ng arduino.

i mean sir, parallel connection ang mga sensors.. collision sensor of pbot connected in parallel with new collision sensor.. so, either sensor sa baba at sa taas ay iilaw ang led.. pwede ho ba un?

Offline glutnix_neo

  • Technical People
  • Nuclear Reactor
  • *****
  • Posts: 4161
  • Pogi/Ganda Points: 166
  • Gender: Female
  • A journey to a thousand lines begins w/ LED Blink
    • Underground Workbench
Re: P-Bot Official Thread
« Reply #392 on: March 25, 2012, 11:29:56 AM »
pwede sigurong i-OR ang signal using diodes...
If we hear,we forget;if we see, we remember;if we do,we understand.
Let's support the use of free and open source softwares...
http://UndergroundWorkbench.wordpress.com

Offline nokia3310

  • CR2032 Battery
  • **
  • Posts: 42
  • Pogi/Ganda Points: 1
Re: P-Bot Official Thread
« Reply #393 on: March 25, 2012, 01:32:09 PM »
pwede sigurong i-OR ang signal using diodes...


paano po yan sir?.. indi po ba pwedeng edirect ang pagkaconnect in parallel sa collision sensor?

Offline glutnix_neo

  • Technical People
  • Nuclear Reactor
  • *****
  • Posts: 4161
  • Pogi/Ganda Points: 166
  • Gender: Female
  • A journey to a thousand lines begins w/ LED Blink
    • Underground Workbench
Re: P-Bot Official Thread
« Reply #394 on: March 25, 2012, 02:30:38 PM »
At first I'm worried about bus contention, pero nung check ko block diagram ng IR detectors, mukhang pwede naman, itest mo rin lang voltage level kapag na on yung isang sensor tapos nakaoff yung isa....

If we hear,we forget;if we see, we remember;if we do,we understand.
Let's support the use of free and open source softwares...
http://UndergroundWorkbench.wordpress.com

Offline nokia3310

  • CR2032 Battery
  • **
  • Posts: 42
  • Pogi/Ganda Points: 1
Re: P-Bot Official Thread
« Reply #395 on: March 25, 2012, 05:54:15 PM »
At first I'm worried about bus contention, pero nung check ko block diagram ng IR detectors, mukhang pwede naman, itest mo rin lang voltage level kapag na on yung isang sensor tapos nakaoff yung isa....



ito po ung schematic diagram lng collision sensor sa pbot na nasa manual..


ito po ung sensor na parallel, edit lng ko lng po ito.. ask lng ako kung pwede ba ito na connection ng sensor..

Offline glutnix_neo

  • Technical People
  • Nuclear Reactor
  • *****
  • Posts: 4161
  • Pogi/Ganda Points: 166
  • Gender: Female
  • A journey to a thousand lines begins w/ LED Blink
    • Underground Workbench
Re: P-Bot Official Thread
« Reply #396 on: March 25, 2012, 07:26:57 PM »
eto ang catch sa ganyang config, kayanin kaya nung internal transistor ng IR detector yung current ng dalawang 80kOhm in parallel?Kaya kaya nyang ipull down yung signal to logic 0?

malalaman kapag ginawa mo na sa actual, hehehe,
If we hear,we forget;if we see, we remember;if we do,we understand.
Let's support the use of free and open source softwares...
http://UndergroundWorkbench.wordpress.com

Offline dummy_c

  • Diesel Generator
  • *
  • Posts: 1588
  • Pogi/Ganda Points: 162
  • Gender: Male
  • If I die 2nyt, 8's bcoz maimai is not at my side!
Re: P-Bot Official Thread
« Reply #397 on: April 30, 2012, 08:31:56 PM »
Master glutnix_neo matanong lang po.

Ano ibig sabihin sa apat na indicator LEDs nearest po sa motor driver.
Umiilaw po yung apat pero hindi po gumagalaw ang kahit isa sa motor. ;D
Minsan din pag isa or dalawa dito ay turned off, hindi pa rin umiikot yung motor.
Ok naman po yung dalawang fuse.
Na try ko na yung mobot, line at sumo ayaw pa din.
Ang isa sa problema sa mobot ay sira ang toggle switch niya.
Kailangan ko pa kapain para mag ON or charging state.
Maraming salamat po.
The world's technology is always changing, no doubt about it, and I hope it’s a while yet before it impacts my ability to tinker.

Offline glutnix_neo

  • Technical People
  • Nuclear Reactor
  • *****
  • Posts: 4161
  • Pogi/Ganda Points: 166
  • Gender: Female
  • A journey to a thousand lines begins w/ LED Blink
    • Underground Workbench
Re: P-Bot Official Thread
« Reply #398 on: April 30, 2012, 08:46:11 PM »
indicator yun ng direction at drive signal sa motor kung di ako nagkakamali...
If we hear,we forget;if we see, we remember;if we do,we understand.
Let's support the use of free and open source softwares...
http://UndergroundWorkbench.wordpress.com

Offline dummy_c

  • Diesel Generator
  • *
  • Posts: 1588
  • Pogi/Ganda Points: 162
  • Gender: Male
  • If I die 2nyt, 8's bcoz maimai is not at my side!
Re: P-Bot Official Thread
« Reply #399 on: April 30, 2012, 08:49:07 PM »
Yun nga din ang inisip ko sir.
Pero ang pinagtataka ko bakit hindi nag-ikot yung motor.
Salamat pala sa sagot master.
The world's technology is always changing, no doubt about it, and I hope it’s a while yet before it impacts my ability to tinker.

Philippine Electronics Forum

Re: P-Bot Official Thread
« Reply #399 on: April 30, 2012, 08:49:07 PM »

 

Privacy Policy

Contact Us: elabph@yahoo.com