Welcome! Log In Create A New Profile

Advanced

Arduino G-code Interpreter - motor one direction

Posted by simonblackmore 
Arduino G-code Interpreter - motor one direction
March 13, 2009 05:13PM
Hi Everyone,

I have just got the x and y carriages of my RepRap set up ok and working with some simple arduino code.... there is a video and the code here.
[www.simonblackmore.net]

I want to be able to control my RepRap from within Processing. The G-code interpreter looks perfect for this but I have seem to have run into a problem and would really appreciate any help.

I have managed to load the firmware onto the Arduino using Arduino 11... I think thats all fine. I don't know much about G-code but it seems that the motors only go in one direction no matter what commands I send. I have defined my pins as bellow but at the moment I have nothing connected to the max pin or the enable pin.... Also I have not connected an extruder. Basically I am just simple trying to get one motor working at at time before I try it on my machine but at the moment the motor is only going one way....

Does anyone know what is the best thing to do if I am not using the min opto stop or the enable pin.

#define X_STEP_PIN 7
#define X_DIR_PIN 6
#define X_MIN_PIN 9
#define X_MAX_PIN 3
#define X_ENABLE_PIN 0


I hope this make sense to someone.... and many thanks for the G-code firmware, it looks fantastic and I can't wait to get to grips with it.


Cheers

Simon
Re: Arduino G-code Interpreter - motor one direction
March 13, 2009 06:38PM
Quote

Does anyone know what is the best thing to do if I am not using the min opto stop or the enable pin.

You have to make the opto inputs inactive so that it doesn't think it has hit an end stop. If it thinks it has hit the min end stop it will not go backwards.

The enable pin is an output, so fine not to connect it to anything.


[www.hydraraptor.blogspot.com]
Re: Arduino G-code Interpreter - motor one direction
March 13, 2009 07:08PM
I recently started using the GCode firmware. I wrote up a wiki page (http://objects.reprap.org/wiki/Getting_Started_with_the_Arduino_GCode_Firmware) to help others get started, although I think you've managed to get that far.

If you run the RepRap host software, you can point it at the G-Code on the arduino, and use the stepper tab to move the steppers using buttons on the screen. If this works, you can check to see what commands it's using.

There's also the skeinforge code and independent gcode interpreters, like Zach's ReplicatorG (http://replicat.org/). You could run a test file, like the minimug, through skeinforge and either pass the gcode bit-by-bit , or use replicatorg or even the host software to control your arduino.

Good luck mate
Re: Arduino G-code Interpreter - motor one direction
March 13, 2009 08:28PM
Thanks David and Nophead,

I am using the G-Code_Host processing sketch from here which I am pretty sure is working fine. [svn.reprap.org]

At the moment I am just running and hacking the G-code examples that come with it but they don't really seem to do what I would imagine,

eg;

G1 X-20 Y-20
G4 1000
G1 X+20 Y+20
G4 1000
G1 X-20 Y-20
G4 1000
G1 X+20 Y+20

just sends the motor in one direction and does not pause or dwell as I would imagine (but that could just be my misunderstanding of dwell)

As Nophead mentioned I think the problem must be to do with my opto inputs.... sorry for such a dumb question, but how do I make them inactive for testing purposes ? Should I pull them both to low with resistors to ground or is it fine just to set them low in software?

Thanks again

Simon
Re: Arduino G-code Interpreter - motor one direction
March 14, 2009 02:58AM
Yes you would need to tie the input to ground to simulate the opto not being blocked.


[www.hydraraptor.blogspot.com]
emt
Re: Arduino G-code Interpreter - motor one direction
March 14, 2009 05:34AM
Hi

I think the correct form for delay is "G4 P1000".


Regards

Ian
Re: Arduino G-code Interpreter - motor one direction
March 14, 2009 09:27PM
Thanks everyone... Unfortunately I can't get to my RepRap to try this until monday, but I am wondering if I need to physically pull down the opto inputs ? It seems on an arduino it can be done like this.


pinMode(pin, INPUT); // set pin to input
digitalWrite(pin, LOW); // turn on pulldown resistors

In theory I should be able to experiment with my opto inputs simply within software.

Anyway I will give it a try on Monday

Thanks again

Simon
Re: Arduino G-code Interpreter - motor one direction
March 15, 2009 04:12AM
Well if you are going to modify the firmware you could simply comment out the lines that read the optos.


[www.hydraraptor.blogspot.com]
Re: Arduino G-code Interpreter - motor one direction
March 16, 2009 06:58AM
Thanks everyone... My motor seems to be running both ways now, I think the problem I had is that my motor driver v1.2 was setting my opto switches high so I turned them low in the firmware and disconnected the wires to the board and this G-code example seems run as expected, with the pauses (thanks Ian)

G1 Y-5
G4 P10000
G1 Y+10
G4 P500
G1 Y-1
G4 P2500
G1 Y+1
G4 P1000
G1 Y+20
G4 P10000

I don't know much about G-code but I guess the motors need to know where they are, Is it therefore standard to send the G28 command at the beginning of each G-Code program. Does anyone have any good pointers for learning about this sort of thing.

Many thanks for your help.

Simon
Sorry, only registered users may post in this forum.

Click here to login