Go to Post Dear Dave, I've been a good student this year. Can I have hint #2 for Christmas? ~Zach - Zach O [more]
Home
Go Back   Chief Delphi > Technical > Technical Discussion
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 13-02-2002, 19:54
Joelster Joelster is offline
Registered User
#0758 (Roboticats)
 
Join Date: Feb 2002
Location: Blenheim
Posts: 11
Joelster is an unknown quantity at this point
Cool Arm Rotation (1 Button Programming!!)

ok......i have asked several questions about the turning of the arm......slowly but surely with all of your help our control team has figured out a simple program to make the arm turn with ONE BUTTON!!!! Thanx for everyone's help and please reply here or pm me if you have any questions!!! Our team will be glad to help out. Here is the code for everyone who needs it


if logged = 1 then hopskipjump:

if count1 = 1 then skippy:
if p1_sw_top = 0 then out:
if p1_sw_top = 1 then in:
in:
relay1_fwd = 1
relay1_rev = 0
count1 = 1
goto hopskipjump:
out:
skippy:


if count1 = 0 then jumpy:
if p1_sw_top = 0 then outy:
if p1_sw_top = 1 then iny:
iny:
relay1_rev = 1
relay1_fwd = 0
count1 = 0
outy:
jumpy:

hopskipjump:
logged = p1_sw_top
  #2   Spotlight this post!  
Unread 14-02-2002, 13:15
Greg Ross's Avatar
Greg Ross Greg Ross is offline
Grammar Curmudgeon
AKA: gwross
FRC #0330 (Beach 'Bots)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Hermosa Beach, CA
Posts: 2,245
Greg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond reputeGreg Ross has a reputation beyond repute
Send a message via AIM to Greg Ross Send a message via Yahoo to Greg Ross
Re: Arm Rotation (1 Button Programming!!)

Hi Joel,

<shamelessplug>
If you were using my BASIC Stamp Preprocessor (available in the wite papers section with additional information elsewhere in this Technical Discussion forum), you could rewrite your code thus to make it more understandable:
Code:
{$if logged = 0} 
    {$if count1 = 0}
        {$if p1_sw_top = 1}
            relay1_fwd = 1 
            relay1_rev = 0 
            count1 = 1 
        {$endif}
    {$else} ' count1 <> 0
        {$if p1_sw_top = 1}
            relay1_rev = 1 
            relay1_fwd = 0 
            count1 = 0 
        {$endif}
    {$endif}
{$elseif}
logged = p1_sw_top
</shamelessplug>

Now that I did that, and examined the code further, I'm not sure this code is going to do exactly what you want. Let me analyze what this code does:

Code:
If the joystick thumb button was NOT pressed the last time we 
came through the loop, then (depending upon whether count1 is 
set or clear) either:
  • Check the status of the thumb button, and if it's currently being pushed, turn on relay1 forward, and SET count1 for the next time through the loop.
OR
  • Check the status of the thumb button, and if it's currently being pushed, reverse relay1, and CLEAR count1 for the next time through the loop.
Finally, save the current thumb button state for the next time through the loop.
Do you really only want the arm to go forward or reverse? Do you sometimes want to stop it? (Maybe you have limit switches, and you always want your arm to travel the full distance between stops.) Or maybe you would like to make the button a three state toggle thusly:
Code:
{$if prevButtonState = 0}
    ' The button was up the last time through the loop ...
    {$if p1_sw_top = 1}
        ' ... but it's now being pressed, so do something:
        {$if relayState = 0}
            relayState = 1 ' Relay on forward
            relay1_fwd = 1 
            relay1_rev = 0 
        {$elseif relayState = 1}
            relayState = 2  ' Relay off. Next time reverse
            relay1_fwd = 0 
            relay1_rev = 0 
        {$elseif relayState = 2}
            relayState = 3 ' Relay reversed
            relay1_fwd = 0 
            relay1_rev = 1 
        {$elseif relayState = 3}
            relayState = 0 ' Relay off. Next time forward
            relay1_fwd = 0 
            relay1_rev = 0
        {$endif}
    {$endif}
{$elseif}
prevButtonState = p1_sw_top
Notice: I changed your variable names to make their functions more clear. I also rearranged some of the code. For example, I check the current button state before checking the relay state so I only have to do it once. I also always set relay1_fwd before relay1_rev to make reading your code less error prone. (When I first read your code, I thought you were always turning the relay on FORWARD, and never reversing it.)
__________________
Greg Ross (The Grammar Curmudgeon formerly known as gwross)
S/W Engineer, Team 330, the Beach 'Bots
<--The Grammar Curmudgeon loves this cartoon.
“Life should not be a journey to the grave with the intention of arriving safely in a pretty and well preserved body, but rather to skid in broadside in a cloud of smoke, thoroughly used up, totally worn out, and loudly proclaiming "Wow! What a Ride!" Hunter S. Thompson
"Playing a practical joke means doing something mean and calling it funny." Me

Last edited by Greg Ross : 14-02-2002 at 16:19.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
which button machine do you use and do you like it? KenWittlief General Forum 10 16-10-2003 00:01
Reflected Inertia? archiver 2001 9 24-06-2002 03:50
Fingers and Robot Controller archiver 2001 4 23-06-2002 23:54
Arm Turning (programming) Joelster Programming 4 13-02-2002 21:35
Light programming punarhero Programming 15 12-02-2002 22:52


All times are GMT -5. The time now is 21:12.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi