Show Posts
Pages: 1 [2]
16  Forum 2005-2010 (read only) / Exhibition / My electrical power meter on: November 23, 2009, 05:14:45 am
I'm so proud!
My first Arduino project is a power meter for my house.
The power meter that the electric company reads every month and sends me a bill from just states how much power is used since it started. It also sends out a light pulse for every thousands of a kWh used. I use a light dependant resistor to read the pulse and count them and the time between the pulses to get power used since my Aruino started and the current power usage. All this is displayed on a LCD shield. With the buttons on the shield i can display different things:
The total power used since the start and current usage.
Power used last minute and mean power last minute.
Power used last hour and mean power last hour.
Power used last day and mean power last day.
Power used last week and mean power last week.
Power used last four weeks and mean power four.

The sketch saves the current usage value every ten seconds and calculates everything. The values are cyclic so last days measyre ment is rather last 24h values and so on. If the Arduino is juststarted it sets a "c" in front of the values that are not correct yet (it takes four weeks to get all values correct).

The power meter, fuses and what not. And my Arduino with LCD shield.

http://imgur.com/Ub3hh.jpg

Close up of the Arduino and shield running showing the default screen: The total power used since the start and current usage .

http://imgur.com/rEISz.jpg

Code doesnt fit. It's too big. How do I do?

It was kind of an anti climax when all was in place and running. What do do now? I have an idea of another shield that kan show graphics so i can draw a graph of power usage. Connecting a memory card so I can import the readings to my computer and analyze the readings more. And... And... Is there evera finished product?



/Ulf


17  Forum 2005-2010 (read only) / Bar Sport / Re: Oxygen blood meter? on: December 16, 2010, 09:15:17 am
For now I'm satisfied with only the oxygen level but measuring the puls might be interresting too.
Good extra reading with the wikiarticle.

I was thinking of callibrating the measurement by just assuming that initially I'm always at say 99% en then see if it drops over time as I hold my breath. Now I can use the different wavelengths instead.

This is not a near future project of mine so don't expect any breakthroughs for quite a while.

Thanks for your input!

/Ulf
18  Forum 2005-2010 (read only) / Bar Sport / Re: Oxygen blood meter? on: December 15, 2010, 08:30:34 am
found me some info here: http://www.picotech.com/experiments/calculating_heart_rate/index.html
Just got to find me some time now to experiment with it.

/Ulf
19  Forum 2005-2010 (read only) / Bar Sport / Oxygen blood meter? on: December 15, 2010, 05:19:25 am
I don't know the right medical term for it but I mean the clip they put on your finger to measure how mych oxygen your blood holds.
Anybody got the knowledge of the inner workings of one of these?
If it is a siple/cheap setup i would like to build one to measure how my oxygen level changes when i hold my breath.

Ideas? Possible?

/Ulf

20  Forum 2005-2010 (read only) / Bar Sport / Re: Speed sensor on: December 28, 2009, 03:58:22 pm
Still on the test bench. Have tested laser pointer module and solar cell about 6 meter apart so this should work. Now I need lots of cable...
I still want to use a reflector so I can have all electronics on one side of the road and just a reflex, mirror or something on the other side.

Now one laser pointer is more of a laser lamp. The point is about 5x5 cm at 6m distance. May need to change it.

/Ulf
21  Forum 2005-2010 (read only) / Bar Sport / Re: Speed sensor on: December 28, 2009, 02:09:02 pm
OK, christmas, free time, hardware and arduino at hand. Got everything hooked up and my code works after some modifications. I realized the hard way that when iside a interrupt routine millis() isn't ticking along. Well, modified and working in my test setup. Here is the code. One problem to solve is that if something breaks one laser beam and not the other the code assumes a car is moving inside the speedgate and calculates a very low speed when the second beem eventually is broken. Have tried several ways to reset this but no good idea works for me.

Code:
int upSpeed, downSpeed; //Speed calculated in each direction
int upCarCounter=0, downCarCounter=0, totalCars=0; //Number of cars in each direction and total
int upMaxSpeed=0, downMaxSpeed=0; //Max speed for both directions
int upMinSpeed=999, downMinSpeed=999; //Minimum speed for both directions
long upAverageSpeed=0, downAverageSpeed=0, totalAverageSpeed=0; //Sum of speeds to calculate average from
int upCarCounterHour=0, downCarCounterHour=0, totalCarsHour=0; //Number of cars in each direction and total
int upMaxSpeedHour=0, downMaxSpeedHour=0; //Max speed for both directions
int upMinSpeedHour=999, downMinSpeedHour=999; //Minimum speed for both directions
long upAverageSpeedHour=0, downAverageSpeedHour=0, totalAverageSpeedHour=0; //Sum of speeds to calculate average from
long upGateTime=0, downGateTime=0;  //When interrupt happened, car passing time gate
long lastUpGateTime=0, lastDownGateTime=0;  //Previous time a car passed
long hourTimer=0;  //Timer to control hourly output
int hourCounter=0;  //Count hours
int upTime, downTime; //Time for car to pass gate in each direction
int distance=10000; // Distance betveen upwards and downwards gate in mm
int upGate=2;  //Pin for up gate
int downGate=3;  //Pin for down gate

void setup()
{
  pinMode(upGate, INPUT);  //Setup pins for input
  pinMode(downGate, INPUT);
  Serial.begin(9600);
  attachInterrupt(0, upwardsTimer, FALLING);  //Set up interrupts to call when change happens, car is passing gate
  attachInterrupt(1, downwardsTimer, FALLING);
}


void loop()
{
  if (millis()-hourTimer>10000) //Check if 60 minutes has passed
  {
    hourTimer=millis(); //Reset hour timer for new measurement period
    hourlyPrintout();  //Print the total and this hours stats
    resetHourlyStats();  //Reset hourly stats for new period
    hourCounter++;  //Increase hour counter
  }


  if (upGateTime!=lastUpGateTime && downGateTime!=lastDownGateTime)  // Both gates have changed so a car has passed
  {
    if (upGateTime<downGateTime)  //Did it pass downwards or upwards?
      downwardsRun();
    else
      upwardsRun();

    lastUpGateTime=upGateTime;  //Reset timers
    lastDownGateTime=downGateTime;
  }

}


void upwardsRun()  //Prints stats for car going upwards
{


  upTime=upGateTime-downGateTime;  //How long for the car to pass the gate
  upSpeed=distance/upTime*36/10;  //Calculate speed in Km/h

  if(upSpeed<upMinSpeed)  //update fastest and slowest speed
      upMinSpeed=upSpeed;
  if(upSpeed>upMaxSpeed)
    upMaxSpeed=upSpeed;

  if(upSpeed<upMinSpeedHour)  //update fastest and slowest speed this hour
      upMinSpeedHour=upSpeed;
  if(upSpeed>upMaxSpeedHour)
    upMaxSpeedHour=upSpeed;

  upAverageSpeed=upAverageSpeed+upSpeed;    //Update average speeds and car counters
  totalAverageSpeed=totalAverageSpeed+upSpeed;
  upCarCounter++;
  totalCars++;
  upAverageSpeedHour=upAverageSpeedHour+upSpeed;    //Update average speeds and car counters this hour
  totalAverageSpeedHour=totalAverageSpeedHour+upSpeed;
  upCarCounterHour++;
  totalCarsHour++;


  Serial.print("Car number ");
  Serial.print(totalCars);
  Serial.print(" upwards speed: ");  //Print the speed
  Serial.println(upSpeed);
  Serial.println("");

}


void downwardsRun()  //Prints stats for car going downwards
{


  downTime=downGateTime-upGateTime;  //How long for the car to pass the gate
  downSpeed=distance/downTime*36/10;  //Calculate speed in Km/h

  if(downSpeed<downMinSpeed)  //update fastest and slowest speed
      downMinSpeed=downSpeed;
  if(downSpeed>downMaxSpeed)
    downMaxSpeed=downSpeed;

  if(downSpeed<downMinSpeedHour)  //update fastest and slowest speed this hour
      downMinSpeedHour=downSpeed;
  if(downSpeed>downMaxSpeedHour)
    downMaxSpeedHour=downSpeed;

  downAverageSpeed=downAverageSpeed+downSpeed;    //Update average speeds and car counters
  totalAverageSpeed=totalAverageSpeed+downSpeed;
  downCarCounter++;
  totalCars++;

  downAverageSpeedHour=downAverageSpeedHour+downSpeed;    //Update average speeds and car counters this hour
  totalAverageSpeedHour=totalAverageSpeedHour+downSpeed;
  downCarCounterHour++;
  totalCarsHour++;

  Serial.print("Car number ");
  Serial.print(totalCars);
  Serial.print(" downwards speed: ");  //Print the speed
  Serial.println(downSpeed);
  Serial.println("");

}


void hourlyPrintout()  //Prints hourly stats
{
  Serial.println("----------------------------------------------------------");  //Print all info about the cars
  Serial.println("");
  Serial.print("          Hour interval: ");
  Serial.print(hourCounter);
  Serial.print("-");
  Serial.println(hourCounter+1);

  Serial.print("      Total cars passed: ");
  Serial.print(totalCars);
  Serial.print("\t      Total cars passed this hour: ");
  Serial.println(totalCarsHour);
  Serial.print("    Total Average speed: ");
  Serial.print(totalAverageSpeed/totalCars);
  Serial.print("\t    Total Average speed this hour: ");
  Serial.println(totalAverageSpeedHour/totalCarsHour);
  Serial.println("");

  Serial.print("    Cars passed upwards: ");
  Serial.print(upCarCounter);
  Serial.print("\t    Cars passed upwards this hour: ");
  Serial.println(upCarCounterHour);
  Serial.print("  Upwards Average speed: ");
  Serial.print(upAverageSpeed/upCarCounter);
  Serial.print("\t  Upwards Average speed this hour: ");
  Serial.println(upAverageSpeedHour/upCarCounterHour);
  Serial.print("      Upwards Max speed: ");
  Serial.print(upMaxSpeed);
  Serial.print("\t      Upwards Max speed this hour: ");
  Serial.println(upMaxSpeedHour);
  Serial.print("      Upwards Min speed: ");
  Serial.print(upMinSpeed);
  Serial.print("\t      Upwards Min speed this hour: ");
  Serial.println(upMinSpeedHour);
  Serial.println("");

  Serial.print("  Cars passed downwards: ");
  Serial.print(downCarCounter);
  Serial.print("\t  Cars passed downwards this hour: ");
  Serial.println(downCarCounterHour);
  Serial.print("Downwards Average speed: ");
  Serial.print(downAverageSpeed/downCarCounter);
  Serial.print("\tDownwards Average speed this hour: ");
  Serial.println(downAverageSpeedHour/downCarCounterHour);
  Serial.print("    Downwards Max speed: ");
  Serial.print(downMaxSpeed);
  Serial.print("\t    Downwards Max speed this hour: ");
  Serial.println(downMaxSpeedHour);
  Serial.print("    Downwards Min speed: ");
  Serial.print(downMinSpeed);
  Serial.print("\t    Downwards Min speed this hour: ");
  Serial.println(downMinSpeedHour);
  Serial.println("");
  Serial.println("");


}


void resetHourlyStats()
{
  totalCarsHour=0;  //Reset hourly stats for new measurement period
  upCarCounterHour=0;
  downCarCounterHour=0;
  upMaxSpeedHour=0;
  downMaxSpeedHour=0;
  upMinSpeedHour=999;
  downMinSpeedHour=999;
  upAverageSpeedHour=0;
  downAverageSpeedHour=0;
  totalAverageSpeedHour=0;
}


void upwardsTimer()  //Car has passed upper gate
{
  upGateTime=millis();  //Time when car passed gate
  /*
  Serial.print("Upper gate passed at: ");
   Serial.println(upGateTime);
   Serial.println("");
   */
}


void downwardsTimer()  //Car has passed lower gate
{
  downGateTime=millis();  //Time when car passed gate
  /*
  Serial.print("Lower gate passed at: ");
   Serial.println(downGateTime);
   Serial.println("");
   */
}



/Ulf
22  Forum 2005-2010 (read only) / Bar Sport / Re: Speed sensor on: November 29, 2009, 01:42:44 pm
I've just ordered the solar panels, they're 2,5cm square. So in a week or two they should arrive and by then i hope to have some code to test them with. Stay tuned...

/Ulf
23  Forum 2005-2010 (read only) / Bar Sport / Re: Speed sensor on: November 22, 2009, 05:52:12 pm
looks great, cant miss that even if i tie the laser to a lamp post. Now I'll just need to find solar panels. (Right after these messages... Implies that I'm taking a break now to go to sleep.)
Thanks a lot for all the help! If, (I'd like to say when), this idea becomes real I'll be sure to post it here.

/Ulf
24  Forum 2005-2010 (read only) / Bar Sport / Re: Speed sensor on: November 22, 2009, 04:12:05 pm
Nice to see your dialogue on my case.
I've looked at the sensors from Maxbotix earlier and ruled them out on count of the price. Nice to see that we think the same way. This is just supposed to be a cheap simple project in my spare time.
Lasers legal or not don't bother me that much so I'll go with that option, but then the issue still is the small light resistor. The solar panel should be a much better idea then. The time gate system is what I'm aiming for, just didn't knew the name for it.
Any hints for a suitable solar panel and how that would work?
25  Forum 2005-2010 (read only) / Bar Sport / Re: Speed sensor on: November 22, 2009, 03:24:00 am
Maybee you're right. I'll try it. The thing is then that with that idea I need power on booth sides of the street and if two cars pass at the same time in both directions the reading will be off. But at the same time I can read the speed in both lanes, thats good. And maybee that two cars pass at the same time is unlikely. I'll give it a go.

/Ulf
26  Forum 2005-2010 (read only) / Bar Sport / Speed sensor on: November 21, 2009, 02:36:14 pm
I want to measure the speed of cars passing by the street where I live. My idea was to have two laser beams that reflects on a small reflex in the middle of the road and then points to two light dependant resistors. I tested my idea on a breadboard to see if it works, and it did. But now I'm thinking that if i scale it up the smallest vibration will make the lasers miss and thereby fool the Arduino that a car has passed.
Any better ideas for a speed sensor? My idea would cost me well under 10$ so price is also a part in this.
27  Forum 2005-2010 (read only) / Bar Sport / Re: Checking a fuse? on: November 23, 2009, 04:06:30 am
There are several types of fuses. Most are designed to easily show if they're burnt. So you should see just by looking at it.
Otherwise, unplug it and check the resistance. It should be close to or 0 ohm. If it's burnt the resistance is infinite.

/Ulf
Pages: 1 [2]