Saturday 30 January 2010

Solenoids- done!

I am now, finally, able to control my solenoid through arduino and NOT just with a power supply.

Big Achievement!!

For the first time with my electronics, the problem was not in the coding, but in the circuit. This is one of the hardest things to hook up, made harder with the use of a program and external power supply.

Coding is simply turning the solenoid on or off. When it is turned on, it will suck the piston in, and when released (off) pushes the piston out. This is why it is easy to use with solely a power supply, turn on the power, the solenoid is on, turn off the power, the solenoid is off. But i want to control it via arduino.


To begin:
I hooked the solenoid straight to the arduino board. Along with the red led, i programmed them to go on and off every second. This did work however, not enough power was available so the piston did not hold very well, i.e it was not strong enough current.



So:
I began using a MOSFET to drive the current up and an extrenal power supply to allow a higher voltage to be available, therfore producing a stronger hold. As you can see in the image, i hooked up one of the solenoid's wires straight to the power supply. This magnetized the solenoid independently of arduino. (With a higher voltage, the strength of the solenoid was greatly improved.)



So:
I started looking at ways to connect the solenoid indirectly to the power supply so I introduced a voltage regulator, which looks identical to the MOSFET. (The MOSFET is to the right)

I believe i hooked this up incorrectly as i smelt burning and touched my voltage regulator. ouch! Next time i advise disconnecting the power and letting things cool down. I discovered that the green wire should not connect the two devices...

Then:
I tried for AGES to hook up the circuit with both components before removing the voltage regulator as i wondered if i even needed it...


So:

I went back to the web and searched for pictures showing how to connect the components. This was very tricky...not much available in books and online showing you how to do it. But i did find a few, and with my systems diagrams i just kept at it.

This one made the solenoid vibrate

This one made the MOSFET really really hot and the solenoid didn't do anything. I don't think the MOSFET likes a direct ground line from the power supply.

This one magnetized the solenoid independently from arduino but the MOSFET did not heat up...


So... I went to the arduino forum hoping they might have a tutorial on how to use them and the only thing i could find was this systems diagram which i had looked at few weeks earlier in the anticipation of receiving my solenoids.

http://www.arduino.cc/playground/uploads/Learning/solenoid_driver.pdf


After studying it for a while i noticed i had missed out the green wire below. This adds an extra ground line from the arduino board to the' source' in the MOSFET.

voila! this is how to hook up a solenoid to arduino

Now i just need to program the pattern i would like my solenoids to play!

Developing form

These are my first proper sketches at developing the form of the device.

The form must include:
  1. a dial
  2. at least 1 toggle switch
  3. flat back edge where the solenoids will be
  4. must look good either on wall or on flat surface
I am also experimenting with the idea of using aluminum and cork. Both these materials are light weight, relatively easy to shape and cork is an excellent shock absorber.



Tuesday 26 January 2010

Related Article

Some more research on sleep cycles, gender related:

http://www.dailymail.co.uk/health/article-1246029/Who-REALLY-needs-sleep--men-women-One-Britains-leading-sleep-experts-says-answer.html?ITO=1490

Zen Alarm

I really hate this device but what i do like is the output this device produces and how it delivers. This device uses a chime and begins its signal soft and gradually gets louder. This makes it perfect for relaxation and yoga apparently.

I thought i would mention this device to show that non recorded sounds are beginning to be used, but i am aiming for a pleasant yet assertive sound that the individual has control over.

The Da Vinci Alarm Clock

I have found a similar product to the one i am developing.

This alarm clock trains you to enjoy a 21 hour day by following the instructions the screen tells you and responding to the high pitched sound produced.


I semi-like the design but what i do like is that this alarm clock does not display time either, but indicates when to wake and when to sleep much like my own to build a routine.

By Marc Owen

Friday 22 January 2010

Wind Charm Alarm clock


This device gently wakes you up in the morning at the set time. I only like the concept of this clock; using natural elements to wake you up.

http://craziestgadgets.com

Wednesday 20 January 2010

The Dial

The dial that controls awake time is now completed with the real time clock. The dial will automatically set off the night time alarm as well.

So:
The dial has been separated into 12 sections or ranges from 0 - 12. Each section has a different alarm time, e.g:

at 0: the time set here is 6am AND 9pm

timeSetValue = analogRead(timeDial); //find what value the dial is sitting at

