Temperature controlled Motor


We are going to build a temperature controlled motor program. We use KMK USB Temperature Sensor Card to read the temperature and control the KMK USB 13 IO Card to switch on/off a DC electric motor. The techniques involved in this application can be applied to any other temperature controlled projects

KMK USB Temperature Sensor CardKMK USB 13 IO Card

Connect the Cards and the motors to the computer.


1. You must have a KMK Temperature Sensor Card and a KMK 13IO Card connected to your computer.

2. A DC 6V motor connect to one of the output terminal of KMK 13IO Card..

3. You must have the OCXs of both cards installed.

4. Open a new project on Visual Basic.

5. Right click on the Tool Box and select "Choose Items.."

6. On the "Com Components" page select KMK5I8OOCX and KMKTemperatureOCX.

7. Put both OCXs on the form as below;

8. Double click on the form and enter the code between Private Sub Form_Load and End Sub as below. This code is used to connect and start two cards while the program is started.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

AxKMKTempOCX1.SerialNumber = "xxxxxxx "
AxKMKTempOCX1.ActivateCode = "xxxxxxx "
AxKMKTempOCX1.Port_Open_Close = 1

AxKMKUSB1.Device = "xxxxxxx"
AxKMKUSB1.Port_Open_Close = 1

End Sub

9. Set the Timer interval to 1000 (1 seconds) and Enable to True.

10. Double click the timer and enter the code between Private Sub Timer_Tick and End Sub as below. This code is used to read the temperature every seconds and select the temperature to start and stop the motor. We use the KMKUSB5I8OOCX to control the ON/OFF of the Motor. In this example, we defined the motor ON/OFF temperature is 30 and 26 degree celcius respectively.

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

If AxKMKTempOCX1.Temperature > 29 Then
AxKMKUSB1.Out = 1
ElseIf AxKMKTempOCX1.Temperature < 27 Then
AxKMKUSB1.Out = 0
End If

End Sub

11. Run the program and check the temperature and the operation of the motor.