WeMos D1 Mini Motor Drive Shield (HCWEMO0010)

Wemos ESP8266 based development boards and shields
admin
Site Admin
Posts: 880
Joined: Sun Aug 05, 2012 4:02 pm

WeMos D1 Mini Motor Drive Shield (HCWEMO0010)

Post by admin » Fri Nov 25, 2016 12:10 pm

Image





The WeMos I2C Dual Motor Driver Module is designed to be able to drive up to two DC motors from your WeMos/Lolin mini or mini Pro development boards (See HCWEMO0002). Using PWM the shield is capable of independently controlling the speed and direction of each connected motor with a maximum average of up to 1.2A (3.2A peak). The shield, together with its supplied headers (2 x 8 way supplied unsoldered), allows for it to be easily inserted and removed from the WeMos Mini. Control of the shield is via the WeMos mini's I2C interface (0x30 default address). A library and example sketch is provided by WeMos to make controlling the shield from your own sketches as simple as possible.



Features

I2C interface
Power supply voltage: VM=15V max
Output current: Iout=1.2A(average) / 3.2A (peak)
Standby control to save power
CW/CCW/short brake/stop motor control modes



Pins

D1 mini	GPIO	Shield
D1	5	SCL
D2	4	SDA
RST	RST	RST

VM: Motor power supply + (Max 15Vdc)
GND: Motor power supply -
1-A-2: Motor A
2-B-1: Motor B





LOLIN V2.0 Shield Arduino sketch (See underside of board for version number)
  1. /*
  2.   Simple Motor Shield Test.
  3. */
  4.  
  5. #include <Wire.h>
  6. #include <LOLIN_I2C_MOTOR.h>
  7.  
  8. LOLIN_I2C_MOTOR motor; //I2C address 0x30
  9. // LOLIN_I2C_MOTOR motor(DEFAULT_I2C_MOTOR_ADDRESS); //I2C address 0x30
  10. // LOLIN_I2C_MOTOR motor(your_address); //using customize I2C address
  11.  
  12. void setup()
  13. {
  14.   Serial.begin(115200);
  15.   Serial.println("Motor Shield Testing...");
  16.  
  17.   while (motor.PRODUCT_ID != PRODUCT_ID_I2C_MOTOR) //wait motor shield ready.
  18.   {
  19.     motor.getInfo();
  20.   }
  21. }
  22.  
  23. void loop()
  24. {
  25.   Serial.println("Change A to CCW, B to CW, Freq: 1000Hz");
  26.   Serial.println("Duty Tesing...");
  27.  
  28.   motor.changeFreq(MOTOR_CH_BOTH, 1000); //Change A & B 's Frequency to 1000Hz.
  29.   /*
  30.       motor.changeFreq(MOTOR_CH_A, 1000);//Change A 's Frequency to 1000Hz.
  31.       motor.changeFreq(MOTOR_CH_B, 2000);//Change B 's Frequency to 2000Hz.
  32.   */
  33.   motor.changeStatus(MOTOR_CH_A, MOTOR_STATUS_CCW);
  34.   motor.changeStatus(MOTOR_CH_B, MOTOR_STATUS_CW);
  35.  
  36.   for (float duty = 0; duty <= 100; duty++)
  37.   {
  38.     motor.changeDuty(MOTOR_CH_A, duty);
  39.     motor.changeDuty(MOTOR_CH_B, 100 - duty);
  40.  
  41.     Serial.print("Change A Duty to ");
  42.     Serial.print(duty);
  43.     Serial.println("%");
  44.  
  45.     Serial.print("Change B Duty to ");
  46.     Serial.print(100 - duty);
  47.     Serial.println("%");
  48.  
  49.     delay(100);
  50.   }
  51.  
  52.   Serial.println("STANDBY Tesing...");
  53.   motor.changeStatus(MOTOR_CH_BOTH, MOTOR_STATUS_CCW);
  54.   motor.changeDuty(MOTOR_CH_BOTH, 100);
  55.   for (int i = 0; i < 5; i++)
  56.   {
  57.     Serial.println("MOTOR_STATUS_STANDBY");
  58.     motor.changeStatus(MOTOR_CH_BOTH, MOTOR_STATUS_STANDBY);
  59.     delay(500);
  60.     Serial.println("MOTOR_STATUS_CW");
  61.     motor.changeStatus(MOTOR_CH_BOTH, MOTOR_STATUS_CW);
  62.     delay(500);
  63.     Serial.println("MOTOR_STATUS_STANDBY");
  64.     motor.changeStatus(MOTOR_CH_BOTH, MOTOR_STATUS_STANDBY);
  65.     delay(500);
  66.     Serial.println("MOTOR_STATUS_CCW");
  67.     motor.changeStatus(MOTOR_CH_BOTH, MOTOR_STATUS_CCW);
  68.     delay(500);
  69.   }
  70.  
  71.   Serial.println("MOTOR_STATUS Tesing...");
  72.   for (int i = 0; i < 5; i++)
  73.   {
  74.     Serial.println("MOTOR_STATUS_STOP");
  75.     motor.changeStatus(MOTOR_CH_A, MOTOR_STATUS_STOP);
  76.     delay(500);
  77.     Serial.println("MOTOR_STATUS_CCW");
  78.     motor.changeStatus(MOTOR_CH_A, MOTOR_STATUS_CCW);
  79.     delay(500);
  80.     Serial.println("MOTOR_SHORT_BRAKE");
  81.     motor.changeStatus(MOTOR_CH_A, MOTOR_STATUS_SHORT_BRAKE);
  82.     delay(500);
  83.     Serial.println("MOTOR_STATUS_CW");
  84.     motor.changeStatus(MOTOR_CH_A, MOTOR_STATUS_CW);
  85.     delay(500);
  86.   }
  87. }



