Category Archives: Daily Devices

DailyDevice – Speedometer – IR_Rotary_Sensor

My daily device is a Speedometer that measures the number of times a wheel turns over time.

I wanted to figure out the relationship between the rotations per minute (rpm) of a DC motor with the amount of PWM voltage (controlled via transistor) and this method worked out.

To figure out the motor and transistor I used Marcello’s Daily Device (DC motor and potentiometer)

Parts for this Setup

– Potentiometer (to control wheel speed)

– Transistor + DC motor + SpokesWheel on axle (to measure amount of rotation)

– IR Rotary Sensor

IR Rotary Sensors

I bought an IR Sensor rotary kit from Creatron to do this. See the below link to see the sensors. It is basically an IR emitter and sensor put adjacent to each other. When the sensor is looping, it returns zeros when the sensor detects a signal from the emitter, and returns ones when the sensor is interrupted.

http://www.tinyosshop.com/index.php?route=product/product&product_id=541

The IR sensor can therefore detect whether it is being interrupted by the spokes of a turning wheel. By sampling the 0s and 1s over a set period of time, and determining the geometry of the spokes and wheels (e.g., 20 spokes per one rotation of wheel) one can calculate the amount that the wheel has turned over a set period of time. This value can then be converted into rotations per minute, which can be then converted into speed (speed = distance / time) by calculating the circumference of wheel.

Visuals of Setup and Demo

Overview

IR Sensor + DC motor with black spokes wheel connected to transistor + Potentiometer

IR Sensor – 3 Pins: 5Vs, Ground, and Digital output

IMG_0160

Clearer image of spokes wheel

IMG_0162

Video Demo

Serial.print values shows Potentiometer, DC voltage, digital IR value, # of rotations per sample interval (1 second), rotations per minute (RPM)

Code

// Function to use IR sensor to measure speed of turning spokes-wheel

// Motor and Potentiometer Values
int potPin = A4; int potValue = 0;
int motorPin = 3; int motorValue = 0;

// Rotary Wheel-Spin Sensor Values
int sensorRotaryPin = A0;
int sensorVal = 0; // 0 or 1 depending on whether the IR sensor detects the spokes or passes through them
int previousSensorVal = 0; // previous 0/1 value to use during loop calculations
int count = 0; // used for counting times digital signal shifts btw 0 and 1
float revolutions = 0; // number of times the wheel has turned 360 degrees
float rpm = 0; // rotations per minute
float speedVal = 0; // distance/time val calculated using revolutions and constants
int samplingInterval = 1000; // sample period of wheel turns over milliseconds to determine speed
long previousMillis = 0;

// Setup and Loop
void setup() {
Serial.begin(250000);
pinMode(8, INPUT);
}

void loop() {
potValue = analogRead(potPin); constrain(potValue, 0, 1023); // if(potValue>1023) {potValue=1023;}
motorValue = map(potValue, 0, 1023, 0, 255); analogWrite(motorPin, motorValue);
sensorVal = digitalRead(sensorRotaryPin);
spokesCounter();
GetSpeed();

// Serial Value Printing
Serial.print(potValue); Serial.print(” “);
Serial.print(motorValue); Serial.print(” “);
Serial.print(sensorVal); Serial.print(” “);
Serial.print(count); Serial.print(” “);
Serial.print(revolutions); Serial.print(” “);
Serial.println(rpm);
}

// Functions
int spokesCounter() { // Counts the number of times that analogRead changes values. A count of 20 spokes is 360 degrees.
if (sensorVal != previousSensorVal) {
count++;
}
previousSensorVal = sensorVal; // sets previous sensor val for next iteration through loop to compare
}

float GetSpeed() {
if(millis() – previousMillis >= samplingInterval) { // uses timer to turn count() value into rotation values and speed data
revolutions = (count/2.0)/20.; // # of revolutions. 20 spokes. count value divided by 2 so each change between 0/1 counts as 1 spoke. If 20 changes then the wheel has gone around 360 degree and revolutions = 1
rpm = revolutions * (60000.0/samplingInterval); // revolutions per minute (60,000 ms)
speedVal = (rpm * 20.0); // 20 cm is the wheel’s circumference. speed = cm/minute
previousMillis = millis(); // reset timer to resample
count = 0; // reset counter for next sample
}
}

Photocell Alarm

Don’t end up getting squashed!!

Trying to get into an elevator or subway, the alarm system is smart enough to detect the presence with effect to light by using sensors and hence, the door slides back if need be.

