Go to Post You know when the school health nurse advises "always wear a condom"? She doesn't actually mean "ALWAYS". ::safety:: I think Dean and Woodie have a pretty good idea of when they need safety glasses and when they don't. Jason - dtengineering [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 16-04-2002, 09:54
[JPTN] [JPTN] is offline
Registered User
#0865 (Warp 7)
 
Join Date: Apr 2002
Location: Toronto, Ontario, Canada
Posts: 3
[JPTN] is an unknown quantity at this point
Division / Mod

Is there a simple way to program a division procedure to divide numbers?

I am programming something to limit a range and if it exceeds this range, it is divided and brought back into the range.

Is there a simpler way to do this because the variables are integers and you can't divide them...

Any help or info is greatly appreciated.

Jeremy Phan
__________________
System Administrator
Western Technical-Commercial School
125 Evelyn Crescent
Toronto, Ontario
M6P 3E3
  #2   Spotlight this post!  
Unread 16-04-2002, 14:25
srawls's Avatar
srawls srawls is offline
Registered User
#0122 (Nasa Knights)
 
Join Date: Dec 2001
Location: Yorktown
Posts: 507
srawls is an unknown quantity at this point
Send a message via AIM to srawls
You can divide integers, it's just that the result is another integer (e.g. 3/2=1). Can you please explain what you're doing this for, however, becasue I'm having trouble seeing what you are trying to do. My initial thought is that if all you want to do is keep a value inside a range just use
myVal = myVal MIN lower_bound MAX upper_bound
But I don't know if that's what you need, so I'd appreciate it if you could clarify your question, unless by some struck of luck I just ansered it

Stephen
  #3   Spotlight this post!  
Unread 16-04-2002, 15:03
[JPTN] [JPTN] is offline
Registered User
#0865 (Warp 7)
 
Join Date: Apr 2002
Location: Toronto, Ontario, Canada
Posts: 3
[JPTN] is an unknown quantity at this point
I'm trying to output 2 values (a, b) taking 2 other values (x, y).

The problem is that over a certain range, the excess has to be carried over to the 2nd variable. Then addition and subtraction have to be done to the 2 variables to produce the 2nd set of variables.

The problem I am encountering is that I need to program an extreme region which would be exempt from this and 2 regions which are "more sensitive". The math is really driving me nuts right now... and the approach I'm trying to do is to use the number and calculate the slope of X and Y to the limit and then using the slope as a identifier to the region, go to a specific procedure.

[JPTN]
__________________
System Administrator
Western Technical-Commercial School
125 Evelyn Crescent
Toronto, Ontario
M6P 3E3
  #4   Spotlight this post!  
Unread 16-04-2002, 17:09
Ameya's Avatar
Ameya Ameya is offline
Freelance Goon
FRC #0293 (SPIKE Robotics)
Team Role: Alumni
 
Join Date: May 2001
Rookie Year: 2000
Location: Pennington, NJ
Posts: 67
Ameya is on a distinguished road
Send a message via ICQ to Ameya Send a message via AIM to Ameya
In that case, you shouldn't need any kind of special procedure to divide. Just use the division ("/") operator; if the result is a non-integer, it should be truncated (I believe). This should be good enough for what you're trying to do.

If you're willing, I'd be interested to hear the specifics of what you're trying to do.
__________________
Ameya Agaskar
Team 293 alumnus
  #5   Spotlight this post!  
Unread 16-04-2002, 17:44
[JPTN] [JPTN] is offline
Registered User
#0865 (Warp 7)
 
Join Date: Apr 2002
Location: Toronto, Ontario, Canada
Posts: 3
[JPTN] is an unknown quantity at this point
I'm trying to program a free-floating arm controlled by a joystick.

It's 3-dimensional movement and I need to program different areas of sensitivity for its different ranges.

The problem is that there are 2 motors controlling a single device and they have to be pulling at different strengths. It's just math but any help is appreciated.

[JPTN]
__________________
System Administrator
Western Technical-Commercial School
125 Evelyn Crescent
Toronto, Ontario
M6P 3E3
  #6   Spotlight this post!  
Unread 16-04-2002, 18:18
Ian W. Ian W. is offline
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
Ian W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to allIan W. is a name known to all
Send a message via AIM to Ian W.
Use a data table in the EEPROM. Then, using C++ (or some other language like that), do all the calculations. make sure to only have integers (since PBASIC truncates), and load it into the EEPROM using the "DATA" command. then, when you take the values, you can read them from the EEPROM using the "READ" command. very simple, and it works just as fast (or fast enough) as if you're doing the calculations on the fly. Just don't let Joe Ross help you program that part.

Ex.

to put something into EEPROM

Joe's Way (The Not-Right Way)
EEPROM 1,2,3,4,5...

The Right Way
DATA 1,2,3,4,5...

The numbers are then placed in the EEPROM starting from the first spot, and working to the last. There's ways where you can get fancy with it, but i'm not sure of them. Check the manual, under DATA. Hope this helps, and if you need any more help, come over to team 810 at nats.
__________________
AIM --> Woloi
Email --> ian@woloschin.com
  #7   Spotlight this post!  
Unread 13-05-2002, 15:32
VanWEric VanWEric is offline
Registered User
#0250 (Dynamos)
 
Join Date: Feb 2002
Location: NY
Posts: 86
VanWEric is an unknown quantity at this point
No IAN NO!

doing anything with the eeprom is considerably slower than doing it mathematically. If i remember back to the CODEX meeting correctly you told us all how you reduced something to 85% of it original value with the eeprom. try saying x=x*17/20. or, if you want to do it only if it is below 127, try x = x/127*127*17/20+(127/x max 1 *x)

do the math, not the eep
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
Coolist "bot" in each division Michael King Championship Event 46 21-04-2003 18:20
Newton Division 2003 Jon K. Championship Event 6 05-04-2003 15:28
Archimedes division team results archiver 2001 3 24-06-2002 03:13
Curie Division Robots information... (not complete) archiver 2001 3 24-06-2002 03:13
My bold predictions + analysis! Andy Grady Championship Event 18 22-04-2002 22:02


All times are GMT -5. The time now is 02:04.

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