Show Posts
Pages: 1 ... 8 9 [10] 11 12 ... 25
136  Using Arduino / Microcontrollers / Re: How to enable BOD fuse? on: May 15, 2013, 11:37:16 am
4,3V BOD has troubles working against USB Pwr and is very sensible , let's say it's on the hi end, more a 4,9 than a 4,3, I had my share of trouble trying out The BOD options.
BTW if you use avr-dude it's easy to program just the fuses without changing the program flash
Oh cool! Can it be done via USB?  I don't have dedicated ISP, and use Arduino as ISP...

I recommend fixing the power connector instead...

I did all I could. Using highest quality silver plated DC sockets and quality DC adapter with good plug. Issue did occur with inferior parts... That should probably reduce chances of such issue almost to 0. But enabling BOD will add another layer of protection, so I think it should be good enough smiley
137  Using Arduino / Microcontrollers / Re: How to enable BOD fuse? on: May 12, 2013, 05:24:00 pm
I don't know about the calculator site, where is it???  That would sure be easier.

Anyway, to the best of my knowledge, yes you have to burn the boot-loader again to set the fuses.  avrdude.exe should be able to tell you the current value for the fuses for a chip that doesn't have that stuff locked out.  

I don't know why ArduinoISP can't burn them, does anybody else know???
Calculator is on this site
I just figured out that typing in values manually will show which values are set, so that part is clear smiley
So I do have to burn bootloader. That's ok, thank you! smiley
There are 3 BOD levels, which would be recommended to select? One that's set to 4.3V?
Edit: I tried 4.3V and it would reset all the time when powered by FTDI (strange, should be 5V). So I set it to 2.7V seems stable...
138  Using Arduino / Microcontrollers / How to enable BOD fuse? on: May 12, 2013, 05:13:49 pm
I'm using my custom Sanguino (ATMega644p) based board.
I've had some issues with loosing data stored in EEPROM due to bad power connector, however now I'm seeing much worse issues when program in Flash gets corrupted!  It happens very rarely (so far I've seen it twice in 3-4 months), every time when power is interrupted (i.e. DC plug wiggled). Program is either gone or corrupted, re-flashing it back solves the problem.
I've see other people reporting this issue, and many recommend enabling Brown Out Detection (BOD).
I'm looking for a guide how to enable it on ATMega644p w/ Sanguino bootloader/hardware definition.
Guessing I need to modify boards.txt file, specifically this line:
Code:
atmega644.bootloader.low_fuses=0xFF
atmega644.bootloader.high_fuses=0x9A
atmega644.bootloader.extended_fuses=0xFF
I know about fuse calculator site (not sure exactly which values I need to choose), so using it I can change above values, but do I need burn Bootloader again in order for them to be active in the chip?
From above values, any way to tell what it's set for right now?
Anything I need to do?
139  Using Arduino / Programming Questions / Re: Need help with complex #define statement on: May 11, 2013, 06:49:34 am
I would reccomend using fatlib16's class: http://arduino.cc/forum/index.php/topic,150325.msg1128634.html#msg1128634

This should combine the two though.
Code:
#define fWrite( _pin_, _state_ ) ( ( _pin_ < 16 ) ? fWriteA( _pin_, _state_ ) : fWriteB( _pin_, _state_ ) )

It is using the C/C++ pre-processor syntax. Search macros and defines.
Wow, thanks!  I haven't thought of that!  So that translates to if (_pin_ < 16) fWriteA; else fWriteB 
Neat!
I'll check out fatlib16's class too!
140  Using Arduino / Programming Questions / Need help with complex #define statement on: May 10, 2013, 09:49:19 pm
I need to modify definition of fWriteA to include all pins. How would I combine these 2 statements into one?
Code:
//Atmega644/1284 Version of fastWrite - for pins 0-15
#define fWriteA(_pin_, _state_) ( _pin_ < 8 ? (_state_ ? PORTB |= 1 << _pin_ : PORTB &= ~(1 << _pin_ )) : (_state_ ? PORTD |= 1 << (_pin_ -8) : PORTD &= ~(1 << (_pin_ -8) )))
//Atmega644/1284 Version of fastWrite - for pins 16-31 (Note: PORTA mapping reversed from others)
#define fWriteB(_pin_, _state_) ( _pin_ < 24 ? (_state_ ? PORTC |= 1 << (_pin_ -16) : PORTC &= ~(1 << (_pin_ -16))) : (_state_ ? PORTA |= 1 << (31- _pin_) : PORTA &= ~(1 << (31- _pin_) )))

Also would be great to know what syntax is this? smiley
141  Using Arduino / Programming Questions / Re: How to pass variable to library? on: May 08, 2013, 07:14:11 pm
Thank you guys it was very educational!
I finally found a way around it. Library has Sleep() and Wakeup() functions, so I was able to disable RF12B with those when SD card was in use. It works now! smiley
142  Using Arduino / Programming Questions / Re: How to pass variable to library? on: May 08, 2013, 10:17:44 am
Thanks a lot Paul, that's exactly what I was looking for! smiley
As to revealing what I'm trying to accomplish, well basically (it's kind of complex scenario):
I'm using SD card (to play audio via WaveHC library) and RF12B receiver and both are SPI devices.  They conflict with each other and I need to disable RF12B when SD card is in use. I can do that by pulling SS pin on receiver to HIGH.
However issue is that RF12B uses hardware interrupt and when it's triggered (which happens when chip thinks it received radio signal) library pulls SS pin low, thus killing SD card interface... This interrupt function is part of the RF12B library...
At least that's my understanding of how it works.
My idea is to add variable "cardinUse" and set to true every time I'm reading SD card and then set it to false after I'm done. I want to add "if" check inside RF12B function that get's triggered by interrupt to exit if (cardinUse).
Alternatively I tried using noInterrupts(); but it kills audio and freezes program(looks like waveHC library is also using interrupts).
So as I described in OP, I had issues passing this "cardinUse" to the library. Because  don't call this function directly (it's triggered by hardware interrupt) I can't pass it as function argument ,  so I needed to pass variable separately...
I can post whole code, but it's enormous, doubt anyone will have fun reading it...
143  Using Arduino / Programming Questions / Re: How to pass variable to library? on: May 08, 2013, 09:29:07 am
It doesn't really matter what's inside .cpp or .h file, I'm just looking for theoretical example how to pass variable between sketch and library without passing it as function argument smiley
Here's an example of simple tutorial LED13 library:
LED13.h
Code:
#ifndef LED13_H
#define LED13_H

#include "Arduino.h"


class LED13 {
public:
LED13();
~LED13();
    void on();
void off();
void blink(int time);
};

#endif

LED13.cpp
Code:
#include "LED13.h" //include the declaration for this class

const byte LED_PIN = 13; //use the LED @ Arduino pin 13


//<<constructor>> setup the LED, make pin 13 an OUTPUT
LED13::LED13(){
    pinMode(LED_PIN, OUTPUT); //make that pin an OUTPUT
}

//<<destructor>>
LED13::~LED13(){/*nothing to destruct*/}

//turn the LED on
void LED13::on(){
digitalWrite(LED_PIN,HIGH); //set the pin HIGH and thus turn LED on
}

//turn the LED off
void LED13::off(){
digitalWrite(LED_PIN,LOW); //set the pin LOW and thus turn LED off
}

//blink the LED in a period equal to paramterer -time.
void LED13::blink(int time){
on(); //turn LED on
delay(time/2);  //wait half of the wanted period
off(); //turn LED off
delay(time/2);  //wait the last half of the wanted period
}

So in the above example, can someone show me how to declare a variable so I can change it's value in the main sketch and library will see that it changed?
144  Using Arduino / Programming Questions / Re: How to pass variable to library? on: May 08, 2013, 08:46:41 am
Ok I'll try it another way smiley
Here's Sketch "A.ino"
Code:
#include <B.h>
void setup() {
  Serial.begin (115200);
}
void loop() {
  if (myVar) Serial.println ("True!")
}

How would I declare "myVar" in B.h/B.cpp so I can access it from "A.ino"?

I've tried declaring myVar in B.h,and in B.cpp (as bool myVar;)  but I still get error "myVar not declared" smiley-sad
145  Using Arduino / Programming Questions / Re: How to pass variable to library? on: May 08, 2013, 07:42:38 am
The library can't see your sketch's globals.  That's why you get the error.

You can add a global to the library, which then your function can see.

Or you could add an additional argument to a library function and pass the boolean in that way.

-br

Thank you. Could you give me an example of how to define global var in library and then address it from the sketch?
I added in the .cpp file:
uint8_t myVar;

but when I try to assign value to myVar from sketch it tells me "myVar" was no declared in this scope.  I do have #include in the beginning...
146  Using Arduino / Programming Questions / How to pass variable to library? on: May 08, 2013, 06:46:45 am
I'm trying to modify existing library (RF12B) and send to it a variable (boolean) from my sketch.  As a simple example, let's say I have
Code:
boolean myVar=true;
In the library .cpp file I add:
Code:
if (myVar) Serial.prinln "True";

But I get error:
RFM12B.cpp:22: error: 'myVar' was not declared in this scope

So how can I pass it to the library's function?
147  Using Arduino / Motors, Mechanics, and Power / Re: Most silent motor out there on: May 07, 2013, 01:49:17 pm
Smaller motors are quieter, especially if the case has no ventilation holes. There are some nice micrometal
gearmotors on eBay that are about 15mm across and various voltages and gear ratios.

For lower speeds/powers computer case and CPU fans have a brushless motor that's very quiet - you'd
have to find an old one and cut off the fan blades and housing.
Thank you! That's a good idea about fan motors! I have some from old videocard smiley
148  Using Arduino / Microcontrollers / Re: ATMega1284p issues with SD Card on: May 07, 2013, 06:03:52 am
Just soldered 10K resistor between CS (hex buffer pin going to RF12B) and +5V line. And everything works without having to do anything in the code at all! smiley
Uploaded unmodified example sketch from SDFat: works!
Sketch from WaveShield: it talks! smiley
Receiver sketch for RF12B: receives!
Haven't tried both at the same time yet smiley

Thank you again!
149  Using Arduino / Microcontrollers / Re: ATMega1284p issues with SD Card on: May 06, 2013, 08:50:40 pm
If both devices are using the same SPI port, then you obviously need to
hold their CS pins HIGH when not accessing.
GENIUS!!!!  Thank you thank you thank you!!!
That was it smiley
I didn't know I have to hold unused port HIGH!
As soon as I added this to the setup of the SD Card test sketch:
Code:
pinMode(18,OUTPUT); // Set Output for RF12B SPI SS
  digitalWrite (18,HIGH); // Set RF12B SPI SS high
It immediately started to list files on the SD card!!! smiley

I think I understand now why Wave Shild had pullup resistor on SS line... I'm pretty sure I need to add one to RF12B so I don't have to pull it high from the code, right?
150  Topics / Product Design / Re: Xronos Clock - Arduino Powered Talking Alarm clock on: May 06, 2013, 04:16:28 pm
Thanks!  Yeah I got it cut at Pololu!  :-)
Pages: 1 ... 8 9 [10] 11 12 ... 25