Welcome! Log In Create A New Profile


replicatorg/motherboardv1.2 gcode parsing

Posted by wireframe 
replicatorg/motherboardv1.2 gcode parsing
December 18, 2010 05:27PM
Hi Guys,

I am running a reprap motherboard v1.2 by MakerBot with v1.6 firmware and replicatorG-0020. I am trying to add a couple of simple modifications to the G-Code parser, but am having no success. I want to add 4 custom M-Codes which basically just raise or lower a digital pin on the Sanguino board.

I have looked through the firmware and found a file called MasterGCodeInterpreter.pde. There is also a program called SanguinoMaster.pde. I am not understanding the big picture. Which program do I need to upload to the Sanguino? Where is the G-Code parsed after it has been entered into ReplicatorG and which files do I need to edit to add some custom M-Codes?

Re: replicatorg/motherboardv1.2 gcode parsing
December 18, 2010 10:28PM
With so many different forums, it can be difficult to tell which is most appropriate, but questions like this would probably get more and/or better answers in the firmware forum.

For starters, which type of code would you like it to be? M, G, something completely new? If you want to use an existing type, you can go to "process_g_code.pde" (shows up as the tab "process_g_code" in the arduino IDE) and do a search for an existing code then add your own code after it.

For instance, lets say you wanted to add M18. You could search for "127". It will take you to the code for M127, which should look like this:
                        case 127:
                                ex[extruder_in_use]->valveSet(false, (int)(gc.P + 0.5));
After "break;", add something like this:
                        case 18: //You are adding M18, just use the numbers as the case since we already ran code to find the "M"
                                //your code here

To turn pins on and off, I suggest using the firmware's method of defining the pin. For instance, in pins.h, you will see stuff like:
#define Z_STEP_PIN (byte)19
#define Z_DIR_PIN (byte)18
#define Z_MIN_PIN (byte)17
#define Z_MAX_PIN (byte)16

Just add another "#define". Make sure it is in the same section as your motherboard type. IE:
#elif MOTHERBOARD == 3 //You have to find this line, the number must match your motherboard type

//other pins defined here
#define MY_NEW_PIN (byte)8 //"8" is the number of the pin you want to control

//Other motherboard types

Now you can go back to your new M code (sticking with the M18 example here):
                        case 18:
                                  digitalWrite(MY_NEW_PIN, HIGH); //turn on the pin
                                  digitalWrite(MY_NEW_PIN, LOW); //turn off the pin
                                  //NOTE: Using both in the same Gcode without a pause in between will 
                                  //cause it to switch so fast you probably won't see it, this is just an example.

                                  //PWM (analog) pins use a different command and can have states that are not fully on
                                  //This is useful for keeping heaters warm but not overheating, for example
                                  //While digitalWrite works on any pin, analogWrite only works on PWM enabled pins             
                                  analogWrite(MY_NEW_PIN, 0); //fully off                                
                                  analogWrite(MY_NEW_PIN, 255); //fully on                   
                                  analogWrite(MY_NEW_PIN, 25); //Not quite off
Re: replicatorg/motherboardv1.2 gcode parsing
December 18, 2010 11:25PM
Thanks for the post. You are right, this is topic is probably best suited for the firmware board. I will post the next question in there.

I understand the code you have posted and I would love to try it, but I have another problem which is stopping me. Your suggestion is for for the FiveD_GCode_Interpreter.pde firmware. I was using an older firmware. While I am happy to switch to this newer firmware, I cannot get it to work with my motherboard.

I downloaded the reprap-mendel-20100806 archive and located the files you were talking about(found at BASE/reprap-mendel-20100806/mendel/firmware/FiveD_GCode/FiveD_GCode_Interpreter). Before modifying anything, I compiled and uploaded the firmware to my motherboard. With this new firmware ReplicatorG is unable to connect to the board. ReplicatorG displays this in the console:
[20:20:31] Loading machine: Cupcake CNC
[20:20:31] Loading simulator.
[20:20:31] Loading driver: replicatorg.drivers.gen3.Sanguino3GDriver
[20:20:39] Read timed out.
[20:20:39] Read timed out; giving up on query.
[20:20:46] Read timed out.
[20:20:46] Read timed out; giving up on query.
[20:20:46] No connection; trying to pulse RTS to reset device.
[20:20:53] Read timed out.
[20:20:54] Read timed out; giving up on query.
[20:20:54] Unable to connect to firmware.

This warning is issued as ReplicatorG launches:
WARNING:  RXTX Version mismatch
	Jar version = RXTX-2.2pre1
	native lib Version = RXTX-2.2pre2

Strangely, when I update firmware through the ReplicatorG interface I have no such problem, but cannot modify the code as I need to.

Does anyone know how to fix this problem?
Re: replicatorg/motherboardv1.2 gcode parsing
December 19, 2010 01:02AM
Ah, you must have been using the makerbot firmware? I wasn't aware you were using ReplicatorG. Far as I know (it has been a while since I bothered looking at firmware updates available through RepG, maybe things have changed recently) the only firmware updates you get through RepG are for the makerbot. Supposedly 5D firmware will work with newer RepG versions, but I didn't have any luck with it.

I have not worked with the source code for the makerbot firmware, so I can't give any specific pointers there. I would venture a guess that the general idea/process is the same.

It looks like this page will help you with getting the source code at least.
Re: replicatorg/motherboardv1.2 gcode parsing
December 19, 2010 01:44AM
Alright. Thanks.

I didn't understand the difference between the types of firmware and the softwares which connect to them. I have no preference of which firmware/host software to use. So long as both can allow me to type in custom G-Code, I will just go with whichever is easiest.

Thanks for the help.
Re: replicatorg/motherboardv1.2 gcode parsing
December 19, 2010 05:02AM
The makerbot firmware doesn't use g-code. The g-code interpretation is done in repg.

Re: replicatorg/motherboardv1.2 gcode parsing
December 19, 2010 10:23PM
If using replicatorg with the reprap software you need to use a different driver and not the cupcake one. With replicator-22 you need to go to preferences, and select "Show experiemental machine profiles". You may need to restart the application at that point. Once you have done this you get a larger drop down menu in Machine->Driver, which is where you then select the 5D model.

This is as far as I have got. I know it controls the axis as I can test that, but I am still working on the extruder and other elements of my printer.

Sorry to butt in, but can you help me find where to setup my gcode parser to edit some of the g-m codes in replicatorg? I can't seem to find the file to "edit" my g and m codes?
Sorry, only registered users may post in this forum.

Click here to login