It works but needs edit please

Hi everyone,
nice to be at this forum. This is so cool :slight_smile:

I finally got this to work, although as Iā€™m not the brightest light in the house, I need some pointers please.
Setup:
1 x Micro Maestro 6ch Item #1350
1 x Analog servo, range in 784-3280 (Ch settings tab) binding occurs if less or more than those numbers
Power = V(in) + V(servo) pin (bridged mode)

Project: to move a servo into position at pc startup. (actually a panel cover for a radiator)

see you-tube link :

Description:

  1. when PC psu is switched on, the uMaestro gets 5VSB
  2. when pc on button is pressed, Meastro gets 5v high signal (from PSU) goes to channel 05 analog input pin, sweet :slight_smile:
  3. servo moves to position and stays there .
  4. When PC shuts down 5V goes low, and servo moves back to ā€œhomeā€ position.Also sweet!
  5. (optional switch off PC PSU at switch.)

When the power hits the Maestro, it jumps a bit to the position in the script

I cant figure how to get the servo to move a tiny bit only (maybe servo resolution ?)

What to do ?

Hereā€™s the code :

begin
2000 delay
30 0 speed 
5 get_position   #get the value of input 5 as a number from 0 to 1023
512 less_than    # test whether it is less than 512 (2.5v) -> 1 if true, 0 if false if
1 0 servo           # this part is run when input5 < 512 (2.5v)
else
10000 0 servo    # this part is run when input5 >= 512 (2.5v)
1000 delay 
endif
repeat

regards,
Adrian
:slight_smile:

Hello,

Are you asking how to control its position during the 2-second delay before you set the position the first time? Why not set the position to exactly what you want on startup? Servos often twitch a little when they are first powered up if they are not receiving any control signal.

-Paul

"Are you asking how to control its position during the 2-second delay before you set the position the first time? "

yep :slight_smile:
[servo jitter isnt the problem here]

When power hits the board the servo jumps back to the start of servo range from its last return position if it was on.

I changed some variables but it doesnā€™t seem to work, it keeps booting up at the start of mechanical servo range.

Ask me to make a youtube if it helps

regards,
Adrian

Hello,

I donā€™t think you answered my second question. Why not set the position to exactly what you want on startup? That is, before your 2-second delay, set the position.

Also, I am a little confused - as far as I can tell, you are setting the servo to the start of its range with ā€œ1 0 servoā€, but you say that is not what you want. The default lower limit is 6000 (edit: I should have said 3968), so that is what it will go to if you try to set it to a position of 1.

-Paul

quote
I donā€™t think you answered my second question. Why not set the position to exactly what you want on startup? That is, before your 2-second delay, set the position.

Ah, thanks. Cant see the forest for the trees.
this:
1 0 servo
begin
Fixed :slight_smile:

Um, could you explain a bit further on this,
Quote:
The default lower limit is 6000, so that is what it will go to if you try to set it to a position of 1.

Hello,

What do you mean by ā€œFixed :)ā€? Does it work the way you want now?

The commands ā€œ1 0 servoā€ set servo 0 to a position of 1, which will set it to whatever you have the channelā€™s minimum configured to. By default the minimum is actually 3968, or about 1ms, which is a safe minimum value for typical servos (I accidentally wrote 6000 in my post - sorry). I wonder why you are writing 1 instead of the actual position that you want it to go to.

-Paul

Hi,
Yes, it works. Better than I expectedā€¦:slight_smile:

To your question:
1)quote
"The commands ā€œ1 0 servoā€ set servo 0 to a position of 1, which will set it to whatever you have the channelā€™s minimum configured to "

OK that makes sense.
The analog servo, range in 784-3280 (Ch settings tab) binding occurs if less or more than those numbers

2)quote
"By default the minimum is actually 3968, or about 1ms, which is a safe minimum value for typical servos (I accidentally wrote 6000 in my post - sorry). I wonder why you are writing 1 instead of the actual position that you want it to go to"

Writing 1 (line 1) prevents the servo from swinging at full speed before the servos next position command.

Writing 1 (line 6) sets the default start position, after the servo initialized (line 1).

Whatever the case it works very well and there is only the slightest hint of jitter.

I have tried various integers other than using ā€œ1ā€ in 2 separate commands (line 1 & 6) and it has proved to be useless. The servo either jumps at high speed to its ā€˜enabledā€™ position, or it moves fwd then moves back without reaching itā€™s preset enabled position.

Anyways, its going well, though if there is a better or efficient way to do this Iā€™d be very open to any suggestions.

Iā€™m certain there is a better way to code this but I just dunno, I just copied from the manual and experimented

regards,
Adrian
:slight_smile:

Well, if it works for you, thatā€™s fine. Good luck with the rest of your project!

-Paul

Thanks Paul :slight_smile:

I would like to see if thereā€™s a better way to do this code though

so if any one has the time to spare it would be nice

Cheers,
Adrian
:slight_smile:

Hello,

I already told you that I am confused by why you use 1 and 10000 instead of the actual positions that you want it to go to. If you can post example programs that use the actual positions and tell me what goes wrong, I would be happy to help you debug them. Otherwise, your script is fine - are there any improvements that you are looking for?

-Paul

Hi Paul,
quote
I already told you that I am confused by why you use 1 and 10000 instead of the actual positions that you want it to go to

OK, I changed 1 to 784
this is minimum before binding occurs

The 10000 is where the servo stops in position nearly full sweep

If 10000 is replaced with 3280 or so it only moves to around halfway position
Not maximum deflection

I cant understand why this is unusual to you ???

If 10000 works and servo 3280 as you say should, doesnā€™t then there must be something fundamentally wrong somewhere

Confused :frowning: ???

Are you trying to say that 784 to 10000 is the full range of your servo? Have you configured the minimum and maximum to something other than the default? If that is the case, this is totally reasonable. I just did not understand why you were going from 1 to 10000 without mentioning that you had changed the limits.

-Paul

Hi Paul,
quote
Are you trying to say that 784 to 10000 is the full range of your servo?

yep

quote
Have you configured the minimum and maximum to something other than the default?

yes
The channel settings tab shows min/max at 784/3280
Why this doesnā€™t reflect actual positions in the code is beyond meā€¦
So I am using 784 as minimum, and 10000 as maximum in the code

quote
I just did not understand why you were going from 1 to 10000 without mentioning that you had changed the limits.

Sorry, what change in limits ?

Iā€™m baffled, considering Iā€™m not the brightest light in the house, but some how this code seems to work. I really cant figure out why the limits are not the same as in the channel settings tab.

Why arenā€™t the limits 784/3280 work instead of 1 to 10000 ???

baffled :frowning:

(I am going to try another servo)

dawg, I havenā€™t followed this thread too closely, but from your last thread it sounds like maybe you arenā€™t aware that the position values displayed in the status/channel settings tabs are in microseconds while the values you need to use in your code are in quarter-microseconds. You need to take the number you see in the status/channel settings tabs and multiply it by 4 to get the correct value for your script commands. So if your servoā€™s range is 784 to 3280 microseconds, then the valid values to use in your script are 3136 to 13120.

ā€“David

Hi David,
I didnā€™t know that it needs to be x4

All good now.

Thanks guys for the help, much appreciated.

Sorry for the hassle, Iā€™m a slow learner so thanks for being patient.

regards,
Adrian
:slight_smile: