MD25 encoder register problem

Motor, Servo, Speech etc.

Moderator: chris

MD25 encoder register problem

Postby mido86 » Mon Jul 19, 2010 3:56 pm

hi,
at first my English ist not very good, so sorry for that, but ineed help.
ich have a emg30 and a md25 which is connected over i2c to the Atmel NGW100 board.

When I try to read the encoder register (for example every 100 miliseconds) i get sometimes maybe 20 good values
and then a wrong one.
When i set the speed at 128 (stop) and read encoders, the value i read should be 0, but sometimes i get in one of the four bytes of
the encoder registers the value 0xff.

example for what i mean:

reg1 : 0 reg2: 0 reg3:0 reg4:0
reg1 : 0 reg2: 0 reg3:255 reg4:0
reg1 : 0 reg2: 0 reg3:0 reg4:0
reg1 : 0 reg2: 0 reg3:0 reg4:0
...
reg1 : 255 reg2: 0 reg3:0 reg4:0
reg1 : 0 reg2: 0 reg3:0 reg4:0



Code: Select all

long MD25_getTicks(int address,int motor){
//   printf("MD25_getTicks\n");
   long speed=0;

   if (ioctl(device_file,I2C_SLAVE,address) < 0) {
      printf("I2C_SLAVE Error!\n");
      return -1;
   }

   if(motor==0)buf[0]=MD25_ENC_1A;
   else buf[0]=MD25_ENC_2A;
   if(read(device_file,buf,1)!=1){
      printf("I2C Read Error!\n");
      return -1;
   }
   speed=buf[0]<<24;
//   printf("0x%x ",buf[0]);
   if(motor==0)buf[0]=MD25_ENC_1B;
   else buf[0]=MD25_ENC_2B;
   if(read(device_file,buf,1)!=1){
      printf("I2C Read Error!\n");
      return -1;
   }
   speed+=buf[0]<<16;
//   printf("0x%x ",buf[0]);
   if(motor==0)buf[0]=MD25_ENC_1C;
   else buf[0]=MD25_ENC_2C;
   if(read(device_file,buf,1)!=1){
      printf("I2C Read Error!\n");
      return -1;
   }
   speed+=buf[0]<<8;
//   printf("0x%x ",buf[0]);
   if(motor==0)buf[0]=MD25_ENC_1D;
   else buf[0]=MD25_ENC_2D;
   if(read(device_file,buf,1)!=1){
      printf("I2C Read Error!\n");
      return -1;
   }
   speed+=buf[0];

   return speed;
}




Please can someone help as soon as possible.
mido86
 
Posts: 2
Joined: Mon Jul 19, 2010 3:37 pm

Re: MD25 encoder register problem

Postby Gerry » Mon Jul 19, 2010 5:55 pm

Hi,

The MD25 is designed for 5v I2C inputs, I'm not sure about the NGW100 but it may be at 3.3v levels. You might like to check that.
The inputs on the MD25 are required to reach 0.7Vdd. At 5v supply, thats 3.5v. It may not be seeing the 3.3v input correctly and missing some I2C frames.
User avatar
Gerry
Site Admin
 
Posts: 133
Joined: Wed Nov 08, 2006 12:28 pm

Re: MD25 encoder register problem

Postby mido86 » Mon Jul 19, 2010 9:04 pm

The MD25 have only 5 Volt outputs and i only connected the ngw100 with SCL, SDA and 0V-Ground pins.

But i think the ngw don't need to be connected to the 5volt output.

Or did i understund you wrong? If so, please explain to me what you meaned.
mido86
 
Posts: 2
Joined: Mon Jul 19, 2010 3:37 pm


Return to Drivers

Who is online

Users browsing this forum: MSN [Bot] and 1 guest

cron