Bajdi electronics

Hobby electronics website

Browse: Page 33

Dagu Rover 5 in action

By Bajdi on February 22, 2012

Finally I received all the parts to make a small pcb to distribute the power for my Rover 5. I soldered some terminal blocks on it so I could connect my 2 cell 7,4V Lipo battery. The Dagu red back spider robot controller and the motors get their power direct from the Lipo battery. I needed 2 voltage regulators, one LM7805 that provides 5V for the logic of the motor controller and a LM1117 that gives 3,3V to the Nrf24L01 module. I put a green led on the pcb that lights up when the power is connected. I also added a voltage divider made up of 2 10K resistors, I’ll connect it to an analog input to monitor the battery voltage. So I can shut it down when the battery goes below a certain level. I used the code that I posted in my previous post. The Rover 5 goes very well, with the 4 motors it has lots of power 🙂 See it spinning around in the video…

Dagu Rover 5 from Bajdi on Vimeo.

Posted in Dagu Rover 5 | Tagged robot | Leave a response

Remote controlling the Dagu Rover 5 with a joystick

By Bajdi on February 18, 2012

I’ve hooked up the 4 motors from the Rover 5 to the motor controller and connected the direction and PWM pins to the red back spider robot controller (that’s a very long name). When you connect the motors to the motor controller take a good look which motor is what number. You don’t want to drive 2 motors on the same side in different directions. For this reason I left the tracks off and put a box under the chassis to easily test my little robot.
I currently use a breadboard with a LM7805 and L1117D, the 7805 provides 5 Volts to the logic terminals of the motor controller and the L1117D gives 3,3V to the Nrf24L01 2,4GHz wireless module. I will make a small PCB with some terminals and the voltage regulators to connect the different voltages. I have already received a 2 cell Lipo battery, the nominal voltage of these batteries is 7,4V. But when fully charged they give 8,4V. The battery will be connected to the robot controller and the motor power terminals on the 4 channel motor controller. I haven’t been able to do this because I don’t have the right connector.

To remote control the Rover 5 I connected my analog joystick and a Nrf24L01 module to my Arduino Uno. I then uploaded the same sketch that I used to remote control my 2 stepper motors. This sketch transmits the analog values from the joystick to the robot controller.
In the sketch for the robot controller the values from the X and Y axis are mapped to PWM values (0-255) to set the speed and the direction is determined by setting the direction outputs high or low. The minimum pins needed to drive the 4 motors are 4 PWM pins and 4 digital output pins. For the Nrf24L01 module you need another 5 pins, 3 for the SPI bus and the CE and CSN pin. Thankfully the Dagu red back spider robot controller is based on the Arduino Mega 1280, which has 54 digital input/outputs (16 are PWM) and 16 analog inputs. So I have a lot of room for expansion 🙂

Here is the sketch I’ve made to remote control the Dagu Rover 5 with an analog joystick connected to another Arduino:

// http://www.bajdi.com
// Dagu Rover 5 chassis with 4 motors
// Remote control through Nrf24L01 2,4GHz wireless module
// µcontroller = Dagu Red back spider, Arduino Mega 1280 compatible
// Motor controller = Dagu 4 channel motor controller
// Motor 1 and 2 on the left
// Motor 3 and 4 on the right

#include <SPI.h>
#include <Mirf.h>
#include <nRF24L01.h>
#include <MirfHardwareSpiDriver.h>

/* Nrf24L01 pinout
1 GND
2 VCC (3,3V)
3 CE    pin 48 on Mega 1280
4 CSN   pin 49 on Mega 1280
5 SCK   pin 52 on Mega 1280
6 MOSI  pin 51 on Mega 1280
7 MISO  pin 50 on Mega 1280
8 IRQ (not used)
*/

int DirM1 = 30; // direction motor 1
int DirM2 = 31; // direction motor 2
int DirM3 = 32; // direction motor 3
int DirM4 = 33; // direction motor 4
int PWMM1 = 3;  // pwm motor 1
int PWMM2 = 4;  // pwm motor 2
int PWMM3 = 5;  // pwm motor 3
int PWMM4 = 6;  // pwm motor 4

int fs; // forward speed
int bs; // backward speed
int ls; // turn left speed
int rs; // turn right speed

int joystick[3];    // Array with 2 analog values (X,Y-axis) and one digital (Z-axis) from transmitter/joystick

void setup() {

  pinMode(DirM1, OUTPUT);  // direction motor 1, left front
  pinMode(DirM2, OUTPUT);  // direction motor 2, left rear
  pinMode(DirM3, OUTPUT);  // direction motor 3, right front
  pinMode(DirM4, OUTPUT);  // direction motor 4, right rear
  pinMode(PWMM1, OUTPUT);  // PWM motor 1
  pinMode(PWMM2, OUTPUT);  // PWM motor 2
  pinMode(PWMM3, OUTPUT);  // PWM motor 3
  pinMode(PWMM4, OUTPUT);  // PWM motor 4
  Mirf.cePin = 48;             //ce pin 
  Mirf.csnPin = 49;            //csn pin 
  Mirf.spi = &MirfHardwareSpi;
  Mirf.init();
  Mirf.setRADDR((byte *)"serv1");
  Mirf.payload = sizeof(joystick);
  Mirf.config();
}

void loop() { 
  
  int X = joystick[0];    // joystick X-axis
  int Y = joystick[1];    // joystick Y-axis 

  while(!Mirf.dataReady()){
  }
  Mirf.getData((byte *) &joystick);

  if (X > 500 && X < 540 && Y > 490 && Y < 530 )    // joystick is centered
  {
    analogWrite(PWMM1, 0);
    analogWrite(PWMM2, 0);
    analogWrite(PWMM3, 0);
    analogWrite(PWMM4, 0);
  }

  if (X <= 500 && Y > 490 && Y < 530)               // joystick forward = all motors forward
  {
    fs = (map(X, 500, 0, 35, 255));
    digitalWrite(DirM1, HIGH);
    digitalWrite(DirM2, HIGH);
    digitalWrite(DirM3, HIGH);
    digitalWrite(DirM4, HIGH);
    analogWrite(PWMM1, fs);
    analogWrite(PWMM2, fs);
    analogWrite(PWMM3, fs);
    analogWrite(PWMM4, fs);
  }

  if (X >= 540 && Y > 490 && Y < 530)               // joystick backward = all motors backward
  {
    bs = (map(X, 540, 1023, 35, 255));
    digitalWrite(DirM1, LOW);
    digitalWrite(DirM2, LOW);
    digitalWrite(DirM3, LOW);
    digitalWrite(DirM4, LOW);
    analogWrite(PWMM1, bs);
    analogWrite(PWMM2, bs);
    analogWrite(PWMM3, bs);
    analogWrite(PWMM4, bs);
  }

  if (Y <= 490 && X > 500 && X < 540)              // joystick left = left motors backward && right motors forward
  {
    ls = (map(Y, 490, 0, 35, 255));
    digitalWrite(DirM1, LOW);
    digitalWrite(DirM2, LOW);
    digitalWrite(DirM3, HIGH);
    digitalWrite(DirM4, HIGH);
    analogWrite(PWMM1, ls);
    analogWrite(PWMM2, ls);
    analogWrite(PWMM3, ls);
    analogWrite(PWMM4, ls);
  }

  if (Y >= 530 && X > 500 && X < 540)              // joystick right = left motors forward && right motors backward
  {
    rs = (map(Y, 530, 1023, 35, 255));
    digitalWrite(DirM1, HIGH);
    digitalWrite(DirM2, HIGH);
    digitalWrite(DirM3, LOW);
    digitalWrite(DirM4, LOW);
    analogWrite(PWMM1, rs);
    analogWrite(PWMM2, rs);
    analogWrite(PWMM3, rs);
    analogWrite(PWMM4, rs);
  }
}

