OCCRA [more] FRC Kickoff : 26d 17h 43m ...
where theres building to do, i'll be there. - Conor Ryan [more]
 Chief Delphi programming problem
 CD-Events CD-Media CD-Spy FRC-Spy
The Chief Delphi Forums are sponsored by Innovation First International, Inc.

#1
02-18-2002, 04:02 PM
 gthakore Registered User #0843 (WOSS Wyverns) Join Date: Jan 2002 Location: Oakville, ON Posts: 11
programming problem

the x-axis have been switched and i want a way to reverse them

basically right now < make the robot go right(>)
and > makes it go (<)

how do i switch it

gaurav email at gthakore@hotmail.com
__________________
gthakore
#2
02-18-2002, 05:37 PM
 Mike Soukup Software guy FRC #0111 (Wildstang) Team Role: Engineer Join Date: May 2001 Rookie Year: 1996 Location: Schaumburg, IL Posts: 762
255 - (x-axis)
#3
02-19-2002, 08:11 AM
 GreenDice Registered User #0891 Join Date: Jan 2002 Location: Syracuse, NY Posts: 33
I think you better use 254 - x instead.
__________________
Peter Liu
#4
02-19-2002, 08:58 AM
 Ian W. College? What? no team (Gompei and the Herd) Team Role: College Student Join Date: Jan 2002 Rookie Year: 2002 Location: Worcester, MA | Smithtown, NY Posts: 1,464
i had this problem with my y-axis, and tried some elaborate solution, but this is much easier. figures, you never think of the easy thing first. oh well, at least the code for the robot is stupidly easy to change.
#5
02-19-2002, 10:40 AM
 Joe Ross Registered User FRC #0330 (Beachbots) Team Role: Engineer Join Date: Jun 2001 Rookie Year: 1997 Location: Los Angeles, CA Posts: 6,974
I think you would be better off with 255 - x max 254, unless you guarantee that x is never greater then 254 before that.

This will help to keep from outputing two 255's in a row which will reset the data packet and cause all kinds of interesting things to happen.
#6
04-12-2002, 12:05 PM
 FotoPlasma \: | no team Join Date: Jul 2001 Rookie Year: 2001 Location: San Jose Posts: 1,900
We use some robot reversal code:

Code:
```'--------------------------------------------------------------------------
'|	The following code reverses joystick directoin				  |
'|	p1_sw_top[reverse jdriection];pwm1,pwm2[motor speed/direction]
'--------------------------------------------------------------------------
' it'll be confusing as hell
' but oh well
' =)

'How to Swap the Iinformation in Two Variables Without Using a Third Variable!:
'or: XOR is Your Friend =)

if p3_sw_top then forwards:
'---swap right and left pwms
PWM1 = PWM1 ^ PWM2
PWM2 = PWM1 ^ PWM2
PWM1 = PWM1 ^ PWM2
'---invert values of joysticks around 127
'------Thanks to Joe Ross from team 340! :D
PWM1 = ( 254 - PWM1 )
PWM2 = ( 254 - PWM2 )
forwards:```
It's not elaborate, or even too important, but I'm really proud of it...
__________________
I played hacky sack with Andy Baker.

2001-2004: Team 258, The Sea Dawgs
2005: Team 1693, The Robo Lobos
#7
04-15-2002, 10:36 AM
 VanWEric Registered User #0250 (Dynamos) Join Date: Feb 2002 Location: NY Posts: 86
impressive

I like the whole xor thing. However, i think it is easiest to just say variable = (!variable). I think that works. If you want to see some really fun manipulation of variables, take a look at one of my previous posts (one line power??). i'll have it bit optimized for next year
#8
04-17-2002, 12:20 AM
 Lloyd Burns Registered User FRC #1246 (Agincourt Robotics) Team Role: Engineer Join Date: Jun 2001 Rookie Year: 1997 Location: Toronto Posts: 292
Quote:
 Originally posted by Joe Ross I think you would be better off with 255 - x max 254, unless you guarantee that x is never greater then 254 before that. This will help to keep from outputing two 255's in a row which will reset the data packet and cause all kinds of interesting things to happen.
The guarantee comes from Innovation First's code which will not allow a reading of a joystick or other pot to become more than 254.

254-x works fine, as shown in this table (in monospaced type font):

x value in :...0........127.........254 (max)
254 - x....: 254........127...........0
255 - x....: 255 ** ...128...........1
#9
04-18-2002, 03:27 PM
 jeremy562 Engineer #0562 (SPARK 562) Join Date: Feb 2002 Location: Fitchburg, MA Posts: 74
Here's the REALLY easy solution

Reverse the wires from the speed controller to the motor. Problem solved!
__________________
SPARK 562: Students Pursuing Applied Robotics Knowledge

2006 BAE Granite State Regional: Finalists with 319 and 176
2006 BAE Granite State Regional: Winners of Motorola Quality Award
2004 BAE Granite State Regional: 7th Seed
2004 Mayhem on the Merrimack Champions! Thanks, 61 and 1289!
#10
04-18-2002, 03:54 PM
 Greg McCoy boiler up! FRC #3940 (CyberTooth) Team Role: Engineer Join Date: Feb 2002 Rookie Year: 2002 Location: Kokomo, IN Posts: 484
Yep, that's the fastest and most efficient way of doing it. Why make your software think more then it has to?

Fast code = good code
#11
04-18-2002, 05:37 PM
 jeremy562 Engineer #0562 (SPARK 562) Join Date: Feb 2002 Location: Fitchburg, MA Posts: 74
hehe it would work in a simple situation where you only care about one axis.. but since in this case he also cares about the y-axis it wouldn't be that simple because swapping the motor wires would reverse both axes. He does need to do something in the software.. in this case
__________________
SPARK 562: Students Pursuing Applied Robotics Knowledge

2006 BAE Granite State Regional: Finalists with 319 and 176
2006 BAE Granite State Regional: Winners of Motorola Quality Award
2004 BAE Granite State Regional: 7th Seed
2004 Mayhem on the Merrimack Champions! Thanks, 61 and 1289!
#12
04-18-2002, 05:58 PM
 rbayer Blood, Sweat, and Code no team (Teamless Orphan) Join Date: Mar 2002 Rookie Year: 2001 Location: Minnetonka, MN Posts: 1,087
At the beginning of my code, I set up a bunch of aliases for variables. (ie leftDrive VAR PWM1, etc). Then, when I run into a problem like this, I just have to change the aliases and everything else in the code changes automatically. Not easy to do for code that's already written, but something to think about next year....
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
#13
04-18-2002, 06:17 PM
 Jnadke Go Badgers! #0093 Team Role: Alumni Join Date: Jan 2002 Location: Appleton, WI Posts: 775
Quote:
 Originally posted by FotoPlasma We use some robot reversal code: It's not elaborate, or even too important, but I'm really proud of it...
Or you can just write it to scratch pad ram...

Swap:
put 0, PWM1
PWM1 = PWM2
get 0, PWM2

Inverse:
PWM1 = ~PWM1
PWM2 = ~PWM2
__________________
The best moments of our lives fall in two categories: those that did happen and those that did not.

Last edited by Jnadke : 04-18-2002 at 06:23 PM.
#14
04-19-2002, 10:34 AM
 rbayer Blood, Sweat, and Code no team (Teamless Orphan) Join Date: Mar 2002 Rookie Year: 2001 Location: Minnetonka, MN Posts: 1,087
Using 254-x Max 254 is better, but it can still cause errors. For example, if x=255, then 254-x will evaluate to -1, which in PBASIC is approx 65,000. You then take the max and get 255. While this will prevent basic run errors, it can still cause run-time logic problems.

While it's not likely that x will be 255, its still a possibility I don't like leaving. Therefore, I would reccomend the following code:

x=2254-x Min 2000 Max 2254 - 2000
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php
#15
04-19-2002, 10:46 AM
 Joe Ross Registered User FRC #0330 (Beachbots) Team Role: Engineer Join Date: Jun 2001 Rookie Year: 1997 Location: Los Angeles, CA Posts: 6,974
Quote:
 Originally posted by Lloyd Burns The guarantee comes from Innovation First's code which will not allow a reading of a joystick or other pot to become more than 254.
Can someone else confirm this, because I can swear that I have seen 255 come from a joystick.

 Thread Tools Display Modes Rate This Thread Hybrid Mode Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 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 User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements     User Announcements FIRST     General Forum         FIRST E-Mail Blast Archive     Rumor Mill     Career     Robot Showcase     Moderated Discussion Technical     Technical Discussion     Robotics Education and Curriculum     Motors     Electrical         CAN     Programming         NI LabVIEW         WindRiver C++         Java         MATLAB & Simulink         Python     intelitek easyC/REC information         easyC v2 for Vex         easyC for FRC         REC/Learnmate         WPILib         easyC PRO     Control System         IFI Control System         FRC Control System         Sensors         USB Chicklet     Pneumatics     Kit & Additional Hardware     CAD         Inventor         SolidWorks         Pro ENGINEER / Creo     IT / Communications         3D Animation and Competition         Website Design/Showcase         Videography and Photography         Computer Graphics     National Instruments LabVIEW and Data Acquisition         LabView and Data Acquisition Competition     Awards         Chairman's Award     Rules/Strategy         Scouting         You Make The Call     Team Organization         Fundraising         Starting New Teams         Finding A Team         College Teams     Championship Event     Regional Competitions     FIRST in Michigan     Mid-Atlantic Robotics     Off-Season Events         Chief Delphi Invitational     Thanks and/or Congrats     FRC Game Design     OCCRA         OCCRA Q&A         OCCRA Programming Other     Unsung FIRST Heroes     Chit-Chat         Games/Trivia             Fantasy FIRST     Car Nack's Corner     College & University Education     Dean Kamen's Inventions     FIRST-related Organizations         Western Region Robotics Forum         Robot Chicks Union (RCU)         Southern California Regional Robotics Forum         FIRST Interactive Rural SupporT         FIRST Scouting Network         The Grand FIRST Team         FloridaFIRST         FIRSTwiki         Ultimate Robot Challenge         Team San Diego         Dream FIRST         The Blue Alliance             Video Archives     FIRST Historians     FIRST-A-Holic's Anonymous Mailbox     FIRST In the News...     FIRST Lego League         Lego Mindstorm Discussion     FIRST Tech Challenge     VEX         VEX Robotics Competition         VEX IQ     Televised Robotics     Math and Science         NASA Discussion ChiefDelphi.com Website     CD Forum Support     Extra Discussion Old Forum Archives     1999     2000     2001

 Similar Threads Thread Thread Starter Forum Replies Last Post Victor problem Andy Baker Electrical 15 06-24-2003 09:49 AM multi-bank programming problem GregC Programming 3 02-14-2003 04:13 PM The problem with scouting... archiver 2001 10 06-23-2002 11:49 PM Major problem with chipphua motors aka Scott White Motors 18 03-19-2002 07:44 PM Error found in programming for the pump and pressure switch sjharobotics Programming 4 02-06-2002 05:46 PM

All times are GMT -5. The time now is 06:16 AM.

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

 -- English (12 hour) -- English (24 hour) Contact Us - Chief Delphi - Rules - Archive - Top