The Alpha Geek – Geeking Out

Vertical

Project #12: Robotics – Vertical – Mk15

——

#DonLucElectronics #DonLuc #Robotics #Arduino #Fio #XBee #Stepper #EasyDriver #Project #Fritzing #Programming #Electronics #Microcontrollers #Consultant

——

Vertical

——

Vertical

——

Vertical

——

Joystick

A joystick is an input device consisting of a stick that pivots on a base and reports its angle or direction to the device it is controlling. A joystick, also known as the control column, is the principal control device in the cockpit of many civilian and military aircraft, either as a centre stick or side-stick. It often has supplementary switches to control various aspects of the aircraft’s flight.

Pololu Adjustable Step-Up Voltage Regulator U1V11A

This compact U1V11A switching step-up voltage regulator efficiently boosts input voltages as low as 0.5 V to an adjustable output voltage between 2 V and 5.25 V. Unlike most boost regulators, the U1V11A offers a true shutdown option that turns off power to the load, and it automatically switches to a linear down-regulation mode when the input voltage exceeds the output.

DL2112Mk05

2 x Fio v3 – ATmega32U4
2 x XBee S1
2 x Lithium Ion Battery – 850mAh
1 x Thumb Joystick
1 x SparkFun Thumb Joystick Breakout
1 x Slide Pot (Small)
1 x Slide Potentiometer Knob
1 x LED Green
1 x Pololu Adjustable Step-Up Voltage Regulator U1V11A
2 x EasyDriver
2 x Small Stepper
1 x Nine Volt Battery
1 x 9V Battery Connector
1 x Half-Size Breadboard
1 x Full-Size Breadboard
1 x SparkFun Cerberus USB Cable

Fio v3 – ATmega32U4 – Transmitter

XBee S1: Transmitter

CH Channel: C
PAN Id: 3333
SH Serial Number: 13A200
SL Serial Number: 40717A1F
CE Coordinator: Coordinator
BD: 9600

RX0 – Digital 0
TX0 – Digital 1
PO0 – Analog A0
JY0 – Analog A1
JY1 – Analog A2
SE0 – Digital 16
VIN – +3.3V
GND – GND

——

DL2112Mk05t.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #12: Robotics - XBee S1 - Transmitter - Mk15
12-05
DL2112Mk05t.ino
1 x Fio v3 - ATmega32U4
1 x XBee S1
1 x Lithium Ion Battery - 850mAh
1 x Thumb Joystick
1 x SparkFun Thumb Joystick Breakout
1 x Slide Pot (Small)
1 x Slide Potentiometer Knob
1 x SparkFun Cerberus USB Cable
*/

// Include the Library Code
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>

// Communication
unsigned long dTime = 50;

// Slide Pot (Small)
// Select the input pin for the slide pot
// Power
const int iSP1 = A0;
// Power to store the value
int iPower = 0;

// Connections to joystick
// Vertical
const int VERT = A1;
// Horizontal
const int HORIZ = A2;
// Pushbutton
const int SEL = 16;
// Initialize variables for analog and digital values
int vertical;
int horizontal;
int select;

// Software Version Information
// Version
String sver = "12-15t";
// Unit ID Information
// UID
String uid = "";

void loop()
{

  // Thumb Joystick
  isThumbJoystick();
    
  // Process Message
  isProcessMessage();

  delay( dTime );
  
}

getEEPROM.ino

// EEPROM
// is UID
void isUID()
{
  
  // Is Unit ID
  // UID
  uid = "";
  for (int x = 0; x < 5; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getProcessMessage.ino

// Process Message
// isProcessMessage
void isProcessMessage() {
  
   // Loop through serial buffer
   // Print = "<" + vertical + "|" + horizontal + "|" + select + "|" + iValue + "|" + sver + "|" + uid + "*"
      
   Serial1.print( '<'  );
   Serial1.print( vertical );
   Serial1.print( '|' );
   Serial1.print( horizontal );
   Serial1.print( '|' );
   Serial1.print( select );
   Serial1.print( '|' );
   Serial1.print( iPower );
   Serial1.print( '|' );
   Serial1.print( sver );
   Serial1.print( '|' );
   Serial1.print( uid );
   Serial1.println( '*' );

}

getThumbJoystick.ino

// Thumb Joystick
void isThumbJoystick() {

  // Read all values from the joystick
  // Joystick was sitting around 520 for the vertical and horizontal values
  // Will be 0-1023
  vertical = analogRead(VERT);
  // Will be 0-1023
  horizontal = analogRead(HORIZ);
  // Will be HIGH (1) if not pressed, and LOW (0) if pressed
  select = digitalRead(SEL);
  // Read the value
  // Power be 0-1023
  iPower = analogRead( iSP1 );
 
}

setup.ino

// Setup
void setup()
{

  // EEPROM Unit ID
  isUID();
  
  // Pause
  delay(5);
  
  // Make the SEL line an input
  pinMode(SEL, INPUT_PULLUP);
  
  // Open Serial1 port at 9600 baud
  Serial1.begin( 9600 );

  // Pause
  delay(5);

}

——

Fio v3 – ATmega32U4 – Receiver

XBee S1: Receiver

CH Channel: C
PAN Id: 3333
SH Serial Number: 13A200
SL Serial Number: 4076E2C5
CE Coordinator: End Device
BD: 9600

RX0 – Digital 0
TX0 – Digital 1
DR0 – Digital 2
ST0 – Digital 3
DR1 – Digital 4
ST1 – Digital 5
LED – Digital 6
VIN – +3.3V
GND – GND

——

DL2112Mk05r.ino

/* ***** Don Luc Electronics © *****
Software Version Information
Project #12: Robotics - Vertical - Mk15
12-05
DL2112Mk04r.ino
1 x Fio v3 - ATmega32U4
1 x XBee S1
1 x Lithium Ion Battery - 850mAh
1 x LED Green
1 x Pololu Adjustable Step-Up Voltage Regulator U1V11A
2 x EasyDriver
2 x Small Stepper
1 x Nine Volt Battery
1 x 9V Battery Connector
1 x Half-Size Breadboard
1 x Full-Size Breadboard
1 x SparkFun Cerberus USB Cable
*/

// Include the library code:
// EEPROM library to read and write EEPROM with unique ID for unit
#include <EEPROM.h>

// LED Green
int iLEDGreen = 6;

// 2 x EasyDriver - 2 x Stepper
// EasyDriver Right
int dirPinR = 2;
// stepPin Right
int stepPinR = 3;
// EasyDriver Left
int dirPinL = 4;
// stepPin Left
int stepPinL = 5;
// Microsteps
int i = 0;
// Power be 0-1023
int iPower = 0;
String POW = "";
// Joystick was sitting around 520 for the vertical and horizontal values
// Will be 0-1023
// Vertical
int vertical;
String VER = "";
// Horizontal
// Will be 0-1023
int horizontal;
String HOR = "";
// Select
// Will be HIGH (1) if not pressed, and LOW (0) if pressed
int select;
String SEL = "";
int firstClosingBracket = 0;
// Map Vertical and Horizontal
int mapVer = 0;
int mapHor = 0;

// Process Message
// Start
bool bStart = false;
// End
bool bEnd   = false;
// Variable to store the incoming byte
int incb = 0;
// Message
String msg = "";
// Index
byte in = 0;
int x = 0;

// Software Version Information
String sver = "12-15r";
// Unit ID information
String uid = "";

void loop() {

  // Check for serial messages
  isProcessMessage();

}

getEEPROM.ino

// EEPROM
// isUID
void isUID()
{
  
  // Is Unit ID
  uid = "";
  for (int x = 0; x < 5; x++)
  {
    uid = uid + char(EEPROM.read(x));
  }
  
}

getProcessMessage.ino

// ProcessMessage
// isProcessMessage
void isProcessMessage() {

  // Loop through serial buffer one byte at a time until you reach * which will be end of message
  while ( Serial1.available() > 0 ) 
  {
      
      // Read the incoming byte:
      incb = Serial1.read();
      
      // Start the message when the '<' symbol is received
      if(incb == '<')
      {
        
        bStart = true;
        in = 0;
        msg = "";
        
      }
      // End the message when the '*' symbol is received
      else if(incb == '*')
      {
        
        bEnd = true;
        x = msg.length();
        msg.remove( x , 1);
        // Done reading
        
        break;
      }
      // Read the message
      else
      {
        
        msg = msg + char(incb);
        in++;
        //Serial.println( msg );

      }
      
   }

   // Start - End
   if( bStart && bEnd)
   {

      // isStepper => msg
      isStepper();
      
      digitalWrite(iLEDGreen, HIGH);
      in = 0;
      msg = "";
      bStart = false;
      bEnd = false;
      vertical;
      horizontal;
      iPower;
      
   }

}

getStepper.ino

// Stepper
// isStepperSetup
void isStepperSetup() {

  // 2 x EasyDriver
  pinMode(dirPinR, OUTPUT);
  pinMode(stepPinR, OUTPUT);
  pinMode(dirPinL, OUTPUT);
  pinMode(stepPinL, OUTPUT);

}
// isStepper
void isStepper() {

  // msg = vertical + "|" + horizontal + "|" + select + "|" + iValue + "|" + sver + "|" + uid
  firstClosingBracket = 0;
  // Vertical
  firstClosingBracket = msg.indexOf('|');
  VER = msg;
  VER.remove(firstClosingBracket);
  vertical = VER.toInt();
  // Horizontal
  firstClosingBracket = firstClosingBracket + 1;
  msg.remove(0, firstClosingBracket );
  firstClosingBracket = msg.indexOf('|');
  HOR = msg;
  HOR.remove(firstClosingBracket);
  horizontal = HOR.toInt();
  // Select
  firstClosingBracket = firstClosingBracket + 1;
  msg.remove(0, firstClosingBracket );  
  firstClosingBracket = msg.indexOf('|');
  SEL = msg;
  SEL.remove(firstClosingBracket);
  // Power
  firstClosingBracket = firstClosingBracket + 1;
  msg.remove(0, firstClosingBracket );    
  firstClosingBracket = msg.indexOf('|');
  POW = msg;
  POW.remove(firstClosingBracket);
  iPower = POW.toInt();

  // EasyDriver Right
  // Set the direction
  // Joystick was sitting around 520 for the vertical and horizontal values
  // Will be 0-1023
  mapVer = map(vertical, 0, 1023, -512, 512);
  mapHor = map(horizontal, 0, 1023, -512, 512);
  
  // Vertical
  if ( mapVer <= 12 ) {

    // Set the direction HIGH
    digitalWrite(dirPinR, HIGH);
    delay(5);
    digitalWrite(dirPinL, HIGH);
    delay(5);
    
  } else {

    // Set the direction LOW
    digitalWrite(dirPinR, LOW);
    delay(5);
    digitalWrite(dirPinL, LOW);
    delay(5);
    
  }

  // Iterate for 200 microsteps
  for (i = 0; i<200; i++)
  { 

     // This LOW to HIGH change is what creates the
     digitalWrite(stepPinR, LOW);
     // "Rising Edge" so the easydriver knows to when to step.
     digitalWrite(stepPinR, HIGH);
     // This delay time is close to top speed.
     delayMicroseconds(iPower);
     // This LOW to HIGH change is what creates the
     digitalWrite(stepPinL, LOW);
     // "Rising Edge" so the easydriver knows to when to step.
     digitalWrite(stepPinL, HIGH);
     // This delay time is close to top speed.
     delayMicroseconds(iPower);

 }
   
}

setup.ino

// Setup
void setup() {

  // Open the serial port at 9600 bps:
  Serial1.begin( 9600 );

  // Pause
  delay(5);

  // EEPROM Unit ID
  isUID();
  
  // Pause
  delay(5);

  // 2 x EasyDriver
  isStepperSetup();

  // Pause
  delay(5);
  
  // LED Green
  pinMode(iLEDGreen, OUTPUT);
  digitalWrite(iLEDGreen, LOW);

}

——

People can contact us: https://www.donluc.com/?page_id=1927

Technology Experience

  • Single-Board Microcontrollers (PIC, Arduino, Raspberry Pi,Espressif, etc…)
  • IoT
  • Robotics
  • Camera and Video Capture Receiver Stationary, Wheel/Tank and Underwater Vehicle
  • Unmanned Vehicles Terrestrial and Marine
  • Research & Development (R & D)
  • Desktop Applications (Windows, OSX, Linux, Multi-OS, Multi-Tier, etc…)
  • Mobile Applications (Android, iOS, Blackberry, Windows Mobile, Windows CE, etc…)
  • Web Applications (LAMP, Scripting, Java, ASP, ASP.NET, RoR, Wakanda, etc…)
  • Social Media Programming & Integration (Facebook, Twitter, YouTube, Pinterest, etc…)
  • Content Management Systems (WordPress, Drupal, Joomla, Moodle, etc…)
  • Bulletin Boards (phpBB, SMF, Vanilla, jobberBase, etc…)
  • eCommerce (WooCommerce, OSCommerce, ZenCart, PayPal Shopping Cart, etc…)

Instructor and E-Mentor

  • IoT
  • PIC Microcontrollers
  • Arduino
  • Raspberry Pi
  • Espressif
  • Robotics
  • DOS, Windows, OSX, Linux, iOS, Android, Multi-OS
  • Linux-Apache-PHP-MySQL

Follow Us

J. Luc Paquin – Curriculum Vitae – 2021 English & Español
https://www.jlpconsultants.com/luc/

Web: https://www.donluc.com/
Web: https://www.jlpconsultants.com/
Facebook: https://www.facebook.com/neosteam.labs.9/
YouTube: https://www.youtube.com/channel/UC5eRjrGn1CqkkGfZy0jxEdA
Twitter: https://twitter.com/labs_steam
Pinterest: https://www.pinterest.com/NeoSteamLabs/
Instagram: https://www.instagram.com/neosteamlabs/

Don Luc

Categories
Archives