Show Posts
Pages: 1 ... 425 426 [427] 428 429 ... 580
6391  Community / Exhibition / Gallery / Re: Greenhouse automation on: May 19, 2011, 01:33:41 am
Code:
/////Light trigger
  if((0 <= hour(t)) && (18 > hour(t))) { ///Between which hours on
    lightstatus = 1;
  }
  if((18 <= hour(t)) && (24 >= hour(t))) { ///Between which hours off
    lightstatus = 0;
  }

could be

Code:
/////Light trigger
  lightstatus = hour(t) < 18 ? 1 : 0;


Code:
if(stats != previousstats) {
This compares the addresses of the two arrays, they will never be ==

As they are arrays of binary numbers you have to use memcmp() to compare them.

Then you can use memcpy() to move one into the other.

______
Rob
6392  Using Arduino / Project Guidance / Re: Coin Counter on: May 19, 2011, 01:16:08 am
No guarantees but I'm happy to help.

As there are much better coders than me here I take some comfort from the fact that no one has pinged me on the code yet, or maybe they just haven't noticed the thread smiley

______
Rob
6393  Using Arduino / Project Guidance / Re: 12 Volt Trigger on: May 19, 2011, 12:29:48 am
Quote
How and where in the sketch does this command need to be?
Normally in the loop() function.

Code:
void loop () {
   if (digitalRead(triggerPin) == LOW) { // assumes the opto is wired to pull pin low
       // sequence code here
   }
}

However if you only want this to run once you can put it in the setup() function.

Quote
Then output to the next pin (cue 2) at a user defined timing delay with a 1 second pulse so forth
I'll get into trouble for using delay() here but for this simple application I would suggest something like this.

Code:
void loop () {
   if (digitalRead(triggerPin) == LOW) { 
       digitalWrite (seq1Pin, HIGH)
       delay (1000);
       digitalWrite (seq1Pin, LOW)

       digitalWrite (seq2Pin, HIGH)
       delay (1000);
       digitalWrite (seq2Pin, LOW)

       digitalWrite (seq3Pin, HIGH)
       delay (1000);
       digitalWrite (seq4Pin, LOW)
   }
   while(1);  // if you don't want this to run a second time, OR put this in setup()
}

If you have a LOT of sequences (did you say 12?) then an array would be better.

Code:
byte pins [] = {2, 3, 4, 6, 8, 9, 10, 11, 18, 23, 44, 51};  // whatever pins you are using
const int N_PINS = sizeof (pins) / sizeof (pins[0]);
 
void loop () {
   if (digitalRead(triggerPin) == LOW) {
       for (int i = 0; i < N_PINS; i++) {
          digitalWrite (pins[i], HIGH)
          delay (1000);
          digitalWrite (pins[i], LOW)
      }
}

Quote
how would the optoisolator be connected to the input pin on the arduino for it to read the input?
Emitter to GND, collector through a resistor to VCC (the resistor can be omitted if you use the Arduino's inbuilt pull up resistor). Collector to Arduino pin.

Quote
Will my 12 volt source need a resistor of some sort so that the current doesn't destroy the optoisolator?
Yes, value depends on the opto's LED but about 1k should be OK.

______
Rob
6394  Using Arduino / LEDs and Multiplexing / Re: programing and wiring 2 Multiplexer / demultiplexer with arduino on: May 18, 2011, 09:17:07 pm
You do realize that you can't use 4067s for outputs unless you only need one output on at a time, it's been stated a couple of times but I'm not sure you've pick up on it.

BTW, your picture links to your C drive, that ain't gonna work smiley
______
Rob
6395  Community / Products and Services / Re: Schematice of all the bricks on: May 18, 2011, 09:08:41 pm
Have a look at Terry King's site

http://yourduino.com/

Or get in touch with him. Last I heard he was trying to document all the bricks.

______
Rob

6396  Using Arduino / Project Guidance / Re: Designed an Attiny "BBB" type board, need input on: May 18, 2011, 08:11:34 pm
Quote
Any thoughts on trace width for signals and for the VCC/GND lines?
For such a small board with only one active component I would say 20-30mil would be more than enough.

Google "pcb trace width calculator"

Quote
I think I'm going to change it to a single 7 or 8 pin connector if I can make it route nicely though.
I can't see why you're having trouble realigning the headers, there's only 5 traces on the whole board smiley If they are in a row the board will plug in directly to a BB. As they are I don't see how it can plug in at all (I'll have to drag out a BB and have a look).

______
Rob
6397  Community / Exhibition / Gallery / Re: Greenhouse automation on: May 18, 2011, 12:47:35 am
Hi SpencerH,

Do you really have 3 phase power or are the three "mains" wired the same active.

6A @ 240V means huge motors, are they really that big?

I gather they are DPDT relays and the "to CP" contacts are just to show they are working with the other pole doing the pump/whatever control.

______
Rob
6398  Using Arduino / Project Guidance / Re: Designed an Attiny "BBB" type board, need input on: May 18, 2011, 12:24:32 am
Why not put the two breadboard power pins in line with the IO pins? That way the whole thing plugs straight onto a breadboard. As it is you'll have to run flying wires from one or the other.

______
Rob
6399  Community / Bar Sport / Re: My electric blanket doesn't work ... on: May 17, 2011, 10:24:28 pm
Yes, in Aus you can pick your climate of choice.

Tassie, mostly cool/cold, green babbling brooks, much like England.
Lower states, pretty cold in winter to very hot (40+) in summer.
High country, more snow than Switzerland in winter, mild to cold in summer (still snow in summer on occasion).
The outback, varies between really cold and boiling hot -10 nights to 45+ (even 50+ in places) days.
Upper states (tropics) same temp all year round (approx 30-35 days) but humidity changes from dry to very humid.

_____
Rob
6400  Community / Bar Sport / Re: Employment for Arduinoites on: May 17, 2011, 10:01:54 pm
No sooner have I spoken than we get this post

http://arduino.cc/forum/index.php/topic,61488.0/topicseen.html

______
Rob
6401  Using Arduino / Networking, Protocols, and Devices / Re: Arduino on: May 17, 2011, 09:55:10 pm
I don't know, but what's the heartbeat for?

If you get Xbee to do it then that tells you nothing about the Arduino.

Also a little more descriptive title (you can change that) may get you some more informed responses.

_______
Rob
6402  Using Arduino / Project Guidance / Re: Coin Counter on: May 17, 2011, 09:29:08 pm
It's morning and no other takers so here is a rough start. As I see it you need to read 30 inputs fast and although the signals should be pretty clean from the opto sensors (depends on the sensor) they probably still need debouncing.

The debounce library may do this I haven't looked at it.

Done for 32 coins, will need slight adjustments for 30

Off the top of my head, thoroughly untested, not compiled, probably has bugs and maybe even logic errors. I think the basic idea is sound, but then I'm not the one putting the tender in for the job smiley


Code:
// Wiring must be organised such that the sensors are connected
// in groups of 8 to to procesor ports
// Assumes
//    4-digit coin counters, ie 9999 coins max
//    digital input goes HIGH when coin over sensor

#define DEBOUNCE_TIME 5
#define TRANSITION_TIME 50  // # of mS it takes a coin to pass the sensor
#define N_COINS 32

byte ports [4] = {PORTC, PORTD, PORTF, PORTG};
byte debounce_counters [N_COINS];
boolean coin_passing [N_COINS];
int coin_counters[N_COINS];
int display_timer;

void setup () {
// do some stuff here
SPI.begin(...); // etc
for (int i = 0; i < N_COINS; i++) {
coin_passing[i] = false;  // shouldn't really need this
}
}

void loop () {
static display_counter = 0;
byte group = 0;

for (int port = 0, port < 4; port++) {
byte portval = ports[port];  // get 8 sensor bits
// now test each sensor bit
// increment the sensor's counter if the bit is 1
//      and we didn't just do so,
//      ie the coin is still passing from the last count
// clear the sensor's counter if 0
for (int sens = 0; sens < 8 sens++) {
if (portval & B00000001 == 1) {
if (coin_passing[i]) {
coin_passing[i]--;  // coin is still passing from last count, dec counter
} else {
debounce_counters[port + sens]++;  // one more closer to being a valid coin
}
} else {
debounce_counters[port + sens] = 0; // any 0 value and we start again
}
portval >>= 1; // move next bit into position 0
}
}

/////////////////////////////////////////
// now we have an updated array of 32 counters
// test to see if any have reached the debounce value
for (int i = 0; i < N_COINS; i++) {
if (debounce_counters[i] > DEBOUNCE_TIME) {
// we have a new coin
coin_counters[i]++;
debounce_counters[i] = 0;
coin_passing[i] = TRANSITION_TIME;
}
}

//////////////////////////////////////////
// every 100mS send the counters out to the displays,
// assumes a string of N_COINS AS1108 shift regs or similar and 4-digit counters
// for 32 displays we need to shift 32*4*7 bits
// at 8mMHz this will take 112uS plus some overhead
static temp_array[4];

display_timer++;
if (display_timer >= 100) {
display_timer = 0;
for (int i = 0; i < N_COINS; i++) {
func_to_convert_bin_to_BCD (temp_array, coin_counters[i]); // there may be a library func for this
SPI.transfer (temp_array[0]);
SPI.transfer (temp_array[1]);
SPI.transfer (temp_array[2]);
SPI.transfer (temp_array[3]);
}
}
delay (1); // 1mS delay added to the time it takes to do the above
}

______
Rob
6403  Community / Bar Sport / Re: My electric blanket doesn't work ... on: May 17, 2011, 09:15:17 pm
Brrrr, I had to go get a jumper just to read your post. smiley

______
Rob
6404  Using Arduino / Networking, Protocols, and Devices / Re: Fast communication to PC with low Arduino footprint on: May 17, 2011, 11:30:11 am
Quote
Sampling + sending raw data through Serial.print (baudrate 115200): 2.2 Hz
That may have been the serial blocking, a non-blocking version might do a lot better although it will never match SPI.

______
Rob
6405  Using Arduino / Project Guidance / Re: Coin Counter on: May 17, 2011, 11:26:28 am
This can be done, it just needs some deep thought.

I'm not sure a method of counting the 30 coins was proposed yet. I was going to suggest PCINTS but there are only 24 of them.

I do have an idea but it's late here, if nobody has come up with something by tomorrow morning I'll post it.


______
Rob
Pages: 1 ... 425 426 [427] 428 429 ... 580