Beginner trying to use arrays


Closed Thread
Results 1 to 9 of 9
  1. #1
    captain's Avatar
    captain Guest

    Question Beginner trying to use arrays

    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

  2. #2
    Join Date
    Jun 2005
    Location
    Wisconsin
    Posts
    382


    Did you find this post helpful? Yes | No

    Default

    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?

  3. #3
    captain's Avatar
    captain Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by DynamoBen
    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..

  4. #4
    Join Date
    Jun 2005
    Location
    Wisconsin
    Posts
    382


    Did you find this post helpful? Yes | No

    Default

    So what information are you trying to store/recall from EEProm?

  5. #5
    captain's Avatar
    captain Guest


    Did you find this post helpful? Yes | No

    Thumbs up

    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...

  6. #6
    Join Date
    Jun 2005
    Location
    Wisconsin
    Posts
    382


    Did you find this post helpful? Yes | No

    Default

    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.

  7. #7
    captain's Avatar
    captain Guest


    Did you find this post helpful? Yes | No

    Talking

    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.

  8. #8
    Join Date
    Jun 2005
    Location
    Wisconsin
    Posts
    382


    Did you find this post helpful? Yes | No

    Default

    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.

  9. #9
    Join Date
    Oct 2005
    Posts
    34


    Did you find this post helpful? Yes | No

    Talking Arrays

    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]]

Similar Threads

  1. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 07:55
  2. Advanced Arrays
    By GoldStar in forum General
    Replies: 2
    Last Post: - 16th May 2009, 06:58
  3. HEX value o/p to PC and arrays
    By Christos_K in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 23rd August 2005, 01:10
  4. word arrays and eeprom
    By Acetronics2 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 9th January 2005, 07:36
  5. storing arrays and reading arrays
    By Yue in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 5th March 2004, 22:03

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts