Mblock wait() function is not accurate


#1

The mBlock wait() function seems to be not accurate.
I am using it for the mBot ranger.
Is this a known problem?

I have also created some code that makes a fix for this problem.
Thank you.


#2

I have noticed a 2-10 second error when trying to use the wait block.
I used the timer(Is it based on Arduino’s millis?) to make a better function.


#3

What is your code? Do you mean the wait {number} seconds block? Are you using device or sprite? Also, welcome to the forum!


#4

I am using as a device for a mBot ranger.
I am using the wait{number of seconds block}
Thanks!


#5

Just wondering, @Best_codes where is the code for mblock(specifically the blocks)?


#6

@V205

What is your more specific code and error / problem?

Yikes! :grimacing: That’s a tough one! You can look around here:

https://github.com/Makeblock-official

The code varies actually, for sprites it is JS rendered on a canvas and for devices it is Python or C+.


#7

Sorry for the later reply but the code is just:

The wait time is always more than a second.
I have timed it.
It is a problem for accurate turning.


#8

So, this is for mBot Ranger… I have no idea why this is happening. Mine works fine. What is the Arduino C part of the code? (In the side panel). Sorry, I have been so busy.


#9

It is fine…
The arduino code is blank for some reason…


#10

Just checking:

image

Sorry for the bad drawing, I was in a rush. :slight_smile:


#11

I did that.
It is just blank.


#12

Because you are using the When 🏳 Clicked block. Use When mBot Ranger starts up instead. @V205


#13

Ok. I will change it and see what happens.


#14

If you are using the green flag block in live mode, then the problem is that the device and computer have to communicate to see what they should do. (Ranger runs C++, mBlock IDE runs JS, and your block combo is both). This has some lag. If you upload a code to the Ranger that does that but using the starts up block, it will be one second.


#15

@Best_codes
I won’t be able to do that.
The block is greyed out(because of the live mode on).
I can’t use the upload mode unfortunately so I can’t use the When mBot Ranger starts up


#16

@V205
Why can you not use upload mode? If you really can’t, the best thing you can do is use the built-in delays in the motor blocks.


#17

I can’t because:

  1. I am using bluetooth 4
  2. The upload using USB is problematic and often bricks the controller.

Oh well.

Is there a program that allows accurate turning?
Like in degrees?
For the Ranger?


#18

@V205
There currently is not. :confused: You could make one though if you had upload mode. Why can your device not use just the USB cable exactly? Maybe you can try from another device.


#19

Ok, sometimes I can use upload but I don’t like to because of the aforementioned problems.
If I could use upload mode I will…

So there are no resources for accurate turning?
I am trying to get the ranger to turn ~90 degrees

(I will probably hit post limit soon)


#20

If you have taken the new user tutorial, then you will not hit a post limit for a while. (if you haven’t, just say

@discobot start new user

)

:slight_smile:

There are no resources, but you can do a code like this:

It might take some tweaking. I just threw it together on the spot :grimacing:.