Shop OBEX P1 Docs P2 Docs Learn Events
algorithm problem with PBASIC — Parallax Forums

algorithm problem with PBASIC

HillsHills Posts: 13
edited 2004-12-12 11:14 in BASIC Stamp
Hi

Before, I had a little problem writing a program who could search the smallest value in an array. So I went to this forum for help and after reading the answers of my questions, I was able to continue the program and it was fine for the arrays. But now I'm writing an algorithm for a mobile robot using some·arrays and I have another problem with the arrays once again. Actually,·the algorithm·is a program who always makes·loops. Exactly, the algorithm·restarts continuously and stops when·a specified·value is attended. The algorithm have to take the first·values of the array who were defined in the begining of the program for example :
······························· ······· array(6) = 23

Then, the program operates, changes the values of the elements and then restarts with the new values.·The problem is that the values don't want to change. When the algorithm restarts to the·begining, it suppose to·operate with the new values but it always operate with the same values·so·it can't·evolve, advance. If you have a solution, please let me know the fastest as possible because I absolutely need to finish the algorithm for a mobile robot.

Thank you

Note :

Hi K de Jong

I received your replied to my question and it help me a lot. If you have a solution to this problem, please let me know. If you don't really understand, tell me and I'll write the problem more clearly.

Post Edited (Hills) : 12/12/2004 1:03:56 AM GMT

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2004-12-12 01:53
    If you start at the beginning with a 'GOTO Beginning', you get a different effect than if you actually 'restart' the program. One solution is to write the values to EEPROM (Using 'Write'). The EEPROM gets cleared when you PROGRAM the BS2, but NOT when you merely restart the program.

    If you do this, the first thing your program should do is READ from eeprom when you program starts up. Then WRITE to eeprom as you robot 'learns'.

    Note EEPROM has a limited (1,000,000) number of write cycles -- AND a limited size. (Of course, it's VERY easy to add an external 24LC640 SPI eeprom). 1 million may not seem like a small number -- and it isn't. But if you WRITE to your eeprom two times a second, you can wear it out in short order.
  • K de JongK de Jong Posts: 154
    edited 2004-12-12 11:14
    Hi Hills,

    This will be something that can be solved. But I don't understand where exactly your problem is.

    Do you use EEPROM memory? Do you RESET the Stamp or are you just in a loop?

    So, best would be if you could post the relevant pieces of code you have.

    Klaus
Sign In or Register to comment.