New user... some programming questions


#1

I recently purchased an mBot Ranger kit and I have some questions:

  1. I enjoy programming robots more than I enjoy building them. How big can my mBlock programs be? Is the program simply sending signals back and forth between the robot and my PC? If so, then theoretically my programs could be quite large, right?

  2. I’d prefer to use the Arduino app and program the robot in C, but it seems like I have to upload my code to the robot. How much RAM does the Me Auriga have? I tried a small program (which failed to transfer – will have to figure that out tomorrow), and it looked like program and variable space was pretty limited.

  3. If the mBlock program is just communicating commands and sensor data via Bluetooth, is there any way to do the same thing using C code?

  4. When I use the Arduino app to write C code which board should I choose? Aurduino Leonardo? (I think I read that somewhere.)

I’ll probably have more questions later. Thanks for any help!


#2
  1. The Ranger is equivalent to an Arduino Mega 2650.
    http://learn.makeblock.com/en/me-auriga/

I use the term tethered-mode to refer to Bluetooth, 2.4hz serial or wired USB connection where the program is running on the computer and streaming commands to the robot.

  1. Tethered mode uses a variation of the standard Firmata protocol. If you’d like, you can write programs that send valid firmata commands in almost any language.

http://firmata.org/wiki/Main_Page

  1. Arduino boards are based on small Atmel processors. The program space for the Ranger board has 256K of program memory, of which (I think) 8K is eaten by the bootloader. The mCore and Uno/Leonardo boards have 32K. So it’s tiny by modern computer standards, but the Ranger is a “big” Arduino. You’ll be fine.

  2. There’s not a similar limit to program size when you’re operating in tethered mode. However, tethered mode does introduce some significant latency. Mind that when building large programs.

–andrew


#3

One thing I would toss out about the Atmel processors is that program memory and variable memory are physically different, unlike most computers. The Atmel 2560 has 8K of variable memory, and while there are techniques that make it possible to put variables in program memory, the reads and writes are generally slower.

If you download the Makeblock libraries from Github (link), you can go through the firmata and the default program to suss out the details. Using the Arduino environment to program the mBot is the topic of the eBook that I’m working on right now but much of that should transfer over to the mBot Ranger, etc.


#4

1)

From the “Getting Started” guide:

http://download.makeblock.com/mblock/docs/getting-started-with-mblock.pdf

In Scratch Mode, the robot or Arduino board must be connect to the computer in order to run the program. You can use Scratch blocks to create graphics or make games.

In Arduino Mode, the program is uploaded into the robot and the robot is run on its own. However, you 
cannot use graphics from Scratch since the computer is no longer there.

Using Scratch mode isn’t all that fun since the robot must be tethered to the PC (not sure if this can be done via BlueTooth). But that mode would probably allow for larger programs.

For the Arduino mode and Arduinio IDE, the code gets stored in the board, which does limit the code size. Even more limiting is the variable space…globals are limited to 1K or so for the mCore board. Not sure about local variables.

2)

I used the Arduino IDE to program the mCore board in C/C++. I’m not sure of the memory sizes of the various boards. Here is a sample program I wrote which has the Remote Control, Line Follower, and also uses the IR sensors to enable the robot to roam around on a table without falling off the edges (use on a low table such as a coffee table on carpet as the robot WILL eventually fall off):

http://somedisassemblyrequired.com/index.php/2017/01/01/mbot-example-program

3)

You could use C code to communicate with the robot. You’d have to learn how the Scratch firmware communicates (it’s open source) and then write C code to run in the PC (server code) to send/receive commands to the Arduino (client). The PC code couldn’t be written in Arduino IDE – the resultant binary won’t run on a PC. You’d have to use a C compiler for the PC to make the server code. You could also write your own client code for the robot using the Arduino IDE instead of using the Scratch firmware. You would still have to write the PC server code for a C compiler specific to the PC.

4)

I use the Arduino IDE to program the mCore on the mBot.

Using Raspberry PI

My next project is to give the robot the ability to “learn” using neural networks. This code is NOT going to fit in the Arduino. I plan to use a Raspberry PI 3 for the thinking. The Arduino board will simply be a pass-through to control the outputs and inputs.

The PI has significant RAM and copious “disk space” in the form of an SD card. You can also program it in Java, which is nice because the Java will also run on the PC for testing.


#5
  1. You can run Scratch code using the green flag hat block over Bluetooth or WiFi. It is literally sending the commands to the firmware. This allows you have much larger programs although you will have to contend with over-the-air time lag.
  2. Sweet! The Auriga and Orion boards are essentially an Arduino Mega and the mCore is an Arduino Uno.
  3. Check the Github repo, the codes are all there.

Great to see what you’re doing!


#6