Skip to content

Commit

Permalink
update readme.md,fix JIRA issue MBLOCK-171,MBLOCK-189
Browse files Browse the repository at this point in the history
  • Loading branch information
YanMinge committed Aug 24, 2016
1 parent 0296f74 commit bfca51e
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 51 deletions.
33 changes: 17 additions & 16 deletions makeblock/README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,21 @@
# Makeblock Library v3.24

Revision of history:
Author Time Version Descr
Mark Yan 2015/07/24 3.0.0 Rebuild the old lib.
Rafael Lee 2015/09/02 3.1.0 Added some comments and macros.
Lawrence 2015/09/09 3.2.0 Include some Arduino's official headfiles which path specified.
Mark Yan 2015/11/02 3.2.1 fix bug on MACOS.
Mark Yan 2016/01/21 3.2.2 fix some library bugs.
Mark Yan 2016/05/17 3.2.3 add support for MegaPi and Auriga Board.
Mark Yan 2016/07/27 3.2.4 fix some JIRA issue, add PID motion for Megapi/Auriga on board encoder motor.

Arduino Library for Makeblock Electronic Modules

How to use:
###How to use:

1. Download the source from the git https://github.com/Makeblock-official/Makeblock-Libraries

2. copy the makeblock folder to your arduino default library. Your Arduino library folder should now look like this
(on Windows): [arduino installation directory]\libraries\makeblock\src
(On MACOS): [arduino Package Contents]\contents\Jave\libraries\makeblock\src
2. copy the makeblock folder to your arduino default library. Your Arduino library folder should now look like this
(on Windows): [arduino installation directory]\libraries\makeblock\src
(on MACOS): [arduino Package Contents]\contents\Jave\libraries\makeblock\src

3. Open the Arduino Application. (If it's already open, you will need to restart it to see changes.)

4. Click "File-> Examples". Here are some test programs in MakeBlockDrive-> example
4. Click "File-> Examples". Here are some test programs in "MakeBlockDrive-> example"

5. Depending on the type of board you're using, you need to modify the header file to match.
For example, if you're using a mCore. You should change "#include <MeOrion.h>" to "#include <MeMCore.h>"
For example, if you're using a mCore. You should change `#include <MeOrion.h>` to `#include <MeMCore.h>`
Corresponding boards and there header file are:

Orion <--------> MeOrion.h
Expand All @@ -39,3 +29,14 @@ How to use:
Auriga <-------> MeAuriga.h

MegaPi <-------> MeMegaPi.h

###Revision of history:
|Author | Time | Version | Descr |
| -------- | :-----: | :----: | :----: |
|Mark Yan | 2015/07/24 | 3.0.0 | Rebuild the old lib.|
|Rafael Lee | 2015/09/02 | 3.1.0 | Added some comments and macros.|
|Lawrence | 2015/09/09 | 3.2.0 | Include some Arduino's official headfiles which path specified.|
|Mark Yan | 2015/11/02 | 3.2.1 | fix bug on MACOS.|
|Mark Yan | 2016/01/21 | 3.2.2 | fix some library bugs.|
|Mark Yan | 2016/05/17 | 3.2.3 | add support for MegaPi and Auriga Board.|
|Mark Yan | 2016/07/27 | 3.2.4 | fix some JIRA issue, add PID motion for Megapi/Auriga on board encoder motor.|
58 changes: 42 additions & 16 deletions makeblock/example/Firmware_for_Auriga/Firmware_for_Auriga.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* File Name : Firmware_for_Auriga.ino
* Author : myan
* Updated : myan
* Version : V09.01.011
* Date : 08/10/2016
* Version : V09.01.012
* Date : 08/22/2016
* Description : Firmware for Makeblock Electronic modules with Scratch.
* License : CC-BY-SA 3.0
* Copyright (C) 2013 - 2016 Maker Works Technology Co., Ltd. All right reserved.
Expand All @@ -20,7 +20,8 @@
* Mark Yan 2016/07/06 09.01.008 Fix issue MBLOCK-61(ultrasonic distance limitations bug).
* Mark Yan 2016/07/27 09.01.009 Add position parameters for encoder motor,fix issue MBLOCK-77.
* Mark Yan 2016/08/01 0e.01.010 Fix issue MBLOCK-109 MBLOCK-110(encoder motor exception handling negative).
* Mark Yan 2016/08/10 0e.01.011 Fix issue MBLOCK-128(ext encoder motor led to reset), MBLOCK-128.
* Mark Yan 2016/08/10 0e.01.011 Fix issue MBLOCK-128(ext encoder motor led to reset).
* Mark Yan 2016/08/24 0e.01.012 Fix issue MBLOCK-171(Stepper online execution slow), MBLOCK-189(on board encoder motor reset issue).
**************************************************************************/
#include <Arduino.h>
#include <avr/wdt.h>
Expand Down Expand Up @@ -149,6 +150,7 @@ float dt;

long lasttime_angle = 0;
long lasttime_speed = 0;
long update_sensor = 0;
long blink_time = 0;
long lasttime_receive_cmd = 0;
long last_Pulse_pos_encoder1 = 0;
Expand All @@ -163,7 +165,7 @@ boolean move_flag = false;
boolean boot_show_flag = true;
boolean blink_flag = false;

String mVersion = "09.01.011";
String mVersion = "09.01.012";

//////////////////////////////////////////////////////////////////////////////////////
float RELAX_ANGLE = -1; //Natural balance angle,should be adjustment according to your own car
Expand Down Expand Up @@ -240,7 +242,6 @@ typedef struct
} PID;

