Show Posts
|
|
Pages: [1] 2 3 4
|
|
2
|
Using Arduino / Networking, Protocols, and Devices / Re: File transfer over xBee
|
on: October 11, 2012, 10:47:33 am
|
|
I am trying to transfer a small file from one arduino to another over xBee. I am using the xBee library. The file would need to be broken up into smaller chunks as the xBee payload isn't that large. One of my concerns is that packets may not arrive in the same order if other xBees are forwarding the packets. Or one packet could be dropped.
|
|
|
|
|
6
|
Using Arduino / Programming Questions / Re: float type format
|
on: September 26, 2012, 01:25:41 pm
|
|
Thanks, i just went to my ascii table and looked up the values. duh! I am sitting here doing binary sign calculations to see if it was something odd. Next question, do I need to worry about the char not being unsigned. I get an error saying "call of overloaded 'println(unsigned char*)' is ambiguous" when I have this (unsigned char *)&number. I would imagine I would the full 0-255 here.
|
|
|
|
|
7
|
Using Arduino / Programming Questions / Re: float type format
|
on: September 26, 2012, 01:14:47 pm
|
I am outputting the value of the float as hex and I do not understand the last 2 bytes. A1:10:51:C0: 0D:0A. It should be just A1:10:51:C0. Maybe this is not right "(char *)&number"? float number = -3.26664; void setup() { Serial.begin(9600); } void loop() { Serial.println((char *)&number); delay(1000); }
|
|
|
|
|
11
|
Using Arduino / Programming Questions / Re: Sleeping arduino randomly crashes
|
on: September 21, 2012, 01:09:39 pm
|
It happens about 40 seconds after sleep. I do have a 10k resistor in between reset and Vcc. I have just ordered a picoscope to get some info on what is happening on this. But disabling reset did do the trick. Looking at this diagram below, it appears that the reset had to have been coming from that line. Please let me know if my think makes sense here. 
|
|
|
|
|
12
|
Using Arduino / Programming Questions / Re: Sleeping arduino randomly crashes
|
on: September 20, 2012, 02:57:58 pm
|
The issue has come back. I have disabled the reset fuse which has shown to clear up the issue. So I wonder if I can conclude that it is noise on the reset line. The ATmega48PA/88PA/168PA/328P has four sources of reset: • Power-on Reset. The MCU is reset when the supply voltage is below the Power-on Reset threshold (VPOT). • External Reset. The MCU is reset when a low level is present on the RESET pin for longer than the minimum pulse length. • Watchdog System Reset. The MCU is reset when the Watchdog Timer period expires and the Watchdog System Reset mode is enabled. • Brown-out Reset. The MCU is reset when the supply voltage VCC is below the Brown-out Reset threshold (VBOT) and the Brown-out Detector is enabled. #include <avr/sleep.h> #include <avr/interrupt.h> int counter;
void setup(void) { Serial.begin(9600); Serial.println("Started"); counter = 0; pinMode(2, INPUT); // our sleep interrupt pin digitalWrite(2, HIGH); }
void loop(void) { counter++; Serial.println(counter); GoToSleep(); }
void wakeUpNow() { }
void GoToSleep() // here we put the arduino to sleep { Serial.println("Sleeping"); Serial.println(); Serial.println();
set_sleep_mode(SLEEP_MODE_PWR_DOWN); // sleep mode is set here sleep_enable(); // enables the sleep bit in the mcucr register // so sleep is possible. just a safety pin attachInterrupt(0,wakeUpNow,RISING);// Use pin 2 to wake up
delay(500); sleep_mode(); // here the device is actually put to sleep!! // THE PROGRAM CONTINUES FROM HERE AFTER WAKING UP sleep_disable(); // first thing after waking from sleep: disable sleep... detachInterrupt(0); // disables interrupt 0 on pin 2 so the wakeUpNow code will not be executed during normal running time.
}
|
|
|
|
|
13
|
Using Arduino / Programming Questions / Re: Sleeping arduino randomly crashes
|
on: September 11, 2012, 10:53:21 am
|
It wakes up from sleep with external interrupts. Do you have the interrupts pulled high with the internal pullups, and have interrupt 0 or 1 attached and set to trigger low? Here's all the pieces I found I needed, in IDE -0023 anyway. Have not tried it in 1.0 or 1.0.1 #include <avr/sleep.h> // powerdown library #include <avr/interrupt.h> // interrupts library
int pin2 = 2; // Int0 interrupt pin byte sleep_flag;
//*************************************************** // * Name: pin2Interrupt, "ISR" to run when interrupted in Sleep Mode void pin2Interrupt() { /* This brings us back from sleep. */ }
//*************************************************** // * Name: enterSleep void enterSleep() { /* Setup pin2 as an interrupt and attach handler. */ attachInterrupt(0, pin2Interrupt, LOW); delay(50); // need this? /* the sleep modes SLEEP_MODE_IDLE - the least power savings SLEEP_MODE_ADC SLEEP_MODE_PWR_SAVE SLEEP_MODE_STANDBY SLEEP_MODE_PWR_DOWN - the most power savings */ set_sleep_mode(SLEEP_MODE_PWR_DOWN); // setting up for sleep ... sleep_enable(); // setting up for sleep ...
// Disable ADC ADCSRA &= ~(1 << ADEN);
// Power down functions PRR = 0xFF;
sleep_mode(); // now goes to Sleep and waits for the interrupt
/* The program will continue from here after the interrupt. */ detachInterrupt(0); //disable interrupts // Power up functions PRR = 0x00;
/* First thing to do is disable sleep. */ sleep_disable();
// then go to the void Loop() }
// *********************************************************************** // set up the pins as Inputs, Outputs, etc. void setup() { /* Setup the pin directions, write inputs High to turn on internal pullups */ pinMode(pin2, INPUT); // our sleep interrupt pin digitalWrite(pin2, HIGH);
} // end of void Setup()
// *********************************************************************** // Main loop for reading the keypad and sending the button pushed out // (with a unique address to be added eventually by reading 0-F from currently unused pins)
void loop() { // your code here to decide to go to sleep, lets say it sets a flag
if (sleep_flag == 1){ // Serial.println("Sleep"); // for debug only
enterSleep(); // call Sleep function to put us out // THE PROGRAM CONTINUEs FROM HERE after waking up in enterSleep() } // end of checking to go to sleep
} // end of void loop
Thanks for the input, it looks like this did it // Disable ADC ADCSRA &= ~(1 << ADEN); // Power down functions PRR = 0xFF; This line was not in there but it needs to be turned back on also when it wakes. ADCSRA |= (1 << ADEN);
|
|
|
|
|
14
|
Using Arduino / Programming Questions / Sleeping arduino randomly crashes
|
on: September 10, 2012, 09:44:33 pm
|
|
I am powering down my arduino with SLEEP_MODE_PWR_DOWN and it randomly wakes and starts back at the setup loop. Any ideas on where to start? I hooked up a multimeter to the Vin pin to see if there were any random spikes but it didn't drop below 3.3v.
|
|
|
|
|