Image

Downloads for Lolin V.20 shield (see bottom of shield to confirm the version you have)

Schematic:
sch_motor_v2.0.0.pdf


Arduino Library:
The library can also be downloaded from the following GitHub page:

https://github.com/wemos/LOLIN_I2C_MOTOR_Library





Libraries, example code, and diagrams are provided as an additional free service by Hobby Components and are not sold as part of this product. We do no provide any guarantees or warranties as to their accuracy or fitness for purpose.

Descriptions and diagrams on this page are copyright Hobby Components Ltd and may not be reproduced without permission.
You do not have the required permissions to view the files attached to this post.

uppermill
Posts: 4
Joined: Sun Jun 18, 2017 3:09 pm

Re: WeMos D1 Mini Motor Drive Shield (HCWEMO0010)

Post by uppermill » Sun Jun 18, 2017 3:13 pm

I connected the motor shield as illustrated in the diagram and run the test library but the shield does not start the motor.

I've tried an I2C scanner but it cannot find any devices.

Can you help?

Regards

Allan

andrew
Site Admin
Posts: 1412
Joined: Sun Aug 05, 2012 4:15 pm

Re: WeMos D1 Mini Motor Drive Shield (HCWEMO0010)

Post by andrew » Mon Jun 19, 2017 9:04 am

Can I first get a little more information about your setup:

What type of microcontroller or development board are you using with it?

Could you describe whats connected to each pin on the module?

Do you have any kind of part number for the motor(s) you are using with it?

When connected is anything on the module getting hot to the touch?
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

uppermill
Posts: 4
Joined: Sun Jun 18, 2017 3:09 pm

Re: WeMos D1 Mini Motor Drive Shield (HCWEMO0010)

Post by uppermill » Mon Jun 19, 2017 3:52 pm

Andrew - the shields is connected to a Wemos D1 mini. VM and GND are connected to a 7.4V LIPO and the motor is a lego train motor connected to pins A1 and A2. Nothing is getting hot.

Regards

Allan

andrew
Site Admin
Posts: 1412
Joined: Sun Aug 05, 2012 4:15 pm

Re: WeMos D1 Mini Motor Drive Shield (HCWEMO0010)

Post by andrew » Tue Jun 20, 2017 9:20 am

Thanks for the answers, everything you're doing looks sensible. Just to be sure I've checked the posted sketch with a D1 mini Pro and Lite and it is defiantly working. Just a few more things:

When running the test sketch, if you open up the serial monitor window do you see any output? This should confirm the sketch is at least running.

The motor shield is very particular about the format of the data it receives and an I2C scanner will just cause the I2C bus to temporarily lock up. Also any bus data errors could cause issues. Is the shield plugged directly into the D1 or is it connected remotely via some wires?

Just as a sanity check, have you confirmed that the motor is working by connecting it directly to your LiPo?
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

uppermill
Posts: 4
Joined: Sun Jun 18, 2017 3:09 pm

Re: WeMos D1 Mini Motor Drive Shield (HCWEMO0010)

Post by uppermill » Tue Jun 20, 2017 10:34 am

Andrew - thanks for checking it out.

The serial port does give output and I've had already checked the motor in the manner that you suggested.

I'll do some further tests.

Regards

Allan

uppermill
Posts: 4
Joined: Sun Jun 18, 2017 3:09 pm

Re: WeMos D1 Mini Motor Drive Shield (HCWEMO0010)

Post by uppermill » Tue Jun 20, 2017 11:49 am

Andrew - looks like I have resolved the problem. It suddenly started working. Looks like I have a bad joint somewhere.

Thanks for all your help - much appreciated.

Regards

Allan

andrew
Site Admin
Posts: 1412
Joined: Sun Aug 05, 2012 4:15 pm

Re: WeMos D1 Mini Motor Drive Shield (HCWEMO0010)

Post by andrew » Tue Jun 20, 2017 2:13 pm

Ok, no problem.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

zjor
Posts: 1
Joined: Wed Jun 28, 2017 9:26 am

Re: WeMos D1 Mini Motor Drive Shield (HCWEMO0010)

Post by zjor » Wed Jun 28, 2017 9:30 am

I'm facing similar issue:

board: wemos d1 mini
motor: DC, working, tested standalone
VCC: 1.5Vx4 batteries, motor is working with it

I've connected everything as on the schema above and motor doesn't move. I changed Serial speed to 115200, connected via serial monitor and see that program prints out PWM values, but the motor is still not moving.

Could you please help?
I've heard that the firmware on the motor shield itself can be broken, could it be the issue?

Regards,

andrew
Site Admin
Posts: 1412
Joined: Sun Aug 05, 2012 4:15 pm

Re: WeMos D1 Mini Motor Drive Shield (HCWEMO0010)

Post by andrew » Wed Jun 28, 2017 11:01 am

The only issue I've seen mentioned on the Wemos forum is that it is possible for the controller to lock up if an incorrect formatted I2C command is sent to the shield or a timeout condition occurs. This is not something we've seen happen in our own tests. However if that was the problem a simple reset should resolve it. Also, this issue should affect the test sketch in the first post so I think it would be unlikely that was the cause of your problem.

If the sketch doesn't work for you then I would suggest checking for a bad connection or bad solder joint on the header pins as this would be the most likeliest cause.
Comments made by this poster do not necessarily reflect the views of Hobby Components Ltd.

Post Reply

Return to “WeMos”