Show Posts
Pages: [1] 2 3
1  Using Arduino / Programming Questions / trouble assigning CONST to some values on: March 28, 2014, 05:01:22 pm
Hi, I'm having trouble assigning a constant some values, and can't make sense of it. Examples:
Code:
const int MAX_GRAPH = 0x567;  // compiles OK
const int MAX_GRAPH = 0x3233; // *error compiling
const int MAX_GRAPH = 0xFF;   // compiles OK
const int MAX_GRAPH = 0xFFF;  // *error compiling
const int MAX_GRAPH = 0xffff;   // compiles OK
const int MAX_GRAPH = INT16_MAX; // *error compiling, I thought defined here: http://www.nongnu.org/avr-libc/user-manual/group__avr__stdint.html

Arduino 1.0.5 error is:
c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr6/crtm2560.o: In function `__vector_default': (.vectors+0x5c): relocation truncated to fit: R_AVR_13_PCREL against symbol `__vector_23' defined in .text.__vector_23 section in core.a(wiring.c.o)

I just want to set a const to maxint. How can I do this?
2  Using Arduino / Installation & Troubleshooting / Reprogram the Mega8U2 (USB-RS232) on Arduino UNO on: January 11, 2014, 06:10:09 pm
How do I reprogram the Mega8U2 (USB-RS232) on my Arduino UNO? I can't find the hex file or revision history, to see if there are updates.
3  Using Arduino / Microcontrollers / Arduino as ISP with the ATtiny85 on: March 22, 2013, 11:10:50 pm
I'm having troubles programming the ATtiny85V using the Arduino as ISP.

What happens is the (Arduino) programmer times out and I get:
avrdude: stk500_paged_write(): (a) protocol error, expect=0x14, resp=0x64
avrdude: stk500_cmd(): programmer is out of sync

The Arduino as ISP seems to work fine. I changed the line delay(40) in ArduinoISP sub heartbeat, and the heartbeat LED pulses and there's some initial data LED blinks, then things stall.  (I tried both Uno and Nano as programmers).
It's as if the ATtiny85 is not responding (I tried a few new ones). Using Arduino IDE 1.0.4, settings are tiny85 internal 8MHz, but I also tried 1MHz.

Have a 10uF cap on Arduino RESET line.

So I'm not sure what to check; usually I'm up against fusebits when this happens? To set the fusebits, I read you select a clock speed and "Burn Bootloader" (even though you can't put one in the 85). I thought "out of the box" the Attiny is running 8Mhz internal RC oscillator.

I'm using the MIT high-low tech ATtiny library and instructions http://hlt.media.mit.edu/?p=1695
4  Using Arduino / Installation & Troubleshooting / Re: Serial Monitor - opens past the edge of my main screen and I can't see it on: March 11, 2013, 02:38:00 pm
Found the way to move the windowe back on my screen, from Microsoft's Tech forums:

"Windows 7 has a cool new feature that should help.  Click the icon in the taskbar to ensure that the program has focus. Then hold down the Windows key and press the right-arrow a few times. That should move the window across your screens and eventually bring it back onto the screen that is still active."
5  Using Arduino / Installation & Troubleshooting / Serial Monitor - opens past the edge of my main screen and I can't see it on: March 11, 2013, 02:11:05 pm
I'm having trouble when I open the Serial Monitor - it opens past the right edge of my main screen and I can't see it.
The Java icon and COM15 show up in my system tray and only a "Close Window" option is there.
I'm using Windows 7 with a dual-monitor setup. Doesn't matter if I run the IDE on the other (left) monitor.
This happened for me in 1.0.1 so I upgraded to 1.0.4 and same thing.
I ran the Java control panel utility (V6.0 Update 26), but nothing about moving things, also cleared the cache.
I assume the Arduino IDE sets the pop-up location?
6  Using Arduino / Programming Questions / a little help with pulsein on: November 20, 2012, 10:59:52 pm
Trying to measure capacitance by turning on a digital output, with R to input pin and C to gnd, and measure the time delay. Arduino Uno.
Using pulsein (see code below) I get timeouts if R=infinity (open) or if tie the input pin low, which is expected.
But if I tie the pulsein input pin to +5V, or use a RC (100k and 0.1uF) to the pulsein pin, I get timeouts, where I expect a number  smiley-confuse 'scope signals look ok to me.

If I disconnect pulsein pin and touch (giving noise) I start to get wandering readings from pulsein. Otherwise, it's always timeouts, as if pulsein gets "stuck" or needs an edge?

Code:
#include <avr/io.h>

byte SensorPin = 3;   // pin "D3", PD3
byte PulseOutPin = 2; // pin "D2", PD2
byte ledPin = 13;

#define TRUE 1;
#define FALSE 0;

//************************************************************************
void setup() {
 
  digitalWrite(ledPin,LOW) ; // led off
  digitalWrite(PulseOutPin, LOW); 
  pinMode(PulseOutPin, OUTPUT); 
  pinMode(SensorPin, INPUT);
  Serial.begin(57600);
}
   
//========================================================================
void loop() {

unsigned long duration;
const unsigned long pulsein_timeout = 100000; // in usec
const unsigned long pulse_triptime = 5000; // in usec

  digitalWrite(PulseOutPin, HIGH);  //
  duration = pulseIn(SensorPin, HIGH, pulsein_timeout);
  if (duration==0) {
      Serial.println("pulse timeout");
  }
  else {
 
    Serial.print("tau= "); Serial.print(duration); Serial.print(" usec");
    if (duration>=pulse_triptime) {
       digitalWrite(ledPin,HIGH) ; // led on
       Serial.print("  * trip *");
    }
    else { 
      digitalWrite(ledPin,LOW) ; // led off
    }
    Serial.println();
  } 
  digitalWrite(PulseOutPin, LOW);  //
   
  delay(1000);
}
[/size]
7  Using Arduino / Installation & Troubleshooting / Xbee and Wireless shields: 3.3V-5V level translating problem on: September 29, 2012, 10:30:16 pm
I bought an XBee shield V03 from geeetech.com and ran into a shield design problem while checking it out- before installing my Xbee module smiley
It's the same circuit as http://arduino.cc/en/Main/ArduinoXbeeShield

The Xbee modules are 3.3V and my Uno is 5V. For level translation there is a 10k/15k divider to lower Arduino's TX swing.
But for RX, the Xbee runs straight into the Arduino. In theory this works, but I found 5V there and traced it back to the USB transceiver, which also drives the AVR's Rx line through a 1k series resistor. So you get 5V backfeed into the Xbee's TX output pin, which I am not okay with.

I found the same design problem also exists with the newer Arduino Xbee Wireless module and Arduino Wireless Protoshield, so any 3.3V RF module will experience this I reckon.

It looks like changing to the newer Leonardo might work, as the serial port OR'ing is not done in hardware. Is this correct? Is there a 3.3V Arduino?
8  Development / Suggestions for the Arduino Project / Please add the AVcc filter on: September 23, 2012, 12:47:25 am
I never get 10-bit A/D performance with Arduino's - there's always too much noise. If I add the (Atmel datasheet) RC +AVcc filter, there is a huge improvement. Can you put these or at least provisions for these on Arduino designs? Even if there is a 0R resistor there, I can add it myself.
9  Using Arduino / General Electronics / Re: ~RECOMMEND A BUCK 12V-5V DC converter? on: September 23, 2012, 12:36:49 am
I think you get higher losses at 10A - in the switcher, wiring etc. I would series connect more LED's to up the voltage, or break them up so you can use smaller 2-3A switchers.

Doc, I tried a few of the LM2596 switchers from eBay, I was going to use one for an iPad charger. They just don't have the heatsinking or diode rating to dish out 5V@2A from 12V, so for $1.59 they let me down. They run quite hot.

DX has some "10A" ones but they are potted: http://dx.com/p/dc-12v-24v-to-dc-5v-car-negative-booster-power-converter-silver-149111?item=14

A cheap buck converter will fail and overvoltage your load, so I don't cheap out on them anymore.
10  Using Arduino / General Electronics / Re: Safe location of a AC current sensor on: February 25, 2012, 10:22:57 pm
Never forget the lead-in wires are always energized, unless you call your power company to disconnect (yank the power meter).

It's too dangerous and too much hassle to make your own current transformers. They also have to have a dielectric rating to prevent any arc- which if that happened on the lead-in, it would be a bad thing, upstream of the 100A breakers...

I would buy two split-core CT's (i.e Leviton Ctd01-k16 $39), call the power company to disconnect for install and put them on each phase coming in (black wires).
Also, CT's need a burden resistor and without them they are dangerous and can generate many kV.

Google "Sub-metering Current Transformer" to find some.

11  Using Arduino / Programming Questions / How to detect loss/presence of AC mains? on: February 25, 2012, 10:08:05 pm
I need some help to detect loss/presence of AC mains. 24VAC runs into an input pin, through 100k resistor=1/2 wave.

I thought of missing pulse detect by having a timer overflow if AC didn't appear and clear the timer. The timer starts on a rising edge. But if AC is not (initially) present, the timer never sees an edge and just sits there?

It looks like 8-bit TMR2 is available= 16.32msec overflow (16MHz clock and prescale/1024, count of 255) so it's too fast for 60Hz 1/2 wave  smiley-cry
Anyone have suggestions for an algorithm...




12  Using Arduino / General Electronics / Re: mobile power recommendations....help on: November 14, 2011, 05:57:22 pm
AA alkalines or NiMh rechargeables (2,000mAh) would run for around 13 hours. 5-6 cells though.

Maybe your sensor does not have to be on all the time- can you turn it on every second or two to save power?
13  Using Arduino / Programming Questions / What hardware timers available on the Arduino ? on: November 14, 2011, 05:43:06 pm
What hardware timer/counters are available on the Arduino (ATmega328)? Of the three, it looks like one is used for the Delay() and AnalogWrite() library routines. Milli() prob uses one? Also I'm not sure what timer interrupts exist in the stock Arduino.

Just trying to see what MCU resources I can use. I couldn't find docs about this.


14  General Category / General Discussion / Re: Professional Engineers' Perspective? on: October 28, 2011, 05:48:46 pm
Some engineers (like me 10 yrs ago) did hard-core programming in assembly and worried about bytes and micro-seconds and saving every penny. Those days are gone, thankfully. Instead, I can quickly put together a hardware/software solution 10x faster, without the learning curve, without mastering the bit-level and compiler. There is so much community support and libraries too.

I was going to use an ARM7 from scratch for an in-house project. The old-school engineering approach I have done many times. Then I saw the MCU alone has an 1,100+ page datasheet! The software development tools were also buggy, layered and complicated. Do I have time to dig into this, and do PCB layout and coding/debugging with my boss's scheduling and deadlines in my face? I decided to go Arduino and have some fun instead- wasting a few bytes and clock cycles. My Arduino projects are a total success. I just let go of perfection.

But I would not use the Arduino (hardware) in commercial products as they're a bit expensive, the shields (physically) are silly awkward and most Arduino's have limitations that are deal breakers- like my need for them to work at -40C, be micropower run off batteries/solar, something you can bolt down etc. I find them a bit hobby/generic.

My only negatives about the Arduino are the poor documentation for the language and routines. My peers at work did not freak out when they saw the Arduinos on my desk (instead of me "rolling my own" from scratch) so my manliness did not take a hit. I will keep using the Arduino a lot for in-house, development, hobby stuff.
15  Using Arduino / Programming Questions / Re: math with float not working on: October 20, 2011, 06:35:15 pm
Thanks for verifying the code  smiley-surprise  I was running a Mega328 and tried it on a Mega2560, as a quick check if more RAM would help, but no change. It has to be a side-effect, stack mismatch. I found the EEPROM read routine seems to be the culprit, having a Union declared inside (?)
Code:
//-----------------------------------------------------
float EEPROMreadFloat(int address) {
  union floatStore {
    byte floatByte[4];
    float floatVal;
  } floatOut;
 
  for (int i = 0; i < 4; i++)
    floatOut.floatByte[i] = EEPROM.read(address + i);
  return floatOut.floatVal;
}
//-----------------------------------------------------

I moved the union declaration up to the top of the program it started working. I hope that's it. I checked all other routines for in/out variable passing and couldn't see anything off. I assume doubles and floats are the same (size).
Pages: [1] 2 3