OpenServo.com Forum Index OpenServo.com
Discussion of the OpenServo project
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Trouble with Open servo v2
Goto page 1, 2  Next
 
Post new topic   Reply to topic    OpenServo.com Forum Index -> Hardware
View previous topic :: View next topic  
Author Message
enigma460



Joined: 12 Feb 2008
Posts: 23

PostPosted: Sat Dec 20, 2008 7:50 pm    Post subject: Trouble with Open servo v2 Reply with quote

Back again.

I had a discussion with Ginge earlier in the year (Feb 2008) with regards to the OSIF and the issues.

Well I decided to try again using the Devantech Interface.

Bye the way it can be located here:

http://www.hvwtech.com/products_view.asp?ProductID=948

I purchased 10 OSV2 finished boards from Jay last year.

Known :

The interface works as tested with several I2C devices, Lcd Displays,
Sonar device, EEproms etc.

Testing:

Supplying 6.6 volts to the OSV2

To read from a I2C device with 1 byte internal address register I use the command 0x55(I2C_AD1) 0x21(OSV2 address) 0x00(address register) 0x30(read 48 bytes) (as indicated in the construction tutorial http://www.openservo.com/ConstructionTutorial

It returns 48 0xFF's

Any ideas to what I might be doing wrong.
Back to top
View user's profile Send private message
ginge
Site Admin


Joined: 14 Jan 2006
Posts: 1029
Location: Manchester, UK

PostPosted: Sun Dec 21, 2008 12:25 pm    Post subject: Reply with quote

Hi,

Quote:
0x21(OSV2 address)


This is 100% the address you set? The V2 shipped with the address of 0x10 by default, and assuming your I2C master does the shifting of the bits for R/W, it should respond at this address.

What does your devantech device say about NACKing and the returned values 0xFF?
_________________
http://www.headfuzz.co.uk/
http://www.robotfuzz.co.uk/
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
ginge
Site Admin


Joined: 14 Jan 2006
Posts: 1029
Location: Manchester, UK

PostPosted: Sun Dec 21, 2008 2:15 pm    Post subject: Reply with quote

Hi again Enigma460,

I just read the devantec datasheet, and have the following suggestions:

the devantech does no address shifting for you, so you will need to follow this transaction pattern...

Most 1 bit addressed devices (OpenServo included) require 2 I2C transactions. one to set the address we are reading from, and then the read transaction. The devantech device does not make it clear that it will write the address before issuing a repeated start, and the address | 1 makes me believe that it probably does not.

In which case, can you try...

1) Write the address of the device and register to be written from ((device address <<1 | R/W))
2) Write the address of the device and start reading.

in USB-I2C speak this translates to:

0x55(I2C_AD1) 0x20(OSV2 write address) 0x00(address register) 0x01(write 1 byte)
0x55(I2C_AD1) 0x21(OSV2 read address) 0x00(address register) 0x30(read 48 bytes)

The example Win32 C application included with the product has a terribly documented example, which I have altered to suit OpenServo ( I hope)

Code:

//Write the address we are reading from
sbuf[0] = I2C_CMD;
      sbuf[1] = 0x20;
      sbuf[2] = 0x00;
      sbuf[3] = 0x01;
       WriteFile(hCom, &sbuf, 4, &n, NULL);
      ReadFile(hCom, &sbuf, 1, &n, NULL);

//Read the data
sbuf[0] = I2C_CMD;
      sbuf[1] = 0x21;
      sbuf[2] = 0x00;
      sbuf[3] = 0x30;
       WriteFile(hCom, &sbuf, 4, &n, NULL);
      ReadFile(hCom, &sbuf, 48, &n, NULL);


Let me know if makes any difference.

Cheers
_________________
http://www.headfuzz.co.uk/
http://www.robotfuzz.co.uk/
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
enigma460



Joined: 12 Feb 2008
Posts: 23

PostPosted: Sun Dec 21, 2008 5:14 pm    Post subject: Reply with quote

Thanks Ginge. I'll look into what you said.

I'm using realterm to send the commands.

Freeware: http://realterm.sourceforge.net/

I tried 0x10 and 0x11 with no response other than 0xFF's
Used 0x20 an 0x21 when I saw the comment at http://www.openservo.com/moin.cgi/ConstructionTutorial

I tried using the 0x54 command and got the following response.
This command is used to read multiple bytes without setting new address.
Every time I send the command , the response is different.
Does the following make any sense to you

