Cannot upload program to mBot make it autonomous


#1

Hello,
I’m teaching my son how to code and wanted that his programs can be used without the mbot being connected by the wire. While the programs work when we use the flag event, they do not work at all when we use the [mBot Program] as first instruction in the programming block. How can we solve that (using mBlock 3.3.1). Please help!

Thank you,

Thierry & Dimitri


#2

You must connect the mBot via the USB cable to upload programs to it. All over the air communications (WiFi/Bluetooth) go through a serial connection, but that connection does not have access to the avrdude programmer that is required to upload a program to the mCore board. The wireless connections only send firmata commands over the air to the mCore board. After you upload a program via the USB cable, it will run without needing to be connected to the mBot.

A word of caution is in order. If your program involves the motors, you might consider putting a wait until (button pressed) block at the beginning so that the mBot does not run off the table after the program is uploaded.

Regards,

Chuck


#3

Hi Chuck,
The mbot is connected with the usb cable. So it really looks like there is a problem. Shall I send the robot back or is there something I should try?
Thanks,
Thierry


#4

Hmm, so when I have my mBot connected via the USB cable and have made the serial connection via the Connection->Serial Port menu, I have to click the Edit->Arduino Mode menu item followed by clicking the Upload to Arduino button on the Arduino-ish IDE that appears on the right side of the screen. Have you tried that?


#5

Hi titidim,

Please kindly try chuck’s suggestion. If there is still issue, could you attach the program you are going to upload to mBot.
Besides, here is a instruction to guide how to upload program on mBot in details, please double check and make sure that you operate properly.Upgrade Firmware and Upload Program for mBot.zip (860.4 KB)
Btw, will the mBot back to work properly as it is after reset default program?


#6

It seems really flaky trying to connect via the serial port. I have to physically disconnect and reconnect several times and keep trying to connect via the menu item. Took me about 20 tries to get one upload attempt, which then fails:

avrdude: stk500_recv(): programmer is not responding

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x16

avrdude: stk500_recv(): programmer is not responding

It’s a shame there wasn’t basic QA done on the software, because the hardware looks quite nice. I suppose that’s what gets cut for something that costs $80, but consider the MindStorms plastic stuff is like $600.

So who has figured out how to upload over the 2.4 Ghz connection? That’s what I really want.


#7

Hi Ophitoxaemia

I have explained in this link that the 2.4G connection is not available for uploading program or Upgrade Firmware: http://forum.makeblock.cc/t/mbot-upload-via-2-4ghz-connection/1587/4

As for the fails message when upload program to mBot with USB connection, please temporarily move the 2.4G module from mCore board and upload program to mBot with USB connection again have a check.


#8

Thanks for the reply.

I was able to get the program uploaded, but nothing happens, which I posted about here: http://forum.makeblock.cc/t/mbot-does-not-execute-uploaded-program/4845

I understand that we can’t upload programs via the 2.4 Ghz connection with the stock unit; my question was about how to make it work that way.

Does the mBot require a constant connection through the 2.4Ghz connection to operate autonomously? I plan to program it to inspect my gutters from the roof and don’t want it to get stranded up there.


#9

vI am not sure if you are aware of that: mBot has 2 modes of programming:

First mode is when you use Scratch and the green flag as to start the program. I think in this case the program is not really uploaded to the mBot - it seems to me that the mBot is remote controlled by the device (laptop or tablet) it is connected to. The default program gets its commands from the device and returns any requested sensor readings. This is also why you are able to see e.g. variables in real time in the Scratch stage. There is no need to upload the program, just start it.
This mode works over Bluetooth, WLAN, and USB.

The second mode is when you use either C or Scratch with the mBot program icon as a start. Then you have to upload the program to the mBot. It replaces the default program and runs autonomous. Drawback is that you no longer see variables in the Scratch stage. Upload is only possible by USB connection, but then you can disconnect.


#10

Spot on. I’d add that when you connect via Bluetooth/Wifi you are really sending commands over the serial port to the mBot firmata. Supposedly there is a way to get data back over a serial connection, but I haven’t explored that area yet.


#11

I’ve uploaded a program to the mBot so it will run autonomously (mode 2 as you mention), but now how do I return it to mode 1? It seems to only run the uploaded program now and ignores anything else from mBlock.

I’ve tried turning it off and on, and pressing the reset button on top, then double clicking on a new program- no luck.


#12

To restore the mBot to the factory setting, you will need to click the Reset Default Program under the Connect menu. When you upload a program to the mBot (or any other microcontroller-based board) you overwrite anything that was previously stored in the memory of the microcontroller. It is important to understand that a microcontroller-based system is not the same as a PC. :slight_smile:


#13

I was able to reset the program on the mBot without resetting the default program, although the exact sequence was lost in experimentation.

It’s been a long time since I’ve had a PC with a reset button. Probably since before the term “PC” was invented.


#14