Arduino Create web-based IDE


#1

Not sure if anyone is interested, but the Arduino team now has a web-based IDE (link) that you can use to compile sketches. I’ve compiled several test sketches for the mBot and it worked well.

To use the Makeblock libraries with the web-based IDE, do the following:

  1. Download the Makeblock libraries as a .zip file from Github (link)
  2. Unzip this file in a temporary directory.
  3. Create a new .zip file of just the makeblock directory in the temporary directory.
  4. Upload the new .zip file to the web-based IDE.
  5. Write lots of code!

#2

Chuck, I would love to learn how to do this. I can download the Makeblock libraries as a .zip file using your link6. But the link16 doesn’t lead to an obvious way to use the web-based IDE. I log in as a user, but then where do I go to upload my new zip file to the web-based IDE. Does this approach let one modify the code in the mbot files? I have a real interest in doing that. Thanks! Eric


#3

Hi @eric03,

You will need to do the following:

  1. Download the zip file from Github using the link.
  2. Extract the makeblock directory from the zip file.
  3. Make a new zip file with just the contents of the makeblock directory.
  4. Click on the Libraries icon on the web editor on create.arduino.cc.
  5. Click the Add Zip button and then select your newly created zip file to upload.

That’s about it.

Regards,

Chuck


#4

Chuck - Your directions are straightforward, but I seem to be missing a critical step. I am trying to modify a particular command (a small change) for controlling the motor in mbot and am using a Mac (OS 10.11). So I make the small change in MeMbotDCmotor.cpp in the newest version of Makeblock (version 3.2.3) located in Arduino/libraries/makeblock/src. But now what? I need to compile and then upload to my mbot some file that combines all the individual commands. Can that be done in the mBlock program itself (presumably not the Upgrade Firmware option, but which one?)? Is there some help file that will let me figure this out without bothering you (which I feel guilty about - I see you provide answers to so many newbie questions). Just to let you know what I am doing, I have implemented using inexpensive stepper motors instead of the DC motor to make much more precise steps and turns, to be used in the Italian elementary school curriculum. My daughter, a math education professor in Rome, is writing a text to go with the robot (actually the robot goes with her text!) and an Italian publishing company is already committed to publishing her text and making the robots to go with it (they are now just using the BeeBot). I am developing the robot for them (gratis, it’s just fun working with my daughter on this). Thanks again for your help.
Eric


#5

I haven’t done what you’re doing (yet), so contacting @tec_support might be the fastest answer. When uploading to the mBot (versus sending over the air commands via the Makeblock firmata), the Arduino IDE compiles all of the source together for you and the resulting binary overwrites the existing PROGMEM/SRAM on the Arduino.

I’m interesting in seeing where you go with this project, so keep me posted! :slight_smile:


#6

Chuck - Here is what I sent to tech. I’ll keep you posted. eric03
I am trying to modify a particular command (a small change) for
controlling the motor in mbot and am using a Mac (OS 10.11). So I make
the small change in MeMbotDCmotor.cpp in the newest version of Makeblock
(version 3.2.3) located in Arduino/libraries/makeblock/src. When a
Makeblock program using the motor command (forward, backward, etc) in
Makeblock is uploaded to the mbot using the Mbot Program start command
and then choosing Upload to Arduino, the modified command works fine.
But I want it to work when I use the wireless module to run the program.
To do that, I need to Upgrade Firmware in the Connect menu. So I do
that, then switch to the 2.4G Serial connection. The Makeblock program
runs, but it uses the standard motor command (again tested with the
forward, backward etc robot commands in Makeblock). What program is the
Upgrade Firmware command using to upload to the mbot? I need to change
the program that is uploaded so I can use the modified command in the
wireless mode.
Thanks for your help with this. Eric Frank efrank03@mac.com


#7

Hi @eric03,

The mBot firmware code is in the Makeblock-Libraries/firmware/mbot_firmware directory. You’ll need to compile the Arduino sketch and use the Export Compiled Binary selection under Sketches in the Arduino IDE. You can use the Show Sketch Folder option to confirm it’s there. That “should” do the trick, but to be sure you might want to verify that with @tec_support.


