Calculating problem

Hello, please help

I have a problem with calculation, here is example:\

int MOTOR=200;
int MICROSTEP=1;
float OSTATAK=0;
double STEPEN=160.000*MOTOR*MICROSTEP/360;


    int tmp=round(steperrot[newPos-1]*STEPEN+OSTATAK);
    OSTATAK=steperrot[newPos-1]*STEPEN*1.00+OSTATAK-tmp;  

    Serial.print("steperrot[newPos-1]= ");
    Serial.println(steperrot[newPos-1]);
    Serial.print("STEPEN= ");
    Serial.println(STEPEN);
    Serial.print("tmp= ");
    Serial.println(tmp);
    Serial.print("steperrot[newPos-1]*STEPEN+OSTATAK= ");
    Serial.println(steperrot[newPos-1]*STEPEN*1.00+OSTATAK);
    Serial.print("OSTATAK= ");
    Serial.println(OSTATAK)

And result is:

steperrot[newPos-1]= 90.00
STEPEN= 88.89
tmp= 8000
steperrot[newPos-1]*STEPEN+OSTATAK= 8000.00
OSTATAK= -0.00

i mark problem with red, there must be 8000.10, what is wrong?

Thanks

what is wrong?

What is wrong is that you failed to post ALL of your code, so we can't see all the variable types.

8000 + 0 doesn't look like 8000.1 to me. Why do you think the 8000.0 value should be 8000.1?

bciric:
what is wrong?

You didn't post a complete program that actually compiles.

Sorrycode is robust, here is complete:

#include <AccelStepper.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <RotaryEncoder.h>
// Define a stepper motor 1 for arduino 
// direction Digital 9 (CW), pulses Digital 8 (CLK)
AccelStepper stepper(1, 8, 9);
AccelStepper stepper2(1, 10, 11);
LiquidCrystal_I2C lcd(0x3f, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);  // Set the LCD I2C address

#define stepPin 8 
#define dirPin  9


#define STEPS_PER_MOTOR_REVOLUTION 200   
#define STEPS_PER_OUTPUT_REVOLUTION 200  //2048 

char* myStrings[]={"Motor 1", "Motor 1", "Motor 1", "Motor 1", "Motor 1","Motor 1"};
char* myVal[]={"01 \xDF", "10 \xDF    ", "30 \xDF      ", "45 \xDF     ", "60 \xDF     ","90 \xDF     "};
//float steperrot[] = { 200/14, 200/12, 200/6, 100, 100, 100 };
//float steperrot[] = { 3.4028235E+38, 200/8, 200/6, 50, 100, 100 };
//float steperrot[] = { 200/14, 200/12, 200/6, 100, 100, 100 };
float steperrot[] = { 1, 10, 30, 45, 60, 90 };
//Pinos de ligacao do encoder
RotaryEncoder encoder(A2, A3);

int contador = 1;
int contador_anterior = 1;
int buttonState = 0;

int MOTOR=200;
int MICROSTEP=1;
float OSTATAK=0;
double STEPEN=160.000*MOTOR*MICROSTEP/360;
byte Bloco_Cheio[8]  = {0b11111, 0b11111, 0b11111, 0b11111,
                        0b11111, 0b11111, 0b11111, 0b11111
                       };
byte Um_invertido[8] = {0b11011, 0b10011, 0b11011, 0b11011,
                        0b11011, 0b11011, 0b10001, 0b11111
                       };
byte Dois_invertido[8] = {0b10001, 0b01110, 0b11110, 0b11101,
                          0b11011, 0b10111, 0b00000, 0b11111
                         };
byte Tres_invertido[8] =  {0b00000, 0b11101, 0b11011, 0b11101,
                           0b11110, 0b01110, 0b10001, 0b11111
                          };
byte Quatro_invertido[8] = {0b11101, 0b11001, 0b10101, 0b01101,
                            0b00000, 0b11101, 0b11101, 0b11111
                           };
byte Cinco_invertido[8] = {0b00000, 0b01111, 0b00001, 0b11110,
                           0b11110, 0b01110, 0b10001, 0b11111
                          };
byte Seis_invertido[8] = {0b11001, 0b10111, 0b01111, 0b00001,
                          0b01110, 0b01110, 0b10001, 0b11111
                         };

static int pos = 1;
int newPos = 0;
int selecionado = 0;

void setup()
{  
  Serial.begin(9600);
  // Change these to suit your stepper if you want
  stepper.setMaxSpeed(500);//1100
  stepper.setAcceleration(100);
  stepper2.setMaxSpeed(500);//1100
  stepper2.setAcceleration(500);
  //stepper.moveTo(2000);

  pinMode(stepPin,OUTPUT); 
  pinMode(dirPin,OUTPUT);

   
  //Inicializa o botao do encoder no pino 7
  pinMode(2, INPUT);
  //Define o LCD com 20 colunas e 4 linhas
  lcd.begin(20, 4);
  //Cria os caracteres customizados
  lcd.createChar(0, Bloco_Cheio);
  lcd.createChar(1, Um_invertido);
  lcd.createChar(2, Dois_invertido);
  lcd.createChar(3, Tres_invertido);
  lcd.createChar(4, Quatro_invertido);
  lcd.createChar(5, Cinco_invertido);
  lcd.createChar(6, Seis_invertido);

  //Informacoes iniciais
  lcd.setCursor(0, 0);
  lcd.print("  1  2  3  4  5  6");
  lcd.setCursor(1, 2);
  lcd.print("Motor: ");
  lcd.setCursor(1, 3);
  lcd.print("Pomeraj:");
}
void loop()
{
  buttonState = digitalRead(2);

  // check if the pushbutton is pressed. If it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
    
    //lcd.setCursor(2, 1);
    //lcd.print("                   ");
    while (digitalRead(7) == 1)
      delay(50);
  } else {
  for (int i=1; i <= 360/steperrot[newPos-1]; i++){
    lcd.setCursor(2, 1);
    //lcd.print("click              ");
    lcd.print(i);
    int tmp=round(steperrot[newPos-1]*STEPEN+OSTATAK);
    OSTATAK=steperrot[newPos-1]*STEPEN*1.00+OSTATAK-tmp;  

    Serial.print("steperrot[newPos-1]= ");
    Serial.println(steperrot[newPos-1]);
    Serial.print("STEPEN= ");
    Serial.println(STEPEN);
    Serial.print("tmp= ");
    Serial.println(tmp);
    Serial.print("steperrot[newPos-1]*STEPEN+OSTATAK= ");
    Serial.println((double)steperrot[newPos-1]*STEPEN*1.00);
    Serial.print("OSTATAK= ");
    Serial.println(OSTATAK);
      
    if (newPos<=3){
      stepper.moveTo(stepper.currentPosition()+tmp);
      stepper.runToPosition();
    }else{
      stepper.moveTo(stepper.currentPosition()+tmp);
      stepper.runToPosition();
    }
    delay(300);
    digitalWrite(3, LOW);
    //lcd.setCursor(2, 1);
    //lcd.print(OSTATAK);
    //lcd.setCursor(10, 1);
    //lcd.print(tmp);
    while (digitalRead(7) == 1)
      delay(50);
  }}

  //Le as informacoes do encoder
  encoder.tick();
  newPos = encoder.getPosition();
  if (pos != newPos)
  {
    //Limite maximo menu
    if (newPos > 6)
    {
      encoder.setPosition(6);
      newPos = 6;
    }
    //Limite minimo menu
    if (newPos < 1)
    {
      encoder.setPosition(1);
      newPos = 1;
    }
    //Atualiza o menu no display
    destaque_selecionado(newPos);
    pos = newPos;
  }
}
void destaque_selecionado(int conta)
{
  //Define posicao inicial
  int posicao = (conta * 3) - 1;
  //Apaga selecao anterior
  if (conta > pos)
  {
    lcd.setCursor(posicao - 4, 0);
    lcd.print(" ");
    lcd.print(conta - 1);
    lcd.print(" ");
  }
  //Apaga selecao posterior
  if (conta < pos)
  {
    lcd.setCursor(posicao + 2, 0);
    lcd.print(" ");
    lcd.print(conta + 1);
    lcd.print(" ");
  }

  //Imprime blocos cheios
  lcd.setCursor(posicao - 1, 0);
  lcd.write((uint8_t)0);
  lcd.write((uint8_t)0);
  lcd.write((uint8_t)0);

  //imprime valor
  lcd.setCursor(posicao, 0);
  lcd.write((uint8_t)(conta));

  //Imprime Opcao atual
  lcd.setCursor(10, 2);
  lcd.print(conta);
  
  //Imprime Opcao atual
  lcd.setCursor(10, 2);
  lcd.print(myStrings[conta-1]);
    //Imprime Opcao atual
  lcd.setCursor(10, 3);
  lcd.print(myVal[conta-1]);
}

double round(double x)
{
        double t;

        if (!isfinite(x))
                return (x);

        if (x >= 0.0) {
                t = floor(x);
                if (t - x <= -0.5)
                        t += 1.0;
                return (t);
        } else {
                t = floor(-x);
                if (t + x <= -0.5)
                        t += 1.0;
                return (-t);
        }
}

Simple multiple steperrot[newPos-1]STEPEN+OSTATAK=9088.89=8000.1

Also which variable type i must use to allow microspreping and operate with big decimal numbers?

Simple multiple steperrot[newPos-1]STEPEN+OSTATAK=9088.89=8000.1

Try printing your floats to more than two decimal places. I suspect that a clue-by-four will whack you.