elevator VLUU L310W L313 M310W / Samsung L310W L313 M310W

I replicated that by using Photo resistor sensor which not only signals through LED but also raises an alarm if the object is in close proximity.

Schematic Photocell Alarm

Here you can also find how this sensor works.

SCHEMATIC

Photocell_LED_Speaker Circuit

CODE

PhotoResistor Sketch

 

Electric Car

DC Car Arduino Circuit

For the Daily Device Project I built a car. But that wasn’t my idea at beginning, I changed it twice, from elevator to crane and then finally to a car, I explained the development of this project in the video below.

Circuit

DC Car Arduino Circuit

Parts

1 x Arduino UNO
2 x DC Gear Motor
1 x 500 ohm potentiometer
2x Tact Switch
2x DC Motor Voltage Inverter
2x 10k ohm resistor
2x 2.2k ohm resistor
2x Transistor FQP30N06 – N-Channel MOSFET
2x Diodes

The transistor works as valve, it can control how much power will pas trough, with the help of the Arduino it will control your motor. Basically your code is giving the order and the transistor is doing it. The information being sent by the button and the potentiometer is being read by the Arduino and then sent to the motors trough the Transistor. The transistor has 3 pins, the first one (with the chair facing you) will be connected to your Arduino, it must be one of the pins with ~ symbol. In this connection,between the transistor and the Arduino put a 2.2k ohm resistor. The second pin will be connected to the negative of your motor, remember to put a diode between your motor and the transistor, the energy coming from the motor may damage your board. The third pin is connected to ground.

To control the back and forth of the motors use Voltage inverter. It has for inputs for cable, the first two you connect to the positive and negative of your motor. The other two, one you connect to the 5v, and the other one you connect to the second pin of the transistor, is trough this pin that the motor will be controlled by the Arduino.

To control the start and stop you use the buttons, it has 4 pins, 1 will be connected to 5v, the other to ground, and the pin across from your ground connection will be connected to the Arduino. Between the ground and the button put the 10k ohm resistor.

The speed will be defined by the potentiometer, it has 3 pins, middle one will be connected to your Arduino using one of the analog pins. The other two is for ground and 5v.

Code

int buttonPinL = 7;

int buttonPinR = 8;

int buttonStateL = 0;

int buttonStateR = 0;

int potPin = A0;

int potValue = 0;

int motorPinL = 3;

int motorValueL = 0;

int motorPinR = 9;

int motorValueR = 0;

void setup() {

pinMode(buttonPinL, INPUT);

pinMode(buttonPinR, INPUT);

Serial.begin(9600);

}

void loop() {

potValue = analogRead(potPin);

buttonStateL = digitalRead(buttonPinL);

buttonStateR = digitalRead(buttonPinR);

motorValueL = map(potValue, 0, 1023, 0, 170);

motorValueR = map(potValue, 0, 1023, 0, 170);

analogWrite(motorPinL, motorValueL);

analogWrite(motorPinR, motorValueR);

if (buttonStateL == HIGH) {

analogWrite(motorPinL, motorValueL);

}

else {

analogWrite(motorPinL, 0);

}

if (buttonStateR == HIGH) {

analogWrite(motorPinR, motorValueR);

}

else {

analogWrite(motorPinR, 0);

}

}

LED Sprite Display

Pedestrian_signal,_Central_Park
Sprite : a computer graphic that may be moved on-screen and otherwise manipulated as a single entity.
My story is that I wanted to have an 8×8 LED Matrix used to mimic the display beside street lights indicating to pedestrians to either walk or stop.  To begin to replicate this, the purpose of my process was to test the ability to control all 64 LED’s of this matrix to display my choice of a sprite.  Starting simple, I wanted to create two sprite symbols, an “X” and an “O” to represent the 2 states that this display will show.
Materials List
– Arduino Uno
– 16 pin 8×8 LED Matrix
– Breadboard
– Jumper wires
– 1k ohm resistors (8)
– Lots of patience
LED Sprite Display_schem
Discovery
At first, working with these LED’s in a matrix seemed overly complicated and frustrating if your research isn’t thorough.  However, after just a little practice, the matrix became “a little” less complex.  The primary thing to notice is wether you are using a common cathode or common anode matrix.

What is the difference between Common Anode and Common Cathode?
 
• Using seven segment displays as an example, when all the anodes are connected to one point, it becomes a common anode. Common cathode means that all the seven cathodes of a 7-segment display are connected together.
 
• To function, a positive voltage should be supplied to the common anode and the common cathode should be grounded.

