# 13. Output devices¶

This week we were focused on the output. For this we measured the power consumption of our different outputs. Please find attached the summary of our measurements.

For all the tests we used the generator present at AgriLab. This generator gives us directly the consumed current and the sent voltage.

## The motor¶

For this week Théo used small engines like this one :

### Datasheet engine :¶

Datasheet
Type Gear motor with wheel
SHAFT 3.6mm on both sides with a 1.9mm hole
ALIMENTATION 3 - 9V DC
DIMENSION 37,6 x 64,2 x 22,5 mm
WEIGHT 58 g
Current in Idle (mA) 190
Rpm 90
Torque (gf/cm min.) 800

### Power consumption¶

Voltage (V)   Current (mA)
9 120
8 112
7 104
6 98
5 86
4 82
3 77
2 70
1 60
0,5 STOP WORKING

### Test of the motor from a printer¶

For the group assignment Elina tested a DC motor. In my lab we have some printer that are not working anymore, and I took from it a DC motor. I tested the motor with a DC motor supply, and by hearing the noise of the motor and the speed of it, I assumed that the motor is working at 3V to 6V, and needs around 0.120A at 5V.

Here is the motor plugged to the DC power supply.

And here it is the value shown on the DC power supply, with how many ampers it consumes at 5V.

Here is the motor powered with 5V.

I tested also with a low woltage, at 1V, and it works also but the motor spins slower.

### 6V motor and H bridge with Arduino¶

To test a motor, I used a H-bridge and an arduino Board with the code I wrote during the machine week with the peristaltic pump

I did the same wiring.

And because this motor is a 6V motor, I powered the H-bridge with 6V.

As a reminder, here is my code, using platform.io with VSCode:

``````#include <Arduino.h>

//declaration des variables et des constantes
int enA = 9; //les pins avec des tilds
int in1 = 10;
int in2 = 11;

int speedmotor = 0; //vitesse du moteur

void setup() {
// put your setup code here, to run once:
pinMode(enA, OUTPUT);
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
Serial.begin(9600); //la valeur de communication
}

void move(int speed, bool testforward) {// speed between 0 and 255 analog write, test d'un booléen pour aller dans un sens ou dans un autre
if (testforward){
digitalWrite(in1, HIGH); //envoie du courant dans un sens (set to +)
digitalWrite(in2, LOW); //en envoie pas, le récupère (set to -)
}
else{
digitalWrite(in1, LOW);
digitalWrite(in2, HIGH);
}
analogWrite(enA, speed);
}

void loop() {
// put your main code here, to run repeatedly:
if(Serial.available() > 0){ //si la board arduino est branchée
speedmotor = Serial.parseInt(); // speedmotor recupere la valeur inscrite dans le serial
Serial.println(speedmotor);
if (speedmotor == 0){
return;
}
if(speedmotor > 0){ //si speedmoto a une valeur, plus grande que 0
if (speedmotor > 255){
speedmotor = 255; //speedmotor est forcé à 255 maxi
}
move(speedmotor, true); //alors marche avant
}
else if(speedmotor < -1){
speedmotor = -1*speedmotor; //pour que la vitesse ait une valeur de vitesse mais en marche arrière
if (speedmotor > 255){ //recopiage du test parce que speedmotor est de nouveau positif
speedmotor = 255; //speedmotor est forcé à 255 maxi
}
move(speedmotor,false); //marche arriere
}
else if(speedmotor == -1){ //c'est zero donc tout s'arrete
digitalWrite(in1, LOW);
digitalWrite(in2, LOW);
}
}
}
``````

### LCD Display¶

I’ve tested the LCD display on 5 Volts with my circuit and I was able to observe the changes in the current consumption with LCD LED blinking.

### RFID reader¶

The RFID was tested with and without the antenna at 5 and 9 Volts.