Вы находитесь на странице: 1из 9

EXPERIMENT 6

SEQUENTIAL CIRCUIT USING PLD


I. OBJECTIVES

a. Students are able to make a sequential circuit by using PLD.

II. SCOPE

A. Theory

In the previous experiment, we have seen that digital circuit can be a


combinational or a sequential circuit. We have known about the use of sequential
circuit like flip-flop, counter and shift register. WinCupl can program a PLD as a
combinational circuit or a sequential circuit.
In general, the programming of sequential circuit is similar with the previous
programming. The difference is in the syntax used. The sequential output in JDEC
is defined in the form of a state.
WinCupl also recognizes some extension used in the variable. But in the GAL
IC, not all the extensions are used.

Figure 6.1

Stepper motor is an electric motor that moves according to the particular steps,
it is triggered by the magnetic field in the coils inside of the motor. The inner part

Digital System Guidance Computer Engineering Laboratory


Experiment 6 Page 1 of 9
of a stepper motor is divided into two parts, rotor and stator. The advantage of this
motor is that it is having an accurate degree of rotation for every steps.

STATOR
STATOR
ROTOR
STATOR
STATOR

Figure 6.2

There are some methods to activate a stepper motor, Half Step and Full Step.
Full Step is a method to move a stepper motor by activating one of the coils inside
the stepper motor. In the practicum class, the stepper motor have red wire for +V,
brown for coil1, orange for coil2, black for coil3, and yellow for coil4. See the
Figure below.

Step Coil 4 Coil 3 Coil 2 Coil 1

a.1 on off off off

a.2 off on off off

a.3 off off on off

a.4 off off off on

Figure 6.3

Half Step is a method to move a stepper motor in such a way, so that the
movement of the motor is smoother. See the Figure below.

Digital System Guidance Computer Engineering Laboratory


Experiment 6 Page 2 of 9
Step Coil 4 Coil 3 Coil 2 Coil 1

a.1 on off off off

b.1 on on off off

a.2 off on off off

b.2 off on on off

a.3 off off on off

b.3 off off on on

a.4 off off off on

b.4 on off off on

Figure 6.4

B. References

1. Floyd., Digital fundamentals, Pearson International,2006, New Jersy.


2. WINCUPL Programmers Reference

Digital System Guidance Computer Engineering Laboratory


Experiment 6 Page 3 of 9
3. A stepper motor explanation: http://en.wikipedia.org/wiki/Stepper_motor
4. A basic theory of using a stepper motor:
http://www.sapiensman.com/step_motor/

III. DEVICES

Wincupl Program
GAL Module
Stepper Motor Module

IV. INSTRUCTION OF LABORATORY

A. Procedure

Type the list of the program in the attachment, then try to make a stepper
motor to move with 2 phase full step!

B. Final Reports requirement for minimum grade

The points below should be explained and developed in the digital system final
reports. State at least 6 conclusions in the end of the final reports.

Stepper motor
DC motor and Stepper motor
Unipolar and Bipolar stepper motor
The methods of moving a stepper motor
The advantages and disadvantages of a stepper motor

GAL
How to use clock in GAL
The function of an OE pin
Make a program to move a stepper motor in halfstep and can be set up its direction
(clockwise/counter-clockwise)!
Make a 4 bit Counter by using a sequential program! (Make sure that the program
is not error while compiling)
Make a 5 bit Shift Register by using a sequential program! (Make sure that the
program is not error while compiling)

Digital System Guidance Computer Engineering Laboratory


Experiment 6 Page 4 of 9
V. ATTACHMENT

o syntax for sequential and condition program:

Table 6.1
SEQUENCE SEQUENCE state_var_list {
SEQUENCED PRESENT state_n0 statements ;
SEQUENCEJK PRESENT state_nn statements ;
SEQUENCERS }
SEQUENCET
The syntax above indicate to a
sequential program, prefix D, JK,
RS, T show the type of the flip-
flop used
Conditional NEXT Statement PRESENT state_n
IF expr NEXT state_n;
IF expr NEXT state_n;
[DEFAULT NEXT state_n;]

Unconditional Synchronous PRESENT state_n


Output Statement NEXT state_n OUT [!]var... OUT [!]var;
Conditional Synchronous Output PRESENT state_n
Statement IF expr NEXT state_n OUT [!]var...OUT [!]
var;
. .
IF expr NEXT state_n OUT [!]var...OUT
[!]var;
[ [DEFAULT] NEXT state_n OUT [!]var;]
Unconditional Asynchronous PRESENT state_n
Output Statement OUT var ... OUT var ;
Conditional Asynchronous Output PRESENT state_n
Statemen IF expr OUT var ... OUT var;
.
.
IF expr OUT var ... OUT var;
DEFAULT OUT var ... OUT var;]

o Extension table

Table 6.2
Description
Extension Side
Used
.AP L Asynchronous preset of flip-flop
.AR L Asynchronous reset of flip-flop
.APMUX L Asynchronous preset multiplexer selection
.ARMUX L Asynchronous reset multiplexer selection
.BYP L Programmable register bypass
.CA L Complement array
.CE L CE input of enabled D-CE type flip-flop
.CK L Programmable clock of flip-flop
.CKMUX L Clock multiplexer selection
.D L D input of D-type flip-flop

Digital System Guidance Computer Engineering Laboratory


Experiment 6 Page 5 of 9
.DFB R D registered feedback path selection
.DQ R Q output of D-type flip-flop
.IMUX L Input multiplexer selection of two pins
.INT R Internal feedback path for registered macrocell
.IO R Pin feedback path selection
.IOAR L Asynchronous reset for pin feedback register
.IOAP L Asynchronous preset for pin feedback register
.IOCK L Clock for pin feedback register
.IOD R Pin feedback path through D register
.IOL R Pin feedback path through latch
.IOSP L Synchronous preset for pin feedback register
.IOSR L Synchronous reset for pin feedback register
.J L J input of JK-type output flip-flop
.K L K input of JK-type output flip-flop
.L L D input of transparent latch
.LE L Programmable latch enable
.LEMUX L Latch enable multiplexer selection
.LFB R Latched feedback path selection
.LQ R Q output of transparent input latch
.OBS L Programmable observability of buried nodes
.OE L Programmable output enable
.OEMUX L Tri-state multiplexer selection
.PR L Programmable preload
.R L R input of SR-type output flip-flop
.S L S input of SR-type output flip-flop
.SP L Synchronous preset of flip-flop
.SR L Synchronous reset of flip-flop
.T L T input of toggle output flip-flop
.TEC L Technology-dependent fuse selection
.TFB R T registered feedback path selection
.T1 L T1 input of 2-T flip-flop
.T2 L T2 input of 2-T flip-flop

o Examples
An example of a program using the extension:
Name Shift Reg ;
PartNo 01 ;
Date 1/30/08 ;
Revision 01 ;
Designer Engineer ;
Company Atmel ;
Assembly None ;
Location ;
Device G16V8 ;
/* *************** INPUT PINS *********************/
PIN 1 = Clk ; /*Clock */
PIN 2 = Din ; /*Data input */
PIN 3 = ER ; /*Enable Rotate */
PIN 11 = EA ; /*Enable Output */
PIN 4 = !RST ; /*Reset*/

Digital System Guidance Computer Engineering Laboratory


Experiment 6 Page 6 of 9
/* *************** OUTPUT PINS *********************/
PIN 19 = Q0 ; /* Output 0 */
PIN 18 = Q1 ; /* Output 1 */
PIN 17 = Q2 ; /* Output 2 */
PIN 16 = Q3 ; /* Output 3 */

Q0.D = (Din&!ER)# (Q3&ER&RST); /* Show that the D part in D flip-flop has this equation */
Q1.D = Q0&RST ; /* */
Q2.D = Q1&RST ; /* */
Q3.D = Q2&RST ; /* */

An example of a program to control a stepper motor:


Name stepper ;
PartNo 00 ;
Date 01/30/2008 ;
Revision 01 ;
Designer Engineer ;
Company Atmel ;
Assembly None ;
Location ;
Device g16v8 ;

