programming EMG30

i need help on programming a EMG30 gear motor with a MD25 drive

am using the sample code made by James Henderson "MD25 RD02 Motor Controller Serial" from the robot-electronics.co.uk website

but i have no idea why it doesn't work. actually most of the codes for the EMG30 which are on blogs are out data or have error when uploading them. some help would be great.

link below look at "MD25 RD02 Motor Controller Serial" setup: http://www.robot-electronics.co.uk/htm/arduino_examples.htm#MD25%20RD02%20Motor%20Controller

code: http://www.robot-electronics.co.uk/files/arduino_md25_serial.ino

i have no idea why it doesn't work

Define, for us, "work" and possibly "doesn't work". Without these definitions, helping you is going to be difficult.

same here…no idea why, now i just connected the EMG30 straight to the Arduino with a simple code reading the encoder feedback as the motor is spinning. would anyone know how i would be able to control the motor with the feedback am getting from the encoder.

code is below:

/* Rotary encoder read */
#define ENC_A 14
#define ENC_B 15
#define ENC_PORT PINC

int motorPin = 9;
int start = 0;

void setup()
{
pinMode(motorPin, OUTPUT);
/* Setup encoder pins as inputs */
pinMode(ENC_A, INPUT);
digitalWrite(ENC_A, HIGH);
pinMode(ENC_B, INPUT);
digitalWrite(ENC_B, HIGH);
Serial.begin (115200);
Serial.println(“Start”);
}

/*

  • loop() – this function will start after setup finishes and then repeat
  • we call a function called motorOnThenOff()
    */

void loop() // run over and over again
{

// read the encoder once every loop
static uint8_t counter = 0; //this variable will be changed by encoder input
int8_t tmpdata;
/**/
tmpdata = read_encoder();
if( tmpdata ) {
Serial.print("Counter value: ");
Serial.println(counter, DEC);
counter += tmpdata;
}

// first loop kick starts the motor so we begin to get a value back
if (start < 500) {
runStartUpCalibration();
}

if (start >= 500){
if (counter < 127) {
digitalWrite(motorPin,HIGH);
}
else {
digitalWrite(motorPin,LOW);
}
}
}

void runStartUpCalibration(){
digitalWrite(motorPin,HIGH);
static uint8_t counter = 0; //this variable will be changed by encoder input
int8_t tmpdata;
tmpdata = read_encoder();
if( tmpdata ) {
Serial.print(“running ca”);
Serial.println(counter, DEC);
counter += tmpdata;
}
delay(10);
start++;
}

/* returns change in encoder state (-1,0,1) */

int8_t read_encoder()
{
static int8_t enc_states = {
0,-1,1,0,1,0,0,-1,-1,0,0,1,0,1,-1,0 };
static uint8_t old_AB = 0;
/**/
old_AB <<= 2; //remember previous state
old_AB |= ( ENC_PORT & 0x03 ); //add current state
return ( enc_states[( old_AB & 0x0f )]);
}

can no one really not help with this question?

can no one really not help with this question?

With the lack of information you have provided, no. That code does something. You want it to do something. What those two somethings are, though, is a mystery.

i need help on programming a EMG30 gear motor with a Arduino uno drive

How can I connect a EMG30 with arduino and control it. I need a motor mandir like Adafruit Shield? I would be grateful if someone can help me greeting

link below: http://www.robot-electronics.co.uk/htm/emg30.htm

http://www.adafruit.com/product/81

i need help on programming a EMG30 gear motor with a Arduino uno drive

To do what?

How can I connect a EMG30 with arduino and control it.

The colors are shown on the page you "linked". You can't connect the motor to the Arduino without a shield. With a shield, you connect the motor wires to the motor out pins.

The + and ground for the hall effect sensor should be pretty obvious.

The code above looks OK for reading the encoder, if you connect the A and B lines to pins 14 and 15 (analog pins 0 and 1).