Show Posts
Pages: 1 2 [3] 4 5 ... 11
31  Using Arduino / Programming Questions / Re: Millis() Timing goes way off over time. on: March 04, 2012, 04:59:39 pm
Hi

This is how I would have done it...

Code:
const unsigned long Sec = 1000L;
const unsigned long Min = 60L * Sec;
const unsigned long Hr = 60L * Min;

//zone 1:
const unsigned long zone_1_Off = 1 * Min; // 1 min
const unsigned long zone_1_On = 5 * Sec; // 5 sec
unsigned long zone_1_Start = 0;
unsigned long zone_1_Stop = zone_1_On;
const int zone_1_Pin = 13;

//zone 2:
const unsigned long zone_2_Off = 30 * Min; // 30 min
const unsigned long zone_2_On = 15 * Sec; // 15 sec
unsigned long zone_2_Start = 0;
unsigned long zone_2_Stop = zone_2_On;
const int zone_2_Pin = 12;


unsigned long myTime = 0;

void setup(){
  pinMode(zone_1_Pin,OUTPUT);
  pinMode(zone_1_Pin,OUTPUT);
}

void loop(){
  myTime = millis();

  // zone 1 logic
  if (zone_1_Start < myTime){digitalWrite(zone_1_Pin,HIGH);}
  if (zone_1_Stop < myTime){
    digitalWrite(zone_1_Pin,LOW);
    zone_1_Start = myTime + zone_1_Off;
    zone_1_Stop = zone_1_Start + zone_1_On;
  }
  
  // zone 2 logic
  if (zone_2_Start < myTime){digitalWrite(zone_2_Pin,HIGH);}
  if (zone_2_Stop < myTime){
    digitalWrite(zone_2_Pin,LOW);
    zone_2_Start = myTime + zone_2_Off;
    zone_2_Stop = zone_2_Start + zone_2_On;
  }
}

-Fletcher
32  Using Arduino / Programming Questions / Re: toggling a true / false value each time a loop is called on: February 03, 2012, 04:51:10 pm
Hi Brian

You had the boolean declared inside the:
Code:
void setup(){ ....

-Fletcher
33  Using Arduino / Programming Questions / Re: toggling a true / false value each time a loop is called on: February 03, 2012, 01:56:56 pm
Hi Brian

No, you did not find the error...

This code is flipping the boolean - can you spot the difference?

Code:
unsigned long Time5;
unsigned long DisplaySwitchTime = 1000;
boolean TickTock = false;

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

void loop(){
  if (millis() - Time5 > DisplaySwitchTime){
    TickTock = !TickTock;
    Time5 = millis();
    Serial.println(TickTock);
  }
}

-Fletcher
34  Using Arduino / Programming Questions / Re: Marine biologist seek programming help with ph controller on: January 06, 2012, 01:39:03 pm
Hi Silverpil

If you are a marine biologist and doing a research projekt - why not stick to commesial products like transmitters from Yokogava with according displays where the A1 .. A4 alarms can drive the ON/OFF valve for CO2?

If this is a home-brew project - just continue the Arduino road.

-Fletcher
35  Using Arduino / Project Guidance / Re: Please Suggest A Electronic Fuel Tank Level Sensor! on: January 03, 2012, 10:01:36 am
Hi Nishant,

This is your main problem (cut from the link):

Quote
Make sure your Sending Unit is working! apparently most gauge problems are due to a faulty sending unit, (basically a potentiometer attached to a float arm in your gas tank)

-Fletcher
36  Using Arduino / Project Guidance / Re: Please Suggest A Electronic Fuel Tank Level Sensor! on: January 02, 2012, 09:40:55 am
Hi Nishant,

Please be carefull when handling electronics inside a closed compartment with mixture of air and fuel. Eventhough the Ex and ATEX rules can be anoying from time to time (and increases the price of hardware) it helps if I want to NOT blow up the chemical plant.

Since this is a costum made bike I reckon that the sensor is a MUST HAVE item - otherwise I would stick to the milage on the trip counter. It's my experience that the trip counter is accurate within +/- 10% counting from full tank to use of reserve.

If this is a showoff sensor how about this:

1) Mount the tank on weight scales and average the mesurments to compensate for vibrations during driving.

2) Mount a pressure difference cell with the "wet-leg" at the lower part and the "dry-leg" at the top head space. If you are building a steampunk bike I would take this option. Dry-leg as a brass tupe on the outside..... oh well.

3) Radar sensor? I guess there will be problems with non-uniform geometri of the tank - and those are a bit expencive.

4) Nuclear sensor - probaly a no-go on street driving bikes...

Please check the conduktivity of fuel (or hexane) if you wannw try with a conductivity rod.

-Fletcher
37  Community / Bar Sport / Re: Greenpeace, makes the world a better place... on: November 07, 2011, 05:52:46 pm
Greenpeace makes the world a better place .... I'm not sure.

It's an organisation that would have a major negative effect on the world as we know it if they had the power to complete their politics.

1) They promote organic grown food and work against the use of pesticids.
If we dropped pesticids and industrial produced fergilizers we would see a crop yield decrease of minimum 1/3. People will hunger.

2) They work against use of GMO foods.
Minimum 80% of all soya is GMO at the moment - along with other crops. Major parts of Asia will see massive hunger if GMO was dropped. Prices on meat from live stock would also sky rocket.

3) They work against nuclear power.
At the moment we have no substitute other than burning coal, oil and propane/buthane. This would give a major increase on CO2 emissions. We can not expand hydro-electric without destroying big eco-systems. Windturbines only works when the wind is blowing - without a supply backbone they are not worth alot.

Greenpeace for a better world - no thank you. They do not have (or want) the knowledge about how to run the world.

-Fletcher
38  Using Arduino / Programming Questions / Re: millis help needed on: August 21, 2011, 03:57:02 am
Hi

Code:
...
void loop() {                      // run over and over again scan inputs then play them

randomSeed (analogRead (0));    // randomize
 .....

You are seeding each time you loop. This is not a good idea.

Nick,
Quote
By the way, you aren't doing anything for 5, you know that, right?

The 5 in
Code:
ran = random(1, 5);
is excluded.

Quote
Parameters
min - lower bound of the random value, inclusive (optional)


max - upper bound of the random value, exclusive


-Fletcher
39  Using Arduino / Programming Questions / Re: A noob is getting started on: June 30, 2011, 02:21:28 am
Quote
Stupid question #1:
delay(1000)

Why the use of 1000 milliseconds for one second and not just 1?
Wouldn't that be much easier?
 

The delay() function was written that way. It counts in milliseconds.

If it were to count in seconds there wound be problems with delay half a second since you would have to write delay(0.5), but this is a no go since delay() only accepts integer numbes as input.

You might wonder - how do I delay half a millisecond?
delayMicroseconds(500);

Just one final note - once you figured out how the blink example works. The next think you do is look at the blink with out delay example. delay() is not your best friend since it hangs the processer - kinda like putting the kids infront of Disney channel  smiley-razz

-Fletcher

40  Using Arduino / Programming Questions / To goto or not to goto on: June 29, 2011, 01:21:55 pm
If speed is all there is to it .... why not overclock the chip by "upgradeing" the oscillator to a faster version?

-Fletcher
41  Using Arduino / Programming Questions / Re: Timer program on: June 16, 2011, 07:40:32 am
Quote
Have at, guys! There's a lot of work to do... especially "delay(10); // waits for a second" (you mean, waits 1/10th a second? haha).

... or maybe even waite 1/100th of a second  smiley-evil

-Fletcher
42  Using Arduino / Programming Questions / Re: delay(1000) = 2 sec on: June 16, 2011, 06:27:34 am
Hi roller

This:
Code:
unsigned long dt, timer = 0;

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

void loop(){
  dt = millis() - timer;
  if (dt >= 1000) // True for every 2 sec.
  {
    timer = millis();
    Serial.println("Mother should I trust the goverment?");
  }
}

is printing out once every second.

I think you have a hardware problem (are you sure about the 8 MHz) or a make file problem.

-Fletcher
43  Using Arduino / Programming Questions / Re: Error in prime printer :( on: June 06, 2011, 06:49:52 am
Hi

Dang Rob, that was advanced optimizing  smiley-eek

My advance advice would have been to make a list of known small primes (like all primes from 2-300) and then check a candidate against that list before switching to Eratosthenes sieve.

I once wrote a pyton code that omitted the power hungry modolo operation. You make a list of boolean items in the full range you wanna test and then declare all items "1" (all numbers are primes). Go though the list, if you meet a "1" all multiplication of that number is switched from "1" to "0". After once through the list it will only contain "1" at prime numbers.

As long long as the list chould stay in PC memory without useing swarp files it was super fast.

Oh well, the prime genie is out of the bottle.

-Fletcher

Btw, looks like OP posted the code here:http://arduino.cc/forum/index.php/topic,63073.0.html
44  Using Arduino / Programming Questions / Re: Error in prime printer :( on: June 04, 2011, 03:44:52 pm
Hi Chicken325

It's easy for you to improve your prime code.

1) Skip all the even numbers. The number 2 is the only even prime.
2) You can stop at sqr(x). There is no primes between sqr(x) and x/2.

-Fletcher
45  Using Arduino / Project Guidance / Re: 1 HP AC motor speed control on: June 01, 2011, 01:23:15 pm
Hi

How about a VLT microdrive?

http://www.csedistributors.com/acatalog/200V.html
The 132F 0002 seems like a good option.

98 pound + 20% VAT for a VLT .... even though it's a small VLT it's cheap.

-Fletcher
Pages: 1 2 [3] 4 5 ... 11