Ecoduino V1 by geab
[May 19, 2013, 09:58:30 pm]


GPS via Arduino using GPS/GPRS/GSM Module V3.0 (SKU:TEL0051) Not working by LearningRobot
[May 19, 2013, 09:08:59 am]


DFRduino L298p Shield Reverse Problems by jakfourie
[May 18, 2013, 08:08:19 pm]


GPS/GPRS/GSM Module V3.0 (SKU:TEL0051) SIM and Online Connection by csmith04
[May 18, 2013, 01:35:40 am]


KIT0015 - MiniQ Motor Wheel Set with Encoder Issue by GastonLagaffe
[May 17, 2013, 05:29:00 pm]


10 DOF Problems ?? by nestor
[May 17, 2013, 05:06:37 pm]


RoMeo V2 [R3] + DF-BluetoothV3 by Jose
[May 17, 2013, 12:54:51 pm]


2A Motor Shield + Graphic LCD4884 Shield?? by Jose
[May 17, 2013, 12:51:20 pm]


USB host shield not working by Giri
[May 16, 2013, 05:06:19 pm]

Sorry, this shoutbox does not exist.

Author Topic: How to connect encoders to romeo???  (Read 1309 times)

SuperMiguel

  • Jr. Member
  • **
  • Posts: 13
  • Karma: +0/-0
How to connect encoders to romeo???
« on: April 07, 2012, 04:38:49 am »
Hey guys i purchased a HCR-Mobile robot platform a bit ago from you guys, and I'm trying to connect the encoders to an DFRduino Romeo V1.0 that i got from you guys few months ago.. But i can't figure out how to do it.. The only guide you guys have is: http://www.dfrobot.com/wiki/index.php?title=HCR-Mobile_robot_platform_(SKU:ROB00021)#Encoder_Connection_Diagram_V2 but it only shows how to connect it to the regular arduino no the Romeo…

Please explain how to do it.. ANd if you have some sample code of how to use the encoder i would love to see it

SuperMiguel

  • Jr. Member
  • **
  • Posts: 13
  • Karma: +0/-0
Re: How to connect encoders to romeo???
« Reply #1 on: April 07, 2012, 04:41:47 am »
Note I have the new style of encoders wires: White, Yellow, Green, Blue

SuperMiguel

  • Jr. Member
  • **
  • Posts: 13
  • Karma: +0/-0
Re: How to connect encoders to romeo???
« Reply #2 on: April 07, 2012, 04:52:06 am »
i kinda figure how to connect them.. I did:

Green to GND
Blue to VCC
Yellow to D4
White to D1

Tried this code:

Code: [Select]
const byte encoder0pinA = 2;//A pin -> 6
const byte encoder0pinB = 4;//B pin -> the digital pin 4
byte encoder0PinALast;
int duration;//the number of the pulses
boolean Direction;//the rotation direction


void setup()

  Serial.begin(57600);//Initialize the serial port
  EncoderInit();//Initialize the module
}

void loop()
{
  Serial.print("Pulse:");
  Serial.println(duration);
  duration = 0;
  delay(500);
}

void EncoderInit()
{
  Direction = true;//default -> Forward 
  pinMode(encoder0pinB,INPUT); 
  attachInterrupt(0, wheelSpeed, CHANGE);
}

void wheelSpeed()
{
  int Lstate = digitalRead(encoder0pinA);
  if((encoder0PinALast == LOW) && Lstate==HIGH)
  {
    int val = digitalRead(encoder0pinB);
    if(val == LOW && Direction)
    {
      Direction = false; //Reverse
    }
    else if(val == HIGH && !Direction)
    {
      Direction = true;  //Forward
    }
  }
  encoder0PinALast = Lstate;

  if(!Direction)  duration++;
  else  duration--;
}

but the motors wont move...

SuperMiguel

  • Jr. Member
  • **
  • Posts: 13
  • Karma: +0/-0
Re: How to connect encoders to romeo???
« Reply #3 on: April 07, 2012, 04:53:22 am »
nvm got it

Hector

  • Not an
  • Hero Member
  • *****
  • Posts: 788
  • Karma: +21/-2
    • Follow us on Twitter for coupons and product updates!
Re: How to connect encoders to romeo???
« Reply #4 on: April 09, 2012, 10:40:24 am »
Cool,


Glad you got it working.
-Hector

Follow us on TWITTER for announcements of specials and product updates! Along with interesting open source robotics news!

jtilghman

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
Re: How to connect encoders to romeo???
« Reply #5 on: September 21, 2012, 11:08:17 pm »
nvm got it

Would love to see the code you got working.

 

SimplePortal 2.3.4 RC1 © 2008-2011, SimplePortal