/**********************************************************************/
/*This program is used to control a stepper motor */
/* PIN configuration used: */
/* PIN 12 = P1 in the Stepper Motor */
/* PIN 13 = P2 in the Stepper Motor */
/* PIN 14 = P3 in the Stepper Motor */
/* PIN 15 = P4 in the Stepper Motor */
/*Dont forget to see the cable colour configuration in the stepper motor */
/* the numbers in the brackets on the right side are for the notation, dont put in the program */

/*The input pins : */


PIN 1 = CLK; (1)
PIN 2 = RST;

/*The output pins : */


PIN [12..15] = [Q3..0]; (2)

field count = [Q3..0]; (3)


$define S0 'b'0000
$define S1 'b'0001
$define S2 'b'0010
$define S3 'b'0100
$define S4 'b'1000
field mode = RST;
go = mode:1;
stop = mode:0;

sequenced count { (4)

present S0 if go next S1;


if stop next S0;
present S1 if go next S2;
if stop next S0;
present S2 if go next S3;
if stop next S0;

Digital System Guidance Computer Engineering Laboratory


Experiment 6 Page 7 of 9
present S3 if go next S4;
if stop next S0;
present S4 if go next S1;
if stop next S0;
}

Notation:
1. Part (1) and (2) are used to declare the name of the input and output pins as a name of
a variable.
2. Part (3) is a declaration of a more complex variable name.
field count = [Q3..0];
o To combine varibale name Q0,Q1,Q2,Q3 to become a new variable name count
$define S0 'b'0000
o $define is a Preprocessor Command to define number, symbol or character to
become a new name. In this case S0 is defined as b0000 after being compiled.
field mode = RST;
o it is used to classify the variable name RST with the name mode (can be more than
one variable by using a bracket, for example: field mode = [clr,dir] )
go = mode:0;
o go is a new variable name containing mode 0. mode:0 means RST = 0
stop = mode:1;
o stop is a new variable name containing mode 1. mode:1 means RST = 1
o if you are using 2 variables you may use wait = mode:2 (the first variable is 1 and
the second variable is 0) or back = mode:3 (both of the variables are 1)

3. Part (4) is the main program of the counter.


o Sequenced count {} means count variable that has been declared will become
sequential by using D flip-flop
present S0 if go next S1;
if stop next S0;
present S1 if go next S2;
if stop next S0;
present S2 if go next S3;
if stop next S0;
present S3 if go next S4;
if stop next S0;
present S4 if go next S1;
if stop next S0;

- The present state is S0 (b0000), if there is mode go, then the next state is S1
(b0001). If the mode is stop then the next state is S0 (b0000). The syntax out
is a syntax used to directly give the output on the particular pin.

- present S0 if go next S1 also can be written in present b0000 if go


next b0001, but the second expression is not as effective as the first
expression. Therefore we need a preprocessor $define, so that the expression is
simpler and the program is easier to be understood.

In WinCUPL we can create a function, like as we do in the other programming


language. The syntax used to create a function in WinCUPL is:

FUNCTION name ([parameter0,....,parametern])


{ body }

Digital System Guidance Computer Engineering Laboratory


Experiment 6 Page 8 of 9
Notation:
Name is the name of the function
Parameter is the value of the parameter
Body is the program (it can be logical combination, truth table, syntax etc) that will be
executed when FUNCTION is called.

Here is an example of using a function in WinCUPL to move a stepper motor:

Name SisDig ;
PartNo 00 ;
Date 2008.01.28. ;
Revision 01 ;
Designer Engineer ;
Company Atmel ;
Assembly None ;
Location ;
Device G16v8 ;

function shift (reset){ /*function declaration */


$define s0 'b'0000
$define s1 'b'0001
$define s2 'b'0010
$define s3 'b'0100
$define s4 'b'1000

field mode = reset;


go = mode:1;
stop = mode:0;
sequenced count {
present s0 if go next s1;
if stop next s0;
present s1 if go next s2;
if stop next s0;
present s2 if go next s3;
if stop next s0;
present s3 if go next s4;
if stop next s0;
present s4 if go next s1;
if stop next s0;
}
}
pin 1 = clk;
pin 2 = reset;
pin [12..15] = [q3..0];
field count = [q3..0];
shift (reset); /* calling a function */

Digital System Guidance Computer Engineering Laboratory


Experiment 6 Page 9 of 9

Вам также может понравиться