Show Posts
Pages: 1 [2] 3
16  Using Arduino / Programming Questions / Re: Analog Comparator falling edge setup on: December 09, 2012, 04:25:04 pm
Quote
I'm using Timer1 to generate an interrupt every Xµs that triggers the pulse for the comparator.

That's a weird set up.

The pulse controls external circuitry and the result of that circuit(very fast) triggers the comparator interrupt. Still weird? How could I improve it?
17  Using Arduino / Programming Questions / Re: Analog Comparator falling edge setup on: December 09, 2012, 04:12:07 pm
By the way, I have another question on that topic.
I'm using Timer1 to generate an interrupt every Xµs that triggers the pulse for the comparator. That means that the comparator interrupt will be triggered just before the other interrupt finishes. Somewhere I heard, that interrupts aren't allowed within interrupts. Is that true? If the Arduino "remembers" that there was another(different) interrupt during the timer interrupt and executes it afterwards, that would be fine because the comparator interrupt only increments a value and timing isn't important, as long as it doesn't forget the comparator interrupt.
18  Using Arduino / Programming Questions / Re: Analog Comparator falling edge setup on: December 09, 2012, 10:28:13 am
I couldn't test it yet, will report back. Thanks!
19  Using Arduino / Programming Questions / Analog Comparator falling edge setup on: December 09, 2012, 09:36:14 am
Hi,

this is the first time I'm using the analog comparator. I'm trying to compare AIN0 and AIN1. A pulse is applied to AIN0 and a rising ramp to AIN1. Once the value of AIN1 is higher than the maximum of the pulses on AIN0, no more falling edges should occur, right? So my goal is to trigger an interrupt on every falling edge of the comparator and detect a missing edge to calculate my results.

Setup:
Code:
  // Analog Comparator Multiplexed Input:
  // If ACME is cleared or ADEN is set, AIN1 is applied to the negative input to the Analog Comparator.
  ADCSRB &= ~(1<<ACME);
 
  // Setup of ACSR (Comparator Register)
  // Bit 7(MSB)  : ACD:          Analog Comparator Disable;               When this bit is written logic one, the power to the Analog Comparator is switched off. This bit can be set at any time to turn off the Analog Comparator. This will reduce power consumption in Active and Idle mode. When chang- ing the ACD bit, the Analog Comparator Interrupt must be disabled by clearing the ACIE bit in ACSR. Otherwise an interrupt can occur when the bit is changed.
  // Bit 6       : ACBG:         Analog Comparator Bandgap Select;        When this bit is set, a fixed bandgap reference voltage replaces the positive input to the Analog Comparator. When this bit is cleared, AIN0 is applied to the positive input of the Analog Comparator. When the bandgap reference is used as input to the Analog Comparator, it will take a certain time for the voltage to stabilize. If not stabilized, the first conversion may give a wrong value.
  // Bit 5       : ACO:          Analog Comparator Output;                The output of the Analog Comparator is synchronized and then directly connected to ACO. The synchronization introduces a delay of 1 - 2 clock cycles.
  // Bit 4       : ACI:          Analog Comparator Interrupt Flag;        This bit is set by hardware when a comparator output event triggers the interrupt mode defined by ACIS1 and ACIS0. The Analog Comparator interrupt routine is executed if the ACIE bit is set and the I-bit in SREG is set. ACI is cleared by hardware when executing the corresponding interrupt handling vector. Alternatively, ACI is cleared by writing a logic one to the flag.
  // Bit 3       : ACIE:         Analog Comparator Interrupt Enable;      When the ACIE bit is written logic one and the I-bit in the Status Register is set, the Analog Comparator interrupt is activated. When written logic zero, the interrupt is disabled.
  // Bit 2       : ACIC:         Analog Comparator Input Capture Enable;  When written logic one, this bit enables the input capture function in Timer/Counter1 to be triggered by the Analog Comparator. The comparator output is in this case directly connected to the input capture front-end logic, making the comparator utilize the noise canceler and edge select features of the Timer/Counter1 Input Capture interrupt. When written logic zero, no connection between the Analog Comparator and the input capture function exists. To make the comparator trigger the Timer/Counter1 Input Capture interrupt, the ICIE1 bit in the Timer Interrupt Mask Register (TIMSK1) must be set.
  // Bit 1,0(LSB): ACIS1, ACIS0: Analog Comparator Interrupt Mode Select; These bits determine which comparator events that trigger the Analog Comparator interrupt.
  /*
     ACIS1 | ACIS0 | Interrupt Mode
     0       0       Comparator Interrupt on Output Toggle.
     0       1       Reserved.
     1       0       Comparator Interrupt on Falling Output Edge.
     1       1       Comparator Interrupt on Rising Output Edge.
  */
  ACSR = B00011010;
 
  // Disable digital input buffer
  // AIN1, AIN0 Digital Input Disable: When this bit is written logic one, the digital input buffer on the AIN1/0 pin is disabled. The corresponding PIN Reg- ister bit will always read as zero when this bit is set. When an analog signal is applied to the AIN1/0 pin and the digital input from this pin is not needed, this bit should be written logic one to reduce power consumption in the dig- ital input buffer.
  DIDR1  |=  (1<< AIN0D);
  DIDR1  |=  (1<< AIN1D);

Will this work or am I doing something wrong?
Thanks for your help!
20  Using Arduino / Sensors / Re: TSOP31238 no longer working? on: November 26, 2012, 07:37:49 am
Ok, i found it. It was just a buggy contact on the Arduino itself. Strange, but luckily an easy fix;)
21  Using Arduino / Sensors / TSOP31238 no longer working? on: November 26, 2012, 03:37:13 am
Hi,

i recently used a TSOP31238 to receive IR signals from an Apple Remote and everything worked fine. Now i rebuilt the sensor on a breadboard and no signals come in anymore!? The sensor is just hooked up to VCC and GND and the signal pin goes into the Arduino pin 2 to be used with an interrupt. If i unplug the signal cable, the interrupt triggers randomly (approx. 50hz) so the software part should be working but once i connect it again nothing is being received anymore.
This is the datasheet: http://www.ic-on-line.cn/view_images.php?id=1434549
And a picture of the "circuit" smiley-wink https://dl.dropbox.com/u/678261/ir.jpg
Should be easy enough, right?

I tested it with two different sensors, none works.
Can anybody help?
22  Using Arduino / Programming Questions / Re: including TimerOne.h in a library on: October 31, 2012, 04:57:04 am
Ok, thanks!
I thought it was me missing something, but that makes it easier smiley-wink
23  Using Arduino / Programming Questions / including TimerOne.h in a library on: October 31, 2012, 04:28:46 am
Hi,

I'm trying to include TimerOne inside a library. But the sketch only compiles if i use
Code:
#include <TimerOne.h>
in the .h,.cpp of the library AND in the sketch that uses the library. I'd like not to have to include it in the actual sketch because that makes my library "harder" to use.

By the way, I try to initialize the timer interrupt in the constructor of my class using:
Code:
Timer1.initialize(15625);
Timer1.attachInterrupt(_function);
and the error i get if i don't include TimerOne in my sketch is:
Code:
undefined reference to `Timer1'

Can anybody help?
24  Using Arduino / Microcontrollers / Re: SoftwareSerial with ATTiny84 using ATtiny library on: September 24, 2012, 01:53:49 am
@Coding Badly
Thanks, I'll try that once I get back from work today.
25  Using Arduino / Microcontrollers / Re: SoftwareSerial with ATTiny84 using ATtiny library on: September 23, 2012, 11:30:06 am
I'm using the newest Arduino version and changed the lines, but now I get:

Code:
TinyISP_RelaySoftSerial.h:45: error: 'SoftwareSerial' does not name a type
TinyISP_RelaySoftSerial.h:51: error: 'SerialRelay' does not name a type
/Users/daniel/Dropbox/Code/Arduino/libraries/TinyISP/TinyISP_Monitor.cpp: In function 'bool monitor_run(uint8_t&)':
TinyISP_Monitor.cpp:130: error: 'RelaySerial' was not declared in this scope

Didn't I disable the serial relay by setting the setting to 0, because that's what I need in the end smiley-wink
26  Using Arduino / Microcontrollers / Re: SoftwareSerial with ATTiny84 using ATtiny library on: September 23, 2012, 02:40:19 am
Thanks, but it won't compile
Code:
In file included from TinyISP.cpp:43:
TinyISP_SanityChecks.h:45:6: error: #error The Knock-Bang Relay and Serial Relay are mutually exclusive for this processor. Enable one or the other but not both. See the <TinyISP_BuildOptions.h> file.
TinyISP_SanityChecks.h:51:10: error: #error Ensure the "#include <SoftwareSerial.h>" line in the sketch is not commented-out or set RELAY_SERIAL_ENABLED to 0 in the <TinyISP_BuildOptions.h> file.
I can remove the 2nd error by removing the comment from the "//#include <SoftwareSerial.h>" line but once I changed the "#define RELAY_KNOCK_BANG_ENABLED  1" to "#define RELAY_KNOCK_BANG_ENABLED 0" in "TinyISP_BuildOptions.h" a whole bunch of compile errors appear.

Code:
SoftwareSerial/SoftwareSerial.cpp.o: In function `__vector_3':
/Applications/Arduino.app/Contents/Resources/Java/libraries/SoftwareSerial/SoftwareSerial.cpp:302: multiple definition of `__vector_3'
KnockBangReceiver.cpp.o:KnockBangReceiver.cpp:271: first defined here
TinyISP/KnockBangParser.cpp.o: In function `TinyDebugKnockBangParserClass::process()':
/Users/daniel/Dropbox/Code/Arduino/libraries/TinyISP/KnockBangParser.cpp:51: multiple definition of `TinyDebugKnockBangParserClass::process()'
KnockBangParser.cpp.o:KnockBangParser.cpp:51: first defined here
TinyISP/KnockBangParser.cpp.o:/Users/daniel/Dropbox/Code/Arduino/libraries/TinyISP/KnockBangParser.cpp:51: multiple definition of `TinyDebugParser'
KnockBangParser.cpp.o:KnockBangParser.cpp:51: first defined here
TinyISP/KnockBangReceiver.cpp.o: In function `TinyDebugKnockBangClass_AssemblyMacros()':
/Users/daniel/Dropbox/Code/Arduino/libraries/TinyISP/KnockBangReceiver.cpp:155: multiple definition of `TinyDebugKnockBangClass_AssemblyMacros()'
KnockBangReceiver.cpp.o:KnockBangReceiver.cpp:155: first defined here
TinyISP/KnockBangReceiver.cpp.o: In function `KnockBangReceive_begin()':
/Users/daniel/Dropbox/Code/Arduino/libraries/TinyISP/KnockBangReceiver.cpp:184: multiple definition of `KnockBangReceive_begin()'
KnockBangReceiver.cpp.o:KnockBangReceiver.cpp:184: first defined here
TinyISP/KnockBangReceiver.cpp.o: In function `KnockBangReceive_end()':
/Users/daniel/Dropbox/Code/Arduino/libraries/TinyISP/KnockBangReceiver.cpp:211: multiple definition of `KnockBangReceive_end()'
KnockBangReceiver.cpp.o:KnockBangReceiver.cpp:211: first defined here
TinyISP/KnockBangReceiver.cpp.o: In function `KnockBangReceive_available()':
/Users/daniel/Dropbox/Code/Arduino/libraries/TinyISP/KnockBangReceiver.cpp:238: multiple definition of `KnockBangReceive_available()'
KnockBangReceiver.cpp.o:KnockBangReceiver.cpp:238: first defined here
TinyISP/KnockBangReceiver.cpp.o: In function `KnockBangReceive_read()':
/Users/daniel/Dropbox/Code/Arduino/libraries/TinyISP/KnockBangReceiver.cpp:250: multiple definition of `KnockBangReceive_read()'
KnockBangReceiver.cpp.o:KnockBangReceiver.cpp:250: first defined here
TinyISP/KnockBangReceiver.cpp.o: In function `__vector_3':
/Users/daniel/Dropbox/Code/Arduino/libraries/TinyISP/KnockBangReceiver.cpp:271: multiple definition of `__vector_3'
KnockBangReceiver.cpp.o:KnockBangReceiver.cpp:271: first defined here
TinyISP/KnockBangReceiver.cpp.o: In function `KnockBangReceive_getStats(kbr_stats_t&)':
/Users/daniel/Dropbox/Code/Arduino/libraries/TinyISP/KnockBangReceiver.cpp:598: multiple definition of `KnockBangReceive_getStats(kbr_stats_t&)'
KnockBangReceiver.cpp.o:KnockBangReceiver.cpp:598: first defined here
TinyISP/KnockBangReceiver.cpp.o: In function `KnockBangReceive_getLastFault()':
/Users/daniel/Dropbox/Code/Arduino/libraries/TinyISP/KnockBangReceiver.cpp:637: multiple definition of `KnockBangReceive_getLastFault()'
KnockBangReceiver.cpp.o:KnockBangReceiver.cpp:637: first defined here
TinyISP/KnockBangReceiver.cpp.o: In function `KnockBangReceive_getLastDebug1()':
/Users/daniel/Dropbox/Code/Arduino/libraries/TinyISP/KnockBangReceiver.cpp:656: multiple definition of `KnockBangReceive_getLastDebug1()'
KnockBangReceiver.cpp.o:KnockBangReceiver.cpp:656: first defined here
TinyISP/TinyISP_AispLED.cpp.o: In function `AispLEDClass::setMode(AispLEDClass::mode_t)':
/Users/daniel/Dropbox/Code/Arduino/libraries/TinyISP/TinyISP_AispLED.cpp:94: multiple definition of `AispLEDClass::setMode(AispLEDClass::mode_t)'
TinyISP_AispLED.cpp.o:TinyISP_AispLED.cpp:94: first defined here
TinyISP/TinyISP_AispLED.cpp.o: In function `AispLEDClass::update()':
/Users/daniel/Dropbox/Code/Arduino/libraries/TinyISP/TinyISP_AispLED.cpp:108: multiple definition of `AispLEDClass::update()'
TinyISP_AispLED.cpp.o:TinyISP_AispLED.cpp:108: first defined here
TinyISP/TinyISP_AispLED.cpp.o: In function `AispLEDClass::flash()':
/Users/daniel/Dropbox/Code/Arduino/libraries/TinyISP/TinyISP_AispLED.cpp:77: multiple definition of `AispLEDClass::flash()'
TinyISP_AispLED.cpp.o:TinyISP_AispLED.cpp:77: first defined here
TinyISP/TinyISP_AispLED.cpp.o: In function `AispLEDClass::error()':
/Users/daniel/Dropbox/Code/Arduino/libraries/TinyISP/TinyISP_AispLED.cpp:66: multiple definition of `AispLEDClass::error()'
TinyISP_AispLED.cpp.o:TinyISP_AispLED.cpp:66: first defined here
TinyISP/TinyISP_AispLED.cpp.o: In function `AispLEDClass::begin(unsigned char)':
/Users/daniel/Dropbox/Code/Arduino/libraries/TinyISP/TinyISP_AispLED.cpp:53: multiple definition of `AispLEDClass::begin(unsigned char)'
TinyISP_AispLED.cpp.o:TinyISP_AispLED.cpp:53: first defined here
TinyISP/TinyISP_AispLED.cpp.o:/Users/daniel/Dropbox/Code/Arduino/libraries/TinyISP/TinyISP_AispLED.cpp:94: multiple definition of `StatusIndicator'
TinyISP_AispLED.cpp.o:TinyISP_AispLED.cpp:94: first defined here
TinyISP/TinyISP_Monitor.cpp.o: In function `monitor_run(unsigned char&)':
/Users/daniel/Dropbox/Code/Arduino/libraries/TinyISP/TinyISP_Monitor.cpp:123: multiple definition of `monitor_run(unsigned char&)'
TinyISP_Monitor.cpp.o:TinyISP_Monitor.cpp:123: first defined here
TinyISP/TinyISP_Programmer.cpp.o: In function `programmer_toggle_hold_in_reset()':
/Users/daniel/Dropbox/Code/Arduino/libraries/TinyISP/TinyISP_Programmer.cpp:820: multiple definition of `programmer_toggle_hold_in_reset()'
TinyISP_Programmer.cpp.o:TinyISP_Programmer.cpp:820: first defined here
TinyISP/TinyISP_Programmer.cpp.o: In function `programmer_error_occurred()':
/Users/daniel/Dropbox/Code/Arduino/libraries/TinyISP/TinyISP_Programmer.cpp:857: multiple definition of `programmer_error_occurred()'
TinyISP_Programmer.cpp.o:TinyISP_Programmer.cpp:857: first defined here
TinyISP/TinyISP_Programmer.cpp.o: In function `programmer_release_target_from_reset()':
/Users/daniel/Dropbox/Code/Arduino/libraries/TinyISP/TinyISP_Programmer.cpp:829: multiple definition of `programmer_release_target_from_reset()'
TinyISP_Programmer.cpp.o:TinyISP_Programmer.cpp:829: first defined here
TinyISP/TinyISP_Programmer.cpp.o: In function `programmer_hold_target_in_reset()':
/Users/daniel/Dropbox/Code/Arduino/libraries/TinyISP/TinyISP_Programmer.cpp:852: multiple definition of `programmer_hold_target_in_reset()'
TinyISP_Programmer.cpp.o:TinyISP_Programmer.cpp:852: first defined here
TinyISP/TinyISP_Programmer.cpp.o: In function `programmer_reset_target()':
/Users/daniel/Dropbox/Code/Arduino/libraries/TinyISP/TinyISP_Programmer.cpp:834: multiple definition of `programmer_reset_target()'
TinyISP_Programmer.cpp.o:TinyISP_Programmer.cpp:834: first defined here
TinyISP/TinyISP_Programmer.cpp.o: In function `programmer_toggle_hold_in_reset()':
/Users/daniel/Dropbox/Code/Arduino/libraries/TinyISP/TinyISP_Programmer.cpp:820: multiple definition of `param'
TinyISP_Programmer.cpp.o:TinyISP_Programmer.cpp:820: first defined here
TinyISP/TinyISP_Programmer.cpp.o: In function `programmer_process_command(unsigned char)':
/Users/daniel/Dropbox/Code/Arduino/libraries/TinyISP/TinyISP_Programmer.cpp:689: multiple definition of `programmer_process_command(unsigned char)'
TinyISP_Programmer.cpp.o:TinyISP_Programmer.cpp:689: first defined here
TinyISP/TinyISP_Programmer.cpp.o: In function `programmer_toggle_hold_in_reset()':
/Users/daniel/Dropbox/Code/Arduino/libraries/TinyISP/TinyISP_Programmer.cpp:820: multiple definition of `programmer_active'
TinyISP_Programmer.cpp.o:TinyISP_Programmer.cpp:820: first defined here
TinyISP/TinyISP_SPI.cpp.o: In function `spi_begin()':
/Users/daniel/Dropbox/Code/Arduino/libraries/TinyISP/TinyISP_SPI.cpp:67: multiple definition of `spi_begin()'
TinyISP_SPI.cpp.o:TinyISP_SPI.cpp:67: first defined here
TinyISP/TinyISP_SPI.cpp.o: In function `spi_end()':
/Users/daniel/Dropbox/Code/Arduino/libraries/TinyISP/TinyISP_SPI.cpp:102: multiple definition of `spi_end()'
TinyISP_SPI.cpp.o:TinyISP_SPI.cpp:102: first defined here
TinyISP/TinyISP_SPI.cpp.o: In function `spi_send':
/Users/daniel/Dropbox/Code/Arduino/libraries/TinyISP/TinyISP_SPI.cpp:120: multiple definition of `spi_transaction(unsigned char, unsigned char, unsigned char, unsigned char)'
TinyISP_SPI.cpp.o:TinyISP_SPI.cpp:120: first defined here
TinyISP/TinyISP_SPI.cpp.o: In function `spi_transaction2(unsigned long)':
/Users/daniel/Dropbox/Code/Arduino/libraries/TinyISP/TinyISP_SPI.cpp:183: multiple definition of `spi_transaction2(unsigned long)'
TinyISP_SPI.cpp.o:TinyISP_SPI.cpp:183: first defined here
27  Using Arduino / Microcontrollers / Re: SoftwareSerial with ATTiny84 using ATtiny library on: September 21, 2012, 10:16:45 am
Ok, I couldn't wait for the zif socket;) Once I removed the Arduino and plugged the Serial cable into the TX(not RX as before) pin on the Arduino board, everything worked just fine! So it seems as if the Arduino blocks the communication if its inserted and your library should be able to solve my problem.
28  Using Arduino / Microcontrollers / Re: SoftwareSerial with ATTiny84 using ATtiny library on: September 21, 2012, 07:07:57 am
That sounds great, could you post the library here? I'll try the serial interface without the 328 once the zif socket arrives.
29  Using Arduino / Microcontrollers / Re: SoftwareSerial with ATTiny84 using ATtiny library on: September 20, 2012, 01:40:50 pm
I already ordered a zif-header to be able to remove the 328 easily and without damage.

If you are interested, I have a version of the ArduinoISP sketch that makes what you are trying to do much simpler.
What does your modified sketch do to make it simpler and would it allow me to program the external micro and still get serial data without changing the connections every time?
30  Using Arduino / Microcontrollers / Re: SoftwareSerial with ATTiny84 using ATtiny library on: September 20, 2012, 12:32:49 pm
Not sure how this is supposed to work without power...

It won't.

That's what they taught me in EE smiley-wink
Pages: 1 [2] 3