Hi I have a Mini Maestro 12 and a airspeed Sensor ( robotshop.com/eu/en/airspeed-sensor-kit.html )
I want to move a servo by the airspeed sensor
Sensor is connect on channel 3 as input
Servo on channel 5 as servo
I tried this code below but is not working, the sensor is working as I look at the maestro control software in the status tab the slide is moving
Servo is working if I move the slide in the software
can someone help me with the code
get_position # get the value of input 3 as a number from 0 to 1023
512 less_than # test whether it is less than 512 -> 1 if true, 0 if false
6000 5 servo # this part is run when input3 < 512
7000 5 servo # this part is run when input3 >= 512
I am sorry you are having trouble using the Maestro. It looks like you might have omitted a “3” from the beginning of your code. (If you try to compile the script without an initial value like “3”, the Maestro will throw errors.) Otherwise, it looks like your code is okay, though it only runs once. To get your code to loop, you should start your code with
begin and end it with
Hi Jon i fix that problem in the code it running now.
the servo is moving as it suppose to do but I have to run 200 km hour to move the servo it is not sensitive enough it has to move by 40 km per hour
so the script I use is not ok or missing something to make it sensitive. that it will move by 40 km hour
You can limit the speed of your servo by adjusting the “Speed” parameter (under the Status tab of the Maestro control center) for the channel your servo is connected to, or by using the “SPEED” command in your Maestro script.
Hi my script look like this now the sensor is sensitive now
now the servo has to stay at point 6000 until the input drops under the 557 how do I get this to work.
[code]# This example uses speed and acceleration to make a smooth
motion back and forth between 1 and 2 ms.
3 0 acceleration
30 0 speed
3 get_position # get the value of the pot, 0-1023
3 get_position # get the value of the pot, 0-1023
dup 557 less_than
4000 # go to 4000 for values 0-557
dup 573 less_than
6000 # go to 6000 for values between 557-573
6000 # go to 6000 for values greater than 573 to prevent stack overflow
drop # remove the original copy of the pot value
I did not notice anything obviously wrong with your code. Can you tell me what behavior you are getting and what it is you expect to see? Can you also tell me how you have your potentiometer connected? It might be helpful to post pictures of your setup or video of your problem.
its not a potentiometer I have connected but a airspeed sensor ( robotshop.com/eu/en/airspeed-sensor-kit.html )
what I what is to move a tail fin on a scale helicopter when I go to fly forewords the tail fin has to move up and has to stay on that position until I going to land the helicopter
the airspeed sensor must detect the forewords fly by airspeed when the airspeed drops to ( almost 0 ) it has to move the fin down.
As the script is, the servo is moving to a point up but it is going back down when the speed is a bit lower. Example in numbers when I going to fly the fin (servo) has to go up by 40 km hour and has to stay in that position until the speed drops to 5 km hour.
As the script is now, when I fly 40 km hour the fin (servo) is going up, When the speed is 35, 30 the fin is going down when the speed is going 40 it moves up again
or saying it otherwise the fin is moving constantly up and down.
what I like to see is by 40 up and stay dear until the speed drops to 0 and then moving down.
picture of the helicopter and the big tail fin modeltec.ch/media/images/pop … 61_720.jpg
It sounds like your Maestro is responding how it should and this is likely an issue with managing the data from your sensor. Are you doing some kind of averaging? If not, you could write a script that does that with the Maestro and see if it helps stabilize the response of your system. You might also want to incorporate some kind of hysteresis in your system so that if your system is returning a target airspeed very close to your threshold, small changes above and below that airspeed will not cause the tail fin to oscillate.
If you have the space, you might also try adding another microcontroller to your system that efficiently processes a running average of your airspeed sensor’s data, and sends serial commands to the Maestro.
I do not now what you mean by averaging or how to write a code for that
I will need some help with that
what about a movement delay for 7 minutes before the servo moves back to position how do I get that in the code .
that is about the flight time I can fly the helicopter .
You might try searching the Internet for ways to calculate the “mean” or “average” of a set of values, or even the “running average”.
I am not entirely sure if that movement delay would work for you, but to get started, you could look at the “Long delays” example under the “Example Scripts” section of the Maestro’s user’s guide, which can be found under the Resources tab of the Maestro’s product page.
Hi Jon I now what the word average means but the average off what only what I think you mean is the average off the stack
I have looked the internet but I can
t find a code or example off it for the pololu I think its the best solution but don`t now how to make the code
I mean averaging the values of the samples you are reading. One way to do that is to use the
plus command, which removes the top two values from the stack and puts the sum of those two values on the top. You could use the
plus command every time you add a new sensor value to the stack, then divide the final large value by the total number of samples you read from you sensor.