B4R Question Problem with counting

BaGRoS

Active Member
Licensed User
Longtime User
B4X:
    Private microPerSteps As Byte = 1
    Private SpeedRPM As Int = 60
    Private microDelayStep As Long = 1500
    Private stepPerRev As Int = 200

Sub SetSpeedRPM (SpeedRPM1 As Int)
 
    SpeedRPM=SpeedRPM1
 
    'calculating step delay in microseconds
    microDelayStep = 60 * 1000 * 1000 / SpeedRPM / stepPerRev * microPerSteps
    Log("Stepper.SetSpeedRPM.microDelayStep : ", microDelayStep, " ;SpeedRPM: ", SpeedRPM, _
    " ;stepPerRev: ", stepPerRev, " ;microPerSteps :", microPerSteps)
    'in this place needs to calculating microsteps if needed
    'because with very high rpm micro steps is not needed
 
End Sub

and log from console

B4X:
AppStart
Stepper.SetSpeedRPM.microDelayStep : -2 ;SpeedRPM: 60 ;stepPerRev: 200 ;microPerSteps :1
StartBlinking
Stepper.SetSpeedRPM.microDelayStep : -2 ;SpeedRPM: 52 ;stepPerRev: 200 ;microPerSteps :1
Stepper.SetSpeedRPM.microDelayStep : -25 ;SpeedRPM: 6 ;stepPerRev: 200 ;microPerSteps :1
Stepper.SetSpeedRPM.microDelayStep : -4 ;SpeedRPM: 37 ;stepPerRev: 200 ;microPerSteps :1
Stepper.SetSpeedRPM.microDelayStep : -8 ;SpeedRPM: 19 ;stepPerRev: 200 ;microPerSteps :1
Stepper.SetSpeedRPM.microDelayStep : -3 ;SpeedRPM: 47 ;stepPerRev: 200 ;microPerSteps :1
Stepper.SetSpeedRPM.microDelayStep : -4 ;SpeedRPM: 35 ;stepPerRev: 200 ;microPerSteps :1
Stepper.SetSpeedRPM.microDelayStep : -9 ;SpeedRPM: 16 ;stepPerRev: 200 ;microPerSteps :1
Stepper.SetSpeedRPM.microDelayStep : -2 ;SpeedRPM: 55 ;stepPerRev: 200 ;microPerSteps :1

?!?!

EDIT:
Small change:

B4X:
'calculating step delay in microseconds
    microDelayStep = 60000000 / SpeedRPM / stepPerRev * microPerSteps
    Log("Stepper.SetSpeedRPM.microDelayStep : ", microDelayStep, " ;SpeedRPM: ", SpeedRPM, _
    " ;stepPerRev: ", stepPerRev, " ;microPerSteps :", microPerSteps)
    'in this place needs to calculating microsteps if needed
    'because with very high rpm micro steps is not needed

and log

B4X:
AppStart
Stepper.SetSpeedRPM.microDelayStep : 5000 ;SpeedRPM: 60 ;stepPerRev: 200 ;microPerSteps :1
StartBlinking
Stepper.SetSpeedRPM.microDelayStep : 15789 ;SpeedRPM: 19 ;stepPerRev: 200 ;microPerSteps :1
Stepper.SetSpeedRPM.microDelayStep : 12500 ;SpeedRPM: 24 ;stepPerRev: 200 ;microPerSteps :1
Stepper.SetSpeedRPM.microDelayStep : 10344 ;SpeedRPM: 29 ;stepPerRev: 200 ;microPerSteps :1
Stepper.SetSpeedRPM.microDelayStep : 8333 ;SpeedRPM: 36 ;stepPerRev: 200 ;microPerSteps :1
Stepper.SetSpeedRPM.microDelayStep : 7142 ;SpeedRPM: 42 ;stepPerRev: 200 ;microPerSteps :1
Stepper.SetSpeedRPM.microDelayStep : 6122 ;SpeedRPM: 49 ;stepPerRev: 200 ;microPerSteps :1
Stepper.SetSpeedRPM.microDelayStep : 5454 ;SpeedRPM: 55 ;stepPerRev: 200 ;microPerSteps :1
Stepper.SetSpeedRPM.microDelayStep : 5000 ;SpeedRPM: 60 ;stepPerRev: 200 ;microPerSteps :1
Stepper.SetSpeedRPM.microDelayStep : 5000 ;SpeedRPM: 60 ;stepPerRev: 200 ;microPerSteps :1
Stepper.SetSpeedRPM.microDelayStep : 5000 ;SpeedRPM: 60 ;stepPerRev: 200 ;microPerSteps :1
Stepper.SetSpeedRPM.microDelayStep : 5882 ;SpeedRPM: 51 ;stepPerRev: 200 ;microPerSteps :1
Stepper.SetSpeedRPM.microDelayStep : 6976 ;SpeedRPM: 43 ;stepPerRev: 200 ;microPerSteps :1
Stepper.SetSpeedRPM.microDelayStep : 8571 ;SpeedRPM: 35 ;stepPerRev: 200 ;microPerSteps :1
Stepper.SetSpeedRPM.microDelayStep : 11538 ;SpeedRPM: 26 ;stepPerRev: 200 ;microPerSteps :1
Stepper.SetSpeedRPM.microDelayStep : 16666 ;SpeedRPM: 18 ;stepPerRev: 200 ;microPerSteps :1
Stepper.SetSpeedRPM.microDelayStep : 25000 ;SpeedRPM: 12 ;stepPerRev: 200 ;microPerSteps :1
 
Last edited:

BaGRoS

Active Member
Licensed User
Longtime User
When I cahnging 60 * 1000 * 1000 on 60000000 then everything working well.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…