Help Arduino uno with md10C

Talk about Arduino board, sheilds. Sharing Arduino projects, program, problems, solutions, suggestions..... many more, all are welcome.

Help Arduino uno with md10C

Postby isamu » Wed Feb 17, 2016 10:01 pm

hi,

I'm benjamin, 42 from france, i'm good at solving mechanical or building problems but don't know nothing to programming.
i'm working on a 1/1 dalek .. it's powered by a powerchair and have many features (light & sound etc..).

I wished to rotate the dome using a reducted motor and controled by a joystick.
searching for ways to make this possible i have decide to try to use an arduino uno and the MD10C (i"ve found the tutorial quite clear and thought that it'll be easy).

I don't have the LCD shield and so i've took of all the LCd part of the programm .. and it doesn't work.. i took it back and it don't compile (I don't have LCD_key library and don't find it (and there is a typo in the programm in the IF section, the " for PWM print are in italic).

I use a 12v battery and the AntiPhase mode controlled by a potentiometer configuration.

During the test i've inverted PWM and DIR cables and my motor start to turn, the joystick Control the speed but not the direction.

may someone help me ?
isamu
Freshie
 
Posts: 4
Joined: Wed Feb 17, 2016 9:46 pm

Re: Help Arduino uno with md10C

Postby Idris » Thu Feb 18, 2016 8:40 am

Hi benjamin,

Could you share a few clear photos of your hardware setup and connection?
And also the Arduino code.

If you have a clear video to explain/show the problem, it's really help much.

Thanks.
Cytron Technologies invest time and resources providing tutorial, training and support for STEM education and maker movement. We need your support by purchasing products from Cytron Technologies. Thanks.
http://www.cytron.com.my
User avatar
Idris
Moderator
 
Posts: 409
Joined: Thu Mar 22, 2012 5:28 pm
Location: Pulau Pinang

Re: Help Arduino uno with md10C

Postby isamu » Thu Feb 18, 2016 3:07 pm

hi,

I've followed this tutorial : http://tutorial.cytron.com.my/2013/07/29/controlling-md10c-with-arduino/

i don't have pictures of my setup and connection, but it's exactly like the schematic, except i don't have a lcd shield.
Image

My joystick is this one :
http://www.robotshop.com/en/joystick-breakout-board.html

and the full code is:
CODE: SELECT_ALL_CODE
#include <LiquidCrystal.h>
#include <LCD_Key.h>

//define keycode
#define None     0
#define Select   1
#define Left     2
#define Up       3
#define Down     4
#define Right    5

//define pin name
#define diy_pwm  A2
#define pwm      2
#define dir      3
#define pot      A1

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
LCD_Key keypad;
byte count = 0;
int pwm_val = 0;        //global variable for DIY PWM purpose

void setup(){

  lcd.begin(16, 2);
  lcd.clear();
 
  pinMode(pwm,OUTPUT);
  pinMode(dir,OUTPUT);
  pinMode(diy_pwm,OUTPUT);
  pinMode(pot,INPUT);

}

void loop()
{
  // LOCKED ANTI-PHASE MODE
  //Control motor with potentiometer

int localKey;                          //initialization
int pwm_value;
int reading = 0;            
int prev_reading = 0;
int output = 0;

lcd.setCursor(0,0);         //LCD display on beginning
lcd.print("PWM:");
lcd.print(digitalRead(pwm));
lcd.setCursor(0,1);
lcd.print("DIR:");
lcd.print(output);

while(1){
   localKey = keypad.getKey();

    reading = 0;                             //get average five consecutive analog readings
    for(int i =0;i<5;i++)            //from A1 pin (pot)
    reading += analogRead(pot);

    reading/=5;
 
    output=reading*0.2493;           //convert from range 1024 to 256
   
  if(reading!=prev_reading){        //update LCD data if only the reading changes
    lcd.print("       ");      //prevent reading on LCD blinking
    lcd.setCursor(0,0);
    lcd.print(“PWM: “);
    lcd.print(digitalRead(pwm));
    lcd.setCursor(0,1);
    lcd.print("DIR:");
    lcd.print(output);
   
    prev_reading = reading;
 }
   
    analogWrite(dir,output);
}
}

I can't make this one work because i don't have the LCD_key library and I can't find where to dwnload it.

Then I've tried to take out all the code for the LCD so i have this code :
CODE: SELECT_ALL_CODE
//define pin name
#define pwm      2
#define dir      3
#define pot      A1

byte count = 0;
int pwm_val = 0;        //global variable for DIY PWM purpose

void setup(){
 
  pinMode(pwm,OUTPUT);
  pinMode(dir,OUTPUT);
  pinMode(pot,INPUT);

}

void loop()
{
  // LOCKED ANTI-PHASE MODE
  //Control motor with potentiometer

int localKey;                          //initialization
int pwm_value;
int reading = 0;            
int output = 0;

while(1){

    reading = 0;                             //get average five consecutive analog readings
    for(int i =0;i<5;i++)            //from A1 pin (pot)
    reading += analogRead(pot);

    reading/=5;
 
    output=reading*0.2493;           //convert from range 1024 to 256
   
    analogWrite(dir,output);
}
}

Nothing happen ... i move the joystick etc... and nothing (I've tested the MD10C and it work just fine)

then i thought i remove too many code so i tried this one:
CODE: SELECT_ALL_CODE
#include <LiquidCrystal.h>

//define keycode
#define None     0
#define Select   1
#define Left     2
#define Up       3
#define Down     4
#define Right    5

//define pin name
#define diy_pwm  A2
#define pwm      2
#define dir      3
#define pot      A1

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
byte count = 0;
int pwm_val = 0;        //global variable for DIY PWM purpose

void setup(){

  lcd.begin(16, 2);
  lcd.clear();
 
  pinMode(pwm,OUTPUT);
  pinMode(dir,OUTPUT);
  pinMode(diy_pwm,OUTPUT);
  pinMode(pot,INPUT);

}

void loop()
{
  // LOCKED ANTI-PHASE MODE
  //Control motor with potentiometer

int localKey;                          //initialization
int pwm_value;
int reading = 0;       
int prev_reading = 0;
int output = 0;

lcd.setCursor(0,0);     //LCD display on beginning
lcd.print("PWM:");
lcd.print(digitalRead(pwm));
lcd.setCursor(0,1);
lcd.print("DIR:");
lcd.print(output);

while(1){

    reading = 0;                          //get average five consecutive analog readings
    for(int i =0;i<5;i++)       //from A1 pin (pot)
    reading += analogRead(pot);

    reading/=5;
 
    output=reading*0.2493;           //convert from range 1024 to 256
   
  if(reading!=prev_reading){        //update LCD data if only the reading changes
    lcd.print("       ");   //prevent reading on LCD blinking
    lcd.setCursor(0,0);
    lcd.print("PWM: ");
    lcd.print(digitalRead(pwm));
    lcd.setCursor(0,1);
    lcd.print("DIR:");
    lcd.print(output);
   
    prev_reading = reading;
 }
   
    analogWrite(dir,output);
}
}

no change at all ..

thanks for your help.
isamu
Freshie
 
Posts: 4
Joined: Wed Feb 17, 2016 9:46 pm

Re: Help Arduino uno with md10C

Postby Idris » Thu Feb 18, 2016 4:00 pm

Hi benjamin,

I'm noticed that you are using "LOCKED ANTI PHASE" method in your program. So you need to set PWM pin to HIGH to enable the motor driver. There have stated in the tutorial. You can either short the PWM pin to 5V pin or set it in the program.
1.png

I try to edit your 2nd code, let me know the result. Thanks.
CODE: SELECT_ALL_CODE
#define pwm 2
#define dir 3
#define pot A1

int reading = 0;
int output = 0;

void setup()

  pinMode(pwm, OUTPUT);
  pinMode(dir, OUTPUT);
  pinMode(pot, INPUT);

  digitalWrite(pwm, HIGH); // Always enable motor
}

void loop()
{
  // LOCKED ANTI-PHASE MODE
  // Control motor with potentiometer

  reading = 0;
  for(int i = 0; i < 5; i++) // Get average five consecutive analog readings
  {
    reading += analogRead(pot);
  }
  reading /= 5;

  output = map(reading, 0, 1023, 0, 255);

  analogWrite(dir, output);
}
Cytron Technologies invest time and resources providing tutorial, training and support for STEM education and maker movement. We need your support by purchasing products from Cytron Technologies. Thanks.
http://www.cytron.com.my
User avatar
Idris
Moderator
 
Posts: 409
Joined: Thu Mar 22, 2012 5:28 pm
Location: Pulau Pinang

Re: Help Arduino uno with md10C

Postby isamu » Thu Feb 18, 2016 4:58 pm

Hi,

thanks for the help, i've seen the notice but thought that it was already in the code given.

So I've tested yours and it works but it sounds weird when the joystick is at 50%
here's a video
https://youtu.be/4IQR_L2Edjg
isamu
Freshie
 
Posts: 4
Joined: Wed Feb 17, 2016 9:46 pm

Re: Help Arduino uno with md10C

Postby Idris » Fri Feb 19, 2016 8:45 am

Yes, for locked anti-phase, there will be audible noise produced by motor (even it is not moving). Because the voltage is still applied, just the amount of voltage for both terminals is same, that makes the motor didn't move.

You can try SIGN MAGNITUDE method if that noise really hurting you. However, you need to modify the coding.

Thanks.
Cytron Technologies invest time and resources providing tutorial, training and support for STEM education and maker movement. We need your support by purchasing products from Cytron Technologies. Thanks.
http://www.cytron.com.my
User avatar
Idris
Moderator
 
Posts: 409
Joined: Thu Mar 22, 2012 5:28 pm
Location: Pulau Pinang

Re: Help Arduino uno with md10C

Postby isamu » Sat Feb 20, 2016 1:34 am

i'll try ;)

thanks for your help !
isamu
Freshie
 
Posts: 4
Joined: Wed Feb 17, 2016 9:46 pm


Return to Arduino Based

Who is online

Users browsing this forum: No registered users and 3 guests