Show Posts
Pages: 1 [2] 3 4 ... 17
16  Forum 2005-2010 (read only) / Troubleshooting / Re: __inline functions: undefined reference error on: January 05, 2010, 11:45:09 pm
Well... if I declare the function in the .h file instead of the .cpp file it works.  But why it works when all text is contained in the same sketch is lost on me.
17  Forum 2005-2010 (read only) / Troubleshooting / __inline functions: undefined reference error on: January 05, 2010, 11:24:47 pm
Please help me understand/eliminate this compiler error for an __inline member function for a class...

"In function 'setup':
C:\.../inlinefunction.cpp:10: undefined reference to `myClass::myFunction()'"

This is the code.
Sketch:
Code:
#include "myClass.h"

myClass Instance;

void setup()
{
    Instance.myFunction();
}

void loop()
{
}

myClass.h:
Code:
class myClass
{
  public:
    myClass();
    __inline void myFunction();
};

myClass.cpp
Code:
#include "myClass.h"

myClass::myClass()
{
  // constructor
}

__inline void myClass::myFunction()
{
  // nothing
}

Interestingly, if I push all the code together into the main sketch, it compiles successfully.  Only with the class defined in separate .cpp/.h files does it throw an error.
Alternately, if I maintain the file structure but remove the "__inline" declaration it also compiles successfully.
18  Forum 2005-2010 (read only) / Troubleshooting / Re: Serial transfers corrupted... on: January 04, 2010, 11:32:57 am
Check details Mike... he's just displaying the data in two formats.  There is a discrepancy between the "read" data and "write" data that doesn't matchup.
19  Forum 2005-2010 (read only) / Troubleshooting / Re: Serial transfers corrupted... on: December 29, 2009, 04:47:52 pm
Maybe dump something like this into your send (processing) code...

Code:
byte b[] = loadBytes("binary.file");
 for(int i = 0; i < b.length; i++) {
   myPort.write(b[i]);
   println("Wrote byte:\t"+b[i]+"\thex: "+hex(b[i]));
   while(myPort.available() < 1) {
     // wait for echo data
   }
   byte Rx = myPort.read();
   if (Rx != b) println("Error: Received " + Rx);
 }
20  Forum 2005-2010 (read only) / Troubleshooting / Re: Serial transfers corrupted... on: December 28, 2009, 11:02:54 pm
It's possible that you're dumping too much data onto the Arduino serial port before it has a chance to read it.
Try some handshaking; don't push all the data unless Arduino is ready to receive it.
That's where I would suspect.
21  Forum 2005-2010 (read only) / Troubleshooting / Re: Can OCR2A be read or printed like any other var? on: December 12, 2009, 02:52:00 pm
OCR2A is a byte on the Atmega168.
OCR2A is a uint on the Atmega1280.

you can Serial.print(OCR2A, DEC) to write the decimal formatted value.
22  Forum 2005-2010 (read only) / Troubleshooting / Re: Question about ICR1 of  timer/counter1 on: December 10, 2009, 11:03:25 pm
Glad it's working for you.  BTW I edited my previous post to point out a mistake I made in my analysis.
23  Forum 2005-2010 (read only) / Troubleshooting / Re: Question about ICR1 of  timer/counter1 on: December 10, 2009, 11:23:04 am
I'm not sure why you're enabling/disabling the interrupt in the main loop, but I believe I understand why you are observing what you are.

The fact that TCNT1 is always 26 tells you that as soon as the interrupt is enabled, it *immediately* jumps to the ISR.  This is because the interrupt flag is already set from the previous input capture event.  But because the interrupt is disabled no action has been taken.

You should clear TIFR1:ICF1 immediately before enabling the interrupt.

But even then I don't expect the TCNT1 and ICR values to be exactly the same.  The reason is that you have no guarantee that you are resetting TCNT1 in-phase with your 1kHz square wave falling edge.
[Edit:  re-reading my own post, this is nonsense.  Of course TCNT1 and ICR will have the same value when the interrupt is thrown... it's a compare match afterall. Duh!]

I believe what you should be doing is resetting TCNT1 inside the TIMER1_CAPT ISR.  Your main loop should do nothing.

Another note, printing all that information out through the serial port at 9600 baud is likely going to take longer than the (1/1kHz) seconds and you're going to backlog the input capture events.
24  Forum 2005-2010 (read only) / Troubleshooting / Re: Garduino wakeup on: November 27, 2009, 06:32:19 pm
Does this portion of the code not work?
Code:
attachInterrupt(0,wakeUpNow, LOW); // use interrupt 0 (pin 2) and run function
                                     // wakeUpNow when pin 2 gets LOW  
25  Forum 2005-2010 (read only) / Troubleshooting / Re: arduino keeps restarting: debugging pointer error? on: November 19, 2009, 11:56:24 pm
Quote
Dropping the complete code on anyone here is too much to ask. And don't forget that the restarting takes place before it even makes it to the loop() function.

Well if we can't get you to punish us with everything, then post everything up to the point (or thereabouts) that it fails.
26  Forum 2005-2010 (read only) / Bugs & Suggestions / arduino.cc/en/Hacking/Programmer on: January 23, 2011, 03:54:19 pm
The subject page might need correction/clarification.

Today for the first time I tried my USBtinyISP bought from ladyada.net.
I followed the instructions here...
http://arduino.cc/en/Hacking/Programmer

I work with Arduino enviro 0021 on a Windows XP machine.

I have multiple arduino boards but only want to program my Arduino Mega with the tinyISP, so I created a new entry in boards.txt...
Code:
megaISP.name=Arduino Mega (ATmega1280) USBtinyISP

megaISP.upload.using=usbtinyisp

megaISP.bootloader.low_fuses=0xFF
megaISP.bootloader.high_fuses=0xDA
megaISP.bootloader.extended_fuses=0xF5
megaISP.bootloader.path=atmega
megaISP.bootloader.file=ATmegaBOOT_168_atmega1280.hex
megaISP.bootloader.unlock_bits=0x3F
megaISP.bootloader.lock_bits=0x0F

megaISP.build.mcu=atmega1280
megaISP.build.f_cpu=16000000L
megaISP.build.core=arduino

Note that the text in programmers.txt for the usbtinyisp shows up as "USBtinyISP".  So when I originally followed the instructions at the [subject] page I copied the text with this exact case.  However when using "...upload.using=USBtinyISP" the Arduino 0021 environment complains with...
Code:
java.lang.NullPointerException
      at processing.app.debug.AvrdudeUploader.getProgrammerCommands(Unknown Source)
      at processing.app.debug.AvrdudeUploader.uploadUsingPreferences(Unknown Source)
      at processing.app.Sketch.upload(Unknown Source)
      at processing.app.Sketch.exportApplet(Unknown Source)
      at processing.app.Sketch.exportApplet(Unknown Source)
      at processing.app.Editor$DefaultExportHandler.run(Unknown Source)
      at java.lang.Thread.run(Thread.java:619)

Only when using "...upload.using=usbtinyisp" in boards.txt does it actually succeed.

This case-sensitivity may or may-not be a problem for other device names in programmers.txt.
27  Forum 2005-2010 (read only) / Syntax & Programs / Re: int confusion on: December 10, 2010, 11:22:03 am
I like Notepad++ for windows... but are you suggesting you want to edit the Arduino core code?  I would suggest that you do *not* want to edit the Arduino code.  I think you only think you need to edit it to achieve what you want, but there are probably more appropriate ways to do it.
28  Forum 2005-2010 (read only) / Syntax & Programs / Re: int confusion on: December 10, 2010, 10:51:31 am
It's an arbitrary 23.  It's the digitalWrite() function that knows how to interpret the value of 23 stored in AX as an actual hardware port and pin on the microcontroller itself.

And maybe that's also worth pointing out here.  The Arduino pin# is unknown to the actual Atmel chip.  There is a mapping that occurs to translate "Arduino pin #10" to "Atmega port B, pin 4" for example.
29  Forum 2005-2010 (read only) / Syntax & Programs / Re: Can someone debounce a button for me? on: December 10, 2010, 11:02:29 am
As funny as that was, here is a more serious answer.  Some untested code to check for switch bounce...

Code:
boolean InitialValue = digitalRead(myPin);
boolean IsBouncing = false;
int n = 100; // you pick this number based on how bouncy your switch is

for (int i =0; i < n; i++)
{
  if (digitalRead(myPin) != Initialvalue)  
  {
     IsBouncing = true;
     break;
  }
}

Note there are some more robust ways to do this through direct port manipulation and interrupts that would catch rare instances where say the switch was bouncing at a frequency that matches the execution period of the for loop.  But this should probably work for most hardware.

The general idea is to not accept that a switch has changed state until it is proven to hold that state without changing for a certain period of time.
30  Forum 2005-2010 (read only) / Syntax & Programs / Re: Serial to control multiple outputs? on: November 23, 2009, 12:19:52 am
Yep, you need to define your own tiny scripting language.  Come up with the commands you want to recognize and start looking for the patterns once they arrive on the serial port.  If the data received doesn't match any commands dispose data and start again.

You're familiar with the Arduino serial object?

Some pseudo-code...

char input[20];
byte i = 0;

loop() {

  if serial.available() {
    while (serial.available()) {
        input = serial.read();
        i++;
        if (i > 20) exit; // this isn't the right syntax but I can't remember what is right now
        if (check_for_command()) exit;  // see above
    }
  }
}

check_for_command() {
  // compare input w 1st command, do something
  // compare input w 2nd command, do something
  // etc.
  input[0] = end_of_command_char;  // use zero?
}
Pages: 1 [2] 3 4 ... 17