# Sensing and Control.

## Presentation on theme: "Sensing and Control."— Presentation transcript:

Sensing and Control

Digital or Analog Digital or Analog

Digital Input: The interface device can detect a simple change in an electrical voltage level.  That is, it can detect if a switch is on or off.   Digital Output: The interface device can change an electrical signal to on or off and therefore turn on motors, lights, etc.

Analog Input: The interface device can detect a continuously changing electrical voltage coming from sensors which may be responding to changing parameters such as light, sound, liquid levels in tanks, etc. The changing voltage levels are changed to digital numbers to be manipulated and stored in the computer. ( done by ADC)   Analog Output: The interface device can take a series of stored digital numbers and change them into a varying electrical voltage. This voltage can be used to control an external device. (done by DAC)

The Simplest Circuit The simplest circuit consists of:
A source of electrical current A conducting path A control element (Switch) Something that converts electrical energy to some other form of energy (called a load resistance) See Mims, pp 14,18-25

There are a number of electrical parameters (measurements) that are of importance. The 3 most basic are: Electric Potential Difference - measured in Volts Electric Current - measured in Amperes Resistance - measured in Ohms

Electric Potential Difference can be very loosely defined as the “electric pressure” which forces electric current through a conductor Electric Current is the flow of electric charge through a conductor in a unit of time Resistance is the opposition to the flow of current through the conductor

1/Rt = 1/R1 + 1/R2…(parallel)
The relationship is expressed as Ohm’s Law V= I * R Rt = R1 + R2…. (series) 1/Rt = 1/R1 + 1/R2…(parallel)

Pulse Width Modulation

DC motors are often run at a constant speed.
Other uses require variable speed. One of the most efficient methods of DC motor speed control is called Pulse Width Modulation

Pulses are simply on/off voltages.
The length of time the voltage in on is the pulse width.

Cycle: a single pulse Period: Time to complete one cycle Duty Cycle: time on/length of cycle Frequency: number of cycles per second

PhidgetLVMotor Controller
Two independent low-voltage terminal blocks Uses PWM for motor control 65 pulse steps (Code allows -100 to 100) Frequency: 2.5KHz Lamp – Brightness DC Motor - Torque

Servo Motors

Servos do not have a continuous supply of voltage given to them
Servos do not have a continuous supply of voltage given to them. Instead, they are supplied with electricity using Pulse Width Modulation. What does this mean?? There are a series of pulses sent to the motor controller which judges how much you want the motor to turn and this causes the shaft to turn that amount.

Servo Motor Control The DC motor is connected to a set of gears which reduces speed and increases torque or the force of the turn. There is a control circuit which controls how much the motor turns. The position sensor is a variable resistor or potentiometer which is responsible for sensing the position of the motor.

Servo Motor Control The position of the motor is monitored by the potentiometer sensor. If the motor is not in the position as sent by the external servo controller, the internal control circuit causes the motor to turn until it is. When the motor is in the correct position, the sensor signals the control circuit to turn the motor off. The process of the sensor sending information to the control electronics which turns the motor which turns the sensor is called feedback or a closed loop control circuit. How does the potentiometer sensor know when the motor is in the correct position??

Servo Motor Control Each position of the servo is referenced by an internal control circuit pulse. 0 degrees is 1ms, 90 degrees is 1.5 ms and 180 degrees is 2 ms. When the external pulse is issued by the controller, it is issued in milliseconds as well. The internal circuit compares the external pulse to the internal and starts turning the motor. As the motor turns, the internal pulse changes relative to the position. When the difference in the two pulses is zero, the motor will stop turning. The difference in pulses is called the error signal. If the incoming pulse is greater than the internal pulse, it turns in the clockwise. If it is smaller, it turns counter-clockwise.

Referencing the Phidgets
Install the Phidget Library on the computer Before you can use Phidget code in Visual Basic the library must be referenced Open the Project menu and select References.  Scroll down and select Phidget Library by clicking the check box.

Declaring the Phidgets
In General...Declarations enter the following code: Dim WithEvents MyPhidgetName As PhidgetDevice Note: MyPhidgetName is called an instance of the class of objects called PhidgetDevice You can use any name as long as it is not a Visual Basic reserved word.

Opening the Phidget Code the Form_Load procedure:
Set MyPhidgetName = New PhidgetDevice Call MyPhidgetName.Open(True, -1) Call MyPhidgetName.Open

Servo Motor Control Phidget Code Example
Assuming the Phidget library is installed and referenced in this Visual Basic application. Declare a variable of PhidgetServo type: Dim WithEvents Servo As PhidgetServo We then have to instantiate that servo instance when we load our form: Set Servo = New PhidgetServo Call Servo.Open(True, xxxx) The Servo instance now exists and has a set of member functions which can be accessed using dot notation. One of these member functions is called MotorPosition( n ) and is accessed by placing the dot between the instance of Servo and the member function. Servo.MotorPosition (n) The (n) is an index which represents which of the motors we are controlling at any given time. The servo controller can control up to four motors. The first is powered by the +5 v supplied by the USB cable. The other three are powered by the power supply attached to the device. Each device is independent of the other and can be assigned a degree value between 0 and 180.