Posted in Arduino sketches, Dagu Rover 5 | Tagged nRF24L01, robot | 2 Responses

Blink without delay and millis but with a DS1307.

By Bajdi on February 15, 2012

I’ve been breaking my head over this for the last hour. I want to use the DS1307 RTC module in a home automation project. To do certain time based things. So I thought lets try to rewrite the “blink without delay” example that comes with the Arduino IDE and use the data from the DS1307 instead of the millis function. To get the data from the DS1307 I used the code that I found on this site. But I got very lost trying to figure out how make this simple sketch. Thankfully there are a lot of friendly helpful people on the Arduino forum who showed me how to do this. It’s actually a lot simpler then I thought.

So here it is, blink without delay and millis but with the DS1307 🙂

/*
 Blink without delay using a DS1307
 Led blinks once every second.
 */

#include <Wire.h>
const int DS1307_I2C_ADDRESS = 0x68;

const int led =  13;      // the number of the light pin
int ledState = LOW;
int lastTime = -1;
byte second, minute, hour;

// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
  return ( (val/16*10) + (val%16) );
}

void getDateDs1307()
{
  // Reset the register pointer
  Wire.beginTransmission(DS1307_I2C_ADDRESS);
  Wire.send(0x00);
  Wire.endTransmission();

  Wire.requestFrom(DS1307_I2C_ADDRESS, 1);

  second     = bcdToDec(Wire.receive() & 0x7f);
}

void setup() {
  Wire.begin();
  pinMode(led, OUTPUT);      
}

void loop(){

  getDateDs1307();
  int time1 = second;
  if (abs(time1 - lastTime) > 1)
  {
    if (ledState == LOW) 
      ledState = HIGH;
    else
      ledState = LOW;

    // set the LED with the ledState of the variable:
    digitalWrite(led, ledState);
    lastTime = time1;
  }
}

Posted in Arduino sketches | Tagged DS1307 | Leave a response

« PreviousNext »

Recent Posts

  • 3D Printer extruders
  • Mearm forked
  • Arduino time lapse – camera pan device
  • Bought a 199$* Prusa I3 3D printer
  • Simple DIY lab power supply
  • Bajduino
    • Bajduino 1284
    • Bajduino 328
  • Stepper robot arm

Recent Comments

  1. 200+ Arduino Projects List For Final Year Students - He Loves Math on Obstacle avoiding robot made from cheap parts
  2. MP3 Alarm Clock: Crafting Customized wake-Up tunes with Arduino on Arduino MP3 alarm clock
  3. Bas on L9110 H-bridge module
  4. Victor on L9110 H-bridge module
  5. WAQAR AHMED on Dimming led with IR remote control

Archives

  • June 2016
  • August 2015
  • May 2015
  • January 2015
  • December 2014
  • November 2014
  • May 2014
  • April 2014
  • March 2014
  • February 2014
  • January 2014
  • December 2013
  • November 2013
  • October 2013
  • September 2013
  • June 2013
  • May 2013
  • April 2013
  • March 2013
  • February 2013
  • January 2013
  • December 2012
  • November 2012
  • October 2012
  • September 2012
  • August 2012
  • July 2012
  • June 2012
  • May 2012
  • April 2012
  • March 2012
  • February 2012
  • January 2012
  • December 2011

Categories

  • 3D printing
  • Arduino
  • Arduino sketches
  • Bajdupod 996R
  • Bajdupod 9G
  • Bob the biped
  • Buying parts
  • Dagu Rover 5
  • Dagu service droid
  • Gentoo
  • Insectbot
  • Line following robot
  • Raspberry Pi
  • Self balancing bot
  • Bajduino
    • Bajduino 1284
    • Bajduino 328
  • Stepper robot arm

Copyright © 2026 Bajdi electronics.

Powered by WordPress and Hybrid by Bajdi.