Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - ndelson

Pages: 1
1
See code I posted for proper motor control:

http://forum.tiny-circuits.com/index.php?topic=148.0

2
New Product Ideas / Re: Tiny Relay shield
« on: August 30, 2013, 10:30:58 AM »
Not a bad idea!

My first thought was why not just use the existing motor driver. But I can see the simplicity of interface of a relay being useful for many applications and users. You probably could drive higher currents. I could see putting some TinyDuinos around the house or lab controlling relays.

Nate

3
I third this!

4
New Product Ideas / Double Sided Connector for TinyShield Proto Board
« on: August 30, 2013, 10:15:39 AM »
Could you make a Proto Board with a double sided connector?

I have already done 2 projects where I would have liked a double sided connector on a Proto Board specifically so I can attach and LED Shield as the top shield. the LED Shields are so neat, but once you connect a Proto Board you have to hide your LEDs inside the pack where they are much less visible.

Thanks

Nate


5
TinyDuino Processors & TinyShields / Reset Switch
« on: August 30, 2013, 10:10:29 AM »
How do you use the reset switch on the TinyDuino?

Do you just put 2 wires into the plug and connect them together? If yes, can you tell me the gauge of wire that will fit in (I assume it has to be solid core).

Thanks

Nate

6
TinyDuino Processors & TinyShields / Motor Driver Function
« on: August 01, 2013, 09:42:09 AM »
I finally got around to implementing a motor function that operates the motor properly in both forward and reverse. The original example code as posted only operates the motor in one direction. Also the original code uses the same pin for the PWM signal to control motor speed. Even if you do get this approach to work it will result in nonsymmetrical motor operation, since in one direction the motor will coast on the low portion of the PWM signal and in the other direction it will brake. The code below operates both directions symmetrically.


Code: [Select]
/* Tiny Motor Function
 
 This program operates the TinyShield Motor Driver x 4 in a function. Board description is at:
 http://tiny-circuits.com/shop/tinyshield-motorx4/
 
 The motor can be operated in forward, reverse, braking, or coast mode. Speed can be controlled via PWM.
 
 Operation is based upon the specs of the H-Bridge motor driver TI DRV8837. The commands use the Bridge Control table on page 6 at:
 http://www.ti.com/lit/ds/symlink/drv8837.pdf
 Unlike other H-Bridges where an Enable pin is operated in PWM mode and other pins control direction, the
 TI DRV8837 has two Input pins. Proper operation requires that the PWM pin varies based upon direction of motor rotation
 to ensure symmetric operation of the motor (otherwise the motor will brake in one direction in low PWM segments and coast in
 the other direction).
 
 Created 1 Aug 2013
 by Nathan Delson
 */

// Define global motor variables
const int Forward = 5;   
const int Reverse = 6;
const int Brake = 7;
const int Coast = 8;
int motorSleepPin = A3;      // Motor sleep is analog pin 3

int LedPin = 13;  // Arduino LED, which is used to flash if error occurs

void setup() {

  digitalWrite(motorSleepPin, HIGH);   // sets the Motor Driver sleep mode to be off

  pinMode(LedPin, OUTPUT);   // for flashing

  // turn all 4 motors off (i.e. to coast)
  for ( int i=0; i <= 4; i++){
    MotorlControl(Coast,0,i);
  }

}

void loop() {

  int MotorNum;  // Motor Number: 1, 2, 3, or 4
  int MotorSpeed;    //  0 to 255
  int ControlMode;   //  Forward=5, Reverse=6, Brake=7, or Coast=8

  MotorNum = 1;

  // Ramp the motor speed up in Forward direction
  MotorlControl(Forward,0,MotorNum);
  delay(50);
  MotorlControl(Forward,63,MotorNum);
  delay(50);
  MotorlControl(Forward,127,MotorNum);
  delay(50);
  MotorlControl(Forward,191,MotorNum);
  delay(50);
  MotorlControl(Forward,255,MotorNum);
  delay(50);

  // Ramp the motor speed down in Forward directoin
  MotorlControl(Forward,191,MotorNum);
  delay(50);
  MotorlControl(Forward,127,MotorNum);
  delay(50);
  MotorlControl(Forward,63,MotorNum);
  delay(50);
  MotorlControl(Forward,0,MotorNum);
  delay(50);

  // Ramp the motor speed up in Reverse direction
  MotorlControl(Reverse,0,MotorNum);
  delay(50);
  MotorlControl(Reverse,63,MotorNum);
  delay(50);
  MotorlControl(Reverse,127,MotorNum);
  delay(50);
  MotorlControl(Reverse,191,MotorNum);
  delay(50);
  MotorlControl(Reverse,255,MotorNum);
  delay(50);

  // Ramp the motor speed down in Reverse direction
  MotorlControl(Reverse,191,MotorNum);
  delay(50);
  MotorlControl(Reverse,127,MotorNum);
  delay(50);
  MotorlControl(Reverse,63,MotorNum);
  delay(50);
  MotorlControl(Reverse,0,MotorNum);
  delay(50);

}


