Shutter Controlled with Buttons

Shutter Controlled with Buttons

von Citilab Edutec

Boards
Boards:

Citilab ED1

Component/s
Weitere Komponenten:

Servo (360°)
This activity is part of the Citilab Course. Check it out!

Shutter Controlled with Buttons

DC motors

  • DC motors use direct current. These motors are also known as CC motors, from corrent continu, which in English is direct current, from where the English motors DC.

  • Motors that use alternating current, in Catalan, are also called CA motors and in English AC motors, from the English alternating current).

DC Motors

AC Motors

Servo motors

  • A servomotor is a direct current (DC) motor whose behavior can be controlled thanks to a small electronic board and a set of gears.

  • Although there are different types of servomotors, the way to control them is the same: by means of an electric pulse with a specific duration.

  • Depending on the duration of this pulse, the servomotor will turn to a certain angle (standard) or it will turn continuously to one side or the other (continuous rotation).

Servo motor

Parts of the servo motor

Angular servomotors

  • These servomotors consume about 100-200 mA and can reach 500mA at the time of start-up or change of direction. You must avoid giving commands to the engines while they are turning.

  • The servomotor can be connected to any of the digital outputs, although D1 and D2 give 3.3V and therefore the servomotor works with less power, while D3 and D4 work at 5V. The D4 output is connected internally to the speaker and small noises may occur.

  • Important! If using outputs 3 and 4 on an ED1 prior to version 2.3 it is recommended to do so with battery and the switch in "ON".

Connection with ED1

consumption

Angular servomotors

  • Standard or angular servomotors move a specific angle between 2 values. The most typical is SG90 which moves between 0 and 180º, taking about 150ms to make this angle. This engine does not spin!

  • It comes with a series of accessories that allow you to connect with gears or pull other elements.

  • The angular servomotors we will use are the SG90, a small and very affordable model.

angular servomotor

Animatronic eye

Angle control by pulse width

  • To set the angle, a pulse is sent every 20 ms. According to the duration of the pulse, the servo changes the angle. It is a pulse width modulation (PWM in English).

  • If the duration is approximately 1ms the servo is placed at an angle of 0º and if it is 2ms at 180º.

  • Once the angle is set, the servomotor does not move even if we send more pulses.

Pulse widths

Challenge 1: Make a program that makes the servo move from one angle to another, alternately

Challege

Solution to challenge 1

Servo library

  • To work with servomotors it is more practical to use the Servo library.

  • The block set servo _ to _ degrees (-90 to 90) is used with the angle motors, whereas the **rotate the servo _ to speed _ (-100 to 100) ** used with continuous rotation motors.

Challenge 2: Control a continuous rotation motor with the up and down button

Challenge

Solution to challenge 2

Home automation

  • Application of different technologies to improve housing, especially to improve energy efficiency.

  • It can also be applied to the improvement of schools, public buildings or even cities.

  • As an example, we will make a shutter that is controlled by the level of light and a lighting system that can be set in motion with the snap of a hand.

home automation

Shutter simulation

  • We will use a simple drawing on the screen to simulate a shutter, whose height will vary according to the value of the y variable.

  • In a real case we should use limit switches that indicate that the shutter has reached the upper and lower limits. Here we will do this control by program using the value of the variable (0 = upper, 128 = lower).

Shutter program

Challenge 3: Simulate a shutter (with screen and servo motor) controlled by the up and down buttons.

Challenge

Solution to challenge 3

CC-BY-SA

© von Citilab Edutec 2019-2022.
This work is licensed under a CC-BY-SA 4.0 license.