Commit 4d98bc60 authored by Elina Nguyen-Cadoret's avatar Elina Nguyen-Cadoret
Browse files

add content group ass w13

parent 10c7408d
Pipeline #226819 passed with stage
in 40 seconds
......@@ -40,4 +40,103 @@ For this week Théo used small engines like this one :
| 1 | 60 |
| 0,5 | STOP WORKING |
## Test of the motor from a printer
For [the group assignment](http://fabacademy.org/2021/labs/agrilab/group/week13/) 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.
![](../images/week13/12.jpg)
And here it is the value shown on the DC power supply, with how many ampers it consumes at 5V.
![](../images/week13/13.jpg)
Here is the motor powered with 5V.
<video controls="true" allowfullscrenn="true" width="35%" muted="muted">
<source src="../../images/week13/vid1.mp4" type="video/mp4">
</video>
I tested also with a low woltage, at 1V, and it works also but the motor spins slower.
<video controls="true" allowfullscrenn="true" width="35%" muted="muted">
<source src="../../images/week13/vid2.mp4" type="video/mp4">
</video>
## 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](http://fabacademy.org/2021/labs/agrilab/students/elina-nguyen-cadoret/assignments/week10/#peristaltic-pump)
I did the same wiring.
![](../images/week13/1.jpg)
And because this motor is a 6V motor, I powered the H-bridge with 6V.
![](../images/week13/2.jpg)
<video controls="true" allowfullscrenn="true" width="35%" muted="muted">
<source src="../../images/week13/vid.mp4" type="video/mp4">
</video>
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);
}
}
}
```
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment