Show Posts
Pages: 1 [2] 3
16  Using Arduino / Microcontrollers / [SOLVED] Atmega644 - problem with digital read on pins 24 (D18) and 25 (D19) on: December 13, 2012, 05:49:24 pm
Hi,

I'm try to read the state of each switch on a DIP switch.


Code:
void setup(){
pinMode(19, INPUT); // Set pin to input
pinMode(18, INPUT); // Set pin to input
pinMode(15, INPUT); // Set pin to input
digitalWrite(19,HIGH); // enable internal pull-up
digitalWrite(18,HIGH); // enable internal pull-up
digitalWrite(15,HIGH); // enable internal pull-up

if (digitalRead(19)==LOW)
        volumeCtrlLocked=true;
else volumeCtrlLocked=false;
if (digitalRead(18)==LOW)
outputLocked=true;
else outputLocked=false;
if (digitalRead(15)==LOW)
phaseLocked=true;
else phaseLocked=false;
}

The digitalRead on pins 24 (D18) and 25 (D19) always returns LOW for some reason. D15 responds as expected, it only returns LOW when the switch is closed.
It also works fine when I connect the DIP switch to some other digital pins, instead of D18 and D19.

I'm using the Sanguino software and upload the code using an Uno. At first I thought that it might have something to do with the JTAG interface being enabled, but the problem still occurs after disabling it by setting the fuses.

The reason that I want to use this pins is that I have a PCB that connects the DIP switch to these pins, so using other pins in no real option for me.
I must be missing something here...

EDIT: I attached the boards.txt file with the settings of the fuses and other settings as well.
17  Using Arduino / Microcontrollers / Re: EEPROM gets erased when programming Atmega644 (Arduino as ISP) on: December 09, 2012, 04:53:59 pm
I got impatient and changed the boards.txt file with success! I needed to upload the bootloader again before the change had the desired effect.
18  Using Arduino / Microcontrollers / Re: EEPROM gets erased when programming Atmega644 (Arduino as ISP) on: December 09, 2012, 04:20:39 pm
you can set a fuse bit to prevent the eeprom from being erased during a upload

http://www.engbedded.com/fusecalc

Quote
 Preserve EEPROM memory through the Chip Erase cycle; [EESAVE=0]

be careful, setting fuses can screw you up
Thanks for your reply. I found the answer myself. I forgot that I had Atmel studio installed  smiley-red

Is it OK to change the high fuses in the boards.txt file to high_fuses=0x92? (see my fore last reply)
19  Using Arduino / Microcontrollers / Re: EEPROM gets erased when programming Atmega644 (Arduino as ISP) on: December 09, 2012, 04:18:07 pm
Oke I was a bit to fast with asking. I know now why the EERPROM gets erased. The fuses are set to erase the EEPROM at the chip erase chip prior to programming it. Correct me if I'm wrong  smiley-roll-sweat

When looking at Sanquino's board.txt file:
Code:
atmega644.name=Sanguino W/ ATmega644P

atmega644.upload.protocol=stk500
atmega644.upload.maximum_size=63488
atmega644.upload.speed=57600

atmega644.bootloader.low_fuses=0xFF
atmega644.bootloader.high_fuses=0x9A
atmega644.bootloader.extended_fuses=0xFF
atmega644.bootloader.path=atmega
atmega644.bootloader.file=ATmegaBOOT_168_atmega644p.hex
#atmega644.bootloader.file=ATmegaBOOT_644P.hex
atmega644.bootloader.unlock_bits=0x3F
atmega644.bootloader.lock_bits=0x0F

atmega644.build.mcu=atmega644p
atmega644.build.f_cpu=16000000L
atmega644.build.core=arduino
atmega644.build.variant=standard

Is see that the low_fuses=0xFF, high_fuses=0x9A and the extended_fuses=0xFF.
When I fill in these values at 'Atmel studio's AVR simulator - device programmin' I see that the 'EESAVE' option is not checked. When I check it the high fuses change to 0X92.

Is it OK to change the high fuses in the boards.txt file to high_fuses=0x92?
20  Using Arduino / Microcontrollers / <SOLVED> EEPROM gets erased when programming Atmega644 (Arduino as ISP) on: December 09, 2012, 03:55:20 pm
Hi,

I'm programming an Atmega644 using the Arduino as ISP. For this I'm using the Sanquino software add in for he Arduino IDE. For some reason the EEPROM gets erased every time I upload the code to the 644.

For uploading I use an Arduino Uno (SMD version) with the Arduino ISP sketch. It doesn't matter if I use Visual micro for compiling and uploading or the Arduino IDE.

Any ideas why the EEPROM gets erased and how I can stop it from getting erased when uploading new code?
21  Using Arduino / Networking, Protocols, and Devices / Re: pull-up resistors for the I2C connection on: November 01, 2012, 12:12:40 pm
Very interesting and informative.
22  Using Arduino / Networking, Protocols, and Devices / Re: pull-up resistors for the I2C connection on: November 01, 2012, 02:01:39 am
Thanks, most devices are not far way (max 20 cm) and some are on the same pcb.
23  Using Arduino / Networking, Protocols, and Devices / pull-up resistors for the I2C connection on: October 31, 2012, 03:31:53 pm
When connecting multiple I2C devices/slaves to the Arduino do I need pull-up resistors at each slave or is one set of pull-up resistors enough. When I look a different examples I see both setups.



