PDA

View Full Version : Looping Variable Assignments



jcb344
- 4th July 2008, 19:01
Hi,

I am building an application that reads an analog signal from one of the adc pins and then saves it to a progressively different variable. I want this action to be looped so I can do it 50 or so times before coming out of the loop. So my question is is their any way of incrementally changing the ram byte address each time the loop comes around or do I have to spell out each variable address (b0,b2,b3…) in my code. I know this is posable if I do this for sending the data to the eeprom but I don't want to slow down the process. Also is it true that the picbasic compiler can only access 96 bytes of ram? I want to take advantage of the PIC16F688 256B of ram. Thanks in advance.

-Jacob B.

tenaja
- 4th July 2008, 19:03
Read in the manual or Help file about arrays. They will do what you want.

jcb344
- 5th July 2008, 00:59
But is their any way of doing this without the pro version, and are you limited to the amount of variables in either version?

Melanie
- 5th July 2008, 09:50
I can't give an authoratative answer (for RAM usage) for the standard PICBasic Compiler (PBC) as I don't use it, but the Pro is constrained only by the limits of the PIC you are using. I have applications with hundreds of variables working just fine. For PBC consult the product specifications, or even send MeLabs an email directly.

As tenaja suggested, use an array. I use just this method for taking multiple sequential ADC readings, and I'm sure you will find suitable examples posted on the forum. The ADC on a 40MHz PIC is fast enough to capture Audio (not exactly Hi-Fi but it does work) - but you have to send it to external Memory as the internal EEPROM is way too slow.