A dual motor controller

I often use my Fischertechnik kits and generally my models employ one or two small DC motors and a few switches. This project will control two DC motors.

Circuit diagram

The motors can be turned on and off individually as well as change direction. This requires four of the experiment board control lines. The relays I picked for this happened to be in my junk box and can carry up to 10A. As there seem to be as many different relays as there are fingerprints, you will have to change my PCB layout to suit your own requirements. 

The circuit is straight forward. The motors have their own supply shown at the top right. Relay RL 1 and RL 3 turn the motors on or off, RL 2 and RL 4 change the direction of their motor. The four relay coils are connected to  digital output lines 5, 6, 7 and 8 of the Velleman board. Notice that the 0V line and the positive line also have to be connected to Ground and Clamp on the board.

For the motor M1 to turn in one direction, the relay RL 1 has to be activated. If you want to change the direction of that motor, relays RL 1 and RL 2 have to be both turned on. To stop the motor, relay RL 1 has to be turned off. The same applies to motor M2 but with the relays LL 2 and RL 4 instead . Notice that with this particular circuit the motors and the relays have to have the same voltage. It is of course an easy matter to separate the power supply so that there is one voltage for the relay coils and a different voltage for the motors.

The PCBOn the right is a suggested printed circuit board layout. Remember what I said above about the different pin out for relays - it is unlikely that your own stuff looks the same as mine. You'll need to adapt the layout to your needs. Remember also that you need two double pole double throw relays as well as two double pole single throw ones.

Unfortunately I can't supply the file for the drawing as I do all my artwork on an Acorn computer - which is not compatible with a PC or a Mac but it is a 1:1 gif file and could be used as a negative.

The controller with the Velleman interface
On the left is a photograph of the complete system.

The relay board is connected to the Velleman board via the connector strip on the left of the board. The connector strip on the right is for the two motors and the power supply.

Controlled by the the small program below, the set-up performed very well. The Velleman board has a slow response time, but this matters little in a simple application like this.



Here is the archive with the  BBC BASIC for Windows program file and the exec file

K8055_2motors.zip

There is also a YouTube video of the project

Below is the same thing for the K8061 interface board

K8061_2motors.zip


   10 REM Control two dc motors
   20 REM Version 2.0
   30 REM
   40 REM Jochen Lueg
   50 REM Limavady, January 2011
   60
   70
   80 PROCinit
   90
  100
  110 REM
  120 REM digital output 5 is for M1 on-off, 6 for M1 left-right
  130 REM digital output 7 is for M1 on-off, 8 for M1 left-right
  140 REM
  150
  160 PRINT"To manually control the M1 press '1' for left, '2' for right and '3' for stop."
  170 PRINT"To manually control the M2 press '8' for left, '9' for right and '0' for stop."
  180 PRINT
  190 PRINT
  200 PRINT"The display shows the current last commands"
  210 PRINT
  220
  230
  240 SYS USB_OpenDevice%, 0
  250
  260
  270 REM Key 1 = M1 left  Key 2 = M1 right   Key 3 = M1 Stop
  280 REM Key 8 = M2 left  Key 9 = M2 right   Key 0 = M2 Stop
  290
  300
  310 Motor1$="Stop" :Motor2$="Stop"
  320
  330 REM Press key S to leave the program
  340
  350 REM Main loop
  360 REPEAT
  370   IF INKEY(-49) PROCmotor1_left(Motor1$)
  380   IF INKEY(-50) PROCmotor1_right(Motor1$)
  390   IF INKEY(-18) PROCmotor1_stop(Motor1$)
  400   IF INKEY(-22) PROCmotor2_left(Motor2$)
  410   IF INKEY(-39) PROCmotor2_right(Motor2$)
  420   IF INKEY(-40) PROCmotor2_stop(Motor2$)
  430   PRINTTAB(10,10);"Motor 1 ";Motor1$;"   Motor 2 ";Motor2$;"           "
  440 ENDIF
  450
  460 UNTIL INKEY(-82)  = TRUE
  470 SYS USB_ClearAllDigital%
  480 SYS USB_CloseDevice%
  490 END
  500
  510
  520 DEFPROCmotor1_left(RETURN m$)
  530 SYS USB_SetDigitalChannel%,5
  540 SYS USB_ClearDigitalChannel%,6
  550 m$="left"
  560 ENDPROC
  570
  580 DEFPROCmotor1_right(RETURN m$)
  590 SYS USB_SetDigitalChannel%,5
  600 SYS USB_SetDigitalChannel%,6
  610 m$="right"
  620 ENDPROC
  630
  640 DEFPROCmotor1_stop(RETURN m$)
  650 SYS USB_ClearDigitalChannel%,5
  660 SYS USB_ClearDigitalChannel%,6
  670 m$="stop"
  680 ENDPROC
  690
  700 DEFPROCmotor2_left(RETURN m$)
  710 SYS USB_SetDigitalChannel%,7
  720 SYS USB_ClearDigitalChannel%,8
  730 m$="left"
  740 ENDPROC
  750
  760 DEFPROCmotor2_right(RETURN m$)
  770 SYS USB_SetDigitalChannel%,7
  780 SYS USB_SetDigitalChannel%,8
  790 m$="right"
  800 ENDPROC
  810
  820 DEFPROCmotor2_stop(RETURN m$)
  830 SYS USB_ClearDigitalChannel%,7
  840 SYS USB_ClearDigitalChannel%,8
  850 m$="stop"
  860 ENDPROC
  870
  880
  890
  900
  910 DEFPROCinit
  920 REM  Typing errors in routine name do not generate an error message - they just hang up the program.
  930 SYS"LoadLibrary","K8055D.dll" TO USB_Board%
  940 SYS"GetProcAddress",USB_Board%,"OpenDevice" TO USB_OpenDevice%
  950 SYS"GetProcAddress",USB_Board%,"ReadAnalogChannel" TO USB_ReadAnalogue%
  960 SYS"GetProcAddress",USB_Board%,"SetAllDigital"  TO USB_SetAllDigital%
  970 SYS"GetProcAddress",USB_Board%,"CloseDevice" TO USB_CloseDevice%
  980 SYS"GetProcAddress",USB_Board%,"ClearAllDigital" TO USB_ClearAllDigital%
  990 SYS"GetProcAddress",USB_Board%,"ClearDigitalChannel" TO USB_ClearDigitalChannel%
 1000 SYS"GetProcAddress",USB_Board%,"SetDigitalChannel" TO USB_SetDigitalChannel%
 1010 SYS"GetProcAddress",USB_Board%,"WriteAllDigital" TO USB_WriteAllDigital%
 1020 SYS"GetProcAddress",USB_Board%,"ReadDigitalChannel" TO USB_ReadDigital%
 1030 ENDPROC
 1040
 1050



Return to the interfacing index

Back to the Roe Valley index page
  Return sign