Shop OBEX P1 Docs P2 Docs Learn Events
Propeller constantly resetting? — Parallax Forums

Propeller constantly resetting?

I have four propellers working together to create a timing system for a drag race. Each propeller is connected to a F4232H mini module, creating 4 separate serial ports. The propellers communicate to a computer via their serial port. I am using the extended fullduplexserial.

I have the code setup as followed:
  startc := "0"

  serial.start(31,30,0,115200)

  repeat until startc == "A"
    serial.RxStr(@startc)
    
  serial.str(string("L"))

  serial.rxflush

  cognew(readSerial, @stack)

The program starts by figuring out what chip it's talking to. It waits for "A," to be written to the serial port where it then sends back a string - either "L", "R'", "S", or "T"
Then the readSerial cog is started where it reads the incoming strings from the computer program. The code is as followed:
repeat

  readBuffer := "0"
  serial.rxflush
  
  repeat until readBuffer <> "0"
    serial.RxStr(@readBuffer)

  if readBuffer == "A"
      serial.str(string("RESET"))

After it initially tells the computer what propeller is communicating with and starts the readSerial cog it will loop through until readBuffer doesn't equal 0. There are many strings that can be sent to the computer, but the biggest one is if it equals "A" again. If it equals "A" then it tells the computer to "RESET", telling the user that the propellers need to be reset.

Here's where my problem comes. Every once in a while (becoming more frequent for some reason) it's like (some) propellers are constantly resetting. I say some because it's not every chip. If I write "A," to the com port I'm expecting to get the identifier back (R, L, S, or T) and if I write "A," once more, I'm expecting to get the reset flag. Now, sometimes this works as expected. Other times, I don't get anything back and have to write it again only to get the identifier. The identifier keeps getting sent. Like I said, it's not every chip. For example the "T" chip will send the reset flag and the other 3 won't.

It's almost like the first part of the code (before the readSerial cog starts) is constantly on repeat.

Now, I added the code just so you can get a better idea of what the program is doing. I don't think this is a code issue. I hope that it makes sense and someone can give me some pointers as to what's happening and how to troubleshoot it. I switched power supplies, unhooked the reset button, basically stripped all the inputs from the propellers just to make sure nothing was shorting the board. I have to have this fixed in order to use this project, it's useless when only the first 5 lines of code works. I should add that I'm not an expert in electrical engineering. My programming experience is in windows software and web design, with the basic stamp and propeller fairly recently.

Comments

  • serial.RxStr is passed the starting address of an area up to 16 bytes in size. This is filled with received characters up until a return character or some other delimiter with the terminating character replaced with a zero byte to mark the end of the received string. It's not clear that you've allocated enough space for readBuffer and startc and the extra bytes are overwriting something adjacent to these variables in memory. Keep in mind that comparisons and assignments involving a string constant don't work the way you might expect them to. The only way they work as expected is when the string is a single character.
  • Why are you starting a new cog, when you could continue in the same one?

    Because if you start a new cog, then there are things to worry about, such as:
    *how large is @stack ?
    *what is the first cog doing after it starts the second cog with "readSerial"? is it looping back to look for startc == "A" again?

  • @"Mike Green" ,

    All strings that are being compared in this case are single characters.

    @whicker

    It continues after reading startc and sending the identifier to monitor variables that values need to be sent to the computer. So the main cog will start a loop to monitor variables and readSerial will be reading the serial port for data coming from the computer. Ones reading the serial port and the other is sending to the computer. No, there is no loop back to startc. The readSerial will send "RESET" as a reset flag if "A" is sent.

    The stack is 50-100 I believe. The thing is though, it's looping back to the very first couple of lines before the cog is even started. It's not even getting a chance to start the readSerial cog.

    The identifier is supposed to be sent once. Not multiple times over and over again. Which means that the propeller is somehow getting reset back to the first lines of code.
  • Please attach your complete program to a forum message (not cut and paste). There are too many bits and pieces missing from what you've described.
Sign In or Register to comment.