MechanicalSystem
Machinery Sensor Driver Control
Control algorithm
ControlSystem
Mechanical System
Engineering realization
• Design of Computer Control System
Hardware: Circuit schematic design + PCB
Software : Algorithm + Programing + Software Simulation
• Question
How to choose a appropriate controller or design a control system
Questions
1. How to choose a controller?
2. Step of designing a control system?
3. How to design a MCU system?
4. How to implement the motion control
of step motor?
Robotic Gecko
AVR microcontroller
Contents
1
2
3
4
Classification and characteristics of
computer control system
AVR fundamental setup
MCU development process
Example : stepper motor motion
control
Classification and characteristics of computer control system
ComputerMCU
ARM、DSP embedded
system
PLC
IPC
Universal PC
Dedicated
embedded
systems
MCU
• AdvantagesTargeted
Small size
Low cost
• DisadvantagesLow reliability
Long development cycle
Principles of choosing a MCU
• Micro control system: Using a self-designed
microcontroller, such as Intelligent instrumentation.
• Normal control system: Choose existing industrial
controller in order to speed up development, such as
PLC.
• Large control system: Choose Industrial PC, and use
high-level language to develop or configure software.
Contents
1
2
3
4
Computer control system
AVR basis
MCU system development
process
Examples: stepper motor control
AVR Microcontroller Basics
2.1 MCU basis;
2.2 Development of MCU;
2.3 Characteristics of AVR;
2.4 ATmega 8 architecture and on-
chip resources;
Typical MCU application system
The development trend of MCU: low power consumption,Wide voltage, high-performance, low cost, ISP or ISP baseddevelop environment.
2.1 MCU basis
Definition of MCU:
CPU, RAM, ROM, timer/counter, and I/O interface
circuit and other major computer components are
integrated on a chip, which is composed of such a chip
microcomputer is called the single chip microcomputer.
• MCU performance indicators:
Clock Speed: The CPU clock frequency CPU
Instruction set : CISC and RISC, the later is more efficiency
Word length: The bits of binary number it processed(8 bits is the mainstream)
MCU comparison of similar prices
CPU AT、STC series 51 MSP430F1 AVR
Clock Speed 2MHz 8MHz 20M Hz
Instruction set CISC RISC RISC
Word length 8 bits 16位 8位
2.1 MCU basis
2.2 Characteristics of AVR
AVR program can be written in parallel, or through ISP,
which can be erased online.
Just a parallel port download cable ISP, the debugged
program can be written into the AVR. So, an ISP
download cable can go through AVR development, the
cost is very low.
ATmega8 architecture
2.3 ATmega8 architecture and on-chip resources
Plastic Dual In-Line Package Thin Quad Flat Pack
2.4 ATmega8 architecture and resources
Contents
1
2
3
4
Classification and characteristics of
computer control system
AVR basis
MCU system development
process
Example: stepper motor control
MCU system development process
MCU application system development is the process of achieving a specific function SCM system, according to the needs of customers or markets,
Need analysis
overall design of system
design of the hardware
in the system
system software design
MCU
system simulation
Program download
1
1
3.1 Need analysis
• Goal: Determine the task the system to complete and its function.
• Product design-work instructions
-- SCM system functions implemented
-- Specifications
• Input and output;
• Function and property;
• Cost;
• Physical size and weight;
• Power consumption.
3.2 Overall design of system
• Design description
• General block diagram
• The overall structural design
• Preparatory for design– Plan design schedule and
organize manpower;
– Prepare place and instrument;
– Develop components’ procurement and external processing program ;
– Budget.
3.3 Design of the hardware in the system
• Selection of the components–MCU Selection;
–Select the peripheral device;
• Circuit Design–Standardization and modular of hardware system;
–Plan and control the system resource;
• Computer-aided design of hardware circuits–Schematic Design;
–PCB diagram design.
• Control system = Scheme selection + modeling and Simulation + Hardware development +
software debug + Joint debugging
3.3 Design of the hardware in the system
Software System Development Tools
Compilation tools: ICC AVR
Simulation tools: AVR STUDIO
Download tools: PROGISP
Software Development
• To develop a MCU software system, it generally go through the following process:
Write code compile Simulation Download
• AVR can use assembly language or C language to programme.
• Atmel offer us a suit of develop tools:– Compiling: ICCAVR
– Simulation: AVR Studio
– Download: PROGISP
Connection
ISP
USB
+12V
220V
USB
Serial
communication
Robotic fish motor control
Contents
1
2
3
4
Classification and characteristics of
computer control system
AVR basis
MCU system development
process
Example: stepper motor control
Experimental Platform
USB转串口线
USB to serial
port cable
MCU ISP download
cable
12V
power
Box
Experimental Platform
AVR Development Board
ZLG728
9
Serial
Communication
12V
Power
input
Power
switch
Nixie tube ISP
Control
button
Potentiom
eter
Step
motor
DC motor
interface
Servo
interface
Step
motor
interface
L298
LM780
5
ATmeg
a8
Motor
Control
Jumper
Reset
LED
PCB diagram
SCH layout
Connection
Power port
Serial port ISP port
• Minimum system:Include ISP, maintain the operation of MCU;
• PMU: For power management, The input voltage is 7.5V~24V(12V);
• RS232communication module: Can undertake serial communication with PC ;
• Keyboard, the analog signal input module: The input control and A/D acquisition experiments;
• LED, Digitron: Common display device;
• Stepper motor module: Control four phase stepper motor
Development board function module
• Input:The AD module; The keyboard module;
• Output:Stepper motor module; LED ;digitron; Steering gear module;
• Input output unit:USART;
Input-output channel
control
systeminput output
I/O
The minimum system wiring diagram
LED1——PC0 LED3——PC2
LED2——PC1 LED4——PC3
LED display
Digitron display
ZLG7289 Digitron
CS_7289
CK_7289
D_7289
CS_7289——PD5
CK_7289——PD6
D_7289 ——PD7
LED and digital display wiring diagram
Serial port communication
This part by PC
This part to the TXD、
RXD of MCU
Max232PC MCU
TXD
RXD
Serial port communication wiring diagram
Keyboard interface module
SW1——PD2(INT0)
SW2——PD3(INT1)
normal state Key
down
Key
up
AD collection module
AD7——ADC7
potentiometer AVRAD7
analog
voltage
0~VCC
digital
quantity
0~1023
Input module wiring diagram
Stepper motor control instance
• Use AVR chip as main control unit ,L298
As the driver chip . Control block diagram
is as follows :
AVR L298Step
Motor
• Displacement: proportional to the input pulse
number strictly
• Rotating speed: proportional to the pulse frequency
•Direction: related to the winding way of electricity
Stepper motor
No. A B C D Dir
1 1 0 0 0 Reverse
Forward
2 1 1 0 0
3 0 1 0 0
4 0 1 1 0
5 0 0 1 0
6 0 0 1 1
7 0 0 0 1
8 1 0 0 1
Four phase eight beats circular distributor
numerical tables as follows
Circular distributor
Stepper motor module
L298 stepper motorIN2
IN3
IN3
IN1
IN1——PB1
IN2——PB3
IN3——PB2
IN4——PB4
Stepper motor layout
• ICCAVR main interface
source file editor window
The Project Manager Window
Compile status window
• Build a new project
• The wizard is used to establish the file, added to the project project
file
wizard
Choose the chip and XTL :
– as follows ,the chip is Atmega64,XTL is 11.059MHz ,External interrupt 4 (rising along the trigger)
• I/Osetting
select the corresponding state according to the need。in the graphic :PB0 output high level;PB1 output low level;PB3 is high resistance 。
Progispfunction:download the program from PC to MCU
• Choose chip ATmega 8
• Set the programming options (Choose the chip erase,
programming FLASH, calibration FLASH )->Load Flash->click automation
①
②
③
④
Let us see how the
Step motor works…
The stepper motor
24BYJ48A
• Stepper motor speed control
Control stepping motor speed is to control pulse frequency or
phase of the cycle。
Two way:
software delay:By calling the delay subroutine method, it
takes up CPU time.
Timer :By setting the TOCNT register.
Stepper motor drive circuit
PB1(OC1A)、PB3(MOSI)、PB2(OC1B)、PB4(MISO)
respectively control A、B、C、D phase。
Jumpers:3---2、6---5、9---8、12---11。
Three sets of control scheme
• Pure MCUprogram control
• Potentiometer and the button control
• upper computer control
Pure MCU control
• Stepper motor speed and direction decide
by the burning process, if you want to
change the speed and direction of step
motor, you can only change in the original
MCU program, burning again.
• Usually the final actual running program is
implemented in this way.
AD sampling circuit and buttons
MCU AD samples analog voltage value to control the
speed of the stepper motor。Two buttons control the direction of stepping motor。
Four phase stepper motor control algorithm
• 1、 Four phase four beat:A->B->C->D->A
• 2、 Four phase double four beat:
AB->BC->CD->DA->AB
• 3、 four phase eight beat:
A-> AB-> B->BC-> C-> CD -> D-> DA->A
Two key points of stepper motor control
• Angular displacement: pulse number
• Speed: pulse frequency
360=
ZNstep angle
60 fSpeedn
ZN (r/min)
Z is the number of teeth on the rotor type, N is the number of beats, f is pulse frequency
What we do now
• 1、 What kind of pulse we need?
• 2、How to generate the pulse ?
– How to produce a certain number of pulse ?
– How to produce the required frequency pulse ?
How to generate pulse signal
• Timer of the MCU --- generate pulse
– Regularly produce beats
– Use PWM function
• Timer generates a certain number of pulse.
change winding current order in Overflow timer interrupt.
• Change the timing - to produce the required frequency pulse
AD sampling circuit and buttons
MCU AD samples analog voltage value to control the
speed of the stepper motor。Two buttons control the direction of stepping motor。
Review our learning :
development board frame
ICC
AVR Studio
AVR AVR JDK sample
functional modules
download softwareProgi
sp
Stepping Motor control exp
eriment
powerMinimum
system
Serial Communi-
cationMotor Module
Digitaldisplay
buttons
LEDAD
sampling
Learning resource
• 1. guidance notes;
• 2. OurAVR Website: www.ouravr.com;
• 3. ATmega8 Datasheet;
• 4. C programming;
MIT Cheetah Robot
Top Related