Go to Post Happy Championship and may the odds be ever in your favor! - Jon Stratis [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

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 01-11-2002, 14:55
f22flyboy's Avatar
f22flyboy f22flyboy is offline
Distributor of Mayhem
#0540 (Rhythmic Disturbance)
 
Join Date: Oct 2002
Location: Richmond, VA
Posts: 199
f22flyboy will become famous soon enoughf22flyboy will become famous soon enough
Toggle?

I see a command in PBASIC called Toggle. From what I understand in reverses the I/O of a pin. I think this could be very useful for FIRST, but I haven't seen any mention of using it, or any example of it being used in FIRST. I've been experimenting with it, but I'm not sure if my syntax is right.

Can anyone give a better explanation of it, its uses, or an example of it being used?


I know I've posted too much today but I am really bored.
__________________
Godwin Robotics Association- Rhythmic Disturbance

Team 540 Forums

FIRST Look... FIRST Shot... FIRST Kill.
  #2   Spotlight this post!  
Unread 01-11-2002, 15:00
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
It acually is used in FIRST. If you look through the default code, you'll see "Toggle 7." This is what makes the Basic Run light blink so fast.

About the only thing we could use it for would be reversing one of the LED outputs, as those are the only things connected directly to I/O pins. Anyway, if you do find a use for it, the syntax is just

Toggle X

where X is the pin you want to change. For FIRST, this can only be 7-15, with 7 being the basic run light and 8-15 being the LED outputs that are visible on the OI.

Also, as long as you're asking valid questions, nobody is going to mind you posting a lot. Asking questions is good--it helps you learn and it helps other people who visit this site sometime later.

--Rob
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #3   Spotlight this post!  
Unread 01-11-2002, 15:17
f22flyboy's Avatar
f22flyboy f22flyboy is offline
Distributor of Mayhem
#0540 (Rhythmic Disturbance)
 
Join Date: Oct 2002
Location: Richmond, VA
Posts: 199
f22flyboy will become famous soon enoughf22flyboy will become famous soon enough
ok thanks, on a semi-related note:

How do you make a joystick button act like a toggle switch? Where you push and release, but the value stays at 1, and then you push and release again to make the value go back to 0
__________________
Godwin Robotics Association- Rhythmic Disturbance

Team 540 Forums

FIRST Look... FIRST Shot... FIRST Kill.
  #4   Spotlight this post!  
Unread 01-11-2002, 18:34
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
OK, here's some basic code for doing this with p1_sw_trig.


In itit section:
p1_sw_trig_old var bit
p1_sw_trig_old=0
p1_sw_trig_toggleVal var bit
p1_sw_trig_toggleVal=0

Sometime after serin:
if((p1_sw_trig=0) or (p1_sw_trig_old=1)) then dontToggleValue
p1_sw_trig_toggleVal=1-p1_sw_trig_toggleVal
dontToggleValue:


Sometime before serout
p1_sw_trig_old=p1_sw_trig


Using this code, the value of p1_sw_trig_toggleVal will flip between 0 and 1 everytime you press the trigger. If you want to do some other action (such as incremement some form of counter), replace p1_sw_trig_toggleVal=1-p1_sw_trig_toggleVal with the appropriate code. If you have any questions about this, please go ahead and ask. I should be able to answer within a few hours at the most.
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
  #5   Spotlight this post!  
Unread 01-11-2002, 20:58
VanWEric VanWEric is offline
Registered User
#0250 (Dynamos)
 
Join Date: Feb 2002
Location: NY
Posts: 86
VanWEric is an unknown quantity at this point
while it is possible to use toggle on the first bot, it really isnt all that useful. toggle only affects the output pins located on the stamp in the hands of the driver, and it has no effect on the stamp on the bot. since everything is communicated with serin and out, changing the state of the output pins dont do nuttin.
  #6   Spotlight this post!  
Unread 03-11-2002, 08:03
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
Quote:
Originally posted by VanWEric
while it is possible to use toggle on the first bot, it really isnt all that useful. toggle only affects the output pins located on the stamp in the hands of the driver, and it has no effect on the stamp on the bot. since everything is communicated with serin and out, changing the state of the output pins dont do nuttin.
Not quite true. First, if you do a toggle on 1, 2, or 3, chances are everything will go horribly awry as these are the pins used to communicate withe the master uP. However, you CAN do a toggle on 7-15 to change the feedback LEDs. It has exactly the same effect as:

out8=1-out8


The advantage of Toggle is that it's a little easier to read and a little faster to type.
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
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
3 way toggle switch programming LeadRiccardoT Programming 3 17-02-2003 02:02
Assigning Joystick buttons.... archiver 2001 5 24-06-2002 00:59
coding, motors, spikes, help archiver 2001 3 24-06-2002 00:48
Wiring custom toggle switches into operator interface DanL Electrical 9 13-02-2002 17:13


All times are GMT -5. The time now is 07:48.

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