Welcome! Log In Create A New Profile

Advanced

Servo Motor Help

Posted by BradStaff 
Servo Motor Help
June 13, 2014 10:08PM
So I'm using the Servo Motor design and am new to all of this and I have some questions.
How do I connect the servo motor to the RAMPS Board?
What do I do to the Gcode the actually move the motor?

I'm just a little confused about how it's going to work. Any help?
Re: Servo Motor Help
June 13, 2014 10:19PM
I wish I could help, but the only servo motors I use are for my R/C Airplanes... But I am interested in learning, so I'll be watching this thread too. Might try this question over in the RAMPS section of the reprap forums too..
Re: Servo Motor Help
June 13, 2014 10:20PM
Quote
madmike8
I wish I could help, but the only servo motors I use are for my R/C Airplanes... But I am interested in learning, so I'll be watching this thread too. Might try this question over in the RAMPS section of the reprap forums too..
Thanks. I'll do that.
Re: Servo Motor Help
June 13, 2014 11:02PM
If you look as the Smartrap Documentation in the Github repo, you will find this pic -



the servo goes at the end where the stops plug in and remember to flip the positive and negative pins around onthe servo connector or it won't work. Then just just the Smartrap Marlin Firmware from the same Github repo for the servo and you should be on your way.

The easy way to get the github repo is to simply -

git clone [github.com] Smartrap

in your desired directory, unless your on a Mac or that other OS (windows or some such). Then your best bet would be to just download a zip of the repo.
Re: Servo Motor Help
June 13, 2014 11:15PM
It is pretty easy to do.
This is the correct way to do it, there are other ways.
First arrange your 5 volt power for the servo. Don't take the lazy way and just short the VCC and 5v pins together on the RAMPS board, it will rob the power from the rest of the board and will let you down. A regulator chip is about a dollar or less, available at any electronics supply shop or online at ebay.




Get a 7805 voltage regulator chip and connect pins 1 and two across the 12 volt power supply line and pin 3 is the 5 volt out. Connect the 5 volt out to the 5v pin on the RAMPS board near the reset button. That's the power supply sorted out.

Now there are 3 rows of pins on the right hand side of the reset button, these are for four servos. Use the first set of pins closest to the rest button. The middle pin is positive,the pin closest to the edge of the board is negative and the pin furthest from the edge is the signal.
Depending on the colours of your particular servo leads, some are red positive, black negative and white signal. Others can be orange positive, brown negative, yellow signal (most common)



In the configuration.h file, towards the bottom you will find the servo settings.
Make sure that you have servos set at 1 (default is usually 0)
The angle of the servo needs to be set, so this is how I have mine set,
*********************************************************************\
* R/C SERVO support
* Sponsored by TrinityLabs, Reworked by codexmas
**********************************************************************/

// Number of servos
//
// If you select a configuration below, this will receive a default value and does not need to be set manually
// set it manually if you have more servos than extruders and wish to manually control some
// leaving it undefined or defining as 0 will disable the servo subsystem
// If unsure, leave commented / disabled
//
#define NUM_SERVOS 1 // Servo index starts with 0 for M280 command

// Servo Endstops
//
// This allows for servo actuated endstops, primary usage is for the Z Axis to eliminate calibration or bed height changes.
// Use M206 command to correct for switch height offset to actual nozzle height. Store that setting with M500.
//
#define SERVO_ENDSTOPS {-1, -1, 0} // Servo index for X, Y, Z. Disable with -1
#define SERVO_ENDSTOP_ANGLES {0,0, 0,0, 10,75} // 0,0, 0,0, 95,0 X,Y,Z Axis Extend and Retract angles
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

To test the servo angle use Pronterface.
I made a couple of buttons, one called servo up with the command M280 po s10 (that 10 is the up angle, change that to suit what works best for you)
The other button servo down with the command M280 po s95 (that is the down angle, change the 95 to suit what works best for yours)

These buttons are only for testing, you can change the settings as in brackets above and see what angle you should be setting in the firmware.

Hope this helps you out.

Edited 1 time(s). Last edit at 06/13/2014 11:20PM by regpye.


