Go to Post "Oblivious" people asking questions are what gives us an excuse to sit around on CD. - Ryan M. [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 10-02-2005, 02:13
Fourevilmonkies's Avatar
Fourevilmonkies Fourevilmonkies is offline
Code monkey
#1369 (Minotaur)
Team Role: Programmer
 
Join Date: Feb 2005
Rookie Year: 2005
Location: Florida
Posts: 11
Fourevilmonkies is an unknown quantity at this point
Send a message via AIM to Fourevilmonkies Send a message via Yahoo to Fourevilmonkies
Unhappy One button wonder

If there is a thread about this please redirect me to it.

I have been fiddling around with this piece of code for quite a while (to me 1 week during build season is much too long). I have come up with an alternative but I found it way too messy for the drivers of the bot. Here is the unhappy code.

//somewhere at the top of user_routines.c
unsigned static int countify = 0;

//else where in the file
if (p1_sw_top == 1){
++countify;
if (countify % 2 == 0){
relay1_fwd = 1;
relay1_rev = 0;
}
if (countify % 2 != 0){
relay1_fwd = 0;
relay1_rev = 1;
}

What the above code is supposed to do is have the driver have to only hit the button once for it to do something then the driver hits it again for it to reset itself or do something else. Idealy we don't want the driver to have to tap the top switch on the joystick.

I only get a spaztastic numatic cylinder. I already know the cause is due to the fact that the value for p1_sw_top is read about every 26.2 ms so it goes through this code like a hot knife through butter. Is there a better way to do this?

The alternate code I am using is this

if ((p1_sw_top == 1) && (p1_sw_trig == 1)){
relay1_fwd = 1;
relay1_rev = 0;
}
if ((p1_sw_top == 1) && (p1_sw_trig == 0)){
relay1_fwd = 0;
relay1_rev = 1;
}

This makes it so I can have multiple buttons set up this way. This code does what its supposed to which is when someone hits the trigger then the button and something happens then they hit the button without the trigger and the inverse happens.
__________________
Come one guys, I just want to make you go pop.
 


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
Looking to borrow a button maker... 1685isalive General Forum 0 31-01-2005 14:03
disabling a button gomez6760 Programming 1 12-08-2004 11:54
Button Programing BobcatProgramer Programming 6 25-02-2004 16:43
which button machine do you use and do you like it? KenWittlief General Forum 10 16-10-2003 00:01
Select button and user mode n[ate]vw Programming 2 20-01-2003 16:33


All times are GMT -5. The time now is 14:13.

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