Evaluating algorithm

Trying to write a 'P' algorithm using a steering wheel and wiper motor. Here I have the basic 'P' algorithm. I have the motor moving both directions but now am trying to make it stop when it reaches a certain max/min on each side so it can stay within range of my constrain functions and be able to read, have a little leeway between both, but it still seems to get a little past that max/min and then it seems to not respond since it is out of range....I do not need it to keep rotating in circles which is the reason I tried to implement it. And when it gets to the max/min ends and stops the motor, I need it to continue reading the serial incase I turn the steering again to get going.

Hi,

I’m a bit surprised with your code, especially the structure. It’s kind of difficult to understand what you get as input, how you use the serial interface etc.

From “scratch”, I’d organise it another way, with a loop() that runs the steering, and just (kind of incidentally) also handles serial.

That would be something like (very much abstracted, not syntatically correct):

void loop ()
{
  while(Serial.available ())
  { 
    processIncomingByte (Serial.read ());
  }
 
  // But in any case always do the following :

  speed=AcquireMeasurement(pin);
  error = Calculate_error(speed, consign);
  ApplyPWM (error, consign, pin);
}

My code issue is in the functions processSteer, processWheel, and setSteer.

And yet there is not a Serial.print() statement in site. If you expect us to debug this for you, you'll need to send one of us the hardware. PM me if you need a shipping address.

Nope, still not seeing any debug/trace prints for the algorithm code.

tb0508: then why even respond to my post? If you don't see it then you don't have to help, just go to the next thread.

This faq: http://www.catb.org/~esr/faqs/smart-questions.html answers that question for you in detail.

then why even respond to my post?

Because I'm trying to help you help yourself. If you don't want to take the hint, that's fine.

But in a smart aleck way right?

I also do patronising, if you prefer.

tb0508: It reads in the steering potentiometer SXXX over serial and I have no limit on the pot so it reads it in constantly to calculate the error.

Seems to me that it only executes each command when it reads the non-numeric leading character at the start of the following command. How frequently do you give it steering signals over the serial link? If it's only every couple of seconds, I'd say that was your main problem right there.

tb0508: then why even respond to my post? If you don't see it then you don't have to help, just go to the next thread.

OK, let me ask you a question. Did you read the "sticky" called "Read this before posting a programming question ..."?

http://arduino.cc/forum/index.php/topic,97455.0.html

One suggestion in there (point 7) is:

If you have puzzling behaviour, it is frequently helpful to put "debugging prints" inside your code.

So the hints above were made by people who see, every day, people asking for help without taking elementary steps to help themselves.

Then when they start getting called "smart alecks" it is a bit much.

wow, not used to that in this forum.

?

tb0508: Any help with rearranging code or adding/removing anything what be great.

You asked for help. Someone suggested adding debugging prints. You reply:

If you don't see it then you don't have to help, just go to the next thread.

I would appreciate help from others without them having to read through posts that are unrelated to the topic.

You're going to find it hard to get help from anyone if you lock the thread. Just sayin'...

Wow, please check this thread I made: http://arduino.cc/forum/index.php/topic,101709.msg762992.html#msg762992

Do I get a bunch of people complaining when I ask a simple question without an output?

Not really comparing like with like though, is it?

One is a simple syntax issue, the other a specific hardware-dependent algorithm not easily replicated or observable by other members.

Can you tell me why you are bogging this thread down with useless non sense that has to correlation to the topic at hand?

Because you asked

Any help with rearranging code or adding/removing anything

, so we suggested the "adding" option :)