analogRead to PROGMEM memory of Arduino[SOLVED]

Is it possible to read analogRead a pin in arduino at the same time storing into PROGMEM memory of Arduino ?

I can't really think of a good reason to do so, but yes, you could rewrite the bootloader to do this.
Why not use EEPROM instead?

I have to read a pin every 1ms for about 1000s(~15 mins). Since I cannot store all the data EEPROM(low memory) neither i can serial.print my data at this rate using Arduino Uno, I am only left with using flash memory to store all the data.

During analog to digital conversion you won't be doing anything else. That's about 1/9th of a millisecond.

You might want to try using an SD adapter to log your data.

AWOL:
I can't really think of a good reason to do so, but yes, you could rewrite the bootloader to do this.
Why not use EEPROM instead?

How to rewrite the bootloader to to do this ?

You don't have a megabit of PROGMEM either so the Uno isn't going to work anyway.

AWOL:
You don't have a megabit of PROGMEM either so the Uno isn't going to work anyway.

It has 32 KB of memory, so probably I can do it for a few seconds( just to learn).

arpit1ug:
How to rewrite the bootloader to to do this ?

You should have the source of at least one bootloader - that should get you started.
Don't forget program memory has limited erase/write life and has to be written a page at a time.

Can anybody be more specific on how to rewrite a boot loader to analogRead into Flash Memory or probably provide me some links to read upon to do the above ?

Writing to FLASH from application. Please test and enjoy :slight_smile:

Just use an SD card!

Mark

arpit1ug:
It has 32 KB of memory, so probably I can do it for a few seconds( just to learn).

Maybe you learn what a big waste of time you set off to do.
Write to flash has uses but no help for what you want.

SD adapter -- you can make your own from a microSD to SD adapter sleeve and a handful of cheap components or a cheap chip and fewer components plus wire, solder and time for little more than the price of the SD card and sleeve.

What you get can hold gigabytes, be exchanged and read by PCs, laptops and tablets, probably even phone.

However as of at least 1.6.9 Arduino IDE you can serial print at 250000 baud. Later versions allow much faster. At 250000 you can print 10 chars in 400 microseconds while doing other things so yes you can print to PC if you don't print too much. Analog read results in 4 digits max. The string fits in 5 bytes. Figure it out or add complexity until it fails, no my problem.

I Know about SD cards, its just that I want to use as less number of components as possible, Basically I need a ADC and a memory holder, so probably I will try FPGA if I couldnt find any smaller microcontrollers. If you have any ideas on components which act as ADC as well as gives 1MB memory suggest something. Thanks for helping by the way

arpit1ug:
If you have any ideas on components which act as ADC as well as gives 1MB memory suggest something. Thanks for helping by the way

The cheapest option for that would be an ATTINY chip or something similar and cheap that has an ADC and an SD card. Trying to get that all in one chip is going to cost more as you will have to pay for all those other features on that chip that you aren't even using.

arpit1ug:
I Know about SD cards, its just that I want to use as less number of components as possible, Basically I need a ADC and a memory holder, so probably I will try FPGA if I couldnt find any smaller microcontrollers. If you have any ideas on components which act as ADC as well as gives 1MB memory suggest something. Thanks for helping by the way

You want a memory holder to store how many bytes per millisecond for how long? That is the crux. 1MB may get you 10 bytes per milli for all of 100 seconds.

There are serial memory chips that connect to SPI bus (which SD does too), static RAM as well as EEPROM chips. They get $expensive$ compared to SD in megabyte capacity.

With a 74HC4050 you can voltage-level 6 lines between 5V and 3V, enough to run SD with a 5V controller. If the controller runs 3V (to about 3.7V) then you can wire to SD directly, only need controller and microSD to SD card sleeve (to not solder in the actual card).

GoForSmoke:
You want a memory holder to store how many bytes per millisecond for how long?

I need to store 1 float type number per ms for about 15 mins

Ok. Do the multiplication. 15 minutes is 900 seconds. That’s 900000 ms. Times 4 bytes per float you’ve got 3.6 MB if you store it binary.

arpit1ug:
I need to store 1 float type number per ms for about 15 mins

You need to or you think that you need to?

Why would you convert int data to float (twice the bytes and less accurate) for storage? If the data is used by a PC type device then the smart thing is to do the conversions in the PC type device.

You could store 2 bytes per read into packets with CRC and get more than 400 seconds per MB, a beastly 6.66 minutes worth.

Consider that you want to collect and store data every millisecond, floats are s-l-o-w on AVR's, unless the float stored contains more data than the ADC gives you can only slow down the process and introduce error by converting to float.

Think of 0 to 1023 as how many (VCC/1024) steps were measured. Turning that into 6 place floats does not make it more accurate or right, it just makes it human readable and needs more and slower code to do it while making the data fatter which goes against the whole fast collect and store on minimal devices idea.

arpit1ug:
Is it possible to read analogRead a pin in arduino at the same time storing into PROGMEM memory of Arduino ?

This is a far better choice...