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 

nothing works, blackfin and usb i2c
Goto page 1, 2  Next
 
Post new topic   Reply to topic    OpenServo.com Forum Index -> Software
View previous topic :: View next topic  
Author Message
erebus



Joined: 01 Apr 2008
Posts: 10

PostPosted: Tue Apr 01, 2008 8:19 pm    Post subject: nothing works, blackfin and usb i2c Reply with quote

I have been struggling with openservo for about 2 months now.

I am part of a group with Case Western Reserve University using the servos in a team biorobotics project. We are making 2 to scale cockroach legs that will be several times larger than the actual legs.

The original plan was to use a blackfin ez kit and labview to communicate with the servo using the blackfin's twi.

A majority of the 2 months has been assuming that the blackfin was the problem and so I had no reason to bother you all with this.

We purchased a handful of openservo boards from pendragon. I will copy those emails to this forum when I am allowed to post urls. They were not purchased under my name, but they were purchased by Case Western.

After getting fed up with labview and blackfin we purchased a usb-i2c device to test the servos. It is a FTDI FT232R module. After purchasing it I noticed in previous posts you thought about using those and then decided instead to make your own boards. I am sure you will suggest I just buy the osif board. But I am only using the usb device to test to ensure the boards work and they should work with any i2c.

When I plugged the servos into the USB to ic2 converter and ran their example labview and C++ programs it showed no devices on the i2c hub. A troubling thing is that it shows the same status regardless of whether the usb converter is in the computer or not. I emailed the FTDI guys to try to get some help with that.

The next problem is that when I put 7 volts across the gnd and Vdd ports of the openservo board that has been put together with a servo it doesn't resist movement. This lead me to think that maybe the boards weren't flashed and need to be flashed and whatnot. This would be a bit of a pain for me.

This project has gone to hell in a hand-basket. The plan was to just use openservos for nice current feedback and extra control, and th blackfin and labview for a nice user interface. And then everything would work perfectly. Currently nothing works and I have no results.

The current plan is to put linux on the blackfin and still use that twi to communicate. But we have had these servos for a month or more and we haven't gotten them to so much as twitch.

Help would be greatly appreciated. For starters how can I tell if my boards work, and why wouldn't they resist movement with 7 volts across it?

Thanks,
Jesse
Back to top
View user's profile Send private message Send e-mail
ginge
Site Admin


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

PostPosted: Tue Apr 01, 2008 10:21 pm    Post subject: Reply with quote

Hi Jesse,

It sounds like you are having a bad time with this Sad

Quote:
The next problem is that when I put 7 volts across the gnd and Vdd ports of the openservo board that has been put together with a servo it doesn't resist movement. This lead me to think that maybe the boards weren't flashed and need to be flashed and whatnot. This would be a bit of a pain for me.


The boards come flashed with firmware, but are designed to not initialise the motor without setting some servo parameters. This is to stop any default values from breaking things when there is a problem.

Quote:
For starters how can I tell if my boards work


The theory is that if you supply 7v input voltage and SCL SDA and GND to the I2C interface, it will work.

A couple of things spring to mind, but I could be wrong Wink The Blackfin dev boards normally run at 3.3v (at least mine does) which means it is voltage incompatible with the 5v OpenServo I2C voltages. This isn't a hard problem to fix and can be solved with either a few of resistors (possibly bad) or a couple of fets and a handful of resistors
The same might go for the FTDI device, but I would guess it will be 5v.

I am also going to assume your cables are of a sane length, and your proposed I2C master devices have relevant pullups to compensate.

As you are getting nothing at all on the bus, it is possibly a good sign. A misbehaving I2C device tends to pull one of the bus lines low or high, breaking the I2C horribly. You can also check to see if any of the I2C lines are changing state to see if there is a problem. You should be able to do this with a multimeter, but a scope would be ideal.

You could also try an I2C device out on the bus to test it. Something as simple as an lm75 temperature sensor.

Sorry I can't be more helpful at this stage.

Barry
_________________
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
erebus



Joined: 01 Apr 2008
Posts: 10

PostPosted: Tue Apr 01, 2008 11:09 pm    Post subject: Reply with quote

I am aware of the power issues. I had a variable power supply when testing if the servo provided any grip on the motor when powered.

I also have a battery that is 6.6v or so that I was hooking up to the servo for power and just sharing the common ground with the clock and data input from the usb converter.

Tomorrow or maybe Thursday's plan is to get a scope hooked up to the usb thing and see if it can find some other i2c devices.
Back to top
View user's profile Send private message Send e-mail
ginge
Site Admin


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

PostPosted: Tue Apr 01, 2008 11:13 pm    Post subject: Reply with quote

ok, fair enough. But remember, there will be no servo movement until you program some parameters!

Good luck,

Barry
_________________
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
erebus



Joined: 01 Apr 2008
Posts: 10

PostPosted: Mon Apr 07, 2008 5:11 am    Post subject: Reply with quote

