View unanswered posts | View active topics It is currently Sat Oct 25, 2014 8:00 am






Reply to topic  [ 7 posts ] 
Controlling Devantech SD21 
Author Message
Rookie

Joined: Sun May 12, 2013 10:15 pm
Posts: 4
Post 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.


Sun May 12, 2013 10:20 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3227
Location: Rotterdam, The Netherlands
Post 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

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Mon May 13, 2013 1:47 am
Profile WWW
Rookie

Joined: Sun May 12, 2013 10:15 pm
Posts: 4
Post 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...


Mon May 13, 2013 7:07 pm
Profile
Rookie

Joined: Sun May 12, 2013 10:15 pm
Posts: 4
Post Re: Controlling Devantech SD21
Aaaaarrrgghhhh

No success!

Any ideas?


Tue May 14, 2013 7:06 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3227
Location: Rotterdam, The Netherlands
Post Re: Controlling Devantech SD21
Do you have a protocol analyser or something like that? They can really help to track down issues.

= Xander

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Tue May 14, 2013 7:17 am
Profile WWW
Rookie

Joined: Sun May 12, 2013 10:15 pm
Posts: 4
Post Re: Controlling Devantech SD21
No I dont have.

Suggestions?

I will google for information.


Tue May 14, 2013 11:21 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3227
Location: Rotterdam, The Netherlands
Post 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

_________________
| Professional Conduit of Reasonableness
| (Title bestowed upon on the 8th day of November, 2013)
| My Blog: I'd Rather Be Building Robots
| ROBOTC 3rd Party Driver Suite: [Project Page]


Tue May 14, 2013 11:41 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 7 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.