Pololu Robotics & Electronics
Menu
My account Comments or questions? About Pololu Contact Ordering information Distributors

Pololu Forum

Programming and

#1

Hello,
i would like to programm that if the first two arguments aren’t both aren’t true that my control should set all servos to a referencepoint but it don’t work. I hope you could help me.
regarts
Riener Lukas-Karl
Not a native speaker

image

#2

Hello.

It looks like you want to check to see if your input on channel 6 is within the 100-800 range (since it cannot be true that it is greater than 800 and less than 100). To do that, you could take a reading of channel 6 with the GET_POSITION command, duplicate it with DUP to check each case, then do a LOGICAL_AND of the results to see if they are both true. For example:

6 get_position    #puts the value of channel 6 on the stack
dup		#puts a duplicate of the same value on the stack
800 less_than     #checks if the value is less than 800
swap 		#swaps the top two values on the stack (to put the reading back on top)
100 greater_than #checks if the value is greater than 100
logical_and         #ANDs the two results together
if
	#code here will run if channel 6's position is between 100 and 800
endif

Please note that if the value of channel 6 is exactly 100 or 800, neither case will trigger, so in practice you would probably want to change the code above so it checks if it is less than 801 and greater than 99.

Brandon