The next thing I did was test the lights to understand how these diodes were mapped to their pins.  My trial and error resulted in one diode getting burned out accidentally missing a resistor on one of the connections.  Luckily, the matrix continues to function with the remaining lights.
Long story short, understanding that the matrix works by a system of rows and columns, was key.  A datasheet is what provided this understanding.  However, this understanding still wasn’t enough as there seemed to be inconsistencies trying to simply isolate one LED with the code.
The fact of this matrix being able to show both red and green, may have bearing on me isolating one light. But throughout the testing, I have only been able to show red.  Further research showed that I may have been better off with a shift register added to the circuit.
IMG_0426
48 wires later

Code
Screen Shot 2015-10-10 at 6.59.15 PM
/*
 *  Creation & Computation: Daily Devices Workshop
 *  LED Sprite Display
 *
 *  Marcus A. Gordon
 *
 *
 *  ASCII MAPPING OF 8×8 MATRIX
 *  ——————————
 *  This ASCII map identifies LED Matrix rows, red/green columns and first pin (1).
 *  Below each row is a red and green column.
 *  Column numbers are the same as the row number above them.
 *
 *  ——————————————-
 *  ROW 4 —-|*  *  *  *  *  *  *  *|— ROW 8
 *  COLRG —-|*  *  *  *  *  *  *  *|— COLRG
 *  ROW 3 —-|*  *  *  *  *  *  *  *|— ROW 7
 *  COLRG —-|*  *  *  *  *  *  *  *|— COLRG
 *  ROW 2 —-|*  *  *  *  *  *  *  *|— ROW 6
 *  COLRG —-|*  *  *  *  *  *  *  *|— COLRG
 *  ROW 1 —-|*  *  *  *  *  *  *  *|— ROW 5
 *  COLRG —-|*  *  *  *  *  *  *  1|— COLRG
 *  ——————————————-
 *
 *  ^ < v
 *  Pins are read, from pin 1: up – left – down)
*/
// Arduino pins connected to the matrix
int rMatrix[] = {2,3,4,5,6,7,8,9}; //rows
int cMatrix[] = {10,11,12,13,14,15,16,17}; //columns
void setup() {
  Serial.begin(9600);         //Open the Serial port for debugging
  for(int i = 0; i <8; i++){  //Set the 16 pins used to control the array as OUTPUTs
    pinMode(rMatrix[i], OUTPUT);
    pinMode(cMatrix[i], OUTPUT);
    digitalWrite(rMatrix[i], HIGH);
    digitalWrite(cMatrix[i], LOW);
  }
  digitalWrite(rMatrix[5], LOW);
  digitalWrite(rMatrix[4], LOW);
  digitalWrite(rMatrix[0], LOW);
  digitalWrite(cMatrix[1], HIGH);
  digitalWrite(cMatrix[3], HIGH);
  digitalWrite(cMatrix[5], HIGH);
  digitalWrite(cMatrix[6], HIGH);
  digitalWrite(rMatrix[6], LOW);
  digitalWrite(rMatrix[7], LOW);
  //digitalWrite(rMatrix[3], HIGH);
}

Daily Devices – Vacuum Cleaner

 

vacuum

vacuum_cleaner2

I built a vacuum cleaner breaking a hair dryer apart. Their mechanism is quite similar if you ignore the heating process of the hair dryer. One is the reverse of the other.

I picked a bottle that would match the size of the fan and bought two 9V batteries with battery clips so the switch function would be solved. A baby wipe has been used for the filter. I drilled the lid and cut a plastic piece from my sports equipment for the hose.

While doing some research for the project, I also found out that in the 1920s, women dried their hair by connecting a hose to the exhaust of their vacuum cleaners…

 

 

Workshop 2: Daily Devices, the Washing Machine

Our washing machine at home seemed so uninteresting so I decided to choose that for analyzing in hope of making it a bit more interesting.

I set up camp in the bathroom with lights, camera and not a whole lot of action.

documenting-the-washing-machine-1

I did though, I think, figure out how the machine’s different knobs, buttons and LEDs work with one another and also how it puts the machine to work. I put together a sort-of combination of a UI and user flow for an example setting of the washing machine.

For the “make-an-inspired-copy-protoype” part of the assignment, I deviated from actuators working with water and found in the 5V fan a similar trait; a spin.

So I decided to put a spin on things (pun à la Andrew Hicks intended) and thought how I could put together an interesting concept based on the washing machine but with a twist (pun, again).

At Hvíta húsið, a wonderful advertising agency I worked for from 2012 – 2015, they tried their hand at an open office space. I for one am all for increased transparency and collaboration between co-workers. That I was put smack-in-the middle of the open work area was perhaps not as ideal – for me at least.

The new situation also didn’t do so well with efficient AC during the warm summers.

So despite my attempts at getting people to voice their dialogue with team members by walking over to them instead of shouting across the room – and in the same moment, me – I thought of AC powered by silence setting for the air conditioning systems at one’s work place.

So an example would be a super warm Tuesday, the new AC is doing great and everybody’s working on their projects within decent noise levels. Then, around 10:30am, the workplace starts to get noisier and louder, slowly turning off the AC (given that it has the above setting turned on).

The noisy chatter would then flow into conversations of “Oh, my! How warm it is! Isn’t the AC working?” and “I know, right?! I’m sweating like a pig!” to which one could respond with “The AC is perfectly fine. It’s just waiting for the sweet silence”.

A working demo can be seen here of a loud-mouthed stegosaurus disturbing the work force.

I’m aware that this concept might come off as a bit bitter from my end. Don’t get me wrong, from time to time I sure like a break from projects to do other, louder stuff. Maybe just not where people are trying to continue on with their own projects in peace.

hardware-diagram-1

 

// Sketch code below, with less-than-ideal map() function values, perhaps

const int fanPin = 9;
const int speakerPin = A0;

const int sampleWindow = 50; // Sample window width in mS (50 mS = 20Hz)
unsigned int sample;

void setup() {
Serial.begin(9600);

pinMode(fanPin, OUTPUT);
pinMode(speakerPin, INPUT);
}

// map function with floats
float mapfloat(float x, float in_min, float in_max, float out_min, float out_max) {
return (x – in_min) * (out_max – out_min) / (in_max – in_min) + out_min;
}

void loop() {
unsigned long startMillis = millis(); // Start of sample window
unsigned int peakToPeak = 0; // peak-to-peak level

unsigned int signalMax = 0;
unsigned int signalMin = 1024;

// collect data for 50 mS
while (millis() – startMillis < sampleWindow) {
sample = analogRead(0);
if (sample < 1024) { // toss out spurious readings
if (sample > signalMax) {
signalMax = sample; // save just the max levels
} else if (sample < signalMin) {
signalMin = sample; // save just the min levels
}
}
}

peakToPeak = signalMax – signalMin; // max – min = peak-peak amplitude
double speakerVolts = (peakToPeak * 3.3) / 1024; // convert to volts

//convert speakerVolts from double to float before mapfloat()

int soundCtrlFan = map(speakerVolts, 0.5, 1.0, 255, 0);

Serial.print(“speakerVolts value is: “);
Serial.print(speakerVolts); // check mic analog input values

Serial.print(“\t soundCtrlAC value is: “);
Serial.println(soundCtrlFan);

analogWrite(fanPin, 0); // turn off fan while initial testing

}

 

 

Daily Device: Tropicana Elevator

Elevators are “thinking” machines, determining which floor to move to next based on their previous movement (in simple form).

elevator1

 

Basic movement steps:

  1. From Idle, wait for a button to be pressed
  2. Move in the direction of the first button pressed (if you’re on floor 1 and floor 2 is pressed, move up; if you’re on floor 10 and floor 9 is pressed, move down)
  3. After opening and closing doors, check to see if another button is pressed.  If not, return to idle state.
  4. Determine direction and move:  If you were previously going up and a button for a higher floor is pressed, keep moving up.  If you were previously going down and a button for a lower floor is pressed, keep moving down.  If a button is pressed from the opposite direction – and there are no other buttons pressed for the current direction – switch and move in the new direction.
  5. Repeat.

elevator_movement_diagram

Tropicana Elevator

Implementation Notes:

  • Uses 2 power sources: (1) Arduino for monitoring switches and opening pins, (2) 9V battery to drive the motor
  • Uses an IC chip to reverse the polarity in the motor (cause it to move forward/reverse)
  • The elevator uses time to determine when to stop when moving
    • There are 3 floors: G, 2, 3
    • Total time = time it takes to go from  G -> 3 = (G -> 2) + (2 -> 3)
    • If moving one floor, run the motor for 1/2 time.  If moving two floors, run the motor for the total time.
  • A Potentiometer, an Up, and a Down button are included (in addition to the G, 2, 3 buttons) to aid in debugging/fine tuning.

Tropicana_elevator

 

Tropicana_elevator_circuits