|
|
|
![]() |
|
|||||||
|
||||||||
|
|
Thread Tools | Rate Thread | Display Modes |
|
#3
|
|||||
|
|||||
|
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 |
|
|
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 |