logo

Tuesday, May 25, 2010

Drive your Carrrrrrrrrrrr with iPhone, Power Wheels, Laptop

Before u see the video:
The goal of this project is to be able to remotely control an automobile. This involves building:
An automobile control system (ACS)
A remote system that sends commands to the ACS. 

These two systems are then connected by a wireless network to complete communication. This allows a controller - such as an iPhone, Power Wheels, computer, etc – to wirelessly command the car to actuate its pedals and steering.
This document describes the implementation of each of these systems, as well as the different types of communication used for each controller.

System:Commands from the remote system are sent to the ACS. The ACS processes the values it receives by performing some basic PID calculations and outputs signals to the motors that define where they should move. Each of the pedals and the steering has a dedicated motor and motor controller such that each can be controlled individually.
Automobile Control System:
The ACS consists of three main elements: motor control, electronic control, and power distribution.
Motor Control used:
3 Brushless DC Motors (power window motors work great)
3 Luminary Micro Jaguar Motor Controllers
2 Single-Turn 10 kΩ Potentiometers
1 10-Turn 10 kΩ Potentiometer
3 5 kΩ Resistors
The DC motors must be positioned such that they can actuate the pedals and steering. For the pedal motors, ‘U’ brackets are used to fasten the motors to the floor of the car at the base of each pedal. ¾” wrenches are then attached to the sprockets to provide lever arm to actuate the pedals. Single-turn potentiometers (Z1) are connected to the sprockets as well using nylon tubing such that their resistance changes when the motors turn. A 5 kΩ resistor (Z2) is placed in series with the potentiometer to create a voltage divider. Applying a voltage across both resistors and measuring across the Z2 shows a change in voltage (Vout) when the potentiometer rotates with the motor. This provides position feedback.
Voltage Divider Calculation
Motor Installed for Brake Pedal
Completed Motor Installation for Gas Pedal
The steering is implemented in a similar manner. The motor is mounted such that it is parallel with the steering column. The steering wheel is replaced with a gear that is fastened to its shaft. A motorcycle chain is laid over the gear and the sprocket of the steering motor. This causes the steering shaft to turn when the motor turns, controlling the angle of the wheels. The multiple-turn potentiometer is connected to the motor sprocket similarly to the pedal motors. It is also put in series with a 5 kΩ resistor in a voltage divider configuration.
Gear Attached to Steering Shaft

Motor Sprocket and Potentiometer Connection
To control the motors, the PWM output of the motor controllers must be connected to the voltage input of the motors. They are fed digital inputs from the electronic control that defines how much the motors should turn.
Electronic Control may be:
NI cRIO-9074
NI 9201
NI 9403
FIRST Digital Side Card (Digital breakout board)
NI LabVIEW 2009
NI LabVIEW FPGA Module
NI LabVIEW Real-Time Module
The Compact RIO (cRIO) is an embedded controller that is programmed with LabVIEW. We program the FPGA to gain fast access to its inputs and outputs, and deploy code to its Real-Time OS for quick testing. We use its network communication capabilities to connect to the remote system and receive commands. All processing is done on the cRIO itself, and outputs signals to the motor controllers via the NI 9403 digital output module to set motor position. The NI 9201 analog input module is used to acquire motor position data from the voltage dividers in the ACS.

In summary, the cRIO receives motor position commands from the remote system. It uses these values in conjunction with the current motor position values received from the NI 9201 module to implement a PID algorithm that sends digital outputs to the Jaguar motor controllers via the NI 9403 module. This allows the remote system to command all three motors simultaneously. The FIRST digital side card is connected between the NI 9403 and Jaguars to simplify the digital connections between the two.
NI Compact RIO with NI 9201 and NI 9403 Modules
FIRST Digital Side Card
Power Distribution:
12 V Battery (Standard Car battery works great)
FIRST Fused Power Distribution Board
The cRIO, wireless gaming adapter (found in the Remote System), and Jaguar motor controllers all require power. The FIRST power distribution board provides the voltage conversion from 12 V to 24 V so that the cRIO receives adequate voltage. It also provides all necessary outputs to power the motor controllers and gaming adapter. The fuses on the power distribution board protect the motor controllers and cRIO from any power surges. The power distribution board is powered by the 12 V battery.
First Fused Power Distribution Board
Remote System:
The remote system consists of a wireless network through which all components of the system are connected. It can be monitored and controlled from a laptop with wireless capability.

Used:
Wireless G Router
Wireless Gaming Adapter
Laptop with Wireless Card

The wireless G router creates a network that all elements of the system can join. The wireless gaming adapter joins this network and plugs into the cRIO, adding the cRIO to the network. The laptop joins the network as well. This allows the user to wirelessly monitor the cRIO and change all parameters dynamically.
iPhone Communication:
iPhone communication consists of UDP packets sent directly from the iPhone to the cRIO via wireless network.
Used:
iPhone
Remote System
ACS
The iPhone application has 2 sliders. One for controlling the brake, one for the gas. The on-board accelerometer is used to pick up rotation, which is used to control the steering. In order to communicate these values to the cRIO over UDP, they must be incorporated into strings. We do this by defining each iPhone control’s range of motion as values from 0-255. The values are then converted ASCII characters, packaged together, and sent to the cRIO. The cRIO is programmed to take characters 2,3, & 4 to be the values for steering, gas, & brake, respectively. For example, if the cRIO receives a string “c€!t” then it knows to assign a value of €(128) to steering, !(33) to gas, and t(116) to brake. These values are processed on the cRIO as commands to move position. ‘c’ is present so that the cRIO can always find the start of a new data packet.
Power Wheels:
The Power Wheels commands the automobile by sending steering angle and speed information to the laptop on the remote system, which relays the values to the cRIO on the ACS.
Used:
Power Wheels
WLS-9215
1 10 kΩ Single-Turn Potentiometer
1 5 kΩ Resistor
1 Encoder (In our case a photo-resistor and striped PVC)
12 V Battery
To monitor the steering angle, the potentiometer and resistor are connected in a voltage divider configuration similar to the one described in the ACS section above. A gear is placed on the rotor of the potentiometer and the steering wheel of the potentiometer with a bike chain connecting the two. In this manner, rotating the steering wheel rotates the potentiometer. An encoder is attached to the side of a wheel such that it turns when the wheel turns. Based on the number of turns per second, speed can be calculated.
The WLS-9215 joins the Remote System’s wireless network. It acquires the voltage signals from the voltage divider and encoder and sends them to the laptop for processing. These processed values are forwarded on to the cRIO via Shared Variables, which direct the motors to their appropriate positions.
Communication between cRIO and Laptop

The communication between cRIO is more or less automatic. Once the cRIO has been configured and has a known IP address, a project in LabVIEW can deploy VIs to the FPGA and Real-Time OS automatically.

When sending data between VIs that are running on different targets, Network-Published Shared Variables are used. These are also configured in the LabVIEW project and implement communication automatically.
Communication between iPhone and cRIO

The iPhone communication bypasses the laptop entirely. It sends packets of data in character form directly to the cRIO via UDP communication.

User Datagram Protocol, or UDP, does not guarantee the safe arrival of data to the destination. In addition, data sent in multiple packets may not arrive at the destination in the order they were sent. Because of this, data is sent at rates of ~30 packets/second. Each packet begins with a ‘c’ character to identify the beginning of a new packet to remove corrupted or misinterpreted packets.
Completed System

Once all parts of the system are complete, they are connected via the remote system. Verify communication and parameters on the Laptop. Enjoy the remotely controlled automobile.

0 comments:

Post a Comment