How to get compass module to work with mBot


#1

I’ve just added a Me Compass module to my mBot. I’ve connected it to port 1, and made a simple program in mBlock 3.4.5 to loop forever, setting the value of a variable to the compass on port 1.

It never returns anything other than ‘0’ for the compass reading.

I can successfully use the line tracker module and the ultrasonic sensor module, and the motors, so I know the mBot is working and communicating properly with the mBlocks program.

The compass module has a red LED turned on when the mBot is on.

How do I get the compass to work?


Makeblock Me Compass
#2

Second to this request. Hey @tec_support!

I’ve gone a step further and used the Compass (and MeGyro) modules with an uploaded program, spitting out the sensor readings through Serial Print statements. This yields non-zero readings.

I can’t get the same readings to display in mBlock. Do these sensors not work in tethered programs?

–andrew


#3

Hi,

to read a value in the mblock program; you have to upgrade firmware ( under the “connect” at the upper left.)

Most of the time , it works.

J-M


#4

Thanks for the suggestion. We update the firmware as a regular part of switching between uploaded Arduino programs and tethered mode.

Is your suggestion that there’s a particular version of the firmware that works better with the Compass sensor in tethered mode, or that there’s a special window right AFTER updating firmware where the Compass sensor works better?

–andrew


#5

OK, I went back and tested this again.

Connected mCore to computer.
Update Firmware
Reset Default Program > mBot
Connect > Serial Port > /dev/tty/wchusbserial

Now mBlock shows Serial Port Connected in the header bar. I’m ready to run a tethered program from mBlock.

Connect MeCompass to port 3

This was my test program for tethered mode.

The program runs, but the Panda only ever thinks “0”

Next, made an similarly simple upload-able program. No action other than reading and reporting data from MeCompass on Port 3.

Once the program is uploaded to the mCore, you have to reconnect the serial port using the Connect menu, and switch the reporting modes to Character. Then the serial write statements will show up in the tiny Serial Monitor window at the bottom right of the mBlock Arduino-mode screen.

As you can see, here MeCompass reports reasonable values. These numbers shift as I moved the sensor around. They may not be properly calibrated, but it at least demonstrates that the sensor is functioning and sending data.

This is where I landed a few months back. There’s some software issue at work here. Either the mBlock Compass Sensor block’s code (the javascript that runs and sends/recieves data to the mCore’s firmata variant) needs fixing
OR
There’s a hardware timing issue that prevents MeCompass (and other white-labeled sensors?) from operating in Scratch/tethered mode. If this is the case, Makeblock needs to say so loudly and clearly, preferably on the product pages for all such sensors.

Anyone else have MeCompass sensors to test? Any thoughts @tec_support ?

–andrew


#6

Hi tieandjeans,

From your reply on above, you reset default program after upgrade firmware, and then test the online program below.

Please note that you need upgrade firmare for the mCore to clear the previous uploaded program right before you test the online program. There is no need to reset default after upgrade firmware.
Please kindly upgrade firmware for mCore again and then test the program below wihtout reseting default program.


#7

Hi @tec_support,

(Ignore this post - I messed up!)

Thanks for your instructions. I have tried them and it doesn’t work for me.

I have installed the Arduino drivers, connected the mBot via the USB cable, and upgraded the firmware.

I have not reset to the default mBot program.

I’ve then tried the program you suggest in mBlocks, and the panda always thinks “0”. The compass module now has a blue light on the bottom, which is progress from earlier.

I’ve also tried the ultrasonic sensor instead of the compass, and that also thinks “0” all the time. I know that the ultrasonic sensor usually works with the default program, so it seems that the ‘upgrade firmware’ has made things worse for me.

I’m also finding that with the upgraded firmware, I can no longer connect to the mBot using 2.4G serial. So that really reduces the usefulness of the robot, as it has to be attached via USB.


#8

D’Oh! I just realised that I forgot to plug in the 2.4G dongle! So ignore my last post. :blush:

I am now using the upgraded firmware, without resetting the default program.

The compass module is giving values - hooray!

The ultrasonic module is also returning correct values.

I guess the confusing part (for me at least) is that the ‘upgrade firmware’ is an alternate to the default program. Maybe if they were labelled as ‘beginner’ and ‘advanced’ that would make it more obvious that they are alternatives, not something you can apply both.


#9

Does this suggest that some Makeblock products are supported by boards running the “firmware” but not the “default Program”?

I am constantly amazed that Makeblock finds new and interesting ways to misuse common phrases.

When I do Upload Firmware, the upload completes with a single beep. When I reset the board, it does not make the three tones of the default program. I had always interpreted this to mean that the board was not ready to communicate with the mBlock - ie, did not have Makeblock Firmata loaded. I can see now that this was incorrect.

Is the program labeled “firmware” just Firmata without the IR controls? Is there a list of what sensors/products are disabled when running the “default Program”?

–andrew


#10

Wow. Using the “update firmware” instead of “default Program” also allows tethered mode to address all 30 LEDs on the strip. When the default program is on the board, the LED strip output is capped to 15.

Who knew?!

–andrew


#11

It seems that the three beeps are part of the ‘default program’, the single beep is the startup for the ‘upgraded firmware’. So yeah, once you get that one beep, it’s good to go. As long as you don’t want to use the IR remote without adding your own code for that, and you don’t get the inbuilt line follower and obstacle avoidance modes. But you do get support for all the sensors it seems.

As a total guess (based on past Arduino coding experience), I’d say that there isn’t enough room on the board to include the IR code, the line tracker code, the obstacle avoidance code, and all of the libraries for all of the sensors. So they ship it with some basic support, and if you buy more sensors that’s when you upgrade to the firmware that has all the libraries (but not the demo modes). Just guessing.


#12

The core of my frustration is that we’re all “just guessing.”

I agree with your assessment that program size might limit some support libraries. Befuddled as to why that would cause the 15-LED limit. It could also have to do with having an interrupt set for signal from the IR port?

Ok. Now we just need to get those terrible names replaced. Not only do they not describe the difference between these two modes, but the names MEAN OTHER THINGS.

–andrew


#13

Hi tieandjeans,

The default program is previous uploaded program from factory. With the default program, customer can play the robot by default modes through IR controller or mobile APP.
Customer can also write and upload their own program to the main board to play the robot in the other way.

As for upgrade firmware, it is needed when you want to run program online. Please refer to this document, it may help you understand the upgrade firmware.


#14

`I’ve read that document, and similar posts to this, several times. My problem is that both use words that don’t match either their technical or common English usage.

The first problem is “run the program online.” Online, in conversational English, normally means “connected to the Internet.” Makeblock uses it to mean “run with an active serial connection (wired, Bluetooth or 2.4g) to mBlock.” This is really confusing.

The other big problem is “firmware.” Arduino programs compile to .hex files and upload to volatile RAM, so they can technically count as “firmware.” But in conversational English those are called “programs.” Firmware normally refers to something that’s a lower-level part of the device. Looking through the Arduino documentation, the only discussion of “firmware” comes when discussing the separate Atmel chip that handles USB-Serial on the Uno.

https://www.arduino.cc/en/Hacking/DFUProgramming8U2

As @mjg mentioned above, using “program” and “firmware” to distinguish between these two is super confusing. It’s bad for novice users, because “firmware” sounds intimidating. It’s worse for intermediate/advanced users, who have incorrect expectations based on the language used.

Can you link to, or provide filenames for, the non-complied .ino files for each of these two? At this point, I’d really like to read the files and see what’s actually going on.

–andrew


#15

Dear tieandjeans,

Thanks for sharing your opionion. I will provide the feedback to our company.
As for the .ino file, you can install the arduino software and makeblock library refer to this link: http://learn.makeblock.com/en/learning-arduino-programming/
Then you can find the two .ino files refer to the picture below:


#16

Is mbot_firmware or mbot_factory_firmware the “default program?”

–andrew


#17

Hi Andrew,

The mbot_factory_firmware is the default program.


#18

I have the same problem as tieandjeans, trying to get the compass (and the 3 axis accelerometer and gyro) to work.

-I have the mBot connected with the serial cable.
-I have upgraded firmware
-I have NOT reset the default program
-My code is very similar to what tieandjeans had to query the compass (and 3d acc & gyro) and say the results
-when I run it from mBlock, the code runs, but I just get 0 values

-if I use mBot Program (and use write line instead of say), let mblock generate code, and then edit in Arduino, and upload from Arduino, then it works, I get reasonable values in the serial terminal.

so, I am still missing a step somewhere?


#19

Hi tgraphic,

You may refer to this document to upgrade firmware again to make sure you have done it correctly.1. How to Upgrade Firmware for mBot.docx.zip (690.6 KB)
Then please run the mBlock program online again.

Once still 0, please paste your program here.
Besides, which port you connect the me compass to the mCore board?
If it is possible, you may take a video to show whole your operations and result.


#20

Tec Support, Wa Hoo! now it works. The missing step was in the document you referenced:

" if your PC is Mac, you need pay attention to two points bellow
Before upgrade firmware, need install a driver for Mac, here is the link to download the driver. …"

My computer is a Mac. As soon as I installed that driver (and restarted, and did ‘upgrade firmware’ again), then it worked.

Thanks!