if(timeSetValue/68 == 0){ // if value = 0 then it is pointing to 6am

if(hour == 6 && minute == 0){ // so at 6am signal
digitalWrite (ledred, HIGH);
delay(1000);
digitalWrite (ledred, LOW);
delay(1000);
}}

else if(hour == 21 && minute == 0){ //AND signal at 9pm, still based on the same value.
digitalWrite (ledred, HIGH);
}

From this, i started to roughly mark out around the dial what value it is (pink) and therefore what time is being activated(black). In this image, you can see that the pointer is over 7am which will activate the 7am alarm along with 22pm alarm automatically.


There is also some circuit problems i need to speak to mike about. The dial will only ever give me my full range of 0 - 12 when plugged straight into my arduino board and not when in my bread board for some reason...

I am also ordering a multi-sector potentiometer that clicks when it is turned between it's values.

Music Box


I have also taken apart a music box to see if i can somehow use this to be my output...still working out how this could be done!

The bell

As i am finding it difficult to get a hold of the correct solenoids to work on my output, i took apart a wind up clock. I am on the search for a digital one so i might be able to hook it up to my circuit.

Hacking 2 digital alarms

I thought it might be an idea to hack two alarm clocks together to show how my device will be working.

First: took 2 digital alarm clocks apart.

Then: removed the on / off switch from both
Attach: wires to one switch which will feed both clocks. More wires were added on the clocks to complete the circuit.
But: this did not work very well, so i replaced both on / off switches back and attached them together physically. This shows: 2 clocks with one control.

One clock is the correct time, the awake alarm
the other is 9 hours behind. the bed time indicator

Thursday 14 January 2010

The dial

So far, with my baby steps, i have managed to get my potentiometer (the dial) working without the real time clock.

The thing for this set of code, is programming the potentiometer to have sections or divides. The potentiometer ranges from 0-1023. If i wanted 7 sections, i would divide 1023/7= 146. (These sections could be allocated alarm times.)

This is the code so far:

const int ledred = 10; // the number of the red pin

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

void loop() {
// read the analog input into a variable:
int analogValue = analogRead(0);
// print the result:
Serial.println(analogValue/146);
// display the pot values in 7 different sections
delay(1000);

if (analogValue/146 == 1) { //if the pot value divided by 7 and is = 1 then...
digitalWrite (ledred, HIGH); // flash the led every half sec
delay(500);
digitalWrite (ledred, LOW);
delay(500);
} }

I am still working at combining it with my real time clock.

User's input

I'm also trying to PLAY with the user's input with the device.

I'm currently programming a dial which provides options for an alarm time. I'm wanting something similar to a safe dial. The user simply turns the dial to the one of the set alarm times. This is so a sleep rhythm is maintained.

Setting the time

Setting an exact time is completed!

I had not realised that i had already achieved this goal with out posting to the ardunio forum. As i mentioned in one of my earlier sites i could only get it to react for 1 second. This is in fact all i need and from this signal i can complete an alarm code / signal.

for exact time:
if (hour == 6){ if (minute == 30) { if (second == 0){
digitalWrite (ledred, HIGH);
delay(500);
digitalWrite (ledred, LOW);
delay(500);
}}}

Data #2

  1. when I wake up on demand, I normally feel groggy & confused (as ever!) sometimes even with a sore head.
  2. 23:00/00:00 - 07:30/08:00
  3. Try to go to bed earlier by working the time out so I get about 8 hours sleep. e.g. If I have to get up at 06:00 I will go to bed at 22:00.
  4. My phone or my alarm clock - beeping noise which I like the best
  5. between 4-6

Data #1

  1. usually get a fright when my alarm goes off early waking me up. Massive struggle to then proceed to get up that i snooze for 15-30mins.
  2. 23:30 - 8:00
  3. try not to drink alcohol - :-/ ,work late and usually to help me wind down i potter around my flat or have a shower. I like to watch tv on my laptop in bed.
  4. iPhone, scifi tone
  5. 5

Data collection question

To collect a bit of data to PLAY around with, i have been asking a range of people to answer these :
  1. a wee sentence summarizing your sleep experience waking on demand.
  2. bed time and awake time/ or duration of sleep - not lies in -
  3. when you know you have to get up early, what do you do, if anything, different to your routine?
  4. what alarm system do you use? sound produced?
  5. your awake rating from 1 to 10 (10 = best, 1 = worst).