void MotorlControl( int ControlMode,  int MotorSpeed,  int MotorNum) {

  /* Definitions of Inputs
   ControlMode - Forward=5, Reverse=6, Brake=7, or Coast=8
   MotorSpeed - 0 to 255
   MotorNum - Motor Number: 1, 2, 3, or 4 
   Flashes on Arduio LED will occur if inputs are outside valid ranges*/

  int IN1Pin;  // Pin on Tiny Duino that connects to Input 1 of motor driver
  int IN2Pin;  // Pin on Tiny Duino that connects to Input 2 of motor driver

  // set IN1 and IN2 according to motor used (1-4)
  switch (MotorNum) {
  case 1:
    IN1Pin = 2;
    IN2Pin = 3;
    break;
  case 2:
    IN1Pin = 4;
    IN2Pin = 5;
    break;
  case 3:
    IN1Pin = 6;
    IN2Pin = 7;
    break;
  case 4:
    IN1Pin = 8;
    IN2Pin = 9;
    break;
  default:
    // Invalid motor number flash
    digitalWrite(LedPin, HIGH);   
    delay(50);               
    digitalWrite(LedPin, LOW);   
    delay(50); 
  }


  pinMode(IN1Pin, OUTPUT);       // sets the pin as output
  pinMode(IN2Pin, OUTPUT);       // sets the pin as output

  // Check that MotorSpeed is between 0 and 255
  if ( MotorSpeed < 0 || MotorSpeed > 255 ) {
    // Invalid MotorSpeed flash
    digitalWrite(LedPin, HIGH);   
    delay(100);               
    digitalWrite(LedPin, LOW);   
    delay(100); 
  }

  // Operate H-Bridge according to the Bridge Control Table of the DRV8837
  // In Forward and Reverse always set the low pin as fixed and the high pin to
  // the PWM value. When the PWM pin is high the motor operates in the specfied direcion,
  // and when the PWM is low the motor coasts.

  switch (ControlMode) {
  case Forward:
    digitalWrite(IN2Pin, LOW);         // sets the Mode
    analogWrite(IN1Pin, MotorSpeed);   // sets the speed with a PWM signal
    break;
  case Reverse:
    digitalWrite(IN1Pin, LOW);         // sets the Mode
    analogWrite(IN2Pin, MotorSpeed);   // sets the speed with a PWM signal
    break;
  case Coast:
    digitalWrite(IN1Pin, LOW);         // sets the Mode
    digitalWrite(IN2Pin, LOW);         // sets the Mode
    break;
  case Brake:
    digitalWrite(IN1Pin, HIGH);         // sets the Mode
    digitalWrite(IN2Pin, HIGH);         // sets the Mode
    break;
  default:
    // Invalid ControlMode flash
    digitalWrite(LedPin, HIGH);   
    delay(200);               
    digitalWrite(LedPin, LOW);   
    delay(200); 
  }

} // End of MotorlControl Function















7
TinyDuino Processors & TinyShields / Re: TinyShield Motor Driver
« on: July 23, 2013, 10:37:33 PM »
Ken,

Thanks for the quick response.

I finally got it to work. But there are some additional changes still needed in the example code.

The posted code only operates the motor in one direction.

To change directions you need to change the signs of both input 1 and input 2. Simply changing the sign of motorDirPin will not change the direction.

See the Bridge Table on page 6 of the motor driver spec sheet:

http://www.ti.com/lit/ds/symlink/drv8837.pdf

So far I operated the motor in both directions at full power by putting one pin high and the other low, and then switching both. I have not yet implemented PWM control.

Thanks

Nate

8
TinyDuino Processors & TinyShields / Re: TinyShield Motor Driver
« on: July 22, 2013, 05:30:20 PM »
Ken,

Thanks for taking a look at this.

I did solder up all the pins that came with the motor driver. The one that is labeled GND and VM are hooked up to my battery, and indeed I measured the 3VDC battery voltage across it.

I did notice that when I remove the AA batteries and program the TinyDuino from the USB connector, I do not get any voltage going into the motor driver. Should the 5VDC from the USB be going to the + and - on the TinyDuino board, and ultimately out to the motor driver? I am not 100% clear how all the grounds and power supplies are connected in the various shields.

I am using the example code from the Motor Driver website. All I did was add a blinking light so I could see something.

Is there anyway to tell if the motor driver is working at all? 

Thanks

Nate

9
TinyDuino Processors & TinyShields / TinyShield Motor Driver
« on: July 22, 2013, 12:52:39 PM »
I am having difficulty getting my Tiny Shield Motor driver to work. I suspect that it has to do with the ground connections.

I know that my code is running since I added an LED Shield and it is blinking as programmed. I am using 2 AA batteries and measure 3VDC going into the Motor Driver, but the motor is not turning (it works on 3VDC).

I followed the wiring instructions on the Tiny-Circuits site, copied below:

◦   "Step 3: Add a wire between the GND pin on the Motor x4 TinyShield and the negative terminal on the battery holder."
   
My Tiny Duino has a coin battery holder, but I am using an external battery. The negative terminal was “hidden” under the battery holder clip, so I used a cardboard piece to press a black ground wire into the coin space. I checked that there was indeed a 3VDC difference between the ground wire and positive terminal.
   
◦   "Step 4: Add a wire between the VM pin on the Motor x4 TinyShield and the positive terminal on the battery holder."

I soldered a red wire to the spot where the coin holder is attached to the Tiny Duino.

◦   "Step 5: Add a wire between the positive connection on the battery holder and the ‘+’ hole on the TinyDuino processor Board. This will connect the VM and VCC power supplies together."

I soldered a red wire to the ‘+’ on the Tiny Duino board.


I then tied the black wire to the AA batteries ground and into the Motor Driver GND. I tied all red wires together and the AA battery positive, and tied it to the Motor Driver VM input.

Nothing was working so I tried connecting the ‘-‘ on the Tiny Duino to the rest of the grounds but that did not help either.

I have used H-bridges and motor drivers before, but have spent 2 days on this and am stuck. I already tried a second motor driver shield. Any advice would be much appreciated.

Thanks

Nate

Pages: 1
SMF spam blocked by CleanTalk