A Direct current (DC) motor, as the name suggests, takes in direct current from one end and uses it to rotate the axle/rod at its other end; we can then connect some other machine to the axle/rod that works when it rotates.
We can control a DC motor in terms of its:
- Direction: We can control the direction of rotation of the motor by reversing the direction of current that flows into it.
- Speed: We can control the voltage of the motor by varying the supply voltage.
evive has two inbuilt motor control units with which you can control motors with the current limit of 1A each. It uses a SN754410NE Quad H-Bridge IC to control two DC Motors.
If you look at the SN754410NE chip, you will notice a u-shaped notch at one end. This helps you identify pin 1.
Pin 4, 5, 12, 13 are connected to ground.
Pin 16 is connected to 5V and pin 8 is connected to power voltage which can vary from 4.5V to 30V.
1A and 2A are connected to Arduino Mega Digital pin 28 and 29 respectively and 3A and 4A to digital pin 30 and 31. You can determine the state of the motor by looking at the states of the pins:
|Pin 30||Pin 31||State|
|LOW||LOW||Motor is free|
|LOW||HIGH||Motor rotates in one direction|
|HIGH||LOW||Motor rotates in another direction|
Motor is stalled
Interfacing a DC Motor with PictoBlox
For interfacing the DC motor with PictoBlox, you must first connect the motor to one of evive’s motor channels as shown in the figure below:
You can control the motor using evive in two ways:
- By using evive’s inbuilt menu
- By writing a script in PictoBlox
You can control a DC motor in PictoBloxwith the help of the following blocks:
- run motor () in direction () with speed ()%: This block controls the speed of the specified motor in the specified direction.
- () motor (): This block allows you to halt/lock or free the motor.
You can find these blocks in the Actuators palette.
Activity: Controlling a DC Motor’s Direction Using Slide Switch
Follow the steps below to write the script:
- Connect evive to your computer and open PictoBlox; if already open and working on a project, save that project. Then, click on New.
- Go to the toolbar and click on the Board menu. Then select evive as your board.
- Next, click on the Connect menu and from the fly-out menu, select the Port to which evive is connected e.g. COMXX or ttyXX.Once you select the port, the icon beside the Connect tab will become connected.
- Go to the Events palette and drag and drop the when flag clicked block.
- Next, go to the Controls palette and drag and attach the forever block below the when flag clicked block.
- From the same palette, drag and drop the if-else block inside the forever block.
- Go to the evive palette and drag and drop the slide switch () is in state () block inside the diamond-shaped space of the if-else block; slide switch 1 and the UP state are set as default.
- Next, drag and drop the run motor () in direction () with speed ()% block from Actuators palette below the if arm of the if-else block; set motor as 1, direction as forward, and speed as 100% from their respective drop-down menus.
- Below the else arm, drag and drop another if-else block from the Control palette.
- Repeat step 6, but this time, set DOWN as the state.
- Repeat step 7, but this time, set direction as reverse.
- Drag and drop the () motor () block below the else arm of the second if-else block; select lock from the first drop-down menu and set the motor as 1.
Below is the complete script:
Click on the green flag to run the script.
Click on the red octagon, next to the green flag to stop the script.
It this tutorial, you learned how to interface a DC motor with PictoBlox.
Hope you had fun! 🙂