Shop OBEX P1 Docs P2 Docs Learn Events
Need reset? — Parallax Forums

Need reset?

lardomlardom Posts: 1,659
edited 2010-04-26 05:09 in Propeller 1
Is it possible to code a software reset? I'm trying to finish up·a project which will allow me to preserve settings through a reset. If, for example, I program my motor to move 10 centimeters I could do it in one of two ways: I could make it move 10 cm continuously in say, two or six seconds or whatever time I choose. I could also program the motor to move that same 10 cm in 2 cm increments or 1 cm and so on.·Each·mode of operation·saves·three variables. The problem is I have to reset the device twice before I can save all three. I could live with one reset if necessary.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-04-21 23:21
    The REBOOT Spin statement does a software reset. If you look at the description of the clock mode register (CLK) in the Propeller Manual, you'll see that it has a RESET bit. If you set that, you'll get a software reset as well.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-04-21 23:28
    "reboot"?
    But why do you need to reset?, I don't quite understand. From your previous threads if you are trying to save your variables to EEPROM though which sounds like this should be the question, then remember that the EEPROM is busy for a few milliseconds for practically every "write". So if your software ignores that it is busy and tries to write the next variable too soon, it will be ignored. The Q&D way of getting around this is to simply wait 5ms or so (after each write). Some I2C objects poll the I2C device and wait until they respond in which case these objects do not need a delay as they will talk to the EEPROM the very moment that it is no longer busy.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
  • lardomlardom Posts: 1,659
    edited 2010-04-21 23:34
    Thanks Mike. I see the command in the manual.
  • lardomlardom Posts: 1,659
    edited 2010-04-22 00:30
    @Peter, I may have made coding errors. I think I also made an error posting. I don't see my previous post. The double reset is annoying. I'll post my code tomorrow if you'd like to take a look at it. I'm a little frustrated in that I've been trying to solve this problem for three days. I am mentally fatigued. I want clean code. I don't want to cover up an error if I made one.
  • lardomlardom Posts: 1,659
    edited 2010-04-22 15:02
    I attached the app. I went through it again and realized I don't need a reset at all as long as I don't make edits and then download it again. So, that part works OK. What does happen is that after a reset the first method call requires an extra button press. After that I can cycle through the methods with a single button press. How do I eliminate the extra keypress after a reset?

    · The 'Mode_Id' variable writes a 1 or 8 to the eeprom. After a reset the 1 or 8 gets copied to the 'select' variable. 1 calls "continuous" and 8 calls "Stepped". I designed the program to·loop through a series of method calls by pressing the 'A' key on a 4x4 keypad. If·I program 'Stepped', 7 cm and·6 steps I only have to press the 'A' key repeatedly which is what I want.

    'B' choose between "continuous" or "Stepped".

    'A' to accept and start and write Mode_Id to the eeprom

    'D' to move curser·to change settings

    '#'·will·display numbers that have been keyed in to the LCD and write them to the eeprom

    'A' to start
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-04-23 00:40
    Hi Larry,
    I haven't had time to look at this properly but I couldn't help but notice the strings of IF xx == nn statements. Have you heard of CASE statements? Here is part of your code rewritten:
      case select
        2 : Continuous
        3 : LS.mark(distance)
        4 : LS.Full(distance,speed)
        5 : select := 2
        9 : Stepped
        10 :
           Debug.cls
           Debug.gotoxy(5,0)
           Debug.str(string("Back",13))
           LS.LL_mark(distince)
        11 : diff_step
        12 :
         Debug.cls   
         Debug.gotoxy(5,0)
         Debug.str(string("Home",13))
         LS.LL_mark(distince)
         select := 9
    
    



    BTW, since I don't have the hardware hookup or that much time can you just give me a heads up on which methods specifically that are called and from where.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
  • lardomlardom Posts: 1,659
    edited 2010-04-23 02:40
    ·@ Peter, I first saw the select case command in Pbasic but I never studied it. I see its purpose. I will rewrite it.

    ·You said; "BTW, since I don't have the hardware hookup or that much time can you just give me a heads up on which methods specifically that are called and from where."
    ·
    · I suspected that my last post might·expose sloppy thinking on my part. I will clear it up.
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2010-04-23 03:10
    Larry, a well laid out program is easy for almost anyone to read but if you are still inexperienced and write a program then it is so much harder for even someone well versed to read. There are so many things you can change to simply the "code" and in so doing will probably clear away most of your bugs as the structure is laid bare, clean, and visible. Perfection is after all not whether you have nothing else to add but rather that you have nothing left to take away.

    The keypad routine is certainly one that can change. It's a matrix so use repeat loops to scan through columns and return with a code, don't try to toggle backlight or do anything else in this function, just return a code. Don't you have a copy of my keypad matrix routines?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    *Peter*
  • lardomlardom Posts: 1,659
    edited 2010-04-26 05:09
    I worked on my app to make it a bit clearer than before. I replaced all those 'if' statements with 'case'. I worked on·the arithmetic to get the motor to return to a 'home' position in both the 'continuous' and the 'stepped' modes. I'm going to switch to a parallel LCD because of its smaller size.

    · I'd like some help figuring why the app hangs if I key in '13 cm' shakehead.gif in the 'continuous' mode. It works fine up to '12 cm'.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔



    Post Edited (lardom) : 4/26/2010 5:34:10 AM GMT
Sign In or Register to comment.