View previous topic :: View next topic |
Author |
Message |
ashrafkhatri
Joined: 06 May 2008 Posts: 14
|
2 servos |
Posted: Wed Aug 02, 2017 1:41 am |
|
|
hi,
I am working on two servos. Both servos are working but i am stuck now.
I want to make a code with the following settings:
Note: these servos operate on analog input:
Condition 1: at analog input 0-10 both servos are closed.
Condition 2: at analog input 10-50, only servo 1 operates from position 0 to full, while servo 2 is remain closed.
Condition 3: at analog input 51-100, servo 1 is already fully opened and servo 2 is now operate from 0 to full for this range.
Kindly suggest me a good piece of code for the above said conditions.
thanks
Ashraf |
|
|
oxo
Joined: 13 Nov 2012 Posts: 219 Location: France
|
|
Posted: Wed Aug 02, 2017 4:20 am |
|
|
School project ? |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Wed Aug 02, 2017 4:28 am |
|
|
This is not a do it for you forum, we will however offer guidance.
Show us how you control just the one servo.
Program needs to be complete and compilable.
Then we may be able to offer some help.
Mike |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19537
|
|
Posted: Wed Aug 02, 2017 4:44 am |
|
|
There are also some strange terms being used. Talking about a servo being 'closed'?.
He must think about hysteresis. A voltage will not read as a simple stable 'number', and at the transition values like '10', you risk having the servo hunt.
There is basic 'operate a servo' code supplied with the compiler, and in the code library. |
|
|
ashrafkhatri
Joined: 06 May 2008 Posts: 14
|
|
Posted: Wed Aug 02, 2017 4:45 am |
|
|
Let me do some more work on it. Then i will ask the same question with a written code if needed.
Thanks for your tip.
Ashraf |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9241 Location: Greensville,Ontario
|
|
Posted: Wed Aug 02, 2017 9:17 am |
|
|
You should post a link to the servos you are using to help us help you.
'servo' means different things to different people. A 'servo' could mean a typical RC style 'hobby' servo, runs off 5 volts with NO feedback. To me a 'servo' means a heavy duty DC motor with gear trains and a 1024 optical encoder for position sensing. How you control the 'servo' will be based on the type of servo.
I see two 'functions' for your program
1st a 'control' function that determines which servo to operate based upon the ADC input value. This function is simple, read the ADC and have a 3 part 'switch'.
the 2nd function is a 'servo operation' function, where the selected servo is commanded to operate, I'm assuming from a second ADC input ??
Jay |
|
|
|