BEST Robotics Forum
Register Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
Mahaflac

Junior Member
Registered:
Posts: 10
Reply with quote  #1 
Greetings,

We have a problem that we can't figure out.  Servos are preset to open and close at 60 degrees. We need to program it so that in the resting position it is vertical from the deck of our robot.  When we press the button to drop the arm it needs to close at 90 degrees and stay.  How can we accomplish this problem. Any picture or diagrams or model examples would be appreciated.

Remember we are a rookie team with no programming experience but we have solved the other problems with programming.  HELP!!!!
0
jgraber

Moderator
Registered:
Posts: 173
Reply with quote  #2 
What have you tried or accomplished so far, in your other programming ?

You can use a Motor block for a Servo, since they both get plugged into a motor port.
Motor ports get values from -127 to +127: 
 MC29 motor controller to motor will interpret this -127 to +127 value to mean full speed backwards to full speed forwards.
 A Servo power adapter to Servo will interpret this -127 to +127 value to mean -45 degrees to +45 degrees, so the range is only 90 degrees total.

I just answered a similar question regarding EasyC, does this description match your request? 
  If not, how is yours different, using the same kind of language that I'm using?

description:
  When turn on cortex and link with joystick, move servo to position B.

  push button A to move servo to position A, and leave it there, even when release button A.
  push button B to move servo to position B, and leave it there, even when release button B.

So basically, you need to set the servo to the value of a variable,  then set the value of the variable when you press a button, for as many buttons and as many values as you want.    

As this is a duplicate to your General topic,  I'll delete the other topic.
0
Mahaflac

Junior Member
Registered:
Posts: 10
Reply with quote  #3 
Here is what we have with button 7 Up, down being the control in question.  I need the servo to open up and stay up until activated. Once activated in will close to at least 90 degrees. I am not sure how to accomplish this.



dogbyte model.png 

0
jgraber

Moderator
Registered:
Posts: 173
Reply with quote  #4 
Try this:
  Copy button 5 path to button 7.
Latch function will be push button 7 once to open servo, push button 7 again to close servo.   Will that meet your needs?
  Button 7 -> latch block -> gain +255 -> add -> DC motor 4
    Constant -127 also goes to add block----^
 
goal is to get the value to the motor to be either -127 or +127.
0
Mahaflac

Junior Member
Registered:
Posts: 10
Reply with quote  #5 
I will try that today and let you know. Thanks
0
Mahaflac

Junior Member
Registered:
Posts: 10
Reply with quote  #6 
Works perfect. I had to adjust the values a little to get the angle we needed.  Thank you very much for the help.
0
jgraber

Moderator
Registered:
Posts: 173
Reply with quote  #7 
You are welcome.  It is nice to get confirmation of a solution.
0
shiremath

Moderator
Registered:
Posts: 78
Reply with quote  #8 
Thanks for the solution, Joel. Looks like that that suggestion worked out well. Another solution for the same problem would look like this:

Button2Motor.PNG 

You can see that I have used a Switch block instead of the Gain and Add blocks combination that Jgraber suggested. The Switch block lets me send a +127*(45/60) angle value when the button is not pressed (i.e. second input to the block, u~=0  or u is not equal to 0) or -127*(45/60) value when button is pressed (i.e. if second input u==0). Switch block is present int he Utilities library. 

Hope this helps, too!

Thanks and good luck.
bestrobotics@mathworks.com




 

0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.