ROBOTC.net forums
http://robotc.net/forums/

Controlling Devantech SD21
http://robotc.net/forums/viewtopic.php?f=41&t=5842
Page 1 of 1

Author:  rosg86 [ Sun May 12, 2013 10:20 pm ]
Post subject:  Controlling Devantech SD21

Hi,

I'm new here. And I need some help.

I'm trying to control de Devantech SD21 using NXT.

Here is what I've done so far:


Code:
#pragma config(Sensor, S1,     ,               sensorI2CCustom)

const tSensors kSc8Port       = S1;   

task main()
{
   ubyte sc8Msg[5];
 
 position=1200;

  // Build the I2C message
  sc8Msg[kMsgSize]          = 3;
  sc8Msg[kSc8Address]       = 0xC2;
  sc8Msg[kSc8Servo]         = 63;
  sc8Msg[kData_low]         = (ubyte)position;

  while (nI2CStatus[kSc8Port] == STAT_COMM_PENDING)
  {
   // Wait for I2C bus to be ready
  }
  // when the I2C bus is ready, send the message you built
  sendI2CMsg(kSc8Port, &sc8Msg[0], 0);
 
  wait10Msec(100);
 
  position=1700;
 
    // Build the I2C message
  sc8Msg[kMsgSize]          = 3;
  sc8Msg[kSc8Address]       = 0xC2;
  sc8Msg[kSc8Servo]         = 63;
  sc8Msg[kData_low]         = (ubyte)position;
  //sc8Msg[kData_hi]          = position/0x100;

  while (nI2CStatus[kSc8Port] == STAT_COMM_PENDING)
  {
   // Wait for I2C bus to be ready
  }
  // when the I2C bus is ready, send the message you built
  sendI2CMsg(kSc8Port, &sc8Msg[0], 0);
 
  wait10Msec(100);

}


No reaction... servo simply dont move.

I'm using 2 x 47k resistors as pullups for SDA and SCL.

Author:  mightor [ Mon May 13, 2013 1:47 am ]
Post subject:  Re: Controlling Devantech SD21

You definitely need to send both high and low bytes at the same time, not in two transactions.
Code:
  sc8Msg[0] = 4;
  sc8Msg[1] = 0xC2;
  sc8Msg[2] = 63;
  sc8Msg[3] = position & 0xFF;
  sc8Msg[4] = (position >> 8) & 0xFF;


As for pull-ups, 82K may be more suitable, YMMV.

= Xander

Author:  rosg86 [ Mon May 13, 2013 7:07 pm ]
Post subject:  Re: Controlling Devantech SD21

=/

I did it. Changed the Resistors but... no success...

I think I am misusing the registers... but I dont know... gonna research more...

Author:  rosg86 [ Tue May 14, 2013 7:06 am ]
Post subject:  Re: Controlling Devantech SD21

Aaaaarrrgghhhh

No success!

Any ideas?

Author:  mightor [ Tue May 14, 2013 7:17 am ]
Post subject:  Re: Controlling Devantech SD21

Do you have a protocol analyser or something like that? They can really help to track down issues.

= Xander

Author:  rosg86 [ Tue May 14, 2013 11:21 am ]
Post subject:  Re: Controlling Devantech SD21

No I dont have.

Suggestions?

I will google for information.

Author:  mightor [ Tue May 14, 2013 11:41 am ]
Post subject:  Re: Controlling Devantech SD21

Try to make it work with the I2C test program in ROBOTC first, so you can rule out code issues.

= Xander

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/