Go to Post I'll try to sum up the icon and compile thing quickly so as not to interrupt the design of SkyNet. - Greg McKaskle [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
  #3   Spotlight this post!  
Unread 16-01-2006, 23:55
Matt Adams's Avatar
Matt Adams Matt Adams is offline
b(o_o)d
FRC #1525 (Warbots)
Team Role: Engineer
 
Join Date: Dec 2003
Rookie Year: 2000
Location: Arlington Hts. IL
Posts: 375
Matt Adams has a reputation beyond reputeMatt Adams has a reputation beyond reputeMatt Adams has a reputation beyond reputeMatt Adams has a reputation beyond reputeMatt Adams has a reputation beyond reputeMatt Adams has a reputation beyond reputeMatt Adams has a reputation beyond reputeMatt Adams has a reputation beyond reputeMatt Adams has a reputation beyond reputeMatt Adams has a reputation beyond reputeMatt Adams has a reputation beyond repute
Send a message via AIM to Matt Adams
Re: Strange Problem, varible not subtracting?

I see 3 lines involved, minus comments:

enc_Right_Difference = 100 - Enc_Right_Count_Old;
enc_Right_Old_Count = 50;
Print enc_Right_Difference


So... basically this is saying

enc_Right Difference = 100 - enc_Right_Count_Old_Which_Isn't_Set_To_Anything_Ye t
Set enc_Right_Count_Old to 50
print enc_Right_Difference

I don't really see anything that suprises me. I think you wanted to do:

Set enc_Right_Count_Old to 50
enc_Right Difference = 100 - enc_Right_Count_Old
print enc_Right_Difference (which will be 50)

You need to set your variable enc_Right_Count_Old = 50 before you want to use math involving it, or it will just use zero (it doesn't know any better!). Move it to the line above the subtraction, it should work as expected.

To better visualize this, you can put print statements right before you do the math and right after the math, and you can see what the variables are set equal to. You happened to put them in places that give you (seemingly) unexpected results.

Hope this helps,

Matt

Last edited by Matt Adams : 17-01-2006 at 00:02.
 


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
Need a realistic Statics Problem sanddrag Technical Discussion 10 05-12-2005 15:07
Strange system problem Bill Becker Control System 16 12-04-2005 17:19
Strange Multi-Turn Potentiometer Problem Yellow Eyes Electrical 10 24-02-2005 13:53
Strange Encoder Problem AIBob Electrical 3 20-02-2005 22:20
Strange Auto Problem NotQuiteFree Programming 6 20-02-2005 17:12


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

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