Show Posts
Pages: 1 2 [3] 4 5 6
31  Using Arduino / General Electronics / Arduino Input 12v Opto-isolators on: February 08, 2012, 10:23:41 pm
Looking for criticism on this circuit, it takes 8 - 12v automotive input on/off signal and uses 2 opto-isolator PS2501-4A-ND to toggle 8 arduino input pins. The circuit shown is just for one of four channels of the PS2501-4A. It would be repeated 7 more times. Its a mix of other ideas I found on the web. Thanks
32  Using Arduino / General Electronics / Re: Pretected Power Supply on: February 08, 2012, 09:31:46 pm
Thanks that looks great! I'm going to try and find some in the USA. Should I still include the diode or will it be protected on-board? I'm sure the on-board caps smooth it out. Also what do you think about this one digi-key has on hand?   PN 811-2196-5-ND

http://search.digikey.com/scripts/DkSearch/dksus.dll?WT.z_header=search_go&lang=en&site=us&keywords=OKI-78SR-5&x=0&y=0
33  Using Arduino / General Electronics / Re: Pretected Power Supply on: February 08, 2012, 08:58:22 pm
Thanks for the replies. The LM7812 maybe pointless, now that I think about it. Do you have any switching regulators to recommend? I have made a boost converter circuit before, to boost a piezo buzzer from 12 to 36 volts. But probably wouldn't feel comfortable making a switching circuit for this project. 
34  Using Arduino / General Electronics / Pretected Power Supply on: February 08, 2012, 06:11:29 pm
I am making an external power supply for a Arduino and xbee. Attached is the schematic. Can someone input on the goods, bads, or changes that need to be made. The plan is to minimize the Arduino by using just the Atmel chip and crystal after prototyping. For prototyping it will have 2 opto-isolators PS2501-4A-ND, Arduino UNO, Level Logic Converter BOB-08745, Xbee series 2. Among other resistors, capacitors, and diodes. The optos are probably not necessary but are cheaper/easier/neater than using transistors for 8 inputs from +12. The power (+12) is from 12v automotive so can swing 11v-16v maybe more. I am looking for a clean protected +5v and +3.3v with minimal heat sink. I'm hoping the 12v regulator will share some "heat" that the 5v and 3.3v would have had to do with out it. Overkill is not a bad thing in my mind, considering the input voltage.

Thanks
35  Using Arduino / Programming Questions / Re: Please Help!! on: May 03, 2011, 12:18:01 am
AWOL
Quote
I'm also wondering why you're passing (or not) "interval" into "buzz"

I posted the buzz(interval) function, the reason for passing the variable was because he first just wanted set the frequency(at 50% duty) of the sound, not the duty cycle. To replace this section of code. (He also had one for 400 and one for 700)
Code:
  analogWrite(10, 128);   
  delay(100);                 
  digitalWrite(10, LOW);
  delay(100);
  analogWrite(10, 128);   
  delay(100);                 
  digitalWrite(10, LOW);
  delay(100);


blitz22
sorry for not replying to your message, Ive been in the fields 18 hours a day for the last three day. It looks like you have yours answers and can continue on with your project. If you want to use AWOL refined version of buzz() and set onTime and offTime in all your if statements. You can pass the variables when calling buzz(). Just like you did for the intervals(without know it, it seems).

buzz(int onTime, int offTime). Don't see why they would need to be long, If you stay under 30 seconds or so... If you do this don't forget to delete your constant onTime and offTime. Might have to unstatic interval.. AWOL should know for sure.

From the last page of posts it looks like it wouldn't hurt to sit down and try to understand what your code is doing. It looks like there is alot of copy paste, and not very much knowing why you are pasting it there.

Example -  (You have changed this function but you will need to know why things are where they are if your going to use my example above.) In some code you posted you call for buzz(100). But you defined "long interval = 500;" at the top of the page. buzz(100) is  on for .1 seconds then off for .1 seconds. If you want it to be .5 seconds you would use buzz(500), not separately define interval. The function makes it so you can have any length of (50% duty cycle) buzz() just by calling buzz(the interval you want).

