Show Posts
Pages: 1 ... 11 12 [13] 14 15 ... 18
181  Using Arduino / Project Guidance / Re: How to use the Maestro A2035-H GPS receiver on: December 07, 2012, 03:04:54 pm
It just starts spitting out NMEA data and they work good I use them for time stamping timing critical events on remote nets.  If you contact tech support with Maestro you email with "Larry" and this is not much better than the manual but once he understands what you want and stops telling you really basic things off his troubleshooting sheet you get what you need from someone behind the curtain.  Given the $20 cost for a fully functional GOS with PPS it is a great deal, even with the poor docs. 

They are surface mount parts but hand solder very easily.

Regarding the shutdown shutdown stuff I just wait the second  then shutdown power.

Thank you so much for responding to my question!  So when you say that you just shutdown power after a second, is this after you do the 200ms high/low pulse on the ON_OFF pin or do you just wait for the wakeup pin to go low and then count 1 second after that?
182  Using Arduino / Project Guidance / Re: How to use the Maestro A2035-H GPS receiver on: December 07, 2012, 02:11:55 pm
Well I am sort of figuring some of this stuff out, but can someone tell me what the phrase "According messages either in NMEA or OSP mode"  below means?

10.2 Proper Shutdown
The A2100-A/B modules require an orderly shutdown process to properly stop internal operation and complete any writes of critical data to BBRAM or Flash memory
data area. Abrupt removal or drop of main power while the system is running has
risks ranging from minor impact on TTFF to  fatal, permanent corruption of flash
memory code area on the module.
A controlled and orderly shutdown while the A2100-A/B is running in full power mode can be initiated by

• A 200ms pulse on the ON_OFF pin, 
• According messages either in NMEA or OSP mode.

The shutdown is completed after maximum 1s. Therefore the module should be
supplied with voltage for that time after the shutdown sequence was initiated.
183  Using Arduino / Project Guidance / How to use the Maestro A2035-H GPS receiver on: December 06, 2012, 08:57:52 pm
I am trying to put together a GPS tracker for my wife to wear while running.  Something that she can plug into the serial monitor afterwards and it will tell her how far she went.  I've noticed that most GPS receivers are pretty expensive ($60 bucks or so) but I found this one on Mouser that is less than $20:

http://www.mouser.com/ProductDetail/Maestro-Wireless-Solutions/A2035-H/?qs=sGAEpiMZZMsjLMBIknjmkmGnNGCc2NtPB414YcTShow%3d

I read this user guide:

http://www.mouser.com/catalog/specsheets/GPS_Receiver_A2035_H_V11[1].pdf

but I don't understand if there is a command set associated with it or if it just starts spitting out position data as soon as it is woken up.  Is there something that I am missing here?
184  Using Arduino / Programming Questions / Re: I'm starting to feel like I have made a Rube Goldberg device on: October 28, 2012, 06:48:42 pm
2.

Code:
    pinMode(i,INPUT);
    digitalWrite(i,On);

Simpler to use:

Code:
   pinMode(i, INPUT_PULLUP);

instead.

Cool!  I didn't know that you could do that.  Good to know.

Quote
3.

Code:
  //set D11 through D16 as OUTPUTS and initialize to logic high
  //which turns the relay off...logic low turns the relay on
  for(int i = 11; i<17; i++)
  {
    pinMode(i,OUTPUT);
    digitalWrite(i, Off);
  }

Better to write the data before setting the pin to be an output, to avoid getting a negative going glitch when using active-low relays:

Code:
  //set D11 through D16 as OUTPUTS and initialize to logic high
  //which turns the relay off...logic low turns the relay on
  for(int i = 11; i<17; i++)
  {
    digitalWrite(i, RelayOff);
    pinMode(i,OUTPUT);
  }


I remember from coding on AVR Studio that this was appropriate because you want to initialize the pins to a known state before exposing them by setting the data direction register.  However, it wasn't working on the arduino so I posted a question on this forum and received a reply that suggested that pinMode initializes the pins to LOW regardless of the state that they were in prior to calling pinMode.  It is under reply #1 on this thread:

http://arduino.cc/forum/index.php/topic,126021.msg948126.html#msg948126

Am I still missing something?

Quote
3. Change:

Code:
Serial.println("Add Salt = True")

to:

Code:
Serial.println(F("Add Salt = True"))

and similarly everywhere else you print a string literal. It saves RAM, which is precious on an Arduino.

I have just started noticing the println(F(...)).  Is this just an alternative to using PROGMEM....not that I have ever even used it?  I could be way off here.
185  Using Arduino / Programming Questions / Re: I'm starting to feel like I have made a Rube Goldberg device on: October 28, 2012, 04:26:34 pm
Not sure I understand.  Do you mean something like this?

Code:
#define RelayTypeOneOn HIGH
#define RelayTypeTwoOn LOW
#define RelayTypeOneOff LOW
#define RelayTypeTwoOff HIGH

const int relayPin = 3

void setup()
{
     digitalWrite(relayPin, RelayTypeOneOn);

}
186  Using Arduino / Programming Questions / Re: I'm starting to feel like I have made a Rube Goldberg device on: October 28, 2012, 03:01:32 pm
Thanks PaulS!  Exactly the kind of advice that I love to get.  I will clean up my code with all of your suggestions.  The only one that I am hesitant on is your first suggestion.  I defined "On" and "Off" at the beginning of the sketch to be "HIGH" and "LOW" respectively because I unfortunately purchased two different types of relay boards.  One type turns the relay on with an active high signal and the other type turns the relay on with an active low signal.  I wanted to make it simple to switch between the two if need be by simply changing the #define at the beginning of the sketch rather than having to go through the entire sketch and change all the HIGH's to LOW's and LOW's to HIGH's.  I guess I could use a find and replace if I needed to.  Thoughts?
187  Using Arduino / Programming Questions / I'm starting to feel like I have made a Rube Goldberg device on: October 28, 2012, 01:13:34 pm
I am trying to automate all of the water handling functions of my aquarium (yes another person trying to make an aquarium controller).  It should be able to keep my filtered freshwater reservoir full, keep my sump topped off from the freshwater reservoir, and perform a complete water change which consists of filling a saltwater mixing reservoir, notifying the user to add salt, mixing for a specified period of time, topping off the sump before draining it, draining the sump, and then pumping in the new saltwater.  It all makes perfect sense in my head but I am starting to feel like it is becoming a mess.  I would love to hear some critique of my code.  Here it is in all of its glory:

Code:
#define On HIGH
#define Off LOW

boolean freshwater_fill_flag = false; //freshwater is topping off flag    `
boolean saltwater_fill_flag = false;
boolean sump_fill_flag = false; //sump needs topping off flag
boolean water_change_flag = false; //water change in process
boolean add_salt_flag = false; //add salt request sent to user..wait for flag to be cleared
boolean mix_saltwater_flag = false; //saltwater mixing in process
boolean drain_sump_flag = false; //sump draining in process
boolean fill_sump_from_reservoir_flag = false; //sump filling in process
int wc_stage = 0;
const int freshwater_high_float_switch = 2;
const int freshwater_fill_float_switch = 3;
const int freshwater_low_float_switch = 4;
const int saltwater_high_float_switch = 5;
const int saltwater_low_float_switch = 6;
const int sump_high_float_switch = 7;
const int sump_fill_float_switch = 8;
const int sump_low_float_switch = 9;
const int salt_added_button = 10;
const int fresh_to_sump_pump = 11;
const int fresh_to_salt_pump = 12;
const int sump_to_drain_pump = 13;
const int salt_to_sump_pump = 14;
const int freshwater_relay_valve = 15;
const int saltwater_mixer = 16;
unsigned long mixTime;



void setup()
{
 
 
  Serial.begin(115200);
  //set D2 through D10 as input with weak pullup enabled
  for(int i = 2; i<11; i++)
  {
    pinMode(i,INPUT);
    digitalWrite(i,On);
  }
  //set D11 through D16 as OUTPUTS and initialize to logic high
  //which turns the relay off...logic low turns the relay on
  for(int i = 11; i<17; i++)
  {
    pinMode(i,OUTPUT);
    digitalWrite(i, Off);
  }
 
}

void loop()
{
  freshwater_level();
  sump_level();
  water_change();
}



void freshwater_level()
{
  //if freshwater fill float switch is logic low and if freshwater high
  //float switch is logic low and if freshwater filling flag is not set
  //then set it and turn the water filter on

  if(digitalRead(freshwater_fill_float_switch) == false &&
     freshwater_fill_flag == false &&
     digitalRead(freshwater_high_float_switch) == false)
     {
       freshwater_fill_flag = true;
       digitalWrite(freshwater_relay_valve, On); //turns the water on
       Serial.println("fill flag = true");
       Serial.println("freshwater relay = on");
     }
 
  //if freshwater high float switch is logic high and if freshwater
  //filling flag is set, then freshwater filling flag is false and turn the
  //water filter off
 
  if(digitalRead(freshwater_high_float_switch) == true &&
     freshwater_fill_flag == true)
  {
    freshwater_fill_flag = false;
    digitalWrite(freshwater_relay_valve, Off); //turns the water off
    Serial.println("fill flag = false");
    Serial.println("relay is off");
  }
 
}

