PDA

View Full Version : Beginner trying to use arrays



captain
- 14th May 2006, 15:55
Hello,
I'm a beginner trying to use arrays stored in EEPROM. I have an interval timer program that needs several different sequences of stop points and jobs to do at each stop point. Only one sequence to be used at one time. Can someone help? Is there an example of software using an array? Please help. The PicBasic Pro manual talks about arrays but does not say how to use them.

Thank You,
Captain

DynamoBen
- 14th May 2006, 16:31
Its difficult to point you in the right direction because I don't have a clear understanding of what you are trying to do.

A few more specifics on what these routines are doing and what type/length of data you are trying to store could help. Also is this the internal EEPROM you are reffering to?

captain
- 14th May 2006, 18:17
Also is this the internal EEPROM you are reffering to?

Yes I am using internal memory.

The program definitions are as follows:
I am programming a timing device in PicBasic. I would like some help with the software architecture. I would like to have 5-10 different timing structures which can be changed via a computer connected to the PIC. An Example of a time sequence is as follows:

Long Pulse = 1 Second (Long), Short Pulse = 1/2 Second (Short)
3 Minutes - 3 Long
2 Minutes - 2 Long
1 1/2 Minutes - 1 Long and 1 Short
1 Minute - 1 Long
30 Seconds - 3 Short
20 Seconds - 2 Short
10 Seconds - 1 Short
5 Seconds - 1 Short

4 Seconds - 1 Short

3 Seconds - 1 Short

2 Seconds - 1 Short

1 Seconds - 1 Short

End - 3 Second

The number of intermediate stops is variable between sequences and what the program does at the end of the sequence is selectable, i.e. Stop; Restart immediately; Restart after a period of time; etc..

DynamoBen
- 14th May 2006, 18:26
So what information are you trying to store/recall from EEProm?

captain
- 14th May 2006, 18:38
I am trying to store/recall the delay times and event times. i.e. 3 - half second pulses, spaces one half second apart at the start of a three minute count, delay 57.5 seconds. 2 - half second pulses, spaces one half second apart at the two minutes. delay 28.5 seconds. 1 - half second pulse, delay 1/2 second, 1 - half second pulse, etc...

DynamoBen
- 14th May 2006, 18:43
Okay so you're hoping to store these parameters in EEProm as a table to recall later.

Then an array is not what you need. You need the following commands DATA, and READ. Take a look at each in the manual.

Basically you're going to use DATA to create the table in EEPROM. Then READ to read info from eeprom into variables. Everything is one byte at a time for the most part.

captain
- 14th May 2006, 19:13
Thanks for the info. Data refers me to WRITECODE due to the fact that I want to have it written realtime. The end result will have the end user enter enter the desired times via PC software. Any further info on either WRITE CODE or the PC interface would be apreciated.

DynamoBen
- 14th May 2006, 19:22
Don't use writecode. The manual is very specific about writecode using program space for storage not EEProm. WRITE is used to store information to EEPROM. Best bet is to consult your manual and experiment. The forum can help but you have to have a fairly specific questions.

Enjoy.

ChrisMicro
- 3rd November 2007, 07:20
To use arrays, first you have to declare the array variable

Sample VAR BYTE[16]
X VAR BYTE

then if you want to write this array to eeprom you have to write one part (Byte) of the array at a time I do it with a FOR/NEXT loop

FOR X = 0 to 15
WRITE X, Sample[X]
NEXT X

and to read it back to the array do the same but use READ

FOR X = 0 to 15
READ X, Sample[X]
NEXT X

And to print the array on LCD

LCDOUT $fe, 1, STR Sample\16

And to send it with SEROUT you have to send the bytes one by one

SEROUT PORTA.7,T9600, [Sample[0],Sample[1],Sample[2],Sample[3],Sample[4],Sample[5],Sample[6],Sample[7],Sample[8],Sample[9],Sample[10],Sample[11],Sample[12],Sample[13],Sample[14],Sample[15]]