Escolar Documentos
Profissional Documentos
Cultura Documentos
On microcontrollers already discussed in previous issues zhurnala1.
Modern microcontrollers - a well-designed device, to significantly simplify the construction of
circuits. Very often, in their composition, they have built-in comparators, ADC, the network
module or USART radio channel RF.
For electronics enthusiasts and professionals who do not specialize in
microprocessor technology, the stumbling block could be the need to write
program, without which the microcontroller is "deaf and dumb." If the scheme is ready
device and boot file, the problem is simplified, but finished the scheme does not always
satisfied in full, and some residue of helplessness, stiffness remains.
By programming means writing a program code
assembler or high level language: C, Basic, Pascal ... But is this true?
For those familiar with electronics, a further order of the work should be
sign: there is a chip that should properly bind a network of wires in
a whole, small difficulties arise only when necessary
chips have to go to the documentation. In this sense FlowCode equipped
tip, and there are examples in the folder «Examples». Very useful to look into this
folder.
Problem described above can be brought to the test on the breadboard,
where the microcontroller will control the LED, soldered to, say,
zero Port pin A (just in case, through a resistor), and let the LED
flashes once per second.
On the toolbar on the left, where the elements of the command is
button with the letter "O" from the word output (output). If you hover your mouse over the
this button, the lights and tip, Output. Hooking command (press
the left mouse button when the cursor is an icon and hold
keys, move the cursor in the working field circuit), drag it to the lines of communication between
ovals Begin (top) and End (end). The cursor looks like
stylized icon that appears on the left and the arrow-pointer.
In passing, we note that user interface is standard for the operating system, Windows, and all
operations very similar to
in other programs.
4c !
c !"
"#!$! % &
#'! ("&")(%%#!!" !
c(!
$(%%#!
$!*$#"") "#!
#"
##)#+
,c"#!
! !(!!" !
! !
(#)%!-"%#
!#!
)#
!
#
#)##$! ""%!!#"
)
#!
(!%(%
#!#"!
( #
!#)#c!%!!!(
)"#!##! !.!
($)
!
( "#)#(!)
#(
(
)
# " +4,#(
##)#(
(#
!
!
#)#4%##!!" !%$#)#(
#)
Fig. 6. Program in FlowCode with the cycle
The list of teams (from left to right in the figure, top-down, the
run):
Input (input), Output (output), Delay (pause), Decision (branch)
Connection Point (two points of connection), Loop (loop), Macro (macro)
Component Macro (macro component is added to the program), Calculation
(Computing), String Manipulation (string operations), Interrupt
(Interruption), C Code (the block of code in C language), Comment (comment).
The second instrument panel for additional external components.
Fig. 12. The toolbar commands
Fig. 13. The toolbox of additional items
! !1"3! %#&:)" !#
c%!=@"#(!
1 53$%
"!
#"
"#!#"%)+ ("")!
,c
!
("!"*
-c(
%
Fig. 22. The line of LEDs
The first button on the main panel LEDs (O) - to access the properties through
pull-down menu where you can select Component Connections ... and replace
bind to the port.
494!
!
* !5"#$)($(:
"#-"!
%)#!#$("!$!
!
1 5A#!3(#!#$%!!
%!" #
"#"$
()("
"+!
!
-,!(##$!!""!
!
:%"##$!-$
"#!
)%% ! ##
#4%
#(6!
:
#"
("! )
!4%
5"#$)).!!###(
%))
:
%!!(
4%5" !"
c!#"#
(
!
!!%"
!=!=
%#! 5"#)<"#"!#!5"("#!%
"+%!=6,!"()(!"
#+#,! 5"#)%!
"
-%("
#/+@"#,LED at pin A7 to indicate the
process of changing frequency. Couple
Connection Point - this in a more familiar shape, the pair formed by the label and
operator Goto (go to label).
Fig. 31. Possible solution to stop the program to poll the buttons
And finally, you can go back to yet another solution to the problem
"Getting into an infinite loop", the variant with the interruption. For this is the program
element Interrupt. Assigning variables "toga" and «less» introduce into the
Interrupt handling routine.
)"
!
"
+"
,(%#
"
4H!
"
4%
"
%(
!
((!
%"
!"$
%!!% """(!"
4H7"
""
"
##$!"%!
(
(!$
Fig. 35. The work program with the interruption
If this interrupt (RBO / INT) was the only available mechanism
interruption, and even then would be to use: instead of two buttons
There will be three, two for the change in frequency, the third button, the changes to take
force. But ...
List of staff interruptions, the proposed program FlowCode, continues
interruption in RB Port Change (change of state interrupt port B). In
description of the microcontroller PIC16F628A can find that the change of state
inputs RB4-RB7 can trigger an interrupt, if enabled. Selection
inputs to connect to the buttons controlling the frequency is not fundamental
nature can be easily replaced input RBO on RB4, a RB1 for RB5. Not difficult
change the properties of the program element Interrupt.
Sub-Program "of the multivibrator remains the same. And in sub-
Interrupt added polls keys on the inputs B4 and B5.
If necessary, the work can make the above-described "antidrebezgovye"
appendix. But in general, we can say that in different situations better
use the methods of work, which give the desired effect, better job
device and well you know and understand, when you quite clearly
imagine why choose one or the other option. Similar considerations
You are guided, and in selecting the type and model of the microcontroller.
!#
4!
"
"!%%
Fig. 36. A program that uses interrupts to change the status of the port in
Fig. 37. Sub-interrupt
In addition to changing the oscillator frequency, we intend to reflect this change
on the seven-segment display. Add it to the program, after removing
LEDs.
It's enough for the desired bit port, select them in the box Bit:
select Unconnected (not attached). Microcontroller PIC16F628A has two
I / O ports of eight outputs each. Such amount to the first
opinion is more than enough, but as the complexity of the scheme was originally
distributed according to the output port are mixed, some of these conclusions have
used internally, quartz is connected to quite definite conclusions
for networking, too, are predetermined conclusions. When in doubt, as
affect binding of the findings when the program to byte-rulers LEDs
transitions or switches, unnecessary conclusions can be immediately disabled
47'!!
!%#!
cC
##
!:
)!
%
#$= !"="!
"
"
)(
#! ""
"c
c !
! !#!"
!
%!!#!
#
#!% !
("#!!
#"%$%!
#
%!
)! 5"#) ()(! 8F$46(!
!
(% #"#
5"#) (!"%#! 5"#) 87+#
"
#)
")
,
###"".#
1#3c! "!!#(=% ")=
:%!D! #
-" !)"(!%""( #"( )"D=
!=%!
"("!4%(
!)"
4(""
4!:(! !<(
"
."!
:*$
)
$:!
!
!#
$$
#)
##"%$? c.!#" " ! "#
#
."!!#
#
!
#
!#("(!##
)#(
(#
/ #(!))
#c!
!)%!"(%!#"
# ( #"#%!#"
-":#? cc!%$ #%"
B47;*-
# " H
#
H+',!#
5"")
!#
=J=
!
"%%
!#!#( %
!) !
"
B47F
"%%(
%!%#!#"
)"
!G"(!
"!!*
-
Fig. 50. Verification of the second module
Fig. 53. Check the operation of the two controllers in the Proteus
So "talk" two of the microcontroller.
Will not disturb them.
Fig 27
Next start from page