ArduinoGeneral

DFRobot Motor Shield Startup

userHead Armen 2013-04-08 18:36:53 6080 Views5 Replies
Hi everyone,

I've recently completed a project using the DFRobot Motor Shield (purchased it here):
[url=http://littlebirdelectronics.com/products/l298-motor-shield-arduinocompatible]http://littlebirdelectronics.com/products/l298-motor-shield-arduinocompatible[/url]

Interfaced with an Arduino Uno...

I've run into a problem which I'm not sure if there is a solution for or not. The project is actually for a mini-vending machine and the motor that the shield is hooked up to engages the vending mechanism (ie vends).

The problem is that whenever the Arduino/Shield is powered up, the motor shield runs the motor output for a second as if it's doing some test or something.

Is there a way to stop it from doing this? Because you can probably guess, everytime someone unplugs and then plugs in the machine, it'll vend one item!

After this intial hick-up, everything runs perfect.

Hope you have some ideas.

Cheers,
Armen

2013-05-07 21:45:27 Hi Armen,

How did you connect the motor driver to arduino? did you directly stack it up on arduino? I am wondering if some of the pins are conflicting with the other modules you have. Please take a look at our example code and pin allocation:
[url=https://www.dfrobot.com/wiki/index.php/Arduino_Motor_Shield_(L298N)_(SKU:DRI0009)#Pin_Allocation]https://www.dfrobot.com/wiki/index.php/Arduino_Motor_Shield_(L298N)_(SKU:DRI0009)#Pin_Allocation[/url]

Best,
Jose
userHeadPic Jose
2013-05-06 22:52:35 Hi Jose,

Here you go:

Cheers,
Armen

[code]
#include <LiquidCrystal.h>
#include <SPI.h>
#include <Smartcard.h>

// initialise the library with address of slave select pin
Smartcard smartcard(10);

// Pins in use
#define SELECTBUTTON          A0  // A0 is the button ADC input
#define LCD_BACKLIGHT_PIN        3  // D3 controls LCD backlight

// ADC readings expected for the 5 buttons on the ADC input
#define LCD_BACKLIGHT_OFF()    digitalWrite( LCD_BACKLIGHT_PIN, LOW )
#define LCD_BACKLIGHT_ON()      digitalWrite( LCD_BACKLIGHT_PIN, HIGH )

LiquidCrystal lcd( 8, 9, 4, 5, 6, 7 );  //Pins for the freetronics 16x2 LCD shield. LCD: ( RS, E, LCD-D4, LCD-D5, LCD-D6, LCD-D7 )

//motor control
int E1 = 3;
int M1 = 2;


//card control
unsigned char psc[3];
boolean credit = false;
boolean mastercard = false;
boolean read = false;
boolean vendcomplete = false;
boolean phonycard = false;
unsigned char serial[5];
byte balance;
byte newbalance;

    unsigned char data[4];
      char ascii_data[2];
      char i,j;




void setup()
{

Serial.begin(9600);

//initialise motors
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
digitalWrite(2,LOW);
analogWrite(2,0);
digitalWrite(3,LOW);


//pull up for button
pinMode(A5,INPUT_PULLUP);


  pinMode( SELECTBUTTON, INPUT );        //ensure A0 is an input
  digitalWrite( SELECTBUTTON, LOW );      //ensure pullup is off on A0
  //lcd backlight control
  digitalWrite( LCD_BACKLIGHT_PIN, HIGH );  //backlight control pin D3 is high (on)
  pinMode( LCD_BACKLIGHT_PIN, OUTPUT );    //D3 is an output

}[/code]
userHeadPic Armen
2013-04-23 22:21:22 Hey Armen,

Not at all, I have not experienced this issue with Arduino UNO before. I did with other boards or MCU's and it was related with the bootloader. But I doubt it is related to the bootloader since it is an Arduino UNO. Can you paste your code? or the init part of the code?
Perhaps you missed something that its using that pin while initializing. Some libraries can do this..

Cheers
:)
userHeadPic Jose
2013-04-17 17:57:51 Hi Jose,

I don't have one handy but if it's the case of the boot loader then do you have a specific bootloader version I can upload to the board?

To be honest, I'm not really sure that it is the case.

Are you implying that the board you have doesn't go through this sort of "star-up check" sequence?

Cheers,
Armen
userHeadPic Armen
2013-04-09 23:41:04 Howdy!

I'm wondering if it is coming from the bootloader from the arduino UNO, do you have any older arduino version to give it a try?

Cheers
userHeadPic Jose