Interfacing Actuators in Embedded Systems: Mohamed Hussain K 410420002 PHD Scholar Ice Dept Nit Trichy
Interfacing Actuators in Embedded Systems: Mohamed Hussain K 410420002 PHD Scholar Ice Dept Nit Trichy
ACTUATORS IN
EMBEDDED SYSTEMS
MOHAMED HUSSAIN K
410420002
PhD SCHOLAR ICE DEPT
NIT TRICHY
Interface
• Relays, solenoids, and DC motors are grouped together because their
electrical interfaces are similar.
• One can add speakers to this group if the sound is generated with a
square wave. In each case, there is a coil, and the computer must
drive (or not drive) current through the coil. To interface a coil, we
consider voltage, current, and inductance.
• We need a power supply at the desired voltage requirement of the
coil.
Interface
• When interfacing a coil to the microcontroller, we
use information in the Table to select an interface
device capable of sinking the current necessary to
activate the coil.
TIP120 circuit
Interface
Electromagnetic and Solid State Relays
• A relay is a device that responds 1. The classic general purpose
to a small current or voltage relay has an EM coil and can
change by activating switches or switch AC power
other devices in an electric 2. The reed relay has an EM coil
circuit. and can switch low level DC
• The input signal determines electronic signals
whether the output switch is 3. The solid state relay (SSR) has
open or closed. an input triggered
semiconductor power switch
SSR
Solenoids
• Solenoids are used in discrete mechanical
control situations such as door locks,
automatic disk/tape ejectors, and
liquid/gas flow control valves (on/off
type).
• Much like an EM relay, there is a frame
that remains motionless, and an armature
that moves in a discrete fashion (on/off).
• A solenoid has an electromagnet.
• When current flows through the coil, a
magnetic force is created causing a
discrete motion of the armature.
Pulse-width modulation
• The basic idea of PWM is to
create a digital output wave of
fixed frequency, but allow the
microcontroller to vary its duty
cycle.
• Figure shows various waveforms
that are high for H cycles and low
for L cycles.
• The duty cycle is defined as the
fraction of time the signal is high: Pulse width modulation used to vary power delivered to a DC motor.
Stepper motors
• Stepper motors are used in
applications where precise
positioning is more important
than high RPM, high torque, or
high efficiency.
• Stepper motors are very popular
for microcontroller-based
embedded systems because of
their inherent digital interface.
struct State{
uint8_t Out; const struct State *Next; uint32_t Delay; }; typedef const struct State StateType;
typedef StateType *StatePtr; StateType fsm[4]={
{10,&fsm[1],5}, { 9,&fsm[2],5}, { 5,&fsm[3],5}, { 6,&fsm[0],5}
}; const struct State *Pt; // Current State #define STEPPER (*((volatile uint32_t *)0x4000703C))
int main(void){
PLL_Init(); // Program for phase locked loop
SysTick_Init(); // Program for time delay
SYSCTL_RCGCGPIO_R |= 0x08; // 1) port D clock enabled Pt = &fsm[0]; // 2) no need to unlock
PD3-0
GPIO_PORTD_AMSEL_R &= ~0x0F; // 3) disable analog function GPIO_PORTD_PCTL_R &=
~0x0000FFFF; // 4) GPIO
GPIO_PORTD_DIR_R |= 0x0F; // 5) make PD3-0 out GPIO_PORTD_AFSEL_R &= ~0x0F;// 6)
disable alt func on PD3-0
GPIO_PORTD_DR8R_R |= 0x0F; // enable 8 mA drive on PD3-0
GPIO_PORTD_DEN_R |= 0x0F; // 7) enable digital I/O on PD3-0
while(1){
STEPPER = Pt->Out; // step motor SysTick_Wait10ms(Pt->Delay); Pt = Pt->Next; // circular
linked list }
}
Stepper motor controller Program.
#define SYSDIV2 4 void SysTick_Init(void){
void PLL_Init(void){ NVIC_ST_CTRL_R = 0; // 1) disable SysTick during setup
// 0) Use RCC2 NVIC_ST_RELOAD_R = 0x00FFFFFF;
SYSCTL_RCC2_R |= 0x80000000; // USERCC2
// 2) maximum reload value NVIC_ST_CURRENT_R = 0; // 3)
// 1) bypass PLL while initializing any write to current clears it
SYSCTL_RCC2_R |= 0x00000800; // BYPASS2, PLL bypass // 2) select the
crystal value and NVIC_ST_CTRL_R = 0x00000005; // 4) enable SysTick with
oscillator source SYSCTL_RCC_R = (SYSCTL_RCC_R & ~0x000007C0) // core clock }
clear bits 10-6 // The delay parameter is in units of the 80 MHz core clock.
+ 0x00000540; // 10101, configure for 16 MHz crystal SYSCTL_RCC2_R &= (12.5 ns) void SysTick_Wait(uint32_t
~0x00000070; //
delay){
configure for main oscillator source // 3) activate PLL by clearing PWRDN
SYSCTL_RCC2_R &= ~0x00002000; NVIC_ST_RELOAD_R = delay-1; // number of counts to wait
NVIC_ST_CURRENT_R = 0; // any
// 4) set the desired system divider
SYSCTL_RCC2_R |= 0x40000000; // use 400 MHz PLL value written to CURRENT clears
SYSCTL_RCC2_R = (SYSCTL_RCC2_R&~0x1FC00000)+(SYSDIV2<<22); // 80 while((NVIC_ST_CTRL_R&0x00010000)==0){ // wait for count
MHz // 5) wait flag }
for the PLL to lock by polling PLLLRIS } // 10000us equals 10ms void SysTick_Wait10ms(uint32_t
while((SYSCTL_RIS_R&0x00000040)==0){}; // wait for PLLRIS bit // 6) delay){
enable use of PLL by
clearing BYPASS uint32_t i; for(i=0; i<delay; i++){
SYSCTL_RCC2_R &= ~0x00000800; SysTick_Wait(800000); // wait 10ms }
} }