#8

Chuck - Thanks. Does that work for you? I installed the new Makeblock-Libraries in Arduino/Libraries/makeblock. The contents of makeblock are examples and src. Inside examples are Firmware_For_mBlock (and others) and inside that is mbot_firmware and mbot_factory_firmware. Inside /src are lots of cpp and h files (for all the subroutines needed) and also a folder called utility. Inside utility are 6 .h files, including EEPROM, Servo, Software.Serial, SPI, twi, and wire. When I open mbot_firmware and compile it, I get a list of errors:
WARNING: Category ‘’ in library EEPROM is not valid. Setting to 'Uncategorized’
WARNING: Category ‘’ in library SPI is not valid. Setting to 'Uncategorized’
WARNING: Category ‘’ in library SoftwareSerial is not valid. Setting to 'Uncategorized’
WARNING: Category ‘’ in library Wire is not valid. Setting to 'Uncategorized’
Warning: platform.txt from core ‘Arduino AVR Boards’ contains deprecated recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} “{build.path}/{archive_file}” “{object_file}”, automatically converted to recipe.ar.pattern="{compiler.path}{compiler.ar.cmd}" {compiler.ar.flags} {compiler.ar.extra_flags} “{archive_file_path}” “{object_file}”. Consider upgrading this core.
Multiple libraries were found for "MeMCore.h"
Used: /Users/efrank/Documents/Arduino/libraries/makeblockOLD
Not used: /Users/efrank/Documents/Arduino/libraries/makeblock
Not used: /Applications/mBlock_v3.3.1.app/Contents/Resources/Arduino/Arduino.app/Contents/Java/libraries/makeblock
Not used: /Users/efrank/Documents/Arduino/libraries/makeblock
Not used: /Applications/mBlock_v3.3.1.app/Contents/Resources/Arduino/Arduino.app/Contents/Java/libraries/makeblock
Not used: /Users/efrank/Documents/Arduino/libraries/makeblock
Not used: /Applications/mBlock_v3.3.1.app/Contents/Resources/Arduino/Arduino.app/Contents/Java/libraries/makeblock
Not used: /Users/efrank/Documents/Arduino/libraries/makeblock
Not used: /Applications/mBlock_v3.3.1.app/Contents/Resources/Arduino/Arduino.app/Contents/Java/libraries/makeblock

One of them I don’t understand is one errors say "multiple copies of MeMCore.h. But I can find only one and it is right in the /src. folder.

Is this what you see? Eric


#9

I had no compilation issues. Did you import the Makeblock libraries into your Arduino environment? If you zip the makeblock directory from the Github repo, you can easily add it to the Arduino IDE as a set of available libraries. At least, that’s what I did. :slight_smile:


#10

Hi eric03,

The suggested steps from chuck is correct, after modified the program, you need compile the mBot firmware and export the binary file which is .hex.
Find this .hex file and put it under the mBlock’s installation path (like D:\mBlock\tools\hex) to replace the original .hex file of mBot firmware.


#11

Hi tec_support,
Your suggestion sounds good, but I use a Mac, not a PC. So what is the mBlock’s installation path on a Mac? Would it be mBlock/Contents/Resources/firmware/mbot_firmware and mBlock/Contents/Resources/tools/hex? In the mbot_firmware.ino file, I find no mention of the MbotDCMotor.h and MbotDCMotor.cpp files. Only the MeDCMotor. How does the firmware execute the “move” command that Makeblock calls with the “run forward at speed xxx” command? I have modified the MbotDCMotor.cpp file, and that works well, but I cannot get it installed in Makeblock so I can run my new command using the wireless module. Thanks for any help you can provide. efrank03


#12

Hi eric03.

After you compiled the mBot firmware and exported the binary file which should be named as the mbot.hex file, you can use this mbot.hex file to replace the original mbot.hex file under mBlock’s installation path.

On my windows PC, I found the original mbot.hex file under the D:\mBlock\mBlock\tools\hex.


You may need look for the path of the mbot.hex file on your Mac PC. It is not the mbot_firmware.ino file.


#13

Hi Chuck - Sorry to bother you with this again, but the tech support just isn’t very useful. Also, my change may be of interest to you because you mentioned in another post the difficulty of making precise turns with the DC motors. I have programed an Arduino-mini to run stepper motors, driving it from the DC motor outputs of the mbot. Those 4 outputs are PWM, so by sampling them for 1 PWM period (about a ms) with the analog arduino inputs (4 or them, 2 for each motor, with one wire active for forward and the other for backwards), I get a voltage proportional to the specified speed, updated each ms. The arduino software I wrote takes this and converts it to stepper motor outputs, using the cheapest steppers I could find (about $3.00 each). So the mbot software doesn’t need to be modified at all. This is still not very precise using the wireless mode to run the bot, however, because one must still start and stop the motor with the robot commands, first starting the movement, then delaying for a second or so, and then stopping the movement. All this takes take time, and varies slightly from one time to the next. So I then modified the mbot software in MeMbotDCMotor.cpp so that a single call to forward, backward etc from Makeblock starts the motors, delays for a certain number of ms, and then stops the motors. This all works fine within Makeblock if I use the mBot Program start button and compile and upload the program. But when I try to run it with the 2.4 G wireless, it never uses my modified MeMbotDCMotor.cpp file. I’ve followed your and the tech’s directions for compiling the mbot firmware and then moving the hex file to the Makeblock/Contents…/tools/hex folder, but I always still get the original forward, backward etc commands - not my modified version. And curiously, in the mbot firmware file, the MeDCMotor file is listed but never the MeMbotDCMotor file. So where is the code for the forward,backward etc commands stored? If you are interested in either my modfications or implementation of stepper motors running from the DC motor outputs for mbot, just let me know. Happy to share them. Thanks for your patience! Eric


#14

Hi Eric,

No worries. I am interested in more info (motors, code, etc.) by the way.

With regard to any over-the-air communications, remember that it is a serial connection and that you will always have lag times compared to running directly on the board. Sad fact of life because the serial transmission occurs at a much slower rate than the processor operates, and multiple commands have to be sent and executed.

Looking into the mBlock extensions, it seems to use the MeMBotDCMotor class, so I’m not really sure why it isn’t picking up your mods. In over-the-air operations, I would think that if you upgrade the firmware via mBlock that it would use the mBot firmware load. You might try porting the mods to the MeDCMotor files and see if that makes a difference.

@tec_support, @bigeyex, could you comment?


#15