[regpye.com.au]
"Experience is the mother of all knowledge." --Leonardo da Vinci
Re: Servo Motor Help
June 13, 2014 11:18PM
Doh! I thought he was talking about servo motors instead of steppers... The new meds the doc has me on has been screwing with my head. Hopefully it levels out soon...
Re: Servo Motor Help
June 13, 2014 11:25PM
Quote
madmike8
Doh! I thought he was talking about servo motors instead of steppers... The new meds the doc has me on has been screwing with my head. Hopefully it levels out soon...
Wait. I am talking about servos. The one for the autolevel. I'm so confused. Who's right?
Re: Servo Motor Help
June 13, 2014 11:33PM
What I posted works for the Smartrap Marlin Firmware found on Github here - [github.com]

i was using this until I got my no servo J Head mount printed out.

Mark

Edited 1 time(s). Last edit at 06/13/2014 11:34PM by markstephen.
Re: Servo Motor Help
June 13, 2014 11:37PM
That's what I thought but then RegPye posted that and I didn't know what was going on.
Re: Servo Motor Help
June 13, 2014 11:55PM
If your using "stock" Marlin source, I believe Reg is very correct with what he posted, either way should work, but mixing the 2 won't.
Re: Servo Motor Help
June 19, 2014 06:07AM
@Brad, is the servo the only thing keeping you from printing?
In case you need to print something urgently, let me show you how to do bed leveling semi-automatically (even with a broken servosmiling smiley)

Here's how my autolevel sequence goes every print while my servo is waiting to be replaced. http://www.youtube.com/watch?v=8H40fNVSUdI

I used the M300 gcode to make my smartrap beep to remind me when to lower or raise the servo arm spinning smiley sticking its tongue out I just refuse to let my broken servo stop me from printing. Hehehe
Re: Servo Motor Help
June 19, 2014 09:59AM
That's not the only thing keeping me from printing. I fried my arduino board and am waiting on a replacement voltage regulator. China mail is taking its time. When I fix that I'll have to fix some hotend voltage problems. My question about the servo motors is how does the code know the distance between the endstop and the hotend so that it prints correctly?
Re: Servo Motor Help
June 19, 2014 12:30PM
On or about line 401, you will see this in Configuration.h (assuming your using the Marlin firmware from the Smartrap repo.)

#define Z_PROBE_OFFSET_FROM_EXTRUDER 2.2

That's your Z offset. You can also set this with your LCD controller if you have one. Its in the Control > Motion section.
Re: Servo Motor Help
June 19, 2014 12:59PM
Z offset.

Mark the spot on the bed.
Maneuver your nozzle over the spot and lower till it just touches the glass. Raise it .1 or until a piece of paper just slides under it.
Set Z to 0 using M555 Z0
Maneuver your probe over the spot.
M401 lowers the Z probe.
Lower the Z axis testing the Z Endstop after each step for triggered using M119
After it triggers use M114 to get the location of the Z axis
Set the Z offset with M555 Zx where x was the number listed for Z with the M114 command
i.e. M555 Z15.5
Use M500 to store the value on the EEPROM.
M402 raises the probe.

I added buttons in Ponterface for Lowering Probe, Raise Probe, Save to EEPROM. Test Probe Spot, Test Nozzle Spot
That makes life easier.

Since there is some movement with the Z axis on the Smartrap, I have to adjust it every now and again. I usually take the starting Z offset and adjust it up or down .1 at a time using the M555 Zx command till it lays down a nice looking layer. Then use M500 to save it. To skip from doing the whole process again.
Re: Servo Motor Help
June 19, 2014 06:56PM
Quote
madmike8
Z offset.

Mark the spot on the bed.
Maneuver your nozzle over the spot and lower till it just touches the glass. Raise it .1 or until a piece of paper just slides under it.
Set Z to 0 using M555 Z0
Maneuver your probe over the spot.
M401 lowers the Z probe.
Lower the Z axis testing the Z Endstop after each step for triggered using M119
After it triggers use M114 to get the location of the Z axis
Set the Z offset with M555 Zx where x was the number listed for Z with the M114 command
i.e. M555 Z15.5
Use M500 to store the value on the EEPROM.
M402 raises the probe.

I added buttons in Ponterface for Lowering Probe, Raise Probe, Save to EEPROM. Test Probe Spot, Test Nozzle Spot
That makes life easier.

Since there is some movement with the Z axis on the Smartrap, I have to adjust it every now and again. I usually take the starting Z offset and adjust it up or down .1 at a time using the M555 Zx command till it lays down a nice looking layer. Then use M500 to save it. To skip from doing the whole process again.

Well put MadMike8


[regpye.com.au]
"Experience is the mother of all knowledge." --Leonardo da Vinci
Re: Servo Motor Help
June 19, 2014 07:30PM
Thanks. This explains a lot. I'm new to a lot of this.
Re: Servo Motor Help
June 20, 2014 12:53AM
Quote
BradStaff
That's not the only thing keeping me from printing. I fried my arduino board and am waiting on a replacement voltage regulator. China mail is taking its time. When I fix that I'll have to fix some hotend voltage problems. My question about the servo motors is how does the code know the distance between the endstop and the hotend so that it prints correctly?

The regulator on my RAMPS broke too, and still is. If you are using an ATX power supply, you may not need to replace your regulator. Maybe this can show you how I got around a broken regulator.
[www.youtube.com]

Like you, I also had my fair share of obstacles during my build that I had to get around smiling smiley
Re: Servo Motor Help
June 20, 2014 01:05AM
And for some reason, changing the Z_PROBE_OFFSET_FROM_EXTRUDER in the configuration.h never worked for me. I hope it did but what worked for me was the alternative way to deal with Z offset which I find easier.

It is by making use of the G92 command in the startup GCODE.

G28 X0 Y0 ;move X/Y to min endstops
G29 ;probe bed
G92 E0 ;zero the extruded length
G1 Z10 ;raise nozzle by 10mm
G92 Z14.7 ;z offset - higher number will bring nozzle closer to the bed during printing

The difference between the Z values will be the offset. So in the case above, the offset is 4.7

I've tried Slic3r and Cura and this method worked for both.

Edited 2 time(s). Last edit at 06/20/2014 07:22PM by MelT.
Re: Servo Motor Help
June 20, 2014 11:39AM
Melt try setting it with the EEPROM by M555 Z14.7
Re: Servo Motor Help
June 20, 2014 07:29PM
Thanks madmike! smiling smiley

I doubted it at first because the reprap documentation says M555 was for another thing and it mentioned M565 as the one for z offset.

M555 worked for me! I just can't change the value in the LCD controller though. The Z offset in the LCD controller is somehow limited to 3. I can't go past that value so I'll still be using the startup gcode for small adjustments.

Do you have a link to the gcodes specific to Marlin? This source seems to be outdated.
Re: Servo Motor Help
June 20, 2014 07:50PM
https://github.com/ErikZalm/Marlin

I think Serge added the M555 into the Smartrap version of Marlin for the Z offset adjustment.

Anyways it works... After you get the Z offset correct the first time, you'll only do minor adjustments.

Oh yeah, after you set the EEPROM with M555, make sure you use M500 to save it...

Edited 1 time(s). Last edit at 06/20/2014 07:51PM by madmike8.
Re: Servo Motor Help
August 30, 2014 06:19PM
M-Codes and G-Codes are nice for temporary...on-the-spot adjstments. You should always mimic these changes in the configuration.h through WinMerge or Notepad++. Othersiwse, you could lose all calibration data (e.g. auto-bed level, DEFAULT_AXIS_STEPS_PER_UNIT, etc).
Not really sure why Smartrap says to put the servo on the I2C bus, when, as RegPye pointed out, the board already has places for them. Though this is not a bad idea, if the intent is to prevent the servo wires from interfering with the airflow blowing across the heat-sinks.
Adding a LM7805 is a good idea, but according to the datasheet to ensure a clean signal you’ll need a 0.33uF capacitor between pins 1 and 3, then a 0.1uF capacitor between pins 2 and 3.

MeIT...the RAMPS board doesn’t have a regulator. Do you mean the MOSFETs?

My configuration.h offets:
#define X_PROBE_OFFSET_FROM_EXTRUDER 1.8
#define Y_PROBE_OFFSET_FROM_EXTRUDER -14.1
#define Z_PROBE_OFFSET_FROM_EXTRUDER -5.8

Here is my starting GCode…
G1 Z10.0 F500 ;ensures probe have enough clearance
M400 ;Wait for clearance
M401;deploy probe
G28 X0 Y0;Home X and Y Axis
G90; Set to Absolute Positioning
G29; Probe the bed
G1 Z10.0 F500;Clearance for retraction
M400 ;Wait for cearance
M280 P0 S0;Retract probe
M400;wait
G1 X10 Y10 Z10; Moves close to origin and await proper temp.

Be very cautious when ordering the important stuff (Arduinos, RAMPS, Printrboard, StepSticks, E3D V5/6 clones) from China...ESPECIALLY Geetech!! They are "cheap" because they substitute components of lesser quality and do not always make their boards with the appropriate amount of copper capable of carrying the required amounts of current through the board. The best place to get the Arduino Mega 2560, RAMPS 1.4, and StepSticks is from kbellenterprises on eBay (ships from near St Louis, MO). Botronicz does a better job at soldering, but they sometimes take a week or two to ship from Michigan.

I hope I didn't sound harsh...I'm also watching football.
Re: Servo Motor Help
August 31, 2014 01:42AM
Quote
nitewing76
M-Codes and G-Codes are nice for temporary...on-the-spot adjstments. You should always mimic these changes in the configuration.h through WinMerge or Notepad++. Othersiwse, you could lose all calibration data (e.g. auto-bed level, DEFAULT_AXIS_STEPS_PER_UNIT, etc).
Not really sure why Smartrap says to put the servo on the I2C bus, when, as RegPye pointed out, the board already has places for them. Though this is not a bad idea, if the intent is to prevent the servo wires from interfering with the airflow blowing across the heat-sinks.
Adding a LM7805 is a good idea, but according to the datasheet to ensure a clean signal you’ll need a 0.33uF capacitor between pins 1 and 3, then a 0.1uF capacitor between pins 2 and 3.

MeIT...the RAMPS board doesn’t have a regulator. Do you mean the MOSFETs?

My configuration.h offets:
#define X_PROBE_OFFSET_FROM_EXTRUDER 1.8
#define Y_PROBE_OFFSET_FROM_EXTRUDER -14.1
#define Z_PROBE_OFFSET_FROM_EXTRUDER -5.8

Here is my starting GCode…
G1 Z10.0 F500 ;ensures probe have enough clearance
M400 ;Wait for clearance
M401;deploy probe
G28 X0 Y0;Home X and Y Axis
G90; Set to Absolute Positioning
G29; Probe the bed
G1 Z10.0 F500;Clearance for retraction
M400 ;Wait for cearance
M280 P0 S0;Retract probe
M400;wait
G1 X10 Y10 Z10; Moves close to origin and await proper temp.

Be very cautious when ordering the important stuff (Arduinos, RAMPS, Printrboard, StepSticks, E3D V5/6 clones) from China...ESPECIALLY Geetech!! They are "cheap" because they substitute components of lesser quality and do not always make their boards with the appropriate amount of copper capable of carrying the required amounts of current through the board. The best place to get the Arduino Mega 2560, RAMPS 1.4, and StepSticks is from kbellenterprises on eBay (ships from near St Louis, MO). Botronicz does a better job at soldering, but they sometimes take a week or two to ship from Michigan.

I hope I didn't sound harsh...I'm also watching football.

i would have to concur about Geeetech and the quality. I have purchased a very lot from them, mostly in a few batches, and have found a large loss due to faulty boards.
I will say that they have been very good and replaced quickly, but when some of the replacements were also faulty, I stopped dealing with them.

Here is my start code using the latest Cura

;Print time: {print_time}
;Filament used: {filament_amount}m {filament_weight}g
;Filament cost: {filament_cost}
;M190 S{print_bed_temperature} ;Uncomment to add your own bed temperature line
;M109 S{print_temperature} ;Uncomment to add your own temperature line
G21 ;metric values
G90 ;absolute positioning
M107 ;start with the fan off
G92 ;zero all axis
G1 Z10.0 F{travel_speed} ;lift nozzle for bed clearance 10mm
G28 ;home all axis
G29 ;auto bed leveling probes
G92 E0 ;reset extruder
M82 ;set extruder mode
G1 X5 Y5 ;almost home X and Y axis
G1 Z0.5 ;move nozzle to print height
G1 E40 X90 F700 ;extrude some filament in a short line to prime the nozzle.
G92 E0 ;zero the extruded length again
;Put printing message on LCD screen
M117 Printing...

Edited 1 time(s). Last edit at 08/31/2014 01:44AM by regpye.


[regpye.com.au]
"Experience is the mother of all knowledge." --Leonardo da Vinci
Sorry, only registered users may post in this forum.

Click here to login