Page 1 of 1

Making my PF bot go backwards?

Posted: 31 Jan 2011, 19:18
by jaspy
Here is a video of a robot I made to test out my new IR Link:


http://www.youtube.com/watch?v=79fq7T6lpKk

When I was first ready to test it, the motor on the bot that was linked to the motor in port B of the NXT ran backwards.
I thought, 'no problem' and multiplied the data wire in the program by -1. This made my robot run fine apart from one thing, when I pushed the paddles backwards on the remote, the robot went forwards, and when I pushed them forwards it still went forwards? :?: I cannot think what to try next so any help would be greatly appreciated.
p.s. I am still programming in NXG as I am too scared to try anything else. :oops:

Re: Making my PF bot go backwards?

Posted: 31 Jan 2011, 19:59
by hassenplug
It sounds like the reading your getting from the remote control is always a positive number.

In your remote program, check the direction, and multiply by -1, when needed.

Steve

Re: Making my PF bot go backwards?

Posted: 01 Feb 2011, 16:53
by jaspy
:idea: :idea: :idea: :idea: :idea:
I have just realized the problem; after multiplying by -1 I then divide by 7 to give a proportionate value, but of course, dividing a negative number gives a positive result!
To fix it I need to divide then multiply.
Thanks for the reply anyway steve.

Re: Making my PF bot go backwards?

Posted: 01 Feb 2011, 19:10
by hassenplug
jaspy wrote:To fix it I need to divide then multiply.
Love to hear if that solves the problem. However, if I remember my elementary math (from long ago), it shouldn't make any difference.

Steve

Re: Making my PF bot go backwards?

Posted: 01 Feb 2011, 21:39
by mattallen37
No it shouldn't make a difference, if he is using signed variables, but if using an unsigned byte as the variable, it just might.

With the wrapping characteristics of variables that overflow, I think that is the issue. It would have to be a unsigned variable in this case (to cause the issue you observed). Try displaying the values. Try something like a power level of 5, in reverse. Does it display -5 (like you want it to), or something more like 250?