Figure 4. Frame of PWM signals.
control an R/C vehicle. As such, the sequence of operation
demands that two programs be written.
The first program is code that runs on Windows-based
PCs and is written in Visual Basic 6. Called VB6, this
event-driven programming language from Microsoft is quite
popular among PC hobbyists and roboticists because it is
easy to learn and enables you to develop Windows-based
programs rather quickly.
For this project, a form was created with text boxes to
display the value being sent to each channel. Arrows were
placed next to each text box to change the value being
sent to the channels. The bulk of the code is executed
inside a timer, which was set to execute the code every 10
A form with four text boxes and four corresponding
horizontal scroll bars was created. Figure 8A shows a screenshot.
Figure 8B shows the form after formatting to better describe
the text boxes. Maximum and minimum values for the scroll
bars must be set to generate the correct eight-bit number
to be sent to the PIC16F84. These values are 255 and 0,
respectively. Lastly, the form includes a timer with an interval
‘Send ch1 value
Call PortOut((OutPutPort%), ch1)
Call PortOut((OutPutPort% + 2), strobelo)
For i = 1 To delay: Next i
Call PortOut((OutPutPort% + 2), strobehi)
For i = 1 To delay: Next I
Figure 5. PIC16F84 pinout.
76 SERVO 07.2004
set to 10 milliseconds.
A module must be added to the project to define global
variables and functions. The code that will be included in the
module is given in Listing 1. Of note are functions called
PortOut and PortIn. These functions utilize a file named
io.dll. This DLL is required to write to the ports for
Windows 95/98/NT/2000/XP and is freely available from
www.geekhideout.com/iodll.shtml When you download
this file, you must place it in the same directory as the Visual
Basic code you are creating.
The parallel port address was assumed to be standard at
0x378 hexadecimal (888 decimal). By writing a byte to the
address 888, data is sent across D0-D7 of the PC’s parallel
port. The status lines and control bits are accessed using
OutPutPort + 1 (889 decimal) and OutPutPort + 2
(890 decimal), respectively.
Constants strobehi and strobelo are assigned
addresses 0x0D hexadecimal ( 14 decimal) and 0x0C
hexadecimal ( 13 decimal), respectively. 0x0D corresponds to
1110 binary, while 0x0C hexadecimal represents 1101. By
toggling between strobehi and strobelo, bit 0
changes, thus toggling the STROBE line (parallel port pin 1).
The bulk of the code is located on the form. The code is
executed every time the timer counts to 10 milliseconds. The
Figure 6. PC to R/C circuit diagram.