void sump_level()
{
  //if sump fill float switch is logic low and if sump high
  //float switch is logic low and if sump filling flag is not set
  //then set it and turn the freshwater topoff pump on. 
  //However, if the freshwater low float switch is logic low,
  //then shut the pump off until the freshwater is replenished
  //to avoid burning it up
 
  if(digitalRead(freshwater_low_float_switch) == false &&
           sump_fill_flag == true)
          {
            digitalWrite(fresh_to_sump_pump, Off);
            sump_fill_flag == false;
          }
         

  if(digitalRead(sump_fill_float_switch) == false &&
     sump_fill_flag == false &&
     digitalRead(sump_high_float_switch) == false &&
     digitalRead(freshwater_low_float_switch) == true &&
     drain_sump_flag == false) //drain sump flag suppresses this function if
                               //the sump is low as a result of a water change
                               //that is in progress
     {
       sump_fill_flag = true;
       digitalWrite(fresh_to_sump_pump, On); //turns the water on
     }
 
  //if sump high float switch is logic high and if sump
  //filling flag is set, then filling flag is false and turn the
  //sump freshwater topoff pump off
 
  if(digitalRead(sump_high_float_switch) == true &&
     sump_fill_flag == true)
  {
    sump_fill_flag = false;
    digitalWrite(fresh_to_sump_pump, Off); //turns the water off
  }
 
}


void water_change()
{
 
  if(water_change_flag == true)
  {
    switch(wc_stage)
    {
      case 0: //top off freshwater reservoir
       if(freshwater_fill_flag == false &&
       digitalRead(freshwater_high_float_switch) == false)
        {
          freshwater_fill_flag = true;
          digitalWrite(freshwater_relay_valve, On); //turns the water on
        }
       
        if(digitalRead(freshwater_high_float_switch) == true)
        {
          wc_stage = 1;
        }
        break;
       
      case 1: //fill saltwater reservoir
        if(digitalRead(freshwater_low_float_switch) == false &&
         saltwater_fill_flag == true)
        {
          digitalWrite(fresh_to_salt_pump, Off);
          saltwater_fill_flag == false;
          break;
        }
        if(digitalRead(saltwater_high_float_switch) == false &&
        saltwater_fill_flag == false &&
        digitalRead(freshwater_low_float_switch) == true)
        {
          saltwater_fill_flag == true;
          digitalWrite(fresh_to_salt_pump, On);
        }
        if(digitalRead(saltwater_high_float_switch) == true)
        {
          saltwater_fill_flag == false;
          digitalWrite(fresh_to_salt_pump, Off);
          wc_stage = 2;
        }
        break;
       
      case 2: //add salt
        if(add_salt_flag == false)
        {
          Serial.println("Add Salt = True");
          add_salt_flag = true;
        }
        if(digitalRead(salt_added_button) == false) //push when salt is added
        {
          add_salt_flag = false;
          wc_stage = 3;
        }
        break;
       
      case 3: //mix saltwater
        if(mix_saltwater_flag == false)
        {
          mix_saltwater_flag = true;
          mixTime = millis() + 600000;
          digitalWrite(saltwater_mixer, On);
        }
       
        if(timer(mixTime))
        {
          mix_saltwater_flag = false;
          digitalWrite(saltwater_mixer, Off);
          wc_stage = 4;
        }
        break;
       
      case 4: //top off sump
        if(digitalRead(sump_high_float_switch) == false &&
         sump_fill_flag == false &&
         digitalRead(freshwater_low_float_switch) == true)
        {
          sump_fill_flag = true;
          digitalWrite(fresh_to_sump_pump, On);
        }
       
        if(digitalRead(sump_high_float_switch) == true)
        {
          wc_stage = 5;
        }
        break;
       
      case 5: //drain sump
        if(drain_sump_flag == false)
        {
          drain_sump_flag == true;
          digitalWrite(sump_to_drain_pump, On);
        }
        if(digitalRead(sump_low_float_switch) == false)
        {
          digitalWrite(sump_to_drain_pump, Off);
          wc_stage = 6;
        }
        break;
       
      case 6: //fill sump but don't let the saltwater reservoir run dry
        if(fill_sump_from_reservoir_flag == true &&
        digitalRead(saltwater_low_float_switch == false))
        {
          fill_sump_from_reservoir_flag = false;
          digitalWrite(salt_to_sump_pump, Off);
        }
       
        if(fill_sump_from_reservoir_flag == false &&
        digitalRead(saltwater_low_float_switch == true))
        {
          fill_sump_from_reservoir_flag = true;
          digitalWrite(salt_to_sump_pump, On);
        }
       
        if(digitalRead(sump_high_float_switch) == true)
        {
          digitalWrite(salt_to_sump_pump, Off);
          drain_sump_flag = false;
          wc_stage = 7;
        }
        break;
       
      case 7: //clean up
        //send message to user notifying them of a completed water change
        wc_stage = 0;
        water_change_flag = false;
       
    }
  }
 
 
}

//keep track of time and handle millis() rollover
boolean timer(unsigned long timeout)
  {
    return (long)(millis() - timeout) >= 0;
  }
188  Using Arduino / Project Guidance / Re: Arduino Android bike computer on: October 26, 2012, 12:43:25 pm
For programming the android I would start with this:
http://www.youtube.com/course?list=ECB03EA9545DD188C3&feature=plcp

It brought me up to speed pretty quickly.  Just work your way through all of the videos.  Don't just watch the video.....actually work right along with him on your own system duplicating everything that he does.
189  Using Arduino / Programming Questions / Re: Question about "break;" on: October 20, 2012, 01:30:15 pm
"break;"
Jumps to the end of the following that the statements:
switch(){}
for(){}
while(){}
do{}while();

If it is contained within more than one of those statements it moves one step out (for lack of a better way of saying it).

This is perfect!  Thanks!  So it sounds like my code will do what I want it to do which is exit the switch case imeediately if the first "if" statement is true.
190  Using Arduino / Programming Questions / Re: Question about "break;" on: October 20, 2012, 11:34:18 am

you should be able to write a simple test program to just check that behaviour.

BTW you miss a break in the second if.



I can put a break in, but it isn't needed because there shouldn't be an instance where both of those are true at the same time.  I need it on the first "If" statement because the first and second "if" statements will likely be true at the same time and the second "if" statement undoes the first "If" statements action.
191  Using Arduino / Programming Questions / Question about "break;" on: October 20, 2012, 10:19:19 am
If I have this segment of a switch case routine:

Code:
case 1: //fill saltwater reservoir
        if(digitalRead(freshwater_low_float_switch) == false &&
         saltwater_fill_flag == true)
        {
          digitalWrite(fresh_to_salt_pump, Off)
          saltwater_fill_flag == false;
          break;
        }
        if(digitalRead(saltwater_high_float_switch) == false &&
        saltwater_fill_flag == false)
        {
          saltwater_fill_flag == true;
          digitalWrite(fresh_to_salt_pump, On);
        }
        if(digitalRead(saltwater_high_float_switch) == true)
        {
          saltwater_fill_flag == false;
          digitalWrite(fresh_to_salt_pump, Off);
          wc_stage = 2;
        }
        break;

I know that the "break;" at the very end will cause the program to leave the switch case routine, but will the "break;" at the end of the first "If" statement cause the program to break out of the switch case or just the "If" statement?  Basically if the first "If" statement evaluates to "true", I want it to leave the switch case and not continue on into the following "If" statements.  Would a "return;" be better in this case?
192  Using Arduino / Project Guidance / Re: Help Needed: Android Controlled 8 Channel Relay on: October 19, 2012, 09:00:54 pm
For this project, bluetooth makes more sense.  I am going to be showing something off at work and the network is pretty restricted.

I'd be very interested to see if you have success with pairing your phone and this shield.

I was able to pair with the HC-05 device through my android phone.  It is the same device that MuttDriver listed but in a arduino friendly format....i.e. a shield.  This is what I have:  http://imall.iteadstudio.com/development-platform/arduino/shields/im120417010.html
193  Using Arduino / Project Guidance / Re: What i need in order to rotate 60° right and then 60° left (back) ? on: October 19, 2012, 10:45:45 am
Probably a stepper motor or a servo

this for example ? https://www.sparkfun.com/products/9065 and it needs 1 pin to control its direction ??

thanks

I am confused.  Are we talking "windows" as in the windows in a house......i.e. the things that typically require a reasonable to significant amount of force to open and close?  If so, that servo won't even come close to having the torque needed.
194  Using Arduino / Project Guidance / Re: What i need in order to rotate 60° right and then 60° left (back) ? on: October 19, 2012, 10:28:51 am
Probably a stepper motor or a servo
195  Using Arduino / Project Guidance / Re: Aquarium Auto Top Off Fail safe on: October 19, 2012, 09:21:10 am
I'd make the emergency float switch physically interrupt the pump power, so the pump will be shut off even if the Arduino or the sketch is non-functioning.
Having an emergency switch pass through software is scary ;-)

Really good point and something that I should probably implement with my setup.  I was thinking more about the possibility of a malfuntioning float switch (i.e. a snail deciding to crawl on it and holding it in the down position) without even considering a software problem.  Just make sure that you don't run the pump current through the float switch.  Pick up a 5v solenoid and use the float switch to trigger the solenoid on and off.  Run the pump current through the solenoid.
Pages: 1 ... 11 12 [13] 14 15 ... 18