Show Posts
Pages: [1] 2 3 ... 20
1  Using Arduino / Project Guidance / Re: Internal Pullup sufficient for long wire length? on: May 10, 2014, 06:52:29 pm
Why change it if you haven't even tested it ? Wait till there is a problem before implementing solutions.

My current setup uses the internal pull-ups on an arduino nano and I've noticed that occasionally when one of the 120V pumps comes on it will cause some jitter on the line and sometimes it will even fire off the subroutine attached to that particular float switch.
2  Using Arduino / Project Guidance / Re: Internal Pullup sufficient for long wire length? on: May 10, 2014, 06:49:23 pm
Yes, I would use 1K external pull-up to try and keep noise down.


That was my thought as well but I wasn't sure if it was overkill.  Thanks!
3  Using Arduino / Project Guidance / Internal Pullup sufficient for long wire length? on: May 10, 2014, 06:16:16 pm
I have some float switches on my aquarium sump that I want to monitor.  The wire length is approximately 15 feet between the float switch and the arduino.  Is the internal pull-ups on the arduino sufficient for this length of wire or should I use an external pull-up resistor on each line….perhaps something that is a lower value than the internal pull-ups?
4  Using Arduino / Programming Questions / Re: Reading in serial data and using strcmp on: May 07, 2014, 05:41:03 pm
Well I managed to figure it out thanks to all of the great replies on this thread!  Basically I had set up a situation where at least one of those conditional statements would always evaluate to true and reset my string builder.  I changed the function to:

Code:
//this just reads data in one character at a time until we have a complete sentence
boolean checkforSentence()
{
  char c;
  while(mySerial.available())
  {
    last_data_received = millis() + 2000;
    c = mySerial.read();
    //Serial.print(c);
   
    if(sentenceBegins && c == '\r') //we have a full sentence
    {
      sentenceBegins = false;
      Serial.println(buffer);
      return true;
    }
   
    if(sentenceBegins) //store characters to buffer
    {
      buffer[index] = c;
      index++;
      buffer[index] = '\0';
      /*
      we need something to segregate out the RMC and GGA sentences and ignore
      everything else.  Originally I was sending a command to the GPS to
      only send the string that I was interested in, but for some reason the GPS
      is not accepting my commands anymore.  It happened pretty suddenly so f'
      it.  I will just ignore everything that I don't want to see.
      */
      if(index==5)
      {
        if(data_index==true)
        {
          if(!(strcmp(buffer, "GPGGA") == 0))
          {
            sentenceBegins = false;
            //Serial.println(buffer);
          }
        }
       
        if(data_index==false)
        {
          if(!(strcmp(buffer, "GPRMC") == 0))
          {
            sentenceBegins = false;
            //Serial.println(buffer);
          }
        }
      }
    }
   
    if(c == '$') //beginning of sentence...start saving to buffer
    {
      sentenceBegins = true;
      index = 0;
    }
   
  }
  return false;
}

which works great now!
5  Using Arduino / Programming Questions / Re: Reading in serial data and using strcmp on: May 07, 2014, 07:26:07 am
I think it needs null terminated strings.

If you just want to compare a few characters maybe the simplest thing would be to write your own function.

...R

It is null terminated. 

Code:
if(sentenceBegins) //store characters to buffer
    {
      buffer[index] = c;
      index++;
      buffer[index] = '\0';

Each increment adds the null termination.  In this case, the null termination would be at buffer[5] when the strcmp happens.
6  Using Arduino / Programming Questions / Re: Reading in serial data and using strcmp on: May 07, 2014, 07:24:09 am
Code:
'GPRMC'
BZZZT

I tried:
Code:
if(!(strcmp(buffer, 'GPRMC') == 0 && data_index == false))

and got the error message:

Code:
invalid conversion from 'int' to 'const char*'
7  Using Arduino / Programming Questions / Reading in serial data and using strcmp on: May 07, 2014, 06:56:20 am
I have a function that reads in the NMEA strings from a GPS module.  In order to just focus on the data that I am interested in I read in the first 5 characters and then perform a strcmp to determine if it is the appropriate sentence.  If not it ignores the rest of the sentence.  Here is the function:

Code:
//this just reads data in one character at a time until we have a complete sentence
boolean checkforSentence()
{
  char c;
  while(mySerial.available())
  {
    last_data_received = millis() + 2000;
    c = mySerial.read();
    //Serial.print(c);
   
    if(sentenceBegins && c == '\r') //we have a full sentence
    {
      sentenceBegins = false;
      Serial.println(buffer);
      return true;
    }
   
    if(sentenceBegins) //store characters to buffer
    {
      buffer[index] = c;
      index++;
      buffer[index] = '\0';
      /*
      we need something to segregate out the RMC and GGA sentences and ignore
      everything else.  Originally I was sending a command to the GPS to
      only send the string that I was interested in, but for some reason the GPS
      is not accepting my commands anymore.  It happened pretty suddenly so f'
      it.  I will just ignore everything that I don't want to see.
      */
      if(index==5)
      {
        if(!(strcmp(buffer, "GPGGA") == 0 && data_index==true))
        {
          sentenceBegins = false;
          Serial.println(buffer);
        }
        if(!(strcmp(buffer, "GPRMC") == 0 && data_index == false))
        {
          sentenceBegins = false;
          Serial.println(buffer);
        }
      }
    }
   
    if(c == '$') //beginning of sentence...start saving to buffer
    {
      sentenceBegins = true;
      index = 0;
    }
   
  }
  return false;
}

I have a feeling strcmp may be looking for a new line and carriage return character at the end of buffer but doing this:

Code:
if(!(strcmp(buffer, 'GPRMC') == 0 && data_index == false))

results in:

Code:
invalid conversion from 'int' to 'const char*'

The result of the Serial.println is:

Code:
GPGGA
GPGGA
GPGSA
GPGSA
GPGSV
GPGSV
GPRMC
GPGGA
GPGGA
GPGSA
GPGSA
GPGSV
GPGSV
GPRMC

which suggests that it is checking the appropriate number of characters.  Any suggestions?
8  Using Arduino / Project Guidance / UP501 GPS module stopped accepting commands on: May 01, 2014, 07:02:37 am
I have a board that uses an UP501 GPS module.  My script sends a command that will make the UP501 only send out the RMC NMEA strings.  It worked fine for a time but now all of a sudden it stopped accepting the commands and sends out all of the strings.  I have verified that the micro controller is sending out the command which is:

Code:
mySerial.println("$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0*35");

The reason I am concerned is that this is the 3rd GPS module that worked fine for a while and then stopped accepting commands.  The first two were Maestro A2035 receivers and this one is a Fastrax UP501.  Has anyone else had this problem with GPS modules?
9  Using Arduino / Programming Questions / Re: GPS Help - Not Getting Expected Data Out on: April 28, 2014, 06:21:45 am


I've attached picture

Unfortunately Sparkfun doesn't link that board to the correct user manual online.  The link goes to the newer board that they sell.  Not sure how that makes any sense.  The manual on the newer board:  https://www.sparkfun.com/tutorials/173 says that there is a solder jumper that has to be desoldered to use DLINE.  Not sure if the board that you have needs that.  Also, are you using D2 and D3 on the arduino for any other purposes?  Have you tried a simple sketch just to make sure that you are getting what you expect to get out of the UART on the Arduino.  Something like "Hello World"?

Code:
void setup()
{
  Serial.begin(115200);
}

void loop()
{
  Serial.println("Hello World!");
  delay(1000);
}

If you aren't seeing the words "Hello World" repeating every second on your serial monitor then you need to fix that first before moving on to reading the GPS strings.  Seriously you need to do this…..open up a new sketch, copy the hello world sketch into it, compile, program, and run and verify that you are getting the words "Hello World" on your screen. 
10  Using Arduino / Programming Questions / Re: GPS Help - Not Getting Expected Data Out on: April 27, 2014, 06:47:41 pm
Quote
Go back to the code you used for that post and instead of using digitalRead(gpsTX), use an appropriately modified form of the following  (where Serial3 is assigned in Setup to the GPS unit):


Getting the following error when compiling .
Quote
error: 'a' was not declared in this scope

after I go this error I tried putting the following into setup() but got same error message.
Code:
int a = 0

you don't put it in setup.  Put it before setup.  Also it isn't an int.  It should be a character.
you need:

Code:
char a;

I've never used the mega but I am guessing that if you have the GPS connected to TX3 and RX3 properly then my simple sketch that I posted above should be streaming out NMEA strings through the serial monitor as soon as you turn it on.  Make sure you have GPS TX to Mega RX3 and GPS RX to Mega TX3.  Can you post a picture of your setup?
11  Using Arduino / Programming Questions / Re: GPS Help - Not Getting Expected Data Out on: April 27, 2014, 03:24:56 pm
Have you tried something really simply just to see what is coming out of the GPS?  Something like:

Code:
char a;

void setup()
{
  Serial3.begin(115200);
  Serial.begin(115200);
}
void loop()
{
  while(Serial3.available())
  {
    a = Serial3.read();
    Serial.print(a);
  }
}
12  Using Arduino / Programming Questions / Trouble using ADC6 on a pro mini on: April 27, 2014, 02:48:15 pm
I've built my own board that uses a TQFP Atmega328p and I am using ADC6 as a battery voltage meter.  It is hooked up to a simple voltage divider.  I used an identical pinout on my board as is used on the Arduino Pro Mini - 3.3V 8MHZ version.  My understanding is that the pro mini has A6 and A7 broken out on the board (well actually I know it does because I have one) and therefore selecting pro-mini as the board when programming should allow me to use A6.  So far I have had no joy.  The function that uses A6 is simply:

Code:
void check_battery()
{ //282 is the difference in value between 980 (4.2V full charge)
  //and 698 (3.0V empty charge).  We display the percent remaining.
 
  b = 0;
  for(int i = 0; i<10; i++)
  {
    b+=analogRead(A6);
    Serial.println(b);
   
  }
  b = b/10;
  Serial.println(b);
  b = (((b-698)*100)/282);
  Serial.println(b);
}

I also tried using:
Code:
analogRead(6)
but it still didn't work.  It just reads in a value of zero.

I notice in the boards.txt file that the arduino pro mini 328 3.3v 8mhz block shows the board variant as "standard".  Should it instead be "eightanaloginputs"?  I tried changing it in the .txt file to no effect.  Not sure what else may need to be changed if anything.

Code:
pro328.name=Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328

pro328.upload.protocol=arduino
pro328.upload.maximum_size=30720
pro328.upload.speed=57600

pro328.bootloader.low_fuses=0xFF
pro328.bootloader.high_fuses=0xDA
pro328.bootloader.extended_fuses=0x05
pro328.bootloader.path=atmega
pro328.bootloader.file=ATmegaBOOT_168_atmega328_pro_8MHz.hex
pro328.bootloader.unlock_bits=0x3F
pro328.bootloader.lock_bits=0x0F

pro328.build.mcu=atmega328p
pro328.build.f_cpu=8000000L
pro328.build.core=arduino
pro328.build.variant=standard
13  Using Arduino / Project Guidance / Re: Addressing analog pins on the arduino pro mini on: April 21, 2014, 08:45:49 pm
This is fantastic!  The code that I posted above seems to work.  The display turns off completely now.  I haven't checked the voltage to confirm that it is zero but it looks very positive that it is.  Thanks everyone for all of the advice!
14  Using Arduino / Project Guidance / Re: Addressing analog pins on the arduino pro mini on: April 21, 2014, 07:31:43 pm
Bring the arduin's output lines low, then turn off power.
Maybe use SPI.end();
then digitalWrite the 4 pins low. CS for sure, the others may be already depending on what SPI mode you are using.
When powering back up, bring up power first, then SPI.begin(), and CS back high.

The u8glib library seems to have its own SPI initialization routine that I can't find in any of the .c or .h files.  I'm a bit concerned about changing the data direction registers and port registers without knowing what their values are supposed to be.  Given this concern, is it reasonable to do something like this:

Code:
  byte ddrcValue = 0;
  byte portcValue = 0;
  //store current value of DDRC and PORTC
  ddrcValue = DDRC;
  portcValue = PORTC;
  DDRC &= ~0b00011111; //clear all of the bits corresponding to SPI
  PORTC &= ~0b00011111;
  digitalWrite(A5, HIGH);  //turns off the GPS and Display
  sleep_enable();
  attachInterrupt(0, button_press, LOW);
  set_sleep_mode(SLEEP_MODE_PWR_DOWN);
  power_adc_disable();
  Serial.println("I'm Asleep");
  Serial.flush();
  sleep_cpu();
 
  //code starts back up here after wake up
  Serial.println("I'm awake");
  sleep_disable();
  DDRC |= ddrcValue;  //set DDRC and PORTC back to its pre-sleep state
  PORTC |= portcValue;
  digitalWrite(A5, LOW);  //turns on the GPS and Display
15  Using Arduino / Project Guidance / Re: Addressing analog pins on the arduino pro mini on: April 21, 2014, 03:46:24 pm
I forgot to mention:
9181x4089

Resize it to something reasonable - like 1000 or 1200 wide.
9000 is like 9 screen widths!

Fixed it.  It should be more easily viewable now.
Pages: [1] 2 3 ... 20