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 

Theory needs to be implemented and tested, help needed
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    OpenServo.com Forum Index -> Theory and Algorithms
View previous topic :: View next topic  
Author Message
Zeddicus



Joined: 21 May 2006
Posts: 109

PostPosted: Wed Jun 28, 2006 8:41 pm    Post subject: Reply with quote

Confused How on EARTH does your servo turn the full 180 degrees in 2.2s, with only a 4V supply and a motor winding resistance of 4.3 ohms, considering that you have a reduction of 720 ???? That means a motor speed of over 9800 rpm's, with the weights attached!!!!

I'm having a very hard time trying to find sane parameters that fit this!!! Very Happy

Do all typical servos have these values, or am I the ignorant one? I still haven't received mine, so I don't really know.

ZZZ
Back to top
View user's profile Send private message
ginge
Site Admin


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

PostPosted: Wed Jun 28, 2006 8:54 pm    Post subject: Reply with quote

180 degrees = 360 revolutions, and it's 5v
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Zeddicus



Joined: 21 May 2006
Posts: 109

PostPosted: Wed Jun 28, 2006 9:06 pm    Post subject: Reply with quote

Supply is 5V, but you told me you have the output limited to 80% (204 for the pwm)? This would mean the maximum applied voltage to the motor is 4v.... right? Or did I misunderstand?

At 4V, for a 4.3 ohm winding resistance, you'd get a stall current of 0.93A. If the motor turns 360 times in 2.2s, you get about 9800 rpm's, which is a lot (I think).

I have to get some work done now, but I'll play around with this again later.

Thanks for the info!

Z.
Back to top
View user's profile Send private message
ginge
Site Admin


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

PostPosted: Wed Jun 28, 2006 9:26 pm    Post subject: Reply with quote

yeah, you got me there Smile 4v it is.

I'm pretty sure my reading are correct... unless I did it wrong.

Something I have noticed, my servos drive the motor using a very small cog, which drives larger ones. This means the motor will have to spin more to move the horn. Surely this doesn't put 9800 rpm out of the question?

You may need to get someone with a standard servo to get some readings for you.

As for what a ""standard servo"" look like, your guess is as good as mine. Although I have some knocking around, they are doing useful things, like moving my security cameras. Maybe I will pull one down and butcher it.

Cheers,

Barry
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Zeddicus



Joined: 21 May 2006
Posts: 109

PostPosted: Thu Jun 29, 2006 6:50 am    Post subject: Reply with quote

Barry,
I've played around a lot with my model parameters. I managed to nail another one down, and I got a ratio for another 3. The only one I'm really missing is the motor winding inductance, but I don't think that is critical.

In general, using the parameters that I either deduced or got from you, the model behaves quite well. So much so, that I managed to match your motor current and full speed, as well as the 2.2s movement time for the 180 degrees.

During all this, I had to fool around with the PID controller, and I observed a behaviour that is very similar to what I see in your curves: the pwm output changes wildly for a short time, and some current oscillation happens when reaching the end of movement. I could be wrong, but it looks to me as though your PID is slightly out of tune. According to what I see, your KI should be lowered, though I can't really tell if a little or a lot. Maybe your Kp should be lowered a bit too. At least this is what I did in my model to ease those symptoms quite a bit.

This can also account for what you told me about the servo doing Bad Things when you go to full PWM output instead of 80%.

The parameters I have at the moment are:
Kp=1
Ki=30
Kd=0.1

This will not be directly useful to you, because, unlike the current openservo controller implementation, these parameters are independent of the sampling time.

So this brings up 2 questions:
1.- Are you using PID or IPD?
2.- What controller values are you using?

I can try to check your parameters against my equations, and try to remove the sampling time factor from them.

I also reached one more conclusion: it is advisable to filter the PWM output in some way. It does not make any sense to have the output varying so wildly. A filter of maybe 1Hz-10Hz should be ok (I think). This is similar to what I mentioned at some point about inserting a rate limiter at the output of the controller. A wildly varying output only destabilizes the control loop by making the current change unecessarily, and this will happen even with the motor behaving like a lowpass filter for the applied voltage, because it is not an ideal system.

Well, I hope all this is helpful in some way...

Cheers,
ZZZZZZzzzzZZZZZzzzzzz (almost 3am..... again.....)
Back to top
View user's profile Send private message
ginge
Site Admin


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

PostPosted: Thu Jun 29, 2006 9:47 am    Post subject: Reply with quote

Nice.

Regarding my PID being slightly out of tune, you are almost certainly right. They were tuned with a diffrent load, and I didn't see that much oscillation when I changed over.

I will fish out my PID values when I'm in from work.

The PWM strangeness I refer to is more to do with the motor rotating far too fast, and eating all of the current in the PSU, and causing a brownout. 80% pwm was a good tradeoff for that.

Barry
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Guest






PostPosted: Thu Jun 29, 2006 5:20 pm    Post subject: Reply with quote

yes, I forgot to mention that your controller was likely tuned either for a different load or a different working point. It works fine as it is though, so the tuning was well done, and if it ain't broken....

I'm going to try and make the model controller more realistic now, by addind the pwm output, and the ADC input. I just have one tiiiiiny problem: I wrote everything in matlab, and it takes about 30 seconds for each simulation, which sucks when you're trying to tweak parameters....

Maybe I should port the whole thing to C/C++.... I could include an opengl simulation of the servo to help visualize what it's doing... and the executable would be available for upload to the wiki..... ummmm..... Twisted Evil

