You are on page 1of 5

Design by U.

Kischel

R/C Analyser
a digital tachograph for R/C model cars

This R/C analyser measures and stores the speed of


an R/C model car directly in the car. It is aimed at
R/C model car builders who want to know how fast
their models can go ‘on the road’.

96 elektor electronics - 7-8/2004


Features
– Supply voltage 5–8 V – PIC microcontroller – Measures, stores and outputs
data
– Connectors for all external – Contrast adjustment for dis-
leads play – Three rotational sensor options
(IR and magnetic)
– Jumper-selectable operating – RS232 interface
modes – All control logic on the
– Graphic data presentation
analyser board
– Simple hardware construction – Connection for external push-
using standard leaded compo- button
nents (Conrad)

The R/C analyser measures the speed obtained as a ‘by-product’. pinion, using a different motor, or
of a model vehicle. The speed is meas- The rate at which the main gear- using a different gearbox, in order to
ured directly in the R/C vehicle, rather wheel is spinning is continually optimise the configuration of the R/C
than being computed from the num- measured using a rotational speed model and allow the motor to run in
ber of laps and elapsed time. This sensor. This continual measurement its optimum speed range. This gives
means that the speed, and in particu- also allows a wide variety of other ambitious model car racers a real
lar the top speed, can be determined factors to be tested and analysed, advantage.
for individual curves and straight- such as the effect of varying the The speed is measured and
aways. The average lap speed is also sizes of the main gearwheel or motor stored once a second. The current

+5V
C5
1µ IC2
Hall-sensor LP2950CZ-5.0
R1 D1 +5V
16V
H1 2
10k

K1 K1
1 V+ 16 1N4148
C3 C1+ K5
1 C1 C2
6 3 IC3 4...8VDC
1µ C1–
16V 1µ 1µ
H601 2 14
T1OUT T1IN
11
16V 16V
7 7 10
T2OUT T2IN
3 13 12
R1IN R1OUT
8 8 9
R2IN R2OUT
Optical reflective sensor 4 4
C4 C2+
9
R1 R2 MAX232
5 1µ 5 15
C2–
10k

150... K1 16V V-
270Ω
6
SUB D9 C6
IC1
1 3 DISPLAY 2 x 16

+5V 16V
VDD
VSS
R/W

VO
RS
D7
D6
D5
D4
D3
D2
D1
D0
A
K

2 4 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
R1
CNY70 +5V
14
10k

K2 K3
Optical interrupt sensor K4 4 13
MCLR RB7
IC1 12
R1 R2 RB6
3 11
T0CK/RA4 RB5
270Ω

10k

K1 10
RB4
17 PIC16F627 9
RA0 RB3
18 8
1 IC1 3 RA1 RB2
JP1 JP2 1 7
RA2 RB1
2 6
R RS RA3 RB0
M D
OSC1 OSC2
2 4
16 15 5
S1 X1
CNY37

4MHz
JP1: R = READ OUT
M = MEASURE

JP2: RS = RS232 P1
D = DISPLAY
10k

030178 - 11

Figure 1. Circuit diagram of the R/C analyser, with three different types of sensors.

7-8/2004 - elektor electronics 97


Table 1. Operating modes and jumper settings
Measuring Readout via display Readout via RS232
Connect K5 to the motor battery or an unused receiver channel (use only the + and – leads)
Connect K4 to the sensor Connect K2 to the display Connect K1 to the RS232 port of the PC
Set JP1 to ‘M’ Set JP1 to ‘R’ Set JP1 to ‘R’
Leave JP2 open Set JP2 to ‘D’ Set JP2 to ‘RS’
Open Excel file rclogex3.xls and press the
Start button. The program will sit in an
– –
endless loop waiting for data (press ESC
to abort).
Press S1
The first of 120 measurements will be
The measured values are shown sequen- The measured values are read. After all of
made after the delay expires. The total
tially on the display in the form of the the data have been read (approx. 20 s),
measurement time is 60 seconds with an
measurement number (0–59 or 0–119) the message ‘Done’ will be displayed.
0,5-s window or 120 seconds with a 1-s
and associated measured value (rps). Click on OK to acknowledge.
window.

The file RSAPI.DLL, which contains the


Start a new measurement session by again function library for driving the PC serial
Start a new readout by pressing the but-
pressing the button (the previous meas- interface, must be first copied to the
ton again (once or twice).
urements will be erased) Windows system directory to allow the
data to be displayed.

version of the software allows up to to the microcontroller to allow the optical sensor using reflected light,
120 values to be measured, stored various functions and settings to be or an optical gate sensor.
and then read out after all the laps configured. If an optical gate sensor is used,
have been run. This permits a total The microcontroller can communi- a small hole must be drilled in the
driving time of two minutes to be cate with a PC via an RS232 level main gearwheel of the R/C model to
analysed. In the future, an additional converter. Only the TxD and RxD allow the IR light beam of the sensor
EEPROM will be fitted to the circuit lines are used, so there is no hard- to pass through once per revolution.
board to achieve a measurement ware handshaking. RxD is included The optical gate sensor requires the
time that is limited only by the for future enhancements. A low-drop most space of the three options. The
capacity of the motor battery (which voltage regulator with a voltage drop distance between the arms of the
means approximately 8 to 10 min- of only 0.5 V ensures reliable circuit gate must be adjusted to match the
utes). The predefined measurement operation from a battery power thickness of the main gearwheel.
interval (gate time for counting source. If a reflected-light optical sensor
pulses) can be configured using a Reset pushbutton S1 is used to is used, the main gearwheel must
software parameter. start a measurement session. Trim- have a small reflective spot (consist-
pot P1 allows the contrast of the ing of a piece of glued-on aluminium
display to be continuously foil or white enamel). The distance
Analyser system adjusted. Pin 5 (R/W) of the display between the reflected-light sensor
The R/C analyser system consists of is connected directly to ground, and the reflecting surface can eas-
the analyser board, a rotational since the software does not read ily be as much as 15 mm without
speed sensor (selected from three any data from the display. All con- interfering with the operation of the
options), a display module for view- nections to the power source, rota- sensor.
ing the data at trackside and an tional speed sensor, display, exter- If a Hall sensor is used, a small
RS232 interface for connection to a nal pushbutton and RS232 link are magnet is glued to the main gear-
PC. made using connectors. wheel to induce a pulse for each rev-
The heart (or more precisely, the The system is rounded out by a olution of the gearwheel. The gap
brain) of the analyser system shown program written in Visual Basic, between the sensor and the magnet
in Figure 1 consists of a PIC16F627 which allows the data to be dis- should not exceed 5 mm.
microcontroller with 1 KB of Flash played and analysed in graphic form.
memory and an integrated 128-byte The R/C analyser system is an ‘open’
EEPROM for storing the measured system, so future modifications and Reading
values. The microcontroller, which new features can easily be inte- and displaying
comes in an 18-pin DIL package, grated into the hardware and soft-
measured values
should be fitted in a socket so its ware.
software can be updated in the Three different types of sensors The sensors operate using three dif-
future. It is clocked at 4 MHz by a can be connected to K4: a Hall sen- ferent principles, but they all yield
three-lead ceramic resonator. Two sor (which responds to a magnetic the same result. The IR light beam
jumpers (JP1 and JP2) are connected field, in this case a rotating field), an interrupted or reflected by the main

98 elektor electronics - 7-8/2004


