Loading...
  Show Posts
Pages: [1] 2
1  Development / Other Software Development / Re: EEPROMex library - An extension of the standard Arduino EEPROM library on: March 25, 2013, 01:39:28 pm
it just sequentially stores them
if you change the order in which you 'declare' the variables you mess it up
you can set a starting address

look at the example 'EEPROMEx' - run it and examine the output - it more or less explains itself

not specifically noted - but you can hard code the address - or use a variable of your own

this is just a convenient way to store variables without overlap or empty gaps

I haven't looked into the other examples - they seem to use another (smarter?) scheme to store variables

if you want - I'd be happy to share a code snippet of what I have so far

*edit* oops sorry - misread and thought you were talking about the EEPROMEx library
2  Using Arduino / Programming Questions / Re: EEPROM Library - Block Read / Write on: March 24, 2013, 10:24:13 am
apparantely somebody else noticed this void (update instead of blindly writing to EEPROM) - and coded a nice library for this

http://playground.arduino.cc/Code/EEPROMex

3  Development / Other Software Development / Re: EEPROMex library - An extension of the standard Arduino EEPROM library on: March 24, 2013, 10:16:28 am
Great - I just stumbled across the limitations of the standard arduino EEPROM library, and this will be real helpful

Thanks for sharing!

tip: make a note about memory used if you include this library, this is always an issue on the 168/328p based boards
tip: most RTC ds1302 modules sold on ebay include a i2c EEPROM - supporting external EEPROMs and in particular this module with a simple example would be a great idea. Most vendors don't even seem to know it is on their module (let alone the optional ds18b20!)
4  Using Arduino / Project Guidance / Re: ArduinoISP on serial rs232 on: March 22, 2013, 08:40:29 pm
Just a follow up ...

I eventually did get it working - using a stand alone 328p
it seems there is a bad connection on the breadboard

I will have to solder it up on some protoboard to get a reliable result.

powered by 4xAA rechargeable
max rs232 to convert rs232 to ttl level
stand alone 328p running the ArduinoISP sketch

When I find some time I'll post some schematics
5  Using Arduino / Project Guidance / Bandgap voltage problems (revisited) on: March 22, 2013, 08:27:10 pm
I am trying to write a sketch that measures the bandgap voltage as precise as possible, and writes the value to the eeprom for future reference
I want to use a 2.5v reference ic on AREF

for those dropping in on this discussion - please read up on the matter - a good starting point is this thread:
http://arduino.cc/forum/index.php/topic,38119.0.html

My code is heavely based on the previous work of Coding Badly, and RetroLefty

My problem is - the code using the sleep mode to produce better results seems to reset the analogreference to internal - where I would like to use an external reference, using a LM336 2v5 (an affordable 2.5 volt reference ic)

my code:

Code:
// use reference 2,47v on AREF to measure the bandgap voltage

#include <avr/sleep.h>

ISR(ADC_vect)
{
}

// This performs an A/D conversion using the current ADMUX settings.  You must set ADMUX before calling this function.
int rawAnalogReadWithSleep( void )
{
  // Generate an interrupt when the conversion is finished
  ADCSRA |= _BV( ADIE );

  // Enable Noise Reduction Sleep Mode
  set_sleep_mode( SLEEP_MODE_ADC );
  sleep_enable();

  // Any interrupt will wake the processor including the millis interrupt so we have to...
  // Loop until the conversion is finished
  do
  {
    // The following line of code is only important on the second pass.  For the first pass it has no effect.
    // Ensure interrupts are enabled before sleeping
    sei();
    // Sleep (MUST be called immediately after sei)
    sleep_cpu();
    // Checking the conversion status has to be done with interrupts disabled to avoid a race condition
    // Disable interrupts so the while below is performed without interruption
    cli();
  }
  // Conversion finished?  If not, loop.
  while( ( (ADCSRA & (1<<ADSC)) != 0 ) );

  // No more sleeping
  sleep_disable();
  // Enable interrupts
  sei();

  // The Arduino core does not expect an interrupt when a conversion completes so turn interrupts off
  ADCSRA &= ~ _BV( ADIE );

  // Return the conversion result
  return( ADC );
}

int bandgapRead(byte us =250) // returns raw measurement of bandgap with aref = 2,47v
{
       
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)  // For mega boards
//  const long InternalReferenceVoltage = 1100L;  // Adjust this value to your boards specific internal BG voltage x1000
        // REFS1 REFS0          --> 0 1, AVcc internal ref. -Selects AVcc reference
        // MUX4 MUX3 MUX2 MUX1 MUX0  --> 11110 1.1V (VBG)         -Selects channel 30, bandgap voltage, to measure
  ADMUX = (0<<REFS1) | (1<<REFS0) | (0<<ADLAR)| (0<<MUX5) | (1<<MUX4) | (1<<MUX3) | (1<<MUX2) | (1<<MUX1) | (0<<MUX0);
 
#elif defined(__AVR_ATmega8__)  // Atmega8 has a 1.3V bandgap. UNTESTED!!! // http://forums.adafruit.com/viewtopic.php?f=25&t=12547
//  const long InternalReferenceVoltage = 1300L;  // Adjust this value to your boards specific internal BG voltage x1000
        // REFS1 REFS0          --> 0 1, AVcc internal ref. -Selects AVcc external reference
        // MUX3 MUX2 MUX1 MUX0  --> 1110 1.1V (VBG)         -Selects channel 14, bandgap voltage, to measure
  ADMUX = (0<<REFS1) | (1<<REFS0) | (0<<ADLAR) | (1<<MUX3) | (1<<MUX2) | (1<<MUX1) | (0<<MUX0);
#else  // For 168/328 boards
//  const long InternalReferenceVoltage = 1100L;  // Adjust this value to your boards specific internal BG voltage x1000
        // REFS1 REFS0          --> 0 1, AVcc internal ref. -Selects AVcc external reference
        // MUX3 MUX2 MUX1 MUX0  --> 1110 1.1V (VBG)         -Selects channel 14, bandgap voltage, to measure
  ADMUX = (0<<REFS1) | (1<<REFS0) | (0<<ADLAR) | (1<<MUX3) | (1<<MUX2) | (1<<MUX1) | (0<<MUX0);
#endif

  delay(us);  // Let mux settle a little to get a more stable A/D conversion
        // Start a conversion 
//  ADCSRA |= _BV( ADSC );
        // Wait for it to complete
//  while( ( (ADCSRA & (1<<ADSC)) != 0 ) );
        // Scale the value
//  return ((InternalReferenceVoltage * 1023L) / ADC); // calculates for straight line value
  return (rawAnalogReadWithSleep());
}

void setup() {
    // initialize the serial port
    Serial.begin(9600);

  pinMode(10, OUTPUT);    // set the digital pin as output:
  digitalWrite (10, HIGH);

  pinMode (9, OUTPUT);  // quick and dirty - make pin9 a gnd - for easy led connection when using pin10
  digitalWrite(9, LOW);

  analogReference (EXTERNAL);
  delay (200);
  pinMode (A5, INPUT);
  int dummy = analogRead (A5); // dummyread
  delay (10000);  // measuring the AREF pin produces a nice 2.47v during this delay
                  // but as soon as we try and measure the bandgap voltage
                  // analogreference seems to revert to internal

  digitalWrite (10, LOW);
}

void loop()
{

  Serial.println (bandgapRead());
  delay(200);
}


In case someone has a atmega8, please verify if the bandgap voltage is indeed 1.3v ?
Thank you all for your contributions
6  Using Arduino / Project Guidance / Re: ArduinoISP on serial rs232 on: March 13, 2013, 11:21:48 am
Update ...
I have tested my idea using the Uno R3 - and that works
And I realized - that if this works using rs232 - it could probably also work using a wireless serial protocol - with some adaptation to the sketch off course - but first i need to go back to the standalone 328p and figure out why that was not working as an isp
To be continued ...

Some more info for those that want to do the same sort of thing ... what works so far:

Arduino ide 1.0.3 on a mac
pl2303 usb to rs232 serial converter
max232 (rs232 to ttl) converter hooked up to tx/rx on a
arduino uno r3 clone, battery fed with 4xAA rechargable battery @ 5v, running the ArduinoISP sketch (adafruit fork)
connected to the target - a 328p

The sketch I am uploading is a customised blink sketch - the rate of the led is changed to show the sketch reached the destination smiley



hmmm - no inline youtube movies?

7  Using Arduino / Project Guidance / Re: MAX voltage level for 5v arduino question on: March 10, 2013, 09:02:36 am
I have used 4xAA rechargeble batterys before, measured at about 5,5v, and did not have any problems with that so far
i even use them to connect through the arduino connector, but passing through the on board regulator means you lose about 1 volt (tested on my mega1280)

hope this helps
8  Using Arduino / Project Guidance / Re: Arduino 2560: ISP for ATMEGA2560 on: March 10, 2013, 08:52:46 am
I think the basic principles apply to an atmega 1280 or atmega 2560
if it is a arduino board, it has a icsp connector you can use
if not - look in the datasheet to find out what pins to connecto to 5v, gnd, miso, mosi, clk, and off course reset
and off course connect a crystal

maybe post pictures, more information if the target is a bare ic or a board, will get you some more help ?
9  Using Arduino / Project Guidance / Re: ArduinoISP on serial rs232 on: March 09, 2013, 09:29:42 pm
I was wondering if you have a spare pcb for that programmer you built?
Only thing that is missing for what I have in mind is a zif socket to program bare chips smiley
I also wonder - if there is no sd card - can you upload a sketch like you do with the arduino/avrdude ? Like if you want to test and find out you need to change things, do you have to compile and put the new hex file on the sd card first?

If you plan on adding an lcd - consider using a touch screen - that would make an awesome interface, but would probably force you to use a mega (for extra pins and memory)


update: still no joy - but I have to admit I got a bit distracted and didn't spend much time on it these last days
I am uncertain about a reset line on the programmer though - from what I learnt so far I don't need to reset the programmer when the serial communication starts
using the uno as a programmer I disable the reset signal using the cap, right?
and the arduinoISP sketch resets the target when it needs to, right?
Just double checking the obvious things - correct me if i'm wrong

so far I think the serial connection is not working right - but I'm still not sure. maybe the arduino/avrdude doesnt like the usb to serial pl2303? I'm going to try and verify that when I find some more time - use the uno but connect the max232 to the tx/rx pins and see if that works


10  Using Arduino / Project Guidance / Re: ArduinoISP on serial rs232 on: March 08, 2013, 06:45:05 am
Yes, a standalone programmer would be very nice for the 'hidden' modules, and I probably will end up building me one of those in the end
I did come across your site in an early search how to make a standalone 328p, and how to set the fuses correctly. Is it my idea or has your project actually evolved a lot in the last half year or so? I am definately going to have to reread all your information. Thanks for sharing and documenting your ideas! (btw - the arduinoISP adafruit version uses the exact 8Mhz pin 9 idea - one of the reasons I use that version)

but for now I want to try and get this experiment running, learning along the way how everything works, get a better understanding of the whole process. This evening I hope to continue and find out what is going wrong exactly

And as I'm also still learning to program, I do feel I need a direct link between the computer and the module, as I seem to need a lot of debugging and testing to get things working

Right now struggling with a test setup of a wireless module and pointers in C - which is actually the direct motivation of trying to build this programmer - I was fed up with the Uno's flaky behaviour as an isp, and swapping the 328p in and out of the module to test things

(the uno totally dislikes being unplugged from my usb and plugged back in - it flashes the pin13 led fast and is totally unresponsive - I have to reprogram the sketch to get it working again - I have not been able to find more info on this weird behaviour - but I figure it has to do with the usb connection in some way)
11  Using Arduino / Project Guidance / Re: ArduinoISP on serial rs232 on: March 07, 2013, 09:43:38 pm
almost ...

the isp is not permanent (to save costs - I plan on having several 'targets')

the target is 'hidden', but I would have a connector that can be reached - and would allow to reprogram and debug
the isp would be hooked up to this connector to allow reprogramming fuses/sketch - maybe even serial communication to allow debugging
so basicaly - a icsp header with added tx/rx - would cover everything I think

so far not much joy on my breadboard experiment - but i'm pretty sure it can be done
I must be overlooking something obvious and simple - right now I'm having trouble using my Uno as isp too

Ah - it is very late and sleep deprivation doesnt help with this sort of thing smiley-sad
Thanks for your insights, they really help a lot!

quick update:
using usb and the uno as isp - i can program a target on the breadboard
but using rs232 and a 328p i keep getting an error 'avrdude: stk500_recv(): programmer is not responding'

tomorrow I'm going to double check that serial communication is working, and I'm going to try serial communication with the uno as isp
Any other trouble shooting tips are welcome

btw - using the uno as isp is problematic, to say the least - i'm not even going into that as I don't think it is related, or relevant to this experiment