ZZZ
Back to top
Zeddicus



Joined: 21 May 2006
Posts: 109

PostPosted: Thu Jun 29, 2006 5:26 pm    Post subject: Reply with quote

stupid cookie double login problem, posted as guest again Embarassed hate that...

Z
Back to top
View user's profile Send private message
ginge
Site Admin


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

PostPosted: Thu Jun 29, 2006 5:44 pm    Post subject: Reply with quote

Z, sounds good,

I was going to convert your matlab source to a C++ class myself, but if you are volunteering.

I was hoping to tweak you estimator models to use on the other servos on my arm, It's always good to have a solid model to work with. GL too? You spoil us.

Oh yeah, my PID values:-
Kp = 500
Ki = 4
Kd = 800

Baz
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Zeddicus



Joined: 21 May 2006
Posts: 109

PostPosted: Thu Jun 29, 2006 8:16 pm    Post subject: Reply with quote

Very Happy it's pretty much all I can do for the moment: play around with equations and algorithms. I already received my electronic components, and the servos are waiting for me at customs, but I still don't have the pcb's, and in any case, I'll just get home on sunday, after which I have to go on a trip overseas untill mid july, so... I'm just about purple from the frustration Laughing

I'll develop the thing under Borland Builder... unless there is another preference?

Cheers,
Z
Back to top
View user's profile Send private message
ginge
Site Admin


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

PostPosted: Thu Jun 29, 2006 11:28 pm    Post subject: Reply with quote

I get the impression the windows guys use MS Visual Studio (.NET). I am a linux kinda guy, so use gcc tools.

But, you know, whatever gets the job done for you. nothing too proprietary would be wise Smile

Barry
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: Sat Jul 15, 2006 12:47 am    Post subject: Reply with quote

Hey Z, hows the model shaping up?

I'm looking forward to seeing your data.

Barry
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Zeddicus



Joined: 21 May 2006
Posts: 109

PostPosted: Sat Jul 15, 2006 6:27 am    Post subject: Reply with quote

hi Barry,

I'm still in Montreal until tomorrow sunday, so I haven't been able to work too much on it. I'm developing the application using CLX, which should (emphasis on the should) compile on Linux as well, though I have little idea how. I have the GUI set up, and I have the motor equations encapsulated as a class. I also have the PID/IPD and other variants encapsulated as a classes.
Since there are so many parameters to handle, I decided to use a configuration file. And since this is the umptieth time I've had to use a configuration file, I got fed up with re-writing the code, so I made a generalized class for that too.
I'm still missing the simulation mechanics as such, and the openGL routines, though that last part is easy.

Also, I'm not sure about leaving everything as classes. Can the AVR compiler handle C++? I think I asked that before somewhere, but I don't remember the answer I got. Sorry about that...

In any case, I'll work on it some on the plane back to Chile, and then I'll have something like 6 days with the afternoons off, so I'll have more time then. I'll let you know as soon as I get it working.

Cheers,
ZZZ

I missed Montreal... lots of memories here for me.....
Back to top
View user's profile Send private message
mpthompson



Joined: 02 Jan 2006
Posts: 650
Location: San Carlos, CA

PostPosted: Sun Jul 16, 2006 5:36 pm    Post subject: Reply with quote

Zedd,

I pulled the following regarding C++ development on the AVR from the WinAVR documentation:

Quote:

7.3.7 Can I use C++ on the AVR?

Basically yes, C++ is supported (assuming your compiler has been configured and compiled to support it, of course). Source files ending in .cc, .cpp or .C will automatically cause the compiler frontend to invoke the C++ compiler. Alternatively, the C++ compiler could be explicitly called by the name avr-c++. However, there?s currently no support for libstdc++, the standard support library needed for a complete C++ implementation. This imposes a number of restrictions on the C++ programs that can be compiled. Among them are:

? Obviously, none of the C++ related standard functions, classes, and template classes are available.

? The operators new and delete are not implemented, attempting to use them will cause the linker to complain about undefined external references. (This could perhaps be fixed.)

? Some of the supplied include files are not C++ safe, i. e. they need to be wrapped into extern ""C"" { . . . } (This could certainly be fixed, too.)

? Exceptions are not supported. Since exceptions are enabled by default in the C++ frontend, they explicitly need to be turned off using -fno-exceptions in the compiler options. Failing this, the linker will complain about an undefined external reference to __gxx_personality_sj0.

Constructors and destructors are supported though, including global ones.

When programming C++ in space- and runtime-sensitive environments like microcontrollers, extra care should be taken to avoid unwanted side effects of the C++ calling conventions like implied copy constructors that could be called upon function invocation etc. These things could easily add up into a considerable amount of time and program memory wasted. Thus, casual inspection of the generated assembler code (using the -S
compiler option) seems to be warranted.


When programming in such a limited resource environment such as the AVR I generally stay clear of C++, but it should be possible. C is a bit more portable to other MCUs and there are many less caveats to worry about when programming.

BTW, if you do try some C++ you'll be glad we upgraded to the ATmega168 Smile.

-Mike
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger
Zeddicus



Joined: 21 May 2006
Posts: 109

PostPosted: Tue Jul 18, 2006 8:35 pm    Post subject: Reply with quote

Um... maybe I'll just implement the calls with Ansi C by using structs... I hate not being able to trust the compiler.

Thanks Mike.

Back to drawing board for me...
ZZZ
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenServo.com Forum Index -> Theory and Algorithms All times are GMT
Goto page Previous  1, 2, 3
Page 3 of 3

 
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