Hi lerameur,
In your code piece here, first you are missing ENDIF. For now say it is there, then;
Your variables are all decimal already.
Also, say that Right = 5 and Left = 2.
Then,
IF Right > Left statement will be executed; then
Temp = Right - Left
(Temp = 3)
Temp = Temp/Right
(Temp = 3/5)
(Temp = 0)
Temp = Temp*254
(Temp = 0)
In this case, you will get TEMP as zero, because you will always be dividing a small number by a bigger number.
Also, if you run your code alone, it will not give you any errors.
Code:
IF Right > Left THEN 'left and right are from sensor reading
Temp =Right-Left
Temp= Temp/Right
Temp= Temp * 254
HPWM 1,255-temp,1000
HPWM 2,255,1000
ENDIF
'No errors !!
Thus, you should check the rest of your code. It seems that you have no problem with your IF statement.
-------------------------------
Last edited by sayzer; - 4th November 2006 at 16:22.
"If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte
Bookmarks