COMPONENTS LIST
Resistors: IC2 = LP2950CZ-5.0 K4 = 3-way pinheader
R1 = 10kΩ IC3 = MAX232CP S1 = pushbutton, 1 make contact (Conrad
P1 = 10kΩ preset Electronics # 704849-8B)
Miscellaneous: X1 = 4MHz ceramic resonator with 3 pins
Capacitors: JP1,JP2 = 3-way SIL pinheader with and internal capacitors.
C1-C6 = 1µF 16V radial jumper PCB, available from The PCBShop
K1 = 9-way sub-D socket (female), angled
Semiconductors: pins, PCB mount
D1 = 1N4148 K2 = 14-way SIL pinheader
IC1 = PIC16F627-4/CP, programmed, K3 = LCD, 2 x 16 characters with
order code 030178-41 flatcable and 14-way IDC connector

C5
+ D1
H1

S1 - K1
C3

ROTKELE )C(
1-871030
JP2 JP1 K4 K5 C1 C2

IC2 IC3
X1 IC1 C4

R1 C6
H3

K2
Figure 2. The printed circuit board is
H2

compact, despite being single sided


1 030178-1 P1
and using leaded components.

gearwheel, or the magnetic field in started using S1, there is ten-second number, measured value, and num-
the case of the Hall sensor, causes delay programmed into the software ber of revolutions per second (rps) of
the sensor to generate a rectangular (this value can be easily modified) to the main gearwheel are displayed.
pulse waveform that is applied to allow the driver to take his or her The speed can be obtained by a sim-
the microcontroller counter input position at the controls or concen- ple conversion. In a planned future
(RA4). trate on the start. During this delay, version of the software, the speed
This Schmitt-trigger input feeds the values previously stored in the will be shown directly in km/h. The
the pulses to counter TMR0, which internal EEPROM of the PIC are revised version of the software will
counts the falling edges of the pulses erased. allow the conversion factor (distance
and writes the number of pulses per Pushbutton S1 not only starts a travelled per revolution of the main
time unit to the appropriate register, measurement session, it also starts gearwheel) to be set using a config-
as well as to the internal EEPROM data readout and output via the LCD uration parameter.
for long-term storage. The time win- or RS232 interface if JP1 and JP2 are The program for reading the data
dow (1/20, 1/10, 1/2 or 1 s), and with suitably configured (see Table 1). via the serial interface and display-
it the number of possible measure- The measurement data are dis- ing it on a PC is written in Visual
ments, can be configured as desired played using a two-line LCD module Basic for Excel. A simple user inter-
using the software. with 16 characters per line. For each face allows suitable parameters to
When a measurement session is measurement, the measurement be selected and shows the car speed
and motor speed in separate charts.
This is ideal for tasks such as inves-
tigating how different combinations
of pinion size and main gearwheel
size affect the speed of the motor.

Small circuit board


Although the circuit board for the
analyser must be fitted in the R/C
car, which means that every square
centimetre counts, we managed to
come up with a satisfactory solution
with a single-sided circuit board
using only ‘normal’ leaded compo-
nents (Figure 2). This spares you the
annoyance of working with SMDs, so
populating the board is dead easy.
There are two wire bridges, and as
previously mentioned, the microcon-

7-8/2004 - elektor electronics 99


Downloads, planned enhancements, and unplanned ideas
The software for this project is www.georgeii.de/analyzer/ana- – Illuminating the brake lights
available for download from the lyzer.htm. The latest version of by suitable manipulation of the
Elektor Electronics website under the software, including future joystick
number 030178-11, and the cir- modifications, enhancements
– Data transfer via ISM radio
cuit board layout can also be and new ideas, can always be
link
downloaded under number found at this site.
030178-1. A pre-programmed – Temperature sensors
– Storing more than 1000 meas-
version of the microcontroller – Reading battery data (e.g. dis-
urements using an external
can be obtained from Readers charge curve)
EEPROM
Services under order number
030178-41. Bare printed circuit – Starting a measurement ses-
boards are also available from sion using the R/C remote con- RSAPI.DLL is available from the
the PCB Shop (see the Elektor trol unit website of B. Kainka:
Electronics website). – Using the analyser as a switch- http://home.t-online.de/home/
The author has a website dedi- ing module for additional func- B.Kainka/rsapidll.zip
cated to the R/C analyser at tions

troller should be fitted in a socket. If the settings of the two jumpers, and values do not have to be first con-
space is tight, you can use a pin deletes the old measurement values verted, but can instead be entered
header instead of the sub-D socket, from the internal EEPROM. directly into a spreadsheet. The DLL
along with a suitable adapter. file must be copied to the Windows
system directory in the PC.
Driving
Software the serial interface The appropriate functions and
The entire intelligence of the R/C procedures (subroutines) of
analyser system is contained in an The RSAPI.DLL function library RSAPI.DLL are declared in a macro in
assembler program. The individual allows devices to be driven via the the Excel document rclogex3.xls. This
functions, which are programmed as serial interface of the PC. It is typi- informs Basic that it has to use new
separate modules for ease of under- cally used for measurement and con- external functions. These declara-
standing, are called from the main trol applications. Device control is tions are located at the beginning of
routine via jumps. Once each module implemented using macros written the VB module, followed by the rou-
has finished its job, it makes an in VB (Visual BASIC) for standard MS tine for reading the measured values.
orderly return to the main routine. Office programs, such as Word or The interface is initialised and
The main routine initialises the Excel. A particular advantage of this opened using the following configu-
inputs and outputs of the PIC, reads is that the transferred measurement ration parameters: 2400 baud, no
parity bit, 8 data bits and 1 stop bit.
The Excel worksheet rclogger is then
opened and column B, which con-
tains the values from the previous
session, is erased. The macro then
waits for new values. The program
remains in an endless loop (which
can be aborted by pressing the Esc
key) until the pushbutton is pressed
on the R/C analyser to start reading
out the measured values.
When the button is pressed, the
measured values are read line by line
using the function READBYTE. After
the data have been transferred, the
interface is closed using CLOSECOM
and a message dialogue is dis-
played. The data are then displayed
in an easily understood form, as
shown in Figure 3.
(030178-1)

Figure 3. The parameters and measured values are displayed using an Excel
worksheet.

100 elektor electronics - 7-8/2004

You might also like