That said here is the example to use in your if statements.
Code:
void buzz(int onTime, int offTime)
{the code in buzz}

to use, call buzz() with the times you want.
buzz(1000, 3000) this would have an on time of 1 second and off of 3 seconds.
 
36  Using Arduino / Programming Questions / Re: sensor does not trigger during the delay time. on: May 01, 2011, 12:52:28 am
Terry King,

You pretty much said what i was trying to say. Thank You.

Also Ive noticed a lot of the examples we refer people to use, could be cleaned up and "streamlined" themselves. BWD is one of them.

I think BWD is just intimidating to most people because of the length of code when you glance at it.


Code:
if(millis() - previousMillis > interval) {
    previousMillis = millis();
    ledState = !ledState;
    digitalWrite(ledPin, ledState);
}


Take out the obvious stuff and its not nearly as intimidating. (For the critics, Yes I do realize previousMillis() might not be the same as if you were to use a variable to set it)  
37  Using Arduino / Programming Questions / Re: sensor does not trigger during the delay time. on: April 30, 2011, 01:34:37 pm
@Groove

I do agree a BlinkWithoutDelay approach is the best. But im thinking back to when i first starting coding. I wouldn't have a clue how to change BWD into something could use. So i would tried other approaches that i could understand to get it todo what i want. Then refine it more and more until HUH i think i can do this "difficult" coding after all.

I was just putting another option out there, so people could learn step by step instead of trying to Run(blinkwithoutdely) before learning how to Walk(the basics of programming). Or maybe even learn how to Jump(attachInterrupt) just because. Even though my goal isn't to Jump, something i learn while Jumping might enable me to learn how to Run.

I was simply trying not to just say, "its easy, just learn BlinkWithoutDelay".
38  Using Arduino / Programming Questions / Re: sensor does not trigger during the delay time. on: April 30, 2011, 11:54:12 am
One way off the top of my head is to split up the delays. This is just an fast exapmle.

while (thisdelay < 500 && Out != 0){
delay(10);
thisdelay++;
}

This would delay for 5 seconds but check if Out has been changed every 10 millis

I added pointers to the line you wanted translated, and these are just ideas not a complete answer
39  Using Arduino / Programming Questions / Re: sensor does not trigger during the delay time. on: April 30, 2011, 11:37:00 am
@AWOL

I do not know what i was thinking when i woke up this morning.... I have changed it a little, and yes tested it now. Works great in my code, and other projects I have used it in. Dont know how it will work for him, he will just have to try and see.

I don't mean for him to use what i posted, but take the idea and make it work for him.
40  Using Arduino / Programming Questions / Re: sensor does not trigger during the delay time. on: April 30, 2011, 09:40:59 am
Your own version of blinkWithoutDelay is the best way to go. But until you learn the usage of it, try using an interrupt. Like....

Code:
         
attachInterrupt (1, breakout, RISING);       ///// Add this some where in your code, you will have to decide depending on your code

void breakout(){           //////////  Add this outside of the main loop
Out = 0;
}


When a button is pressed on pin 3, it set out to 0. So depending on where you put it(the attachInterupt), and if you redefine Out to soon(if you change the value of Out again before you use it), it should work. It looks like you have quite a bit of cleaning up to do just from what you posted. Cant really help without all the code.

http://arduino.cc/en/Reference/AttachInterrupt
41  Using Arduino / Programming Questions / Re: Way to run a program for a set number of seconds? on: April 30, 2011, 02:00:04 am
a vary simple way, would be to just add this line in your loop().

while(millis() > 210000){}

it will stop your code until you reset manually. (well unless millis() overflows but i doubt you will use it for that long)

not the best way but probably the simplest. (if you have nothing fancy in mind)

How it works:  (assuming your using a factory arduino 16mhz, with no timers changed)
millis(); reads the amount of time from when your program started.

all the below are equal.
210,000 millis
2100 seconds    1000 millis in a second
3.5 minutes    60 seconds in a minute

So ..while.. millis() ..is greater than.. 3.5 minutes.. do..{nothing}..

Millis goes over the set time and your program gets stuck in a while loop doing nothing.
42  Using Arduino / Programming Questions / Re: LED fading on: April 30, 2011, 12:46:39 am
if (fadeValue != 0){fadeValue = fadeValue-5;}

will keep them dark in your code until the loop breaks

Code:
while(sensorValue <= 15)
  {
     sensorValue = analogRead(sensorPin);
     sensorValue = map(sensorValue,0,1024,0,50);
      
     analogWrite(ledPin11, fadeValue);
     analogWrite(ledPin10, fadeValue);
     analogWrite(ledPin9, fadeValue);
     delay(20);
     fadeValue = 255;   /////////!! Delete this, you are setting fadeValue back to 255 every loop?? Then subtracting 5 in the next line??
                            /////////!!!! you will need to put it in the main loop so it resets when the loop breaks
     fadeValue = fadeValue-5;  //////////////!!!!! This is the line you want to add the if statement to.
     if(fadeValue = 0){ //If the fade reaches 0 (dark),                                       //////////!!!!!  Delete
       analogWrite(ledPin11, 0); //Then stay dark?                                            //////////!!!!!  Delete
       analogWrite(ledPin10, 0); //This doesn't work at all, the LEDs just switch off when    //////////!!!!!  Delete
       analogWrite(ledPin9, 0); //the LDR reads dark, even though fadeValue starts as 255? //////////!!!!!  Delete
     }                                                                            //////////!!!!!  Delete
   }

Adding the if statement makes it so once the fadeValue hits 0, it does not get changed until the loop break

My only guess, why it helps, is that if you -5 when the fadeValue is 0, it starts over at 255.
43  Using Arduino / Programming Questions / Re: LED fading on: April 30, 2011, 12:30:00 am
This code is simple and will fade the led's in order when your sensor falls below 16, and keep them off until the sensor rises above 15.

Code:
int fadeValuePin11 = 255;
int fadeValuePin9 = 255;

void loop()  {

  while(sensorValue <= 15)
  {
     analogWrite(ledPin11, fadeValuePin11);
     analogWrite(ledPin9, fadeValuePin9);
     delay(20);
     if (fadeValuePin11 != 0){
     fadeValuePin11 = fadeValuePin11-5;
     } else {
     if (fadeValuePin9 != 0){
     fadeValuePin9 = fadeValuePin9-5;
     }
     }
    
  sensorValue = analogRead(sensorPin);
  sensorValue = map(sensorValue,0,1024,0,50); //Map for LED.
}
  fadeValuePin11 = 255;
  fadeValuePin9 = 255;
  analogWrite(ledPin11, 255);
  analogWrite(ledPin9, 255);
  sensorValue = analogRead(sensorPin);
  sensorValue = map(sensorValue,0,1024,0,50); //Map for LED.
}
44  Using Arduino / General Electronics / Re: Piezo Buzzers. Best Option on: April 29, 2011, 11:33:46 pm
I have been reading up on the "watchdog" and its uses. I will be testing the code after i receive my 85's. So for now i have plenty of time to make the code nice and neat.

Thanks Again, I'll post when i see how it all works. And am sure will have plenty more questions once i start working on the 100 other ideas that are bouncing around in my head.
45  Using Arduino / Programming Questions / Re: Code don't do what it should do on: April 29, 2011, 10:22:30 pm
!!!!!!!!!!!!!!!    FINALLY   !!!!!!!!!!!!!!!!!!!!
Finally found your issue, although your code could use some cleaning up it will work if you add a pull-down resister to you input. This has been a big headache lol. Because if I changed your code, not even very much, I could get it to work without the pull-down. I do not know why but your code requires it.

UPDATE
I figured out most the time when i changed the code i would use a debounce in it. So it ignored the noise you are having.

Kind of interesting, when testing your code on a bare uno, i could get the led to flash, although not very brightly, but at the interval set... Just by putting my finger over the input pin..
Pages: 1 2 [3] 4 5 6