Joystick Negative Values


#1

Hello,

I have just started to have problems with the joystick. I’m using mBlock version 3.4.11 and the mCore computer.

When the value for either X or Y is less than -255 the value reported drops to 0. So for all values of -255 to -500 I get 0. From -255 to +500 everything is fine. The odd thing is It works fine on one PC computer but not two others. The mBlock files on the working PC computer are dated 9/21/17. The files on the non-working PC computers are now dated 1/15/18 as I reinstalled the program is see if that would fix the problem. It did not.

If I use the potentiometer instead of the joystick then the numbers are reported correctly as they go from 0 to 1000. If I put the potentiometer in place of the joystick using a function of (Potentiometer - 500) to force the numbers negative (-500 to +500) it works. What is even odder is that on one of the computers I installed mBlock for the first time today and the joystick worked correctly but after saving the program it no longer worked correctly. It now returns 0 whenever the joystick value drops below -255.

+/- 255 is the largest number that can be returned for an 8 bit system. So it appears that we are working with a 10 bit system to get values close to +/- 1000. It seems like something in the joystick program block is cutting off at 8 bits.

Any ideas?

Thanks


#2

Hello,

Just found my answer. In an earlier post someone suggested going to “Extensions” and selecting “Clear Cache”. That fixed the problem. Now by adding 500 to the joystick position and dividing by 5.6 I can get the values of 0 to 90 for the “set servo” angle to work correctly.


#3

Hi MrBill,

What are the operating systems for the three computers (the one works and the other two not works)?
Besides, before you testing reading the value from the joystick, please clear the cache on the mBlock software, then upgrade firware for the mainboard have a try.