[20/12/2008 20:07:24] - Written data

54 21 2f T!/

[20/12/2008 20:07:24] - Read data

00 07 00 00 00 00 00 00 00 00 10 30 00 00 00 00 ...........0....
00 00 00 60 03 a0 00 28 28 28 28 28 28 28 28 28 ...`. .(((((((((
28 28 00 00 00 00 00 00 00 00 00 00 00 00 00 ((.............

[20/12/2008 20:07:56] - Written data

54 21 2f T!/

[20/12/2008 20:07:56] - Read data

00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 28 28 28 28 28 ...........(((((
28 28 28 28 28 28 28 28 28 28 28 00 00 00 00 (((((((((((....

[20/12/2008 20:08:11] - Written data

54 21 2f T!/

[20/12/2008 20:08:11] - Read data

00 00 00 00 00 00 00 00 00 00 00 00 01 01 00 02 ................
00 03 58 9f 00 3e 00 00 00 00 00 00 01 7a 00 00 ..XŸ.>.......z..
01 9b 00 07 00 00 00 00 00 00 00 00 10 30 00 .›...........0.

[20/12/2008 20:08:35] - Written data

54 21 2f T!/

[20/12/2008 20:08:35] - Read data

00 00 00 00 00 00 60 03 a0 00 28 28 28 28 28 28 ......`. .((((((
28 28 28 28 28 00 00 00 00 00 00 00 00 00 00 00 (((((...........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ...............

[20/12/2008 20:08:54] - Written data

54 21 2f T!/

[20/12/2008 20:08:54] - Read data

00 00 00 00 00 00 00 00 00 00 00 00 00 00 28 28 ..............((
28 28 28 28 28 28 28 28 28 28 28 28 28 28 00 00 ((((((((((((((..
00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 ...............

[20/12/2008 20:09:03] - Written data

54 21 2f T!/

[20/12/2008 20:09:03] - Read data

01 00 02 00 03 5b 2c 00 3e 00 00 00 00 00 00 01 .....[,.>.......
7a 00 00 01 9b 00 07 00 00 00 00 00 00 00 00 10 z...›...........
30 00 00 00 00 00 00 00 60 03 a0 00 28 28 28 0.......`. .(((

[20/12/2008 20:13:52] - Written data

54 21 2f T!/

[20/12/2008 20:13:52] - Read data

28 28 28 28 28 28 28 28 00 00 00 00 00 00 00 00 ((((((((........
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ...............

[20/12/2008 20:14:02] - Written data

54 21 3f T!?

[20/12/2008 20:14:02] - Read data

00 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 .(((((((((((((((
28 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 (...............
00 01 01 00 02 00 03 69 ba 00 3f 00 00 00 00 00 .......iş.?.....
00 01 7a 00 00 01 9b 00 07 00 00 00 00 00 00 ..z...›........
Back to top
View user's profile Send private message
ginge
Site Admin


Joined: 14 Jan 2006
Posts: 1029
Location: Manchester, UK

PostPosted: Sun Dec 21, 2008 6:40 pm    Post subject: Reply with quote

Hmm... doesn't look familiar. I am pretty certain it is because you didn't do an addressed write first.

The output from doing a non addressed read is going to return an undefined output. The OpenServo may be returning valid data at this point, but the internal incrementer will be very confused.

The data doesn't look too familiar, but doesn't mean it is not real output.
_________________
http://www.headfuzz.co.uk/
http://www.robotfuzz.co.uk/
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
enigma460



Joined: 12 Feb 2008
Posts: 23

PostPosted: Sun Dec 21, 2008 8:21 pm    Post subject: Reply with quote

I noticed that the seq 01 00 02 does repeat, all though in different places.

Now I can use the commands to access eeproms and a sonar device.

Details here.

http://www.hvwtech.com/products_view.asp?ProductID=945

You would think it would access the OSV2 the same way.

I tried your suggestion and it returns all 0xFF's.

Very Strange.
Back to top
View user's profile Send private message
enigma460



Joined: 12 Feb 2008
Posts: 23

PostPosted: Mon Dec 22, 2008 7:11 pm    Post subject: Reply with quote

@Ginge

I decided to take a look at the code in the atmega168

0000 - 1C19 Code
1C1A - 3BFF FF's
3C00 - 3FAF Code
3FB0 - 41FF FF's

Does this seem correct?
Back to top
View user's profile Send private message
ginge
Site Admin


Joined: 14 Jan 2006
Posts: 1029
Location: Manchester, UK

PostPosted: Mon Dec 22, 2008 9:22 pm    Post subject: Reply with quote

Yeah looks pretty normal.

The first portion is the main application, the FF is blank space.

The second portion is the bootloader.

Code:

0000 - 1C19 Code  - Main application
1C1A - 3BFF FF's   - Blank space
3C00 - 3FAF Code  - Bootloader
3FB0 - 41FF FF's    - Blank space

_________________
http://www.headfuzz.co.uk/
http://www.robotfuzz.co.uk/
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
enigma460



Joined: 12 Feb 2008
Posts: 23

PostPosted: Fri Dec 26, 2008 1:02 am    Post subject: Reply with quote

Further study indicates that using the 0x54 command reads multiple bytes without setting new address. So if I plug in the OSV2 and wait 30 seconds (bootloader time) then issue the 54 21 2F the returned bytes are correct. I then un-plug the OSV2 and plug it in (Hard Reset) and issue the command again (after 30 seconds), the same bytes are returned. so it seems that the OSV2 seems to be responding.

Now I have to figure out how to read individual registers.
Back to top
View user's profile Send private message
ginge
Site Admin


Joined: 14 Jan 2006
Posts: 1029
Location: Manchester, UK

PostPosted: Fri Dec 26, 2008 5:28 pm    Post subject: Reply with quote

That makes sense too.

When you power on the OpenServo, it defaults the internal register to 0x00, so resetting each time will give you the right data.

So... just need to figure out how to write an address to read.
_________________
http://www.headfuzz.co.uk/
http://www.robotfuzz.co.uk/
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
enigma460



Joined: 12 Feb 2008
Posts: 23

PostPosted: Sat Dec 27, 2008 6:25 pm    Post subject: Reply with quote

Now the sonar unit (the Srf10) is a 1 byte register device.

I can read individual registers using only the command 55 E0 xx(register) xx(number of bytes) and it returns the correct values.

Now the sonar device was mfg by Devantech which may explain why it works.

But you would think if it is a 1 byte register device it would be the same protocal as the OSV2??
Back to top
View user's profile Send private message
enigma460



Joined: 12 Feb 2008
Posts: 23

PostPosted: Sun Dec 28, 2008 3:44 am    Post subject: Reply with quote

Ok

Some more interesting stuff.

I decided to test all ten units (which I hadn't done before) the same way.

9 units take 30 full seconds before I can use the 54 command.

1 unit takes 3 seconds before I can use the 54 command.

9 units do not not respond to the 55 command to read an individual register.

1 unit does respond to the 55 command and reads what ever register I assign.

So, any ideas what I should look at next, software,hardware?? since it looks like 9 defective units.
Back to top
View user's profile Send private message
enigma460



Joined: 12 Feb 2008
Posts: 23

PostPosted: Sun Dec 28, 2008 4:23 am    Post subject: Reply with quote

Starting to sound like a Blog. I apologize but it may help someone else that's starting out.

I took the code from the working unit and downloaded it to the other boards and voila, they respond now to the Devantech commands.

Why the code was wrong, I don't know. I could post it and maybe someone could look at it?

Perseverance paid off Ginge and I thank you for your time and patience.

And if Jay reads this ,I may be calling in that raincheck from last year as one board has a trace issue which I will try to repair.
Back to top
View user's profile Send private message
enigma460



Joined: 12 Feb 2008
Posts: 23

PostPosted: Sun Dec 28, 2008 6:52 pm    Post subject: Reply with quote

This is so-o-o-o-o much fun Shocked

Using a MG995 servo and gutting it for the OSV2.

I may be missing something but if I write to 0x10 an 0x11 there should be some movement. Initial values are 02 14. I set them to 03 D4 and read back that the values changed but no movement.

Also on power-up I can rotate the servo arm by hand. This would mean that there is no power to the motor.
Back to top
View user's profile Send private message
ginge
Site Admin


Joined: 14 Jan 2006
Posts: 1029
Location: Manchester, UK

PostPosted: Mon Dec 29, 2008 9:54 am    Post subject: Reply with quote

Getting there slowly...

Did you set PID values for the servos?
_________________
http://www.headfuzz.co.uk/
http://www.robotfuzz.co.uk/
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    OpenServo.com Forum Index -> Hardware All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group