PID PID_angle, PID_speed, PID_turn;
PID PID_speed_left, PID_speed_right;

/**
* \par Function
Expand Down Expand Up @@ -812,12 +813,22 @@ void parseData(void)
case RESET:
{
//reset
Encoder_1.setMotorPwm(0);
Encoder_2.setMotorPwm(0);
/* Off on-Board LED lights */
buzzer.setpin(BUZZER_PORT);
led.setColor(0,0,0,0);
led.show();

/* reset On-Board encoder driver */
Encoder_1.setPulsePos(0);
Encoder_2.setPulsePos(0);
PID_speed_left.Setpoint = 0;
PID_speed_right.Setpoint = 0;
Encoder_1.moveTo(0,10);
Encoder_2.moveTo(0,10);
Encoder_1.setMotorPwm(0);
Encoder_2.setMotorPwm(0);
Encoder_1.setMotionMode(DIRECT_MODE);
Encoder_2.setMotionMode(DIRECT_MODE);

/* reset dc motor on driver port */
dc.reset(PORT_1);
dc.run(0);
dc.reset(PORT_2);
Expand All @@ -826,8 +837,21 @@ void parseData(void)
dc.run(0);
dc.reset(PORT_4);
dc.run(0);

/* reset ext encoder driver */
encoders[0].runSpeed(0);
encoders[1].runSpeed(0);

/* reset stepper motor driver */
steppers[0].setCurrentPosition(0);
steppers[1].setCurrentPosition(0);
steppers[2].setCurrentPosition(0);
steppers[3].setCurrentPosition(0);
steppers[0].moveTo(0);
steppers[1].moveTo(0);
steppers[2].moveTo(0);
steppers[3].moveTo(0);

callOK();
}
break;
Expand Down Expand Up @@ -2741,8 +2765,6 @@ void setup()
delay(5);
attachInterrupt(Encoder_1.getIntNum(), isr_process_encoder1, RISING);
attachInterrupt(Encoder_2.getIntNum(), isr_process_encoder2, RISING);
PID_speed_left.Setpoint = 0;
PID_speed_right.Setpoint = 0;
led.setpin(RGBLED_PORT);
buzzer.setpin(BUZZER_PORT);
led.setColor(0,0,0,0);
Expand Down Expand Up @@ -2814,8 +2836,8 @@ void setup()
PID_speed.P = -0.1; // -0.1
PID_speed.I = -0.008; // -0.008
readEEPROM();
// auriga_mode = AUTOMATIC_OBSTACLE_AVOIDANCE_MODE;
lasttime_speed = lasttime_angle = millis();
// auriga_mode = BALANCED_MODE;
update_sensor = lasttime_speed = lasttime_angle = millis();
blink_time = millis();
}

Expand Down Expand Up @@ -2912,8 +2934,6 @@ void loop()
}
readSerial();
}
gyro.fast_update();
gyro_ext.update();
if(Compass.getPort() != 0)
{
Compass.getAngle();
Expand All @@ -2922,7 +2942,12 @@ void loop()

if(auriga_mode == BLUETOOTH_MODE)
{

if(millis() - update_sensor > 10)
{
update_sensor = millis();
gyro.fast_update();
gyro_ext.update();
}
}
else if(auriga_mode == AUTOMATIC_OBSTACLE_AVOIDANCE_MODE)
{
Expand All @@ -2932,6 +2957,7 @@ void loop()
}
else if(auriga_mode == BALANCED_MODE)
{
gyro.fast_update();
Encoder_1.setMotionMode(DIRECT_MODE);
Encoder_2.setMotionMode(DIRECT_MODE);
balanced_model();
Expand Down
73 changes: 54 additions & 19 deletions makeblock/example/Firmware_for_MegaPi/Firmware_for_MegaPi.ino
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* File Name : Firmware_for_MegaPi.ino
* Author : myan
* Updated : myan
* Version : V0e.01.011
* Date : 08/10/2016
* Version : V0e.01.012
* Date : 08/22/2016
* Description : Firmware for Makeblock Electronic modules with Scratch.
* License : CC-BY-SA 3.0
* Copyright (C) 2013 - 2016 Maker Works Technology Co., Ltd. All right reserved.
Expand All @@ -21,6 +21,7 @@
* Mark Yan 2016/07/27 0e.01.009 Add position parameters for encoder motor,fix issue MBLOCK-77.
* Mark Yan 2016/08/01 0e.01.010 Fix issue MBLOCK-109 MBLOCK-110(encoder motor exception handling negative).
* Mark Yan 2016/08/10 0e.01.011 Fix issue MBLOCK-126(on board encoder motor speed symbol).
* Mark Yan 2016/08/24 0e.01.012 Fix issue MBLOCK-171(Stepper online execution slow), MBLOCK-189(on board encoder motor reset issue).
**************************************************************************/
#include <Arduino.h>
#include <MeMegaPi.h>
Expand Down Expand Up @@ -154,6 +155,7 @@ float dt;

long lasttime_angle = 0;
long lasttime_speed = 0;
long update_sensor = 0;
long blink_time = 0;
long last_Pulse_pos_encoder1 = 0;
long last_Pulse_pos_encoder2 = 0;
Expand All @@ -166,7 +168,7 @@ boolean start_flag = false;
boolean move_flag = false;
boolean blink_flag = false;

String mVersion = "0e.01.011";
String mVersion = "0e.01.012";
//////////////////////////////////////////////////////////////////////////////////////
float RELAX_ANGLE = -1; //Natural balance angle,should be adjustment according to your own car
#define PWM_MIN_OFFSET 0
Expand Down Expand Up @@ -242,7 +244,6 @@ typedef struct
} PID;

PID PID_angle, PID_speed, PID_turn;
PID PID_speed_left, PID_speed_right;

/**
* \par Function
Expand Down Expand Up @@ -926,24 +927,56 @@ void parseData(void)
case RESET:
{
//reset
Encoder_1.setMotorPwm(0);
Encoder_2.setMotorPwm(0);
Encoder_3.setMotorPwm(0);
Encoder_4.setMotorPwm(0);
/* reset On-Board encoder driver */
Encoder_1.setPulsePos(0);
Encoder_2.setPulsePos(0);
Encoder_3.setPulsePos(0);
Encoder_4.setPulsePos(0);
PID_speed_left.Setpoint = 0;
PID_speed_right.Setpoint = 0;
dc.reset(PORT_1);
Encoder_1.moveTo(0,10);
Encoder_2.moveTo(0,10);
Encoder_3.moveTo(0,10);
Encoder_4.moveTo(0,10);
Encoder_1.setMotorPwm(0);
Encoder_2.setMotorPwm(0);
Encoder_3.setMotorPwm(0);
Encoder_4.setMotorPwm(0);
Encoder_1.setMotionMode(DIRECT_MODE);
Encoder_2.setMotionMode(DIRECT_MODE);
Encoder_3.setMotionMode(DIRECT_MODE);
Encoder_4.setMotionMode(DIRECT_MODE);

/* reset dc motor on driver port */
dc.reset(PORT1A);
dc.run(0);
dc.reset(PORT_2);
dc.reset(PORT1B);
dc.run(0);
dc.reset(PORT_3);
dc.reset(PORT2A);
dc.run(0);
dc.reset(PORT_4);
dc.reset(PORT2B);
dc.run(0);
dc.reset(PORT3A);
dc.run(0);
dc.reset(PORT3B);
dc.run(0);
dc.reset(PORT4A);
dc.run(0);
dc.reset(PORT4B);
dc.run(0);

/* reset stepper motor driver */
steppers[0].setCurrentPosition(0);
steppers[1].setCurrentPosition(0);
steppers[2].setCurrentPosition(0);
steppers[3].setCurrentPosition(0);
steppers[0].moveTo(0);
steppers[1].moveTo(0);
steppers[2].moveTo(0);
steppers[3].moveTo(0);
steppers[0].disableOutputs();
steppers[1].disableOutputs();
steppers[2].disableOutputs();
steppers[3].disableOutputs();

callOK();
}
break;
Expand Down Expand Up @@ -2644,8 +2677,6 @@ void setup()
attachInterrupt(Encoder_2.getIntNum(), isr_process_encoder2, RISING);
attachInterrupt(Encoder_3.getIntNum(), isr_process_encoder3, RISING);
attachInterrupt(Encoder_4.getIntNum(), isr_process_encoder4, RISING);
PID_speed_left.Setpoint = 0;
PID_speed_right.Setpoint = 0;
Serial.begin(115200);
Serial2.begin(115200);
Serial3.begin(115200);
Expand Down Expand Up @@ -2693,7 +2724,7 @@ void setup()
//megapi_mode = BALANCED_MODE;
Serial.print("Version: ");
Serial.println(mVersion);
lasttime_speed = lasttime_angle = millis();
update_sensor = lasttime_speed = lasttime_angle = millis();
blink_time = millis();
}

Expand Down Expand Up @@ -2806,22 +2837,26 @@ void loop()
readSerial();
}

gyro_ext.fast_update();
if(Compass.getPort() != 0)
{
Compass.getAngle();
}
angle_speed = gyro_ext.getGyroY();
if(megapi_mode == BLUETOOTH_MODE)
{

if(millis() - update_sensor > 10)
{
update_sensor = millis();
gyro_ext.fast_update();
}
}
else if(megapi_mode == AUTOMATIC_OBSTACLE_AVOIDANCE_MODE)
{
ultrCarProcess();
}
else if(megapi_mode == BALANCED_MODE)
{
gyro_ext.fast_update();
balanced_model();
}
else if(megapi_mode == LINE_FOLLOW_MODE)
Expand Down

0 comments on commit bfca51e

Please sign in to comment.