12  Using Arduino / Project Guidance / Re: ArduinoISP on serial rs232 on: March 07, 2013, 08:30:57 pm
mmm - yeah - I guess it gets confusing
first want to thank you for your info - I came across it in my search for breadboarding up a 328p, and reprogram the fuses, and it helped me a lot!

So let me try and explain what I want to do exactly:

the mac is running arduino ide - it has a prolific 2303 usb to rs232 converter
-
(long) rs232 cable
-
a max232 chip converts the signal to ttl and is part of the (battery fed) programmer - which is basically a 328p running the arduinoISP sketch
-
which programs the target, a 328p low voltage module which is in a difficult to reach place


my motivations?
why rs232? is an easy way to bridge quite a long distance - and I have the parts on hand
why not program the target through a ftdi/bootloader? usb cables are limited in length - ftdi does ttl serial - also limited in cable length I'd think
why the more complex programmer approach? I need one anyway to reprogram the fuses - so i figured to make it multi functional - and I'm fed up with having to pull my uno from other projects any time I need to program a 328p. And I have a couple of 328p to spare smiley

alternatives I have considered?
rs232 cable and reset the 328p using the rts signal - using a standard optiboot bootloader - which is something I will try too. Main disadvantage: you can't program the fuses or bootloader
ethernet or internet programmable modules ... some people are working on a bootloader that allows programming the 328p over the internet - but it is far from ready yet

my goal? design a module that can be permanently integrated in my house. figure out what connections the target has to have so I can reprogram it later without having to redesign it. So far I figure, if I have a icsp connector - and maybe add the tx/rx combo, I can reprogram the fuses and the sketch without having to remove the module
13  Using Arduino / Project Guidance / Re: ArduinoISP on serial rs232 on: March 07, 2013, 06:22:34 pm
i don't think so ...
I am using a 328p with the arduinoISP sketch as a programmer - to program a module based on a 328p

When I use a arduino Uno as the programmer, I have to use a capacitor to prevent the uno to reset when the ide starts sending code
it is the programmer that resets the target, using pin 10 wired to the reset of the target

But please correct me if I'm wrong on this

I understand that programming an arduino directly with rs232 would need this functionality.
I do plan to try this approach too, but for now I need a programmer anyway as I reprogram the fuses too on the target. I have done this using a arduino Uno as a programmer so far, but now I want to make a dedicated programmer
14  Using Arduino / Project Guidance / Re: ArduinoISP on serial rs232 on: March 07, 2013, 05:16:33 pm
I think my setup is not too far off from this ...

On the mac side I use a usb to serial converter based on the prolific 2303 chipset - this is true rs232

On the arduino programmer side I use a max232 chip to convert to ttl level

So far I have not figured out the reset trick with rts - (My max232 chip doesnt have the connection for that) - but I don't think I need to in my case?

As the arduino/328p modules are low level battery powered, and I don't want to risk damaging components (nRF24l01 wireless module - to name one) that are not meant for 5v, I want to use a programmer to (re)program. I plan to make the programmer battery powered and switchable between 3,3v and 5v. This way I can have a long cable run. (tested 20m between this pl2303 and a siemens logo and that worked flawless)

There is more coming, but for now, I want to get the basics working.
I am going to go over everything again, double check connections, probably some minor detail.

But from what I read here, I'm pretty certain my idea is feasable
thank you for the feedback

If anyone is interested in my progress, I'm happy to share
15  Using Arduino / Project Guidance / ArduinoISP on serial rs232 on: March 06, 2013, 09:24:50 pm
I want to build my own programmer using a 328P running the arduinoISP sketch, and rs232 to hook it up to the computer
I want to use the arduino IDE to program the target (using the menu entry "upload with programmer")

I gave this idea a try on a breadboard and it doesnt seem to work - "avrdude: usbdev_open(): did not find any USB device "usb"

Did anyone try this idea, and get good results? Or does the arduinoISP sketch only work via usb?

Some more details for those that are still reading:
Mac Running IDE 103, arduinoISP sketch is the adafruit version (works on an Uno board)
selected the correct board, selected the correct serial port, selected arduinoISP
I verified the serial communication is working (9600 baud with another sketch)
Hardware is shown on http://avrprogrammers.com/bld-avr-arduino-isp-232.php

Why do I want to do this?
rs232 allows for longer cables than usb, and you can easely solder the connectors yourself. I need to bridge some distance between the computer and the arduino/328P modules i want to (re)program
Pages: [1] 2