Skip to content

Capítulo 4:PC Interfaces

JosbaneyPereira edited this page Jan 22, 2018 · 29 revisions

4 PC Interfaces


In order to be able to program a robot for repetitive tasks or to integrate with sensors like cameras, we need to be able to connect the robot to a con- troller. We will use a PC as the robot controller for some robots in this book. Therefore, we need to interface the robot with a PC. There are many ways the robot can be connected to a PC. We can control the robot using relays by developing a sensor board that connects to some computer port, such as the parallel port or a USB port or a serial port. Serial ports are getting obsolete, so we will not discuss those in detail. In order to develop interface, we need to know how the parallel port works and how we can use it to connect to the robot. This is discussed below.

FTDI

El adaptador de USB a serie Pololu es una unidad pequeña que facilita la conexión de un proyecto de microcontrolador a una PC. Puede conectar el adaptador directamente a un microcontrolador sin un convertidor de nivel RS-232 a TTL. Es compatible con USB 2.0 y funcionará con sus programas existentes que interactúan con un puerto serie.

TABLA

Hardware Description
ARDUINO Arduino Nano
Rhino 1750mAh 2S 7.4v 20C Lipoly Pack Rhino 1750mAh 2S 7.4v 20C Lipoly Pack
12 x Turnigy TGY-1269HV Titanium Turnigy 1269HV Digital Titanium Gear Servo 21kg / 0.16sec / 57g.
Carbon Fiber Square Tube 750x10mm Carbon Fiber Square Tube 750x10mm.

CÓDIGO


#include "msp430g2553.h"
void main()
{
  WDTCTL =  WDTPW + WDTHOLD;    // Stop the Watchdog
        
  void Delay(int j);
        
  P2SEL  &= ~BIT6;              // Clear P2.6 in P2SEL  (by default Xin)
  P2SEL2 &= ~BIT6;              // Clear P2.6 in P2SEL2
  P2DIR  |=  BIT3 + BIT4 + BIT6; // P2.3,P2.4,P2.6 all output
  P2OUT  &= ~BIT3 + BIT4 + BIT6; // Clear P2.3,P2.4,P2.6  
        
  // Rotate the Motor clockwise
  P2OUT |= BIT3; // P2.3 = 1,P2.4 = 0
  P2OUT |= BIT6; // P2.6 = 1 ,3&4_EN = 1,Motor is started
  Delay(10);     // Rotate motor for sometime
        
  // Stop the motor 
  P2OUT &= ~BIT3 + BIT4; // P2.3 = 0,P2.4 = 0
  Delay(5);              // Stop the motor for sometime 
        
  // Rotate the Motor Counter clockwise
  P2OUT &= ~BIT3; // P2.3 = 0
  P2OUT |=  BIT4; // P2.4 = 1
  P2OUT |= BIT6;  // P2.6 = 1 ,3&4_EN = 1,Motor is started
  Delay(10);      // Rotate motor for sometime
        
  P2OUT &= ~BIT6; // P2.6 = 0,3&4_EN = 0,Motor is stoped
}//End of Main

void Delay(int j)
{
  int i;
  for(j=0;j<10;j++)
      for(i=0;i<0xFFFF;i++);
}

IMAGEN

VIDEO

Click to see the youtube video

:octocat: