Week 9. Output devices¶
¶
Group assignment¶
Tasks
- measure the power consumption of an output device
we tried three methods.
- with power supply
- with power supply and multimeter
- with Arduino + simulation
Individual assignment¶
For output devices I decided to use a water pump which will be useful for my final project. I’ve found some pumps and ultrasound fog maker.
After trying the fog maker with power supply I find out it works starting with 11V to 24V. I was given a 24 V power supply. And I wanted to modulate the power of this device with transistor.
! UNFINISHED
Transistor with LED¶
I tried to use a transistor. What I found is IRFZ44N mosfet transistor and I observed it’s datasheet.
I connect the gate with a digital pin on my Quentorres.
gate is powered by pin 1, which we can see is also turning on/off the LED on the board. And when it delays 5 seconds HIGH the transistor lets the LED on the breadboard to light.
And when I unplug the gate pin, LED gets powered from board and lights up. And when I plug the gate pin back, the transistor gets 3.3V and opens chain to provide power the LED.
code I took is simple pin toggle example
#define pin 1
void setup() {
// put your setup code here, to run once:
pinMode(pin, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(pin, 1);
delay(5000);
digitalWrite(pin, 0);
delay(5000);
}
Servo motor¶
CS-939MG servo motor is what tried as an output device.
First, I tried to adjust rotation angle with Arduino code.
I opened example code for sweep on Arduino.
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards
void setup() {
myservo.attach(1); // attaches the servo on 1 pin to the servo object
}
void loop() {
int pos;
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}
Potentiometer¶
Then I tried to use with potentiometer
I used this scheme that I’ve found on Internet. It’s using Arduino board but I changed pins and used the RP2040 same way. I Connected the potentiometer to A0 analog pin and remaining pins same as in the scheme.
#include <Servo.h>
Servo servo1;
int potin;
void setup()
{
servo1.attach(2);
}
void loop()
{
potin = analogRead(A0);
potin = map(potin, 0, 1023, 0, 180);
servo1.write(potin);
delay(15);
}
Servo tester¶
Additionally I used servo tester device to check it’s angular limits. it varies from 800 to 2200 values, which are from 0 to maximum posible angle o this servo.
Store page for this Servo tester HJ speed controller Tester for brushless servos 2X3 1-4 Servos / ESC.
Conclusion¶
This week I used few outpud devices and tried to conntrol them with using PWM on my microcontroller and transistor.
I used
- Ultrasound fog maker
- LED and transistor
- Servo motor with and without potentiometer.