Ok well we have had minor progress. I now have uClinux running on the blackfin, and when I use U-boot and probe the valid addresses when i have nothing plugged in i get no output but when i plug the servo in i suddenly get a large number of valid addresses. So at least it has had an effect on something. Never mind that both 0x10 and 0x20 show up in valid addresses, (I'm not sure which is the default).

I have in frustration told my boss to order a osif board.

However, while I wait for it to come I have questions that I think should be easily answered.

How do i write to /dev/i2c-#

I have read a lot on the topic and I am confused as to what goes into this thing.

I read two webpages on outputting to i2c with the dev/ interface, but I can't post links yet because apparently my previous two posts have not been approved as legit or somesuch.

I don't really want to write a Kernel module. I would much rather just output a buffer with a read or write command but it seems to want me to pick an adapter in the dev/ folder to output on. Isn't there some code developed already to output on the i2c output in linux for the open servo? I thought about just putting 0 in as my number and hoping but I didn't want to frustrate myself if that didn't work.

I looked through the whole cvs. It is hard to know what folder leads to what exactly for generic library code.

So, what files should I download/what code should I write which will very simply allow me to read and write from the dev/i2c-# output thing in linux?

Also, when I get the osif what files do I download to use your pre-made functions? I thought I saw a get_position() function and others written for it, but I can't find them in the cvs.

In the end I plan on ditching the blackfin and just using the osif and creating a sweet opengl visualization of the leg while its position is manipulated by the servos and by people. But, until that osif board gets to me I would like to poke at the servos some with the blackfin.

Thanks,
Jesse
Back to top
View user's profile Send private message Send e-mail
erebus



Joined: 01 Apr 2008
Posts: 10

PostPosted: Mon Apr 07, 2008 5:24 am    Post subject: Reply with quote

superservo looks like what I want, but the readme doesn't tell me everything I need to know really. Am I at least right that I need superservo?
Back to top
View user's profile Send private message Send e-mail
ginge
Site Admin


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

PostPosted: Mon Apr 07, 2008 8:32 am    Post subject: Reply with quote

Quote:
Never mind that both 0x10 and 0x20 show up in valid addresses, (I'm not sure which is the default).


0x10 is the default address. Anything else detected above that is likely an OpenServo power issue.

Quote:
How do i write to /dev/i2c-#


The /dev/interface uses the standard unix way of file like interfaces. To read data form a /dev/ interface, treat it as a file. Use fopen and fread, Writing likewise uses fwrite. I can send over some sample code that presents the /dev/i2c-x interface as two functions: dev_read and dev_write for simplicity.


Quote:

I don't really want to write a Kernel module.


Depending on your final interface, you can use the kernel module supplied with the OSIF. Just tear it down and refactor it for your io adapter. The other option would be to use libusb, which is a cross platform user space usb library.

Quote:
Isn't there some code developed already to output on the i2c output in linux for the open servo?

Sure there is. The OpenServo InterFace comes with a kernel module to access the /dev/ module, or alternatively a libusb module to allow cross platform i2c access. I have a more comprehensive interface between an OpenServo and the dev interface which I can post up.

Quote:
Also, when I get the osif what files do I download to use your pre-made functions? I thought I saw a get_position() function and others written for it, but I can't find them in the cvs.


You have two options:-

Use the GUI. There is a QT user application that gives you basic access to all servo functions. It allows you to scan, tune and setup a servo.

Use the cli testapplication. This application allows lower lever I2C communication you can use as a wrapper, or borrow the code and place it into your own.

You sound like you need is the wrapper I have to communicate. I will post it up. I have a c language wrapper as well as a c++ class wrapper. Another user Kevin Black has a wrapper in the /Interfaces/ directory in CVS.

Quote:
superservo looks like what I want, but the readme doesn't tell me everything I need to know really. Am I at least right that I need superservo?


SuperServo is the Microchip PIC version of OpenServo, and is the project that OpenServo was derived from. It is fairly old and hasn't had a significant update in a good long while. I doubt you could leverage this for anything useful... unless you knew it was the hardware for you.

Barry
_________________
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
erebus



Joined: 01 Apr 2008
Posts: 10

PostPosted: Mon Apr 07, 2008 8:40 am    Post subject: Reply with quote

Thanks for the quick reply. Could you please send the example using fread/write and the more comprehensive interface you mentioned.

I changed my profile so you can send emails now. Just include the example code in an email.

Thank!
Back to top
View user's profile Send private message Send e-mail
ginge
Site Admin


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

PostPosted: Mon Apr 07, 2008 9:07 am    Post subject: Reply with quote

I can't post up the newer version of the code for some hours (at work at the mo) but there is an older, albeit functional version of the source on my web site. I will mail the latest and greatest to you later on.

http://www.headfuzz.co.uk/?q=openservolib
Download that library and look through the code, specifically i2c_func.c

The readme in the file has an overview of the basics, but the /dev/i2c interface is not particularly well documented in this. Here is a quick rundown:

Initialise the dev-i2c interface. Pass in a pointer to a string of the interface. E.g "/dev/i2c-0"
Code:
i2c_init_linux(char *filename)


Read the i2c interface previously set up. This uses an internal storage mechanism for the file pointer, so you will need to change this for your own needs.
Code:
int i2c_read( int file, unsigned char i2c_dev_addr, unsigned char *buf, int read_len ) {


Performs a standard I2C write then read request. This is to do a proper I2C style transaction. If you want to get some data from an i2C device, use this mechanism.
Code:
int i2c_block_read8( int file, unsigned char i2c_dev_addr, unsigned char cmd_addr, unsigned char *buf, int read_len ) {


The code in the example uses IOCTLs instead of raw file read/writes for more fine grained control and faster bus access. This is the best and most common way of accessing I2C devices.

This page has an excellent writeup on the lower level I2C dev interface stuff, well worth a read.

http://xgoat.com/wp/2007/11/11/using-i2c-from-userspace-in-linux/
_________________
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
erebus



Joined: 01 Apr 2008
Posts: 10

PostPosted: Fri Apr 11, 2008 7:59 am    Post subject: Reply with quote

major success finally. uClinux is working with the blackfin and i figured out how to load the i2c module so now the servo is communicating using your code!

It can get position fine, I havent set the pid stuff so set pos isnt working yet. Do you have your newer version of your code to post? that would be great.

Also, how long does an osif take to get to the US I ask cause we ordered one and the business wouldn't respond.

Thanks
Back to top
View user's profile Send private message Send e-mail
ginge
Site Admin


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

PostPosted: Fri Apr 11, 2008 8:43 am    Post subject: Reply with quote

Great news!

Quote:
Do you have your newer version of your code to post? that would be great.


I did look at sending over the code, but it is not really suitable. I forgot that I took most of the code and made it into a TCP server for my Gumstix. The code does not add any more functionality over the the code you have,
You are still welcome to look over the code, but it is a horrible terrible mess Sad

Quote:
Also, how long does an osif take to get to the US I ask cause we ordered one and the business wouldn't respond.


The business is mine, and I am curious how you asked about the delivery? Was it email or the contact form?
I am normally very punctual with communication, and although I occasionally don't get an email, I respond to any enquiry I receive.

In any case, the OSIF ships out on a 3-5 day airmail delivery. So it could take up to a week to get there.


Barry
_________________
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
erebus



Joined: 01 Apr 2008
Posts: 10

PostPosted: Fri Apr 11, 2008 6:19 pm    Post subject: Reply with quote

I'm not sure how they tried to contact you but I will find out.

The servos still don't move. I am using futaba s3102 servos. Which should run off 4.8 volts. I am feeding them 6.0

here is their site

http://www3.towerhobbies.com/cgi-bin/wti0001p?&I=LXH291#tech

i am setting the maxpos and minpos and the gain values. Any thoughts on what I'm doing wrong? I am still reading positions fine. What exactly do the gain values do? I tried looking them up but it wasn't well documented on the site? I set them all to 10 is that too low? too high? prior to setting them to 10 I just tried using the "safe" default values. still no movement. Whats wrong?
Back to top
View user's profile Send private message Send e-mail
erebus



Joined: 01 Apr 2008
Posts: 10

PostPosted: Sat Apr 12, 2008 1:26 am    Post subject: Reply with quote

the person who tried to contact you was Alan Pollack. He said he tried emailing you through your webpage. He also said he ordered an osif this past Tuesday or Wednesday. Can you confirm that? Still no luck on the movement.

My code looks like this


openservo_add_adapter("gumstix",0);
openservo_add_servo(0,0x10);

openservo_start(0,0x10);
openservo_configure(0,0x10,MAX_SEEK, 304);
openservo_configure(0,0x10,MIN_SEEK, 26);
openservo_setpos(0,0x10,305);

while(1){
//print out stuff
}



that isnt copy pasted but written from another computer so forgive a typo but it does compile and run.
I can read current and pwm and pos and speed. Current is at 9, pwm is 0 pos is static and speed is 0. What am I missing?
Back to top
View user's profile Send private message Send e-mail
erebus



Joined: 01 Apr 2008
Posts: 10

PostPosted: Sun Apr 13, 2008 1:11 am    Post subject: Reply with quote

found a major error in your code for writing to the servo. in your file i2c_func.c in your function i2c_block_write8()
you make a call to i2c_write() but you pass the wrong value into it. you are passing your cmd_addr variable, you should be passing your tmpwr variable.
Back to top
View user's profile Send private message Send e-mail
kbb



Joined: 01 Jun 2007
Posts: 180

PostPosted: Sun Apr 13, 2008 10:06 pm    Post subject: Reply with quote

erebus wrote:
What am I missing?

The standard firmware does not set PID values (they are 0). Neither does your code snippet. If no PID values have been set, then the servo will not move when commanded. If this is the case, try adding

openservo_configure(0,0x10,PID_PGAIN, 1500);
openservo_configure(0,0x10,PID_DGAIN, 2000);

caveat: I don't know your setup and am not using the same environment, so the above code is untested and the values may not be the best choice for your servos.

Kevin.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenServo.com Forum Index -> Software 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