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 

External PID control..where to start

 
Post new topic   Reply to topic    OpenServo.com Forum Index -> Software
View previous topic :: View next topic  
Author Message
whiptrackercracker



Joined: 18 Apr 2008
Posts: 5

PostPosted: Thu Jun 19, 2008 4:22 pm    Post subject: External PID control..where to start Reply with quote

Hello,

I just finally got the open servo board in and got it soldered into a standard hitec servo. I purchased the OSIF board and got the whole thing wired up. I ran the OSIF software demo interface and I was able to control position, tune the internal PID, and get measurements. I must say I am impressed thus far. My initial goal at this point is now to figure out how to get an external PID control running just on one servo. My ultimate goal will be to run a lynxmotion arm all externally controlled. I understand possible time delays which I am willing to deal with. However, I have fairly complex control algorithms to run and test and this board seems very capable of doing such. To be a little more specific, I'm looking to drive the servo just using PWM type speed control and I can then use the position and speed feedback to adjust speed input to obtain position, etc. It sounds as if I need to set up a few registers and null the others. Then its just up to me to write the computer based program to run external control. My issue is this; I am new to the atmega world of boards and I really do not know where to start with this project. Can I set up the servo to do this through standard I2C communications and just have the board prepped each time my computer program starts? Or do I have to use the ISP programming lines into the servo board to change the onboard program? Has anyone done this type of project before? I've been reading through the forums, but I feel a bit lost on some of these issues. I could really use a starting compass or point in the right direction. Again, this is a really cool open source board. Thanks!!!
Back to top
View user's profile Send private message
ginge
Site Admin


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

PostPosted: Fri Jun 20, 2008 9:44 am    Post subject: Reply with quote

Hi!

Quote:
My initial goal at this point is now to figure out how to get an external PID control running just on one servo. ... To be a little more specific, I'm looking to drive the servo just using PWM type speed control and I can then use the position and speed feedback to adjust speed input to obtain position, etc. It sounds as if I need to set up a few registers and null the others.


Yes, it does sound a little like you are writing a direct PWM stream into the servo. It should be fairly easy to do, and all of the source for OpenServo is written in c. The best place to start would be to expose a register for direct pwm control (we can help some more if you want) and write this value directly to the motor output. There will probably no more than 5 lines of code needed to change it.

I would start by reusing the position register REG_POSITION_SEEK_HI and LO and repurpose them to control pwm. You can see the pwm control in action in main.c and pwm.c

Quote:
My issue is this; I am new to the atmega world of boards and I really do not know where to start with this project. Can I set up the servo to do this through standard I2C communications and just have the board prepped each time my computer program starts? Or do I have to use the ISP programming lines into the servo board to change the onboard program?


You can update the firmware from the "OpenServo test application". To build the OpenServo firmware, you will need avrlibc avrgcc and optionally avr studio. If you are running windows, you can get all of this from http://www.atmel.com/dyn/Products/tools_card.asp?tool_id=2725

Once you have the new firmware built, load it into the openservo test, and click flash.


Quote:
Has anyone done this type of project before?


Yes, there is a member who has done something similar, namely having a different control method to the normal position control. Stefan's modifications (which are in CVS) allow for PID looped velocity control, which is so very similar it would be worth looking at.

Good luck, and give us a shout if you need any more help.
_________________
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
whiptrackercracker



Joined: 18 Apr 2008
Posts: 5

PostPosted: Fri Jun 20, 2008 2:00 pm    Post subject: Reply with quote

Cool...That does not sound too terribly difficult. I'll have to crunch on this over the weekend and see if I understand it as it sounds. Looks as if it is fairly straight forward. Thanks!!!
Back to top
View user's profile Send private message
whiptrackercracker



Joined: 18 Apr 2008
Posts: 5

PostPosted: Wed Jun 25, 2008 6:35 pm    Post subject: Reply with quote

Alright I have on more sanity check before I start coding. I got hung up on other duties and so I have not had time till now to look at this. Let me know if this sounds as if I am on the right track. Looking at the code, the registers

REG_POSITION_SEEK Hi and Lo

It seems as if these are only used in the PID loop. Here is what I was thinking. Inside the main loop of main.c, I comment out the function:

pwm =pid_position_to_pwm(positioin)

Then instead I set pwm to the combination of the registers above. Then inside the function:

pwm_update(pwm,position)

I need to add a few lines to convert the 0-510 value of the pwm to the -255 to 255 value of the min/max output range. Of course, I also would need to put in some code to band limit values above or below the position seek values I am using. If I understand this right, then if I put 0 as my position I should move at max pwm output in one direction, 255 should get me no movement, and 510 should get me max movement in the other direction.

This should give me direct PWM control without harming the sensor feedback capabilities, should it not. I have not gotten into conquering the whole build and flash part of this, but it appears at face value not to be too terribly difficult once I was pointed in the right direction. Thanks for you help!!! Its really appreciated.
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
Page 1 of 1

 
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