and

24  Using Arduino / Programming Questions / Re: Storing IR codes in EEPROM on: October 21, 2012, 03:21:40 pm
That's what I needed. Thanx!

I'm still struggling on how to store IR codes that switch bits back and forth on every key press for a single key. Like the RC5 protocol does.
when a single key is pressed once I receive the following value:

Code:
110100000001

Press the same key again and I get this value:

Code:
10100000001

Press it once more and it goes back to the first value:

Code:
110100000001

Storing these codes is not a problem anymore. But I really don't see a simple way to use these codes after storing them. When remote sends the same code every time a single key is pressed it is easy to use it, but when it changes on every key press I need to store both codes and later on compare any new received to both of the stored code or something like that. I know how to compare codes, but there must be a easier method then the one I described.
25  Using Arduino / Programming Questions / Storing IR codes in EEPROM on: October 20, 2012, 08:47:49 pm
Hello,

I'm trying to figure out a good and simple way to store IR codes to the EEPROM of the Arduino Uno. I am building a DAC and want to create some sort of IR learn function that allows me to teach my DAC the IR codes for certain functions.
I'm using Ken Shirriff his IR library to get the codes, but the codes consist out of two sets of 32 bits for nearly all my remotes. If I get it right I can only store 8 bit values to the EEPROM at the time, so I need to split the received value. Now this is where I'm beginning to struggle. I must warn you that I'm really not into bits and byte but I'm eager to learn.

I used this to split the 32 bits binary value into four pieces (probably not the best way)

Code:
a = lowByte(results.value);
b = (results.value >> 8);
c = (results.value >> 16);
d = (results.value >> 24);

this is done twice for most IR codes
Now I have this four/eight pieces and want to store these to a certain location in the EEPROM, so when a remote is used the code can compare its code to the stored code and should therefore be able to determine which function it should call. I know how to store and read the values in the EEPROM by using a small loop to shift position at the EEPROM, but how to handle remote codes that switch bits between each key press?

I can't see the forest for the trees anymore  smiley-sad-blue

It is probably done before....


26  Using Arduino / Microcontrollers / Re: Upload to stand alone Atmega328 Using Arduino Uno SMD edition on: October 14, 2012, 11:06:19 am
Thanks! That's what I was doing wrong. I used the upload button instead of the menu option "Upload using programmer".
27  Using Arduino / Microcontrollers / [SOLVED] Upload to stand alone Atmega328 Using Arduino Uno SMD edition on: October 13, 2012, 08:41:14 am
Hello,

I'm quite new to programming AVRs. I managed to upload the bootloader to my Atmega328 by using these tutorials:

1.  http://arduino.cc/en/Tutorial/ArduinoToBreadboard
and
2.  http://arduino.cc/en/Tutorial/ArduinoISP

Now want to upload a sketch to it. I had already managed to upload sketches to Attiny's before, but when I try to use the Arduino as ISP programmer to program the Atmega328 it gives an error "avrdude: stk500_getsync(): not in sync: resp=0x00". The error LED controlled by the "mega-isp" sketch also starts burning. Maybe i'm doing something wrong here, perhaps programming it with the Arduino as programmer  is impossible when the bootloader is already burned to the chip??

The first tutorial says that the Atmega chip needs to be removed and then the stand alone Atmega can be programmed via USB by connecting it to digital pins 0 and 1. Removing the atmega is more or less impossible with the SMD edition of the UNO, so is there any other solution to use the arduino as programmer?
28  Using Arduino / Sensors / Re: how fast is the digitalread function? on: July 28, 2012, 09:36:17 am
No, not a hall sensor. It came to my mind, but using a precision resistor the measurements become a lot more accurate. It has two extra legs for measuring the voltage over it.

The datasheet.
http://www.produktinfo.conrad.com/datenblaetter/425000-449999/447331-da-01-en-Praezisionswiderstand_PBV.pdf
29  Using Arduino / Sensors / Re: how fast is the digitalread function? on: July 27, 2012, 05:57:51 pm
I wrote the ShowInfo sketch: http://arduino.cc/playground/Main/ShowInfo
There is a speedtest in it.
On a Arduino Uno, the AnalogRead uses 112 us.
But if you write your own code to control the ADC, it can be faster.
Nice! This makes it clear that the arduino is fast enough to sample every 2 ms and also do some calculations with the data.
30  Using Arduino / Sensors / Re: how fast is the digitalread function? on: July 27, 2012, 11:34:21 am
Wouldn't it be easier to monitor the line-in signal then, if no input was coming in than for sure nothing was being amplified.
Add a simple envelope follower circuit and a comparator. When the comparator was not tripped for a long time, use that as the turn-off signal.
I`m not that familiar with electronics, but it sounds like it has to be build into the signal path. I have two reasons for not wanting to use this envelope follower.
1. Lack of space between the input and the amps.
2. I don`t like the idea of more components in the signal path. Less=more  smiley-lol

Anyways, I must have been real sleepy last night (and this morning) smiley-roll-blue I wrote digitalRead instead of analogRead and also 2 us instead of 2 ms

Reading every 2 ms means 500 samples per second.  Reading the replies I understand that an arduino is suitable for the job.
Pages: 1 [2] 3