Using the TS 2068 With an Exercycle Machine

See all articles from Sinc-Link v4 n3
Author(s): Fred Schakel
Publication: Sinc-Link
Pub Details: Sinc-Link v4 n3 (Volume 4, Issue 3)
Date: May/June 1986
Pages: 8-9

The object of the whole experiment was to play a game on a computer (2068 or ZX81) and exercise at the same time.(I am in need of both!!) By combining an exercise bicycle, a joystick, and a 2068 with a special program, I proved that this is very possible.

My exercise bike already had a magnetic sensor on it, so I wired it in parallel with the FIRE button on my cursor joystick. The program displays a crude map of the subdivision that I live in, with a bicycle at my home, and several places of interest labelled as follows:

CTC --- Canadian Tire
MALL -- Shopping Mall
MOM --- Mother's place
A & D - Angie and Dwight's place
PK ---- Park
CLN --- Cleaners
MAC --- Mac's Milk store
H ----- My home
The blue area is the river

A machine code routine senses the bike speed through the FIRE button, by reading the bit on the zero key. This is much quicker than with BASIC. Even if the bike is stopped with the magnet on the switch, it recognises that the wheel is not turning. One may think that this should give a repeating “zero” key press, but this is so only in BASIC.

Getting away from the technicalities, the pink locations on the map represent goals to reach. When you reach one of them, points are awarded. It is also capable of letting you know when you go off the road or in the river. Steering is by left and right on the joystick, and you need to be moving in order to turn.

My plan is to involve obstacles such as pedestrians, trains, cars, puddles, etc. On the hardware end of it, I want to use an I/O port that will drive a motor which increases the tension on the bike. This would simulate going up and down hills.

I have included the program for you to try. ( Just tap the zero key, and steer with keys 5 and 8 at the same time. It takes quite a few taps on the zero key to move ahead, depending on your speed. I will continue with the software and hardware development of this project, but anyone is welcome to help out. I can supply further information on the machine code for anyone who wants it.

An easy way to convert the speed signal from an exercycle to the 2068 is with a simple magnet and reed switch. Mount the magnet near the edge of the wheel. Put the reed switch on the cycle frame so that, as the wheel turns, the magnet passes close by the switch without touching it. Wire the reed switch leads to the two contacts on the fire button of the joystick. The joystick port can now read the speed of the wheel similarly to a tachometer.

Listing for X-R-Cycle Program

10 LET o=0
20 POKE 58443,74: POKE 58444,201: POKE 58445,0: POKE 58446,64: RANDOMIZE USR 51480: REM move screen from 51530 to d-file
50 REM init vars
60 LET a=2: LET x=12: LET y=12
70 LET sc=0: LET x1=x: LET y1=y
80 GO SUB 9200: LET a$="\q\r\s\t"
90 PRINT AT 12,11; INK 3; PAPER 0;"\::";AT 12,4;" ";AT 5,19;" ";AT 12,28;" "
100 REM print bike
110 PRINT AT y,x; INK 6; PAPER 0;"\::"
130 PRINT INK 4; PAPER 6;AT y1,x1;a$(a)
140 LET x=x1: LET y=y1
200 REM sense speed
210 LET w=USR 51400: IF w<20 OR w>1000 THEN LET s=0: GO TO 260
220 LET s=1500/w
260 PRINT AT 20,1;"SPEED ";INT s;" "
300 REM direction
310 LET a=a+(IN 61438=26)-(IN 63486=15): IF a=0 THEN LET a=4
320 IF a=5 THEN LET a=1
400 REM locate
405 LET d=s/500
410 LET x1=x1+(a=2)*d-(a=4)*d
420 LET y1=y1+(a=3)*d-(a=1)*d
430 LET o=o+d
440 PRINT AT 21,1;"MILES ";INT o;" "
500 REM collision
505 LET c=ATTR (y1,x1)
510 IF c=6 OR c=52 THEN GO TO 100
520 IF c=5 THEN PRINT FLASH 1;AT 20,12;"FELL IN RIVER": GO TO 700
530 IF c=3 THEN GO SUB 1000: LET sc=sc+p: PRINT AT 20,12;"ARRIVED at ";q$;AT 21,19;"SCORE ";sc: GO SUB 2000: GO TO 130
540 PRINT AT 20,12;"RAN OFF the ROAD": GO TO 700
700 FOR q=1 TO 4: BEEP .1,11: BEEP .1,30: NEXT q: PAUSE 150: GO TO 20
1000 IF y1>17 THEN GO TO 1100
1010 IF INT y1=12 THEN GO TO 1200
1020 IF INT y1<7 THEN LET q$="PARK": LET p=425: IF INT y=5 THEN LET a=3: RETURN
1025 LET a=2: RETURN
1100 IF INT x1=4 THEN LET q$="MOM'S": LET p=350: LET a=1: RETURN
1110 IF INT x1=10 THEN LET q$="MAC'S": LET p=225: LET a=1: RETURN
1120 IF INT x1=21 THEN LET q$="CLEANERS": LET p=475: LET a=1: RETURN
1130 IF INT x1=28 THEN LET q$="CTC": LET p=550: LET a=1: RETURN
1200 IF INT X1=4 THEN LET q$="MALL": LET p=350: LET a=3: RETURN
1210 IF INT x1=11 THEN LET q$="HOME": LET p=0: RETURN
1220 IF INT x1=27 THEN LET q$="A&D": LET p=550: LET a=3: RETURN
2000 LET y1=y: LET x1=x: FOR q=1 TO 50: LET w=COS q: NEXT q: PRINT PAPER 0;AT 20,12;" ": RETURN
9000 CLEAR 51000: LOAD ""CODE : BEEP .2,22: RUN
9199 REM get map from memory
9200 DATA 16,124,84,56,56,56,16,16,0,0,6,58,255,58,6,0,16,16,56,56,56,84,124,16,0,0,96,92,255,92,96,0
9210 RESTORE 9200: FOR q=65496 TO 65527: READ w: POKE q,w: NEXT q: RETURN
9999 SAVE "bike" LINE 9000: BEEP .01,11: SAVE "code"CODE 51400,7045: BEEP .01,11

NOTE: About 7K of code is also required to run this program

Fred wrote to me about this project, and I thought it was so interesting it should be put into the newsletter. I am sure Fred would like to hear from anyone out there so I take the liberty of giving his address. Fred Schakel, 181 Seawood Ave. London Ont. N6J 1B8

George Chambers

Media

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.