Looking for help with switch code

Hello all,

I am using a 24 Maestro Servo Controller and looking to control a servo motor with a switch. I would like the high signal (255.75) to run to one position (9600) and the low signal (0) to run to another position (2500). Currently the switch is on channel 20, with “Enable pull-ups on channels 18-20” enabled, and the motor is on channel 1. I used the code from “Using multiple buttons or switches to control servos”

begin
  button_a if sequence_a endif
repeat

sub button_a
  0 get_position 125 less_than
  return

sub sequence_a
  2500 1 servo 1000 delay
  9600 1 servo 1000 delay
  Return

This works running the servo back and forth, as long as it reads “0 get_position 125 less_than” if I change it to channel 20 I get nothing. Any suggestions would be great.

Thanks.

Hello,

Have you configured channel 20 as an input? Without your script running, what do you see in the status window when you press and release the switch? (If it responds correctly in the status window, it should work in the script.) Also, how is the switch connected?

If you still cannot get it working, please post your configuration file so we can take a look.

-Paul

Hello Paul-

Channel 20 is configured as an input and I can see the state change on the status page from 0 to 255.75 when toggled. I have +5v and signal connected to one side of the switch and 0v connected to the other side.
I am not using a resistor at this time but have made sure that the “Enable pull-ups on channels 18-20” is enabled. I am also using one power supply; 5 volts wired to the servo power, the blue screw terminals on the 24 Maestro, and have “VSRV=VIN” the blue shorting block plugged in. I also have the USB plugged in and am not sure if that is a problem because both are powering the board.

I have tried a few different programs with little success:

begin
		button_a if sequence_a endif
		button_ai if sequence_ai endif
repeat

sub button_a
		20 get_position 125 less_than
		return
sub button_ai
		20 get_position 125 greater_than
		return
sub sequence_a
		2500 1 servo
		return
sub sequence_ai
		9600 1 servo
		Return

Thanks for getting back so quickly Paul. Please let me know if you need any other information.
Ring Cycle1maestro_settings.txt (4.49 KB)

Hello,

If you have +5V connected to one side of the switch and Ground on the other side, you are shorting +5V to Ground every time you press it. Also, the 5V (out) line on the board is an output, so you are also risking damaging things if you connect it to any other voltage outputs. Is that what you did? What is your +5V power supply? Your switch should only be connected to the signal line and to 0V.

If you want to use your servo voltage as an alternate power supply when USB is disconnected, you can put the “VSRV=VIN” jumper into place.

I recommend unplugging everything except USB and the switch from your servo controller and debugging it in the Control Center before connecting additional items like the servo and power supply. You should be able to see everything working properly in the status tab before plugging other things in that might be causing the problem.

-Paul

Paul-

I have linked, through flicker, some photos so you can see what I did, because I did not explain it right and as you said a picture is worth a 1000 words. flickr.com/photos/71641306@N04/
The first photo is of the power supply. The second is a close up of the board. The bottom left red and black wires are the servo power, from the power supply. The upper left is the switch cable, with black (0v), red (not hooked up), and yellow (signal). The cable on the right side of the picture is the servo cable. The last picture is an over view, you can see the yellow (signal) cable going into one side of the switch and the black (0v) coming out of the other side. Here is the motor spec’s that I am using servocity.com/html/hs-425bb_super_sport_bb.html .

All that being said I unplugged everything but the USB and switch, I than set the card back to default and got rid of the code that I was playing with. So starting from scratch I was able to get the code to work on the Control Center and than plugged up the power and servo. The motor would not run but the status on the Control Center did as I expected.

Here is the code that I was using:

begin
		button_a if sequence_a endif
		button_ai if sequence_ai endif
repeat

sub button_a
		20 get_position 125 less_than
		return
sub button_ai
		20 get_position 125 greater_than
		return
sub sequence_a
		2500 1 servo
		return
sub sequence_ai
		9600 1 servo
		Return

Since I reassigned everything I have attached another setting file.

Thanks again Paul,
Ring Cycle2maestro_settings.txt (4.75 KB)

Hello,

From your settings file, it looks like you went back to detect baud rate mode, which will prevent your servos from moving until the baud rate is detected.

Also, what is the red wire on the switch connector connected to? It goes out-of-frame in all the pictures.

-Paul

Paul-

Yeah that fixed it. I switched the baud rate back. The red wire is not hooked up to anything; it is just hanging over the edge of the table. Thanks for all your help; I will keep you posted on the rest of the project.

Great, I am glad to hear that you got it working. Good luck with everything else, and yes, please do let us know how it goes!

-Paul

Hello-

After a few weeks of messing with this project I had a weird issue this morning. The servo motor shutters back and forth when plugged into the board. The motor still responds to the switch, moving from 0 to 180, but will just shutter at position. I switched out motors and the new motor did not shutter basically worked as expected. My concern is that once the project is completed other motors will start to see the same shutter effects.
Here is a link to the Motor servocity.com/html/hs-425bb_super_sport_bb.html The motor should be able to run 0-180 rotation with out any changes to the motor, which I was concerned about.

Is there anything that I can meter on the output of the card to make sure that it is out putting the correct signal?

Thanks and Happy Holidays

Hello,

Sorry for not getting back to you earlier!

It sounds like you are hearing some noise when it reaches an extreme position. Does it behave correctly in the normal 90-degree range? This could indicate that you are hitting a physical limit of the servo, which could easily break it. I recommend following the instructions in our FAQ under “How do I use my Maestro servo controller to get the maximum possible range of motion from my servo?” so that you can avoid causing damage to your servo.

Are you sure that you bought the version that was modified for 180 degree motion?

Anyway, if you have any kind of oscilloscope, you should be able to look at the signal line and measure the pulse width. But you can be almost certain that the value shown in the status window under “Position” is the actual width of the pulse.

-Paul