Wednesday 13 January 2010

Buttons

Step 1: keep time with on / off button.
Step 2: alarm to go off when hour and min is set, e.g. 7:30
Step 3: snooze

Step 1:To do this, i am using if statements with an anolog input.

The on / off button works by using this command:

// read the state of the set button value:
buttonSet = digitalRead(dayoff); // check if the dayoff button is pressed.

if (buttonSet == HIGH) { // if it has NOT been pressed, complete these steps
digitalWrite(ledgreen, HIGH); // turn green on:THIS IS TO ACT AS AN INDICACTOR!!

This still keeps time and can turn output off any time in code once pressed. This means my on / off button acts as setting the alarm and turning it off on signal. This is good as it means less buttons!!

Step 2: The tough part!

Changing the source; I've tried now, using LOTS of different codes to try and send the alarm signal to go off with an hour and min being specified.

The most affective so far is going back to my ' if else' statements.

if (hour == 8) {
digitalWrite(ledred, HIGH); // turn on red

This will reconise the hour, but using such commands as

if (hour ==8) { if (second ==10)} (seconds used as faster)
digitalWrite(ledred, HIGH); // turn on red

This sets the alarm to go off at 08:00:10 but at 08:00:11 it will come back on again...

if (hour ==8) { if (second >10)} (seconds used as faster)
digitalWrite(ledred, HIGH); // turn on red

This sets the alarm to go off at anything over 08:00:10 but it will come back on again at a new minute over 10 seconds 08:01:11...

I cannot get the alarm to go off indefinitely!

' If else' is good for hours
'case' is good for setting range

Step 3: Snooze

I couldn't get snooze working for some time. It did turn lights off once pressed but would not turn them back on after delay.

I had forgotten that i was using latching buttons, so to turn the lights back on, the switch had to be returned to its original position; lights turned off, delayed and came back on. Big lesson on the types of hardware you use!

The snooze is not working with real time tho! i seem unable to have 2 working buttons with time!

Sunday 10 January 2010

Log Clock


I find this concept fantastic, simple and elegant. Simply saw the log to cut off a clock(s).

by gogo

Mood board

Draft 1: This board is to help me to start to develop my form with function for my am-pm alarm.

My theme: Looking at elegance and simplicity through form and material.

Friday 8 January 2010

character cards

For the form to start to take shape, I have started to think about who my potential customer is:


Draft 1 hastily add

Thursday 7 January 2010

Related Article

http://news.bbc.co.uk/1/hi/health/8435955.stm (02.01.10)

This adds rationale behind my project

Tuesday 5 January 2010

Buttons

My circuit design needs to be able to contain 3 buttons: one to activate the alarm, snooze and turn off like all basic alarm clocks. (I'm hoping to merge my alarm activation with my off button so fewer is needed.)

Before the holidays broke up, I found myself launching straight into combining a button into my real time clock. This was unsuccessful. A button you might think, and what i thought, would be relatively simple to add is not! When i added my button, it stopped my clock counter- so stopped my clock from working. This was bad! I need my clock to always be on regardless of external factors.

I decided that i would strip back to basics and build on the 'button' example provided by arduino without my real time clock. This could then be transferred back into my real time clock with a higher understanding of this particular set of codes.

This was actually relatively straight forward to do without using the clock, once of course i knew what to do;

Difficulty 1: planning what i would need and what i wanted to be the outcome. I drew myself a systems diagram to help break this down and order my actions. This would act like a guide for writing my code.

Difficulty 2: translating my systems diagram into Arduino code. The difficulty is to include all the loops. (I knew how to do one loop) This was a problem as i have 5 small loops in 1 big loop. I knew how i could complete this in 'P BASIC', a different programming software. As arduino is knew to me, i did not know what could or could not be manipulated. I did follow my P BASIC knowledge to overcome this. I found that i could use IF ELSE statements with lots of little loops in one big loops, solving my multiple loop crises!

Difficulty 3: Circuit building. I am just going to say it...i'm crap at making a working circuit! Just take a loop at this;


Difficulty 4: Testing.It took some time to realise that within my one big 'IF' statement with 5 smaller ones that i had added an extra '}' which closed my big loop and made 6 smaller loops...it now works hours later!!

My next step is start placing the button loops in my real time clock code.