Chuck: The steppers I use are the cheapest I could find. 28BYJ-48. They are available at SparkFun but then you have to buy the drivers. From BangGood they sell them for a couple of dollars each, and include a little board that provides the LM2003 drivers plus pins for other connections from the Arduino. Those cheapest ones have a 64:1 reduction, so they don’t turn so quickly. The ones from Sparkfun have a 16:1 reductio, otherwise identical, and make the robot go faster. I found them on Ebay (you need to look for the 16:1 reduction in the description, and they work fine, but buy some of the other ones so you can get the driver chips. I use a Arduino Uno (the smallest one) for the computer. The four wires from the motor output from the mbot board go to 4 input pins on the Arduino, and two sets of 4 output pins go to drive the two LM2003 driver chips (which have the sockets for the cable to the stepper built right into the board. I power the driver board with 8V as it makes the stepper move more positively. Have a look at the program (included below) and of course I can answer questions. This setup runs all the motor commands available for the mbot, just as if you were using the DC motors. Here is the code:
/*
Code to convert mbot motor output to stepper motor commands,
using arduino digital inputs to read the PWM motor outputs
(providing speed info) and other stepper code
to drive the 2 small unipolor stepper motors
using LM2003 chips. Motors can be run together or
separately, in either direction and at different speeds.
PWM motor outputs are read digitally and converted to
analog speed values, which are then used to set the delay
times between stepper motor pulses and hence the stepper motor
speed. Before each iteration, check if there is enough time
for the currently active motors. Otherwise a new mbot motor read
is made every 1.2 ms, which is the time for one
complete PWM cycle from the mbot motor output
05/23/2016 Eric Frank
02/06/2016 Modified for testing so not requiring
input from the mbot
27/06/2016 changed order of digital out pins
01/07/2016 New way to read PWM speed from mbot. Digitally read
mbot outputs on all 4 wires as fast as possible.
60 reads (of each of 4 inputs) is 1 PWM cycle.
So sum the 60 values (T is high, F is low) to get the speed.
60 is max speed (255 for mbot), 30 is half speed (127
for mbot), etc.
14/07/2016 basically working, although all speeds are set here to
give max rotation speed
31/08/2016 works well when driven by mbot motor output
04/09/2016 modify to get new motor data only every 20 ms and
keep stepping with current data in between new data reads
*/
long int M1F=0; //Motor M1, forward
long int M1B=0; //Motor M1, backward
long int M2F=0; //Motor M2, etc
long int M2B=0;
int Steps1 = 0;
int Steps2 = 0;
int i;
//defaults to forward
int Dir1 = 2;// 0 is forward, 1 is backwards
int Dir2 = 2;// 2 is don’t step & turn off power
long int Speed2LT = 60000; //LoopDelay=90000/speed? should be 60000?
long int LoopDelay1=0; //how fast can this go?
long int LoopDelay2=0; //
long WaitTime=20; //# of ms to wait for new data collection
unsigned long NextCycle=0; //# of ms to wait for new data collection
unsigned long NextTime1=0;
unsigned long NextTime2=0;

//Stepper1
#define OUT11 2
#define OUT12 3
#define OUT13 4
#define OUT14 5

//Stepper2
#define OUT21 6
#define OUT22 7
#define OUT23 8
#define OUT24 9

void setup() { //these are the inputs to the LM2003 stepper drivers
//Serial.begin(115200);
pinMode(OUT11, OUTPUT);
pinMode(OUT12, OUTPUT);
pinMode(OUT13, OUTPUT);
pinMode(OUT14, OUTPUT);
pinMode(OUT21, OUTPUT);
pinMode(OUT22, OUTPUT);
pinMode(OUT23, OUTPUT);
pinMode(OUT24, OUTPUT);
}

void loop() {
//Initialize motor controls
M1F = 0; M1B = 0; M2F = 0; M2B = 0;
Dir1 = 2; Dir2 = 2;
//read motor data from mbot
for (int i=0; i<60; i++)
{M1F += digitalRead(14); M1B += digitalRead(15);
M2F += digitalRead(16); M2B += digitalRead(17);}

//calculate step rates
if (M1F>1) //move M1 forward
{Dir1 = 0; LoopDelay1 = Speed2LT/M1F;}
if (M1B>1) //move M1 backwards
{Dir1 = 1; LoopDelay1 = Speed2LT/M1B;}
if (M2F>1) //move M2 forward
{Dir2 = 0; LoopDelay2 = Speed2LT/M2F;}
if (M2B>1) //move M2 backwards
{Dir2 = 1; LoopDelay2 = Speed2LT/M2B;}
// Serial.print(M1B); Serial.print(" "); Serial.println(LoopDelay1);

//if ((Dir1==2) && (Dir2==2)) reset(); //no motor runing so turn them off
NextCycle = millis() + WaitTime;

if (millis()<= NextCycle){ //run steppers until time for next data read
if (Dir1 != 2) //M1 should move
{if(micros() >= NextTime1) //move if step delay big enough
{NextTime1 = (micros() + LoopDelay1); stepper1();}
}
if (Dir2 != 2) //M2 should move
{if(micros() >= NextTime2) //move if step delay big enough
{NextTime2 = (micros() + LoopDelay2); stepper2();}
}
}
}

// stepper1 and 2 provide the outputs to the LM2003 chips that
// drive the stepper motors (M1 and M2)
void stepper1(){
switch(Steps1)
{case 0:
digitalWrite(OUT11, LOW);
digitalWrite(OUT12, LOW);
digitalWrite(OUT13, LOW);
digitalWrite(OUT14, HIGH);
break;
case 1:
//Serial.println(i);
digitalWrite(OUT11, LOW);
digitalWrite(OUT12, LOW);
digitalWrite(OUT13, HIGH);
digitalWrite(OUT14, HIGH);
break;
case 2:
digitalWrite(OUT11, LOW);
digitalWrite(OUT12, LOW);
digitalWrite(OUT13, HIGH);
digitalWrite(OUT14, LOW);
break;
case 3:
digitalWrite(OUT11, LOW);
digitalWrite(OUT12, HIGH);
digitalWrite(OUT13, HIGH);
digitalWrite(OUT14, LOW);
break;
case 4:
digitalWrite(OUT11, LOW);
digitalWrite(OUT12, HIGH);
digitalWrite(OUT13, LOW);
digitalWrite(OUT14, LOW);
break;
case 5:
digitalWrite(OUT11, HIGH);
digitalWrite(OUT12, HIGH);
digitalWrite(OUT13, LOW);
digitalWrite(OUT14, LOW);
break;
case 6:
digitalWrite(OUT11, HIGH);
digitalWrite(OUT12, LOW);
digitalWrite(OUT13, LOW);
digitalWrite(OUT14, LOW);
break;
case 7:
//Serial.println(i);
digitalWrite(OUT11, HIGH);
digitalWrite(OUT12, LOW);
digitalWrite(OUT13, LOW);
digitalWrite(OUT14, HIGH);
break;
default:
digitalWrite(OUT11, LOW);
digitalWrite(OUT12, LOW);
digitalWrite(OUT13, LOW);
digitalWrite(OUT14, LOW);
break;
}
if(Dir1==1) Steps1++;
if(Dir1==0) Steps1–;
if(Steps1>7) Steps1=0;
if(Steps1<0) Steps1=7;
}

void stepper2(){
switch(Steps2)
{case 0:
digitalWrite(OUT21, LOW);
digitalWrite(OUT22, LOW);
digitalWrite(OUT23, LOW);
digitalWrite(OUT24, HIGH);
break;
case 1:
digitalWrite(OUT21, LOW);
digitalWrite(OUT22, LOW);
digitalWrite(OUT23, HIGH);
digitalWrite(OUT24, HIGH);
break;
case 2:
digitalWrite(OUT21, LOW);
digitalWrite(OUT22, LOW);
digitalWrite(OUT23, HIGH);
digitalWrite(OUT24, LOW);
break;
case 3:
digitalWrite(OUT21, LOW);
digitalWrite(OUT22, HIGH);
digitalWrite(OUT23, HIGH);
digitalWrite(OUT24, LOW);
break;
case 4:
digitalWrite(OUT21, LOW);
digitalWrite(OUT22, HIGH);
digitalWrite(OUT23, LOW);
digitalWrite(OUT24, LOW);
break;
case 5:
digitalWrite(OUT21, HIGH);
digitalWrite(OUT22, HIGH);
digitalWrite(OUT23, LOW);
digitalWrite(OUT24, LOW);
break;
case 6:
digitalWrite(OUT21, HIGH);
digitalWrite(OUT22, LOW);
digitalWrite(OUT23, LOW);
digitalWrite(OUT24, LOW);
break;
case 7:
digitalWrite(OUT21, HIGH);
digitalWrite(OUT22, LOW);
digitalWrite(OUT23, LOW);
digitalWrite(OUT24, HIGH);
break;
default:
digitalWrite(OUT21, LOW);
digitalWrite(OUT22, LOW);
digitalWrite(OUT23, LOW);
digitalWrite(OUT24, LOW);
break;
}
if(Dir2==1) Steps2++;
if(Dir2==0) Steps2–;
if(Steps2>7) Steps2=0;
if(Steps2<0) Steps2=7;
}

void reset() //turn off power to steppers
{digitalWrite(OUT11, LOW);
digitalWrite(OUT12, LOW);
digitalWrite(OUT13, LOW);
digitalWrite(OUT14, LOW);
digitalWrite(OUT21, LOW);
digitalWrite(OUT22, LOW);
digitalWrite(OUT23, LOW);
digitalWrite(OUT24, LOW);
}

End of code. More comments in another post on this thread. Eric


#16

Chuck - Here are comments on your last message in this thread: You are correct that the wifi commands execute slowly, and with variable delay. The steppers make the speed of the two motors the exactly the same for the move commands (unlike for DC motors), so the the robot goes precisely forward and turns pivoting precisely on the midpoint between the two motors. But to control the run time (i.e. the size of the step or the angle of the turn) a program needs to start the movement, wait a precise time, and then stop the movement. And each of these commands must be transmitted separately by wifi, with variable timing. So the movements (especially the turns) are not reproducible from one trial to the next. To make the movements precise, I want to modify the move command (in MeMbotDCmotor.cpp) so that instead of specifying speed, you specify the length of time the movement takes. My modified move command starts the two motors, delays for a specific number of ms and then stops the motors, all contained in the move command. Wifi sends the move command, but all the timing is controlled in compiled code. I modified the MeMbotDCmotor.cpp file to do this, and it works fine if I use Makeblock to upload the compiled file to the mbot. But I have not been able to figure out how to incorporate this code into the mbot firmware. The mbot firmware file has only the run and reset commands specified, and I can’t find where the uploaded firmware accesses the MeBbotDCmotor information to run the move command. Perhaps tech can provide this information if I ask them that directly. Hope this makes some sense! Best, efrank03


#17

Hi Chuck,
This is in response to your post #13 in this thread, about 23 days ago. I now understand more of the problems in what I was trying to do. I want my modifications to the Forward, Backward, Right,Left commands to work wirelessly, so I now see from your comment that I need to do this in the mbot.js file so it works wirelessly. I succeeded in doing that, running the motors appropriately, then pausing (tricky in javascript but it works) and then stopping the motors, so the bot moves F or B one step (about 15 cm) or turns R or L by 90 degrees, all without having to do a F at 255, then wait for the appropriate amount of time and then stop (F at 0 speed). But as you point out, the timing is not very precise, because this is all done in multiple serial commands sent wirelessly In mbot.js, the move (F,B,R,L) command finally acts by issuing a function
sendPackage(argList, type)
which then finally executes a
device.send(bytes)
Where does that go? Into code that is already in the Arduino? If so, then maybe I could modify that code to get the start, pause, and stop commands to be executed sequentially at Arduino speed. Does that make sense? I don’t know where to look to find out where the device.send(bytes) is sending them.
Sorry to keep bothering you about this! Eric


#18

Hm, this is one of those questions that should likely go to @tec_support. From what I can tell, the Javascript will send a group of serial bytes which is used by a function in the mbot_firmware.ino file named parseData. The first five bytes seems to designate the device to be used (MOTOR is defined as 10, for example) and passes it to runModule. From that point, the runModule parses the rest of the parameters and executes as necessary. This is pure speculation from doing a cold code read, but it might be a starting point for a discussion.


#19

Your “pure speculation” is exactly right. The mbot.js program sends the motor data to the mbot_firmware.ino program (whose .hex version has been uploaded to mBlock) by sending runPackage(5,short2array(leftSpeed),short2array(rightSpeed)). With your input, MOTOR being 10, I looked to see what 5 was. Turns out it is JOYSTICK! So looking in the firmware file, indeed under JOYSTICK was the code used to execute F, B, R, L. So I modified that code so that it runs M1 and M2 (like in the original) but then delays (using Arduino IDE code of course) and then runs the M1 and M2 code again at 0 speed. Works fine. Thank you! But of course I would like to be able to set both the motor speeds and the delay time from within mbot.js. So I need to add another variable. As you can see, the 2 variables sent now (leftSpeed & rightSpeed) are send as short2array(xxx)'s and are received as readShort(6) and readShort(8). But I don’t know how to send another variable from mbot.js and to read it in the firmware file. If you have done this, that would be great to learn, but I will also send this request to @tec_support. Anyway, I really appreciate your help with this. Eric


#20

Hi,

this doesn’t work for me.
I’ve downloaded from Git, extracted and re-zipped.
The upload in/to Arduino-IDE throws:
Error while importing a library
makeblock: An error occurred while importing the library. Please make sure the file is not corrupted.

Packed on mac-osx 10, from the finder menue.

Have you got any Ideas ??

Thank you
Marcel