Loading...
  Show Posts
Pages: 1 ... 11 12 [13] 14 15 16
181  Using Arduino / Project Guidance / Re: Help with hooking up a power supply on: August 15, 2012, 07:29:45 am
How do you know it's 12V output. Is there a more meaningful label on the side of the PSU that gives the input/output rating of the power supply?

L = Live
N = Neutral
FG = Earth
In the UK Live is Brown, Neutral is Blue & Yellow/Green is Earth but you will have to determine the correct colours for your country.

Unfortunately the output stencil is partially obscured in the image so I cannot see if you have a +Vo & -Vo or if both are +Vo. If you have the former then be sure to connect output correctly else you may fry something important. If the latter then maybe they are different voltages.
Just take care.

Hi and thank you for replying!  This is the item that was purchased which shows it as 12V.

http://www.mpja.com/12V-35A-Ilan-Power-Supply/productinfo/16741+PS/

 I think it may say it on the unit itself somewhere but I am in the office now and don't have it to check.  I will verify that both outputs are +12V with a meter before I use it.  Thanks again for your response! smiley
182  Using Arduino / Project Guidance / Help with hooking up a power supply on: August 15, 2012, 05:40:04 am
I purchased a few of these power supplies from MPJA.com and I can't find a data sheet on it.  There is an "L", an "N", and an "FG" on one side and then a couple of "Vo" and "GND" pins on the other side.  I am assuming the "Vo" and "GND" is the regulated 12 volt out side but I want to make sure I understand where to hook up the high voltage AC side.  I would guess that "L" would stand for "Line Voltage" which would connect to a black or red wire in a plug, the "N" would stand for "Neutral" which would connect to the white wire, and "FG" would stand for "Frame Ground" which would connect to the green or bare copper wire in a plug.  Does this sound right?  Do the "GND" and "FG" connections need to be isolated from each other or does it matter?  I have a picture below of the unit.


IMAG0542 by jg1996business, on Flickr
183  Using Arduino / Programming Questions / Re: #define not working within switch case? on: August 07, 2012, 01:49:26 pm
Oops......I was programming last night and when I set up all of my #define's I did have an "=" in there.  Works now and I need to work on my attention to detail :-)

Better yet, change your programming style:
Code:
const int outOne = 10;
const int on = 11;

This gives the compiler more information and lets it do more syntax checking for you.

Thanks!  I will remember that and use it in my sketch.  I mainly just need to be able to keep the commands straight across multiple sketches because the commands will be sent from one arduino over bluetooth to be received by another arduino.  I was having trouble keeping things straight across my different sketches.
184  Using Arduino / Programming Questions / Re: #define not working within switch case? on: August 06, 2012, 08:39:56 am
Oops......I was programming last night and when I set up all of my #define's I did have an "=" in there.  Works now and I need to work on my attention to detail :-)
185  Using Arduino / Programming Questions / #define not working within switch case? on: August 05, 2012, 09:01:19 pm
if I put:

Code:
#define outOne 10
#define on 11

and then later on write:

Code:
switch(client.read()){
              case '1':
                Serial.write(outOne);
                Serial.write(on);

i get this error:

Code:
Temperature:101: error: expected primary-expression before '=' token

What am I doing wrong?

I know it is that line of code because if I change the "outOne" to the number 10 it works fine.
186  Using Arduino / Project Guidance / Re: Waiting for a byte to received in the Serial buffer before moving on on: August 05, 2012, 02:05:55 pm
Code:
while(Serial.available()>0)
{
// do an action here

}
waits for one byte, >1 will wait for 2 and so on

Here is what i did to make two arduino's talk, the RX waits for 2 bytes then actions it
http://arduino.cc/forum/index.php/topic,114239.msg859538.html#msg859538

Thanks for the guidance!  I will give that a try.  I need the system to be fairly robust because it will be controlling all of the systems on my saltwater reef tank.  I need to make sure that the command makes it through and if not it will try again a few times and finally notify me of any failure.
187  Using Arduino / Project Guidance / Re: Waiting for a byte to received in the Serial buffer before moving on on: August 04, 2012, 07:08:48 pm

while(Serial.available()) Serial.read(); //Clear the buffer

That way when you get to your wait there is definately nothing already there.


This worked!  I am trying to figure out how there is anything in the Serial buffer though.  This is the code for the Arduino Master:

Code:
//uses the iteadstudio bluetooth master/slave shield v 2.2

//http://imall.iteadstudio.com/development-platform/arduino/shields/im120417010.html

void setup() {               
  // initialize the digital pin as an output.
 
  Serial.begin(38400); 
 
 
}


void loop()
{
 
  for(int i = 0; i < 11; i++)
  {
    //clear the serial buffer
    while(Serial.available()) {Serial.read();}
   
    //send the first command to the bluetooth shield
    Serial.write(i);
   
    //wait for a response from the slave device
    while(!(Serial.available())){}
   
    delay (1000);
  }
}

and this is the code for the arduino slave:

Code:
//used the iteadstudio bluetooth shield slave v 2.1

//http://imall.iteadstudio.com/development-platform/arduino/shields/im120417006.html

#define led 13
 

void setup() {
  // initialize serial:
  Serial.begin(38400);
  pinMode(led, OUTPUT);
  // reserve 200 bytes for the inputString:
  //inputString.reserve(50);
}

void loop()
{
  
  //wait for a command
  while(!(Serial.available()));
  
  //read the command
  int i = Serial.read();
  
  //blink the led
  for(int j = 0; j < i; j++)
  {
    digitalWrite(led,HIGH);
    delay(200);
    digitalWrite(led, LOW);
    delay(200);
    
  }
    
    //let the master know that you are ready for another command
    Serial.write(1);
}


188  Using Arduino / Project Guidance / Re: Waiting for a byte to received in the Serial buffer before moving on on: August 04, 2012, 06:43:39 pm
if there is nothing in the buffer, Serial.read() returns 0xFF (255).

Code:
while(!Serial.available());
is indeed correct (what you wrote is equivalent). What it suggests is that there is already something in the buffer. Before that section of code, you could try this:

while(Serial.available()) Serial.read(); //Clear the buffer

That way when you get to your wait there is definately nothing already there.

I will give that a try.  Thanks!
189  Using Arduino / Project Guidance / Re: Waiting for a byte to received in the Serial buffer before moving on on: August 04, 2012, 06:42:51 pm



It's not a particularly good way top handle serial port input,l but if you want your sketch to wait and do nothing until input arrives on the serial port, that while loop will do it.

What would be a better way to wait for serial data to show up?  The objective is to have two arduino's talk to each other over bluetooth.  To coordinate their activities I want to make sure the master device waits until the slave device has finished executing a command before sending another command.  So it will send a command over bluetooth (by writing to the serial port) and then wait for the slave device to respond with a '1' (not ascii...just a byte) and then it will send the next command.
190  Using Arduino / Project Guidance / Waiting for a byte to received in the Serial buffer before moving on on: August 04, 2012, 05:47:03 pm
I have tried:

Code:
while(!(Serial.available())){}

but the code seems to be rolling right over that.  There shouldn't be anything in the serial buffer at that point in the code.  On a sort of related note:

Code:
Serial.read();

should empty a byte from the buffer shouldn't it?
191  Using Arduino / Project Guidance / Re: Code to have two arduinos talk to each other over bluetooth on: August 02, 2012, 10:33:32 am
As soon as it sends a "1" back though it should break the Master out of that loop and in to the master's "while(1)" loop shouldn't it?

Yes but the damage has already been done. If the slave ever has more than one byte in its buffer it will never clear out those bytes faster than the master sends more.

The fix might be as simple as:

Code:
//If you receive a 1 respond with a 1
    if (Serial.read()==1){
      Serial.write(1);
      while (Serial.read()) {} // <---------------------------
    }

Nice!  I will try that.  I'm surprised that in the Serial library there isn't a Serial.purge or something to empty the buffer :-)
192  Using Arduino / Project Guidance / Re: Code to have two arduinos talk to each other over bluetooth on: August 02, 2012, 10:04:53 am
In the master:

Code:
void loop() {
 
  //Query device and wait for a response
  while(!(Serial.available()))
  {
    delay(20);
    Serial.write(1);
  }

It's sending "1"s every 20ms. If it manages to send more than one before the slave can respond then the slave will store the extra in its buffer. Your slave will never purge its buffer but instead, in the main loop, keep asking for another "1" after each is processed.


Thanks!  I will increase the delay and see what happens.  I think what you are saying is that the slaves Serial Buffer is filling up with a bunch of 1's and it is trying to work through all of those.  As soon as it sends a "1" back though it should break the Master out of that loop and in to the master's "while(1)" loop shouldn't it?
193  Using Arduino / Project Guidance / Re: Code to have two arduinos talk to each other over bluetooth on: August 02, 2012, 09:05:22 am
Does anyone see any thing?  I can explain what is supposed to happen more clearly.

1. Slave waits for the master to contact
2.  Master sends a '1' integer (not ascii) and waits for a response
3.  Slave receives the '1' and responds with a '1' to let the master know that it is there
4.  Master sends an integer (again not in ascii) and waits for the slave to sent a '1' to let the master know that the command has been executed
5.  Slave receives the integer and blinks its LED whatever number of times the master requested.  Then sends a '1' to notify the master that the command has been executed.
6.  Master receives '1' from the slave and sends the next integer and again wait for a '1' to come back
7.  Slave receives the integer from the master and blinks the led.....etc.

So the communication would go something like this:

Master Sends '1'
Slave Sends '1'
Master Sends '5'
Slave blinks the led 5 times and then send '1'
Master Sends '6'
Slave blinks the led 6 times and then send '1'
Master Sends '7'
Slave blinks the led 7 times and then send '1'
and so on
194  Using Arduino / Project Guidance / Re: Wireless arduino on: August 02, 2012, 08:57:22 am
Just break the big complicated project down into a lot of small easy steps and get them working one at a time.  That is how I have been tackling my projects as I am very much an amateur with this.
195  Using Arduino / Project Guidance / Code to have two arduinos talk to each other over bluetooth on: August 01, 2012, 08:58:17 pm
Hello,

So far I have been able to get things to work in terms of communication between two arduinos but it has been using delays to give the slave device time to execute a request.  Now I would like to use a query/response type of system where the master sends a 1 and waits to receive a 1 before sending its first request.  Then it waits to receive a 1 from the slave before sending the next request.  Right now it is just sending numbers that the slave will use to blink the pin13 led.  When I run it the LED pin just blinks continuously rather than once, twice, three times, and so on.  Hopefully someone can help me spot my problem in my logic.  The Master code is:
Code:
void setup() {               
  // initialize the digital pin as an output.
 
  Serial.begin(38400); 
 
}


void loop() {
 
  //Query device and wait for a response
  while(!(Serial.available()))
  {
    delay(20);
    Serial.write(1);
  }
  //Once we get a response begin sending data
  if(Serial.read() == 1){
    while(1)
    {
 
    for(int i = 1; i<11; i++)
      {
        Serial.write(i);
       
        //wait to get a response back from the slave saying
        //that the command was executed
        while(!(Serial.available())){}
        if(Serial.read() == 1)
        {
          delay(500);
        }
       
       
      }
    }
  }
}

and the Slave code is:
Code:
#define led 13


void setup() {
  // initialize serial:
  Serial.begin(38400);
  pinMode(led, OUTPUT);
 
}

void loop() {
  // wait for a query from the master
  while(!(Serial.available())){}
 
  //If you receive a 1 respond with a 1
    if (Serial.read()==1){
      Serial.write(1);
    }
    while(1){
    //wait for the data to come in
    while(!(Serial.available())){}
      int i = Serial.read();
    for(int j = 0; j < i; j++)
    {
      digitalWrite(led,HIGH);
      delay(200);
      digitalWrite(led, LOW);
      delay(200);
     
    }
    //send a 1 to notify the master that the command has been executed
    Serial.write(1);
    }
  }
Pages: 1 ... 11 12 [13] 14 15 16