Calculation-glitch in mBlock5


#1

I ran into a glitch in mBlock5 (this worked perfectly in mBlock3), which has a lot of impact on the lesson-material i made so far.

I use potentiometers to control LEDs and servo’s. To make use of the complete range of the potentiometer i calculate the scale. For example if i want to control the brightness of a LED, i will calculate the scale by dividing the range of the potentiometer (1024) by the range of the LED-channel (255). In this case the scale is 4.015686274509804.

A long number, but i’m not bothered, because i store it in a variable, and this works OK in mBlock3.

In mBlock5 however this somehow results in a potentiometer-value that is divided by 1000. But only when there are more than 8 digits behind the decimal point, otherwise it works fine (see picture).

@tech_support: Can you check with the engineers if there is a way to fix this?

I would upload an mBlock-file if i could, but the forum software won’t let me.
You can download it here: calculate_scale_mbot_test.mblock


#2

This is the wrong data format, please try:


#3

That’s not the solution, ‘ceiling’ and ‘round’ will force the value into integers, i need to use floating numbers as well.
The problem is, as described in the picture, calculations with the scale-variable work fine as long as ‘scale’ has no more than 8 digits behind the decimal point.
Otherwise, the result-value is divided by 1000.

for example:
1000/255 = 3.92156862745098 - doesn’t work
1000/256 = 3.90625 - works!


#4

Does this one always works?
image


#5

Yes, in this picture you can see what happens.
A: the potentiometer-value is divided by a floating number with more than 8 digits.
The result is wrongly divided by 1000.
B: the potentiometer-value is divided by a floating number with 8 (or less) digits.
This result is correct!


#6

or in short:
calculate_4


#7

Hi albertepp,
I just forwarded to the develop team, the problem should be the software issue. We will try to fix it in the next version. Thank you for your time and patience.


#8

Thanks! Do you have a clue when the next version will be released?


#9

There will be a update at the end of this month, but I am not sure this fix will be added in this version.


#10

Hi tech_support, i noticed this has been fixed in mBlock 5.1. Nice!
Thanks to the engineers for fixing this so quickly.


#11

Hi Albert,
Glad to hear that. Again, thank you for your feedback. :grin: