Show Posts
Pages: 1 [2] 3 4 ... 7
16  Forum 2005-2010 (read only) / Troubleshooting / strtok problem on: April 21, 2010, 10:09:40 pm
i am trying to switch my project over to arduino v18 linux from v18 mac
when i try to compile i get an error with strtok

error: 'strtok' was not declared in this scope

any help is greatly appreciated

Thanks
Jeff
17  Forum 2005-2010 (read only) / Troubleshooting / Arduino v13 changes on: April 25, 2009, 09:45:42 pm
Hi All,
I have some code i wrote that uses an interrupt to detect reed switch pulses. this code has been burned on decimillias over the last 14 moths with arduino IDE 11 and 12 and now 13. i am seeing some weird readings all of a sudden and wonder if something might have change in v13 with interrupts or Timer2 stuff as i am using both of these in my program.
any insight would be well appreciated even if just to say that those things have not changed.

Thanks

Jeff
18  Forum 2005-2010 (read only) / Troubleshooting / Re: power consumption/sleep questions on: May 29, 2008, 07:47:28 pm
I've been reading section. 9.8 "Minimizing Power Consumption" (pg42) of the atmega168 doc. some of the recommendations are to disable analog to digital converter, disable the watch dog timer, and configure all port pins to use minimum power. i would like to try all this but i don't have a clue as to do this. i'm really new to this stuff and the bit manipulation stuff is a little foreign to me. does any body know of any code examples for this stuff.

here is my side question. i'm trying to make a pulse counter that will be able to run on a battery. lets say the log interval will be two minutes. it will be asleep but counting pulses, then wake up every two minutes and dump its pulse count to some kind of memory device. i actually have this whole thing working quite nicely while being plugged into the wall, but the power consumption is way too high for a battery. my current config uses an external interrupt to count pulses from the reed switch. my fear is that this interrupt will cause the chip to wake up from sleep mode. also i have studied the sleep example from the playground and i don't fully understand the wake up part. i believe they are using the external interrupt to cause the wake up from sleep but could it be done with a timer? if it does wake up from the external interrupt then my guess is that i won't be able to use an interrupt to count reed switch pulses. so how else would you quietly count pulses? and how would you set it up to wake from a timer?

i know there are a lot of random thoughts/questions in the above paragraph. let me know if you need me to clarify anything

Thanks
Jeff
19  Forum 2005-2010 (read only) / Troubleshooting / Re: power consumption/sleep questions on: May 29, 2008, 03:38:27 pm
i am using a 9 volt battery into the VIN pin and my meter is connected in series with one of the lines from the 9v battery. is this not the correct way of measuring current draw?

Jeff
20  Forum 2005-2010 (read only) / Troubleshooting / power consumption/sleep questions on: May 29, 2008, 02:14:57 pm
with the following code and nothing connected the Diecimila uses 9 milliamps. the board uses about 32ma before it goes to sleep. i was expecting it to be a lot less than this. has anybody been able to do better than this?

Thanks
Jeff O'Brien

Code:
#include <avr/sleep.h>

void setup()
{
 
  delay(5000);
    set_sleep_mode(SLEEP_MODE_PWR_DOWN);   // sleep mode is set here
    sleep_enable();
    sleep_mode();
    sleep_disable();
  
}

void loop() {

}
21  Forum 2005-2010 (read only) / Troubleshooting / board locks up on: April 15, 2008, 08:05:25 pm
I'm trying to set a pin high or low from a serial message from my app
and i am setting it's initial state at setup
the board locks up when i do the following.
if i set the alarm pin high then close the serial port and reopen it the board hangs

my realbasic app establishes a serial connection. if they change something in prefs i close the serial port and reopen it. before i added the alarm code this worked fine. now the board hangs when i close the serial port and reopen it.

any ideas?

Thanks Jeff

the new code in setup is

  pinMode(alarmPin, OUTPUT);
  digitalWrite(alarmPin, LOW);

the new code in loop is
all the serial stuff to do if incomingbyte is "A", "F" or "V"


Code:
void setup()
{
  Serial.begin(57600);

  pinMode(ledPin, OUTPUT);
  pinMode(2, INPUT);
  pinMode(alarmPin, OUTPUT); //pin 4
  digitalWrite(alarmPin, LOW);
  digitalWrite(2, HIGH); //anemometer input pin
  Serial.print(ver, DEC);  //display board firmware version #
  Serial.println("ver");  
  ledPinState = digitalRead(ledPin);
  count = 0;
  attachInterrupt(0, increment_counter, FALLING);

}

void loop()
{
  delay(1000);

  digitalWrite(ledPin, !ledPinState); //blink led on board
  ledPinState = !ledPinState;

  if (Serial.available() > 0) // read the incoming byte
  {        
    incomingByte = Serial.read();
    if (incomingByte=='A') // turn alarm pin on
    {
      digitalWrite(alarmPin, HIGH);
    }
    if (incomingByte=='F') // turn alarm pin off
    {
      digitalWrite(alarmPin, LOW);
    }
    if (incomingByte=='V') // get version
    {
      Serial.print(ver, DEC);  //display board firmware version #
      Serial.println("ver");  
    }

  }

}
22  Forum 2005-2010 (read only) / Syntax & Programs / Re: printing a double variable on: October 09, 2008, 12:13:51 am
mem,

How might you rewrite the "printDouble" function to return a string instead of printing to the serial port?

I need to create a string of comma separated data, and some of the data contains floats that i want to format. i want to create the whole string then check the length before i send it to the serial port.

i was thinking of using sprintf for this but then found out that it doesn't support floats.
so i was thinking, instead of passing in a float to sprintf i would pass in a string of a float that was already formatted by a new version your "printDouble" function.

Thanks
Jeff
23  Forum 2005-2010 (read only) / Syntax & Programs / Call setup() from elsewhere on: December 19, 2009, 01:32:32 am
is it OK to call setup() from some where else in your program?
24  Forum 2005-2010 (read only) / Syntax & Programs / Re: Traverse struct with pointer on: December 18, 2009, 07:15:14 pm
i need to apologize to you Mike and Spinlock

in the process of testing my eeprom reading and writing, i changed one byte of my servers ethernet address to allow my self to see the eeprom data change during testing and i never changed it back in my default config settings.

So please accept my humble apologies and my enthusiastic thanks for helping me out today.

also i found something else out that i think i can fix by adding a setter method to the client.cpp file

i can't seem to instantiate the client object in the setup method.
so i do it before the setup method then in the setup method i read the data off the eeprom into the struct and then i use my custom setter method to set the server value from the struct data in the client object and then i make the call to ethernet.begin with the rest of the address data from the struct and this seems to work.

so just in case i lost you
i can't seem to instantiate the Client object inside the arduino setup method.
if you know how to do that, please let me know so i don't have to alter the client library with that setter method i spoke of.

thanks again for all your help and i hope this thread will be helpful to others

Jeff
25  Forum 2005-2010 (read only) / Syntax & Programs / Re: Traverse struct with pointer on: December 18, 2009, 06:43:54 pm
its not filling in the structure that is the problem. once i have a good structure i do the following
Code:

void setup()
{
Ethernet.begin(configuration.mac, configuration.ip, configuration.gateway, configuration.subnet);
}

void loop()
{

  if (takeSampleNow)  // check flag at this point. occurs every second or 1000 overflows of the timer
  {
    TakeSample();
    Client client(configuration.server, 80);
    if (client.connect()) {
    client.println(sampleString);
    client.println();
    client.stop();
    }
    else {
    Serial.println("connection failed");
    }
    takeSampleNow = 0; // turn off flag
  }
  CheckSerial();
}


for some reason this is not working. meaning that i get connection failed message

now if i hard code the different address' like in the ethernet examples on the arduino site it all works

to answer your other question
for the sake of testing the reading and writing of the config data from the serial port i was just sending in some random chars to see if it could write and read them from the eeprom into the struct and then print to screen. my gui app sends in the proper byte info though.
26  Forum 2005-2010 (read only) / Syntax & Programs / Re: Traverse struct with pointer on: December 18, 2009, 04:33:37 pm
Mike,
this is true
i wrote a little gui app to configure all the settings and i have set it up to put the /r at the end. i noticed as i was trying to do some testing with the serial monitor that i had no way of sending the /r from the serial monitor and it was hanging. i will also be able to control max path from the gui.

on another note.
now that i have this nice system for maintaining the configuration settings, can you think of a reason why calling ethernet.begin with the members from the struct wouldn't work?
also Client client(configuration.server, 80);
I can't tell which is not working. but if i bypass the struct and hard code all of the same address values everything is fine with my logger.
only when i switch to configuring the address's with the structs members does it fail.
jeff
27  Forum 2005-2010 (read only) / Syntax & Programs / Re: Traverse struct with pointer on: December 18, 2009, 03:55:46 pm
mike,
i think i need a provision if the path supplied is shorter than max path and the /r is omitted.
not sure how to deal with this
i think it loops forever in this situation as written.
Jeff
28  Forum 2005-2010 (read only) / Syntax & Programs / Re: Traverse struct with pointer on: December 18, 2009, 02:33:53 pm
Hi Mike,
Thanks , again very helpful to see how others work out these problems.

Correct me if i am wrong, but it looks like to me that your read_path function will put the terminating nul character in on every iteration of the while loop?
Should it maybe be moved down one curly brace?
Jeff
29  Forum 2005-2010 (read only) / Syntax & Programs / Re: Traverse struct with pointer on: December 18, 2009, 12:08:47 pm
thanks mike, very helpful

how does this look for a function to read the path. be gentle ;-)

Code:
void read_path(char *pathPtr)
{
  int i = 0;
  byte c = Serial.read();
  while (Serial.available() && c != '\r')
  {
    pathPtr[i++] = c;
    c = Serial.read();
  }
}
30  Forum 2005-2010 (read only) / Syntax & Programs / Re: Traverse struct with pointer on: December 18, 2009, 11:01:22 am
sorry here is a link

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1261109565
Pages: 1 [2] 3 4 ... 7