Welcome! Log In Create A New Profile

Advanced

DIY project: homemade electronics?

Posted by Niben 
DIY project: homemade electronics?
April 07, 2015 11:49AM
I'm fairly new to the world of 3D printing, altough i've worked with these machines before, but i've decided to build my own printer now. My question is: how can I use marlin for my own controller board, so i'm just using the arduino mega 2560, but I do not use ramps or any of the other default boards. I have made myself a mother board with stepper motor driver boards on it, but how to i use Marlin now? Do i have to make myself a declaration for this board?

I hope someone has done this before, so someone can help me!

Niben
Re: DIY project: homemade electronics?
April 07, 2015 12:28PM
You have to create two header files with the description of your board see here for examples:

[github.com]
Re: DIY project: homemade electronics?
April 08, 2015 10:56AM
Again, i'm a complete beginner, but I think I partly understand what you mean.
So i have to create a folder like the ones in the link you sended me. But in most of them, there is two files indeed, a configuration.h file and a configuration_adv.h file. And in these files there is a huge bunch of ajustable code. But i do not see any places where the pins of the arduino are assigned to certain functions. For example, i do not see to which arduino pins the motor drivers are connected. Moreover: i do not use the standard motor drivers, but i use different IC motor drivers, the L293E to be precise. So what do i have to do?

Hope I do not ennoy you, but i really hope you can help me!

Niben
Re: DIY project: homemade electronics?
April 08, 2015 11:48AM
Take a look at the pins.h file
Re: DIY project: homemade electronics?
April 08, 2015 12:14PM
Quote
Niben
i do not use the standard motor drivers, but i use different IC motor drivers, the L293E to be precise. So what do i have to do?

Marlin works with stepper controller chips that have a Step and Dir signal. It creates a pulse on the step signal and expects the driver IC to have the stepper move by one step. If your driver chips does not comply to this, then you will have to change that part of Marlins code.

If you are new to embedded software then that will be a hard task. You might want to reconsider your choice of driver chip,..
Re: DIY project: homemade electronics?
April 08, 2015 03:27PM
Quote
george4657
Take a look at the pins.h file
I've done that, but there I can't discover any assignments of pins, no pin number there. I have searched in the rest of the files, and for example the pins_CHEAPTRONIC.h file looks very organized and nice. I think I have to create such a file, but how do I make sure that file works with the rest of Marlin (for example with the configuration.h file)?

Quote
JustAnotherOne
Marlin works with stepper controller chips that have a Step and Dir signal. It creates a pulse on the step signal and expects the driver IC to have the stepper move by one step. If your driver chips does not comply to this, then you will have to change that part of Marlins code.

If you are new to embedded software then that will be a hard task. You might want to reconsider your choice of driver chip,..
Hm, that doesn't sound nice. I think I might be able to rebuild my board a little bit so that it does what you said it does with direction, enable and step. You have some link where this is explained a little more?

Kind regards, and I'm sorry about my probably stupid questions, but I try to understand al these crazy new things!

Niben
Re: DIY project: homemade electronics?
April 08, 2015 03:39PM
Quote
Niben

Quote
JustAnotherOne
Marlin works with stepper controller chips that have a Step and Dir signal. It creates a pulse on the step signal and expects the driver IC to have the stepper move by one step. If your driver chips does not comply to this, then you will have to change that part of Marlins code.

If you are new to embedded software then that will be a hard task. You might want to reconsider your choice of driver chip,..

Hm, that doesn't sound nice. I think I might be able to rebuild my board a little bit so that it does what you said it does with direction, enable and step. You have some link where this is explained a little more?

The standard used by everybody are the Pololu modules. The datasheet should have all the details. The principle is that the Enable signal switches the motor on and off. The Dir signal defines if moving clockwise or counter clockwise and the pulses on the step line create the steps. Most people use 200steps per rotation motors. But than can be configured in the steps per mm setting.

Quote
Niben
Kind regards, and I'm sorry about my probably stupid questions, but I try to understand al these crazy new things!

There are no stupid Questions. Just stupid answers.
Re: DIY project: homemade electronics?
April 09, 2015 02:30AM
Inside the pins.h file you see different pin assignements, for different electronics. Since you want to create your own, you need a customized pins.h assignements for where your pins will be inserted into the arduino, leading to different "utilities" like stepper motor, thermistors, endstops, heaters, etc.
You can set in config.h the MOTHERBOARD to be 99, and inside the pins.h, change the section of MB 99 to reflect your hardware. You could aslo do the same and use/edit any other section, marlin wont care, but its simpler to use 99 part coz its usually more clear than other parts, some parts are quite messed up with "ifs" and what-not conditions.

So in config.h at top set motherboard=99 and in pins.h inside the section which says MB==99 there are some pins to wich you have to change their numbers with the ones on the arduino where you have connected your stuff. In general basic functions are named like following.
// for example pins for stepper motors, step/dir/enable pins, the -1 on enable means it does not use enable, although you should use that; similar for each axis including Extruder
#define X_STEP_PIN 2 //change the number with your number
#define X_DIR_PIN 3
#define X_ENABLE_PIN -1
//the endstop for each axis (except E), depends on what endstop are used, their configuration is in config.h instead of pins.h, you will have to figure that part out, things like configuration of pullups, and positive/negative logic
#define X_STOP_PIN 16
...
//the fan and heaters are pins which basically go to mosfets to control such fans and heaters
#define HEATER_0_PIN 13
#define HEATER_1_PIN -1
#define HEATER_2_PIN -1
#define FAN_PIN -1
#define HEATER_BED_PIN 4
...
//temp pins are the connections that lead to thermistors, usually these pins have a pullup of 4.7k and a 10uF cap to gnd, thats the termistor sensor:
#define TEMP_0_PIN 6 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
#define TEMP_1_PIN -1 // MUST USE ANALOG INPUT NUMBERING NOT DIGITAL OUTPUT NUMBERING!!!!!!!!!
#define TEMP_2_PIN -1 
#define TEMP_BED_PIN 10
...
//other pins like these are extra for special functions and probably you wont care so for start you can disable their function with like -1
#define SDPOWER -1
#define SDSS 53
#define LED_PIN -1
#define PS_ON_PIN 9
#define KILL_PIN -1
//other pins like those for sd card need special reading and have to be specific pins, e.g. cant just connect the hardware to any place, but if you do the hardware you will know where to put them
Thats basically the idea. The pins like stepper drivers step/dir/enable have this specific name on the driver or the driver documentation. The fans/heaters are pins which essentially lead to a mosfet's Gate pin to control that mosfet. Thermistors are pins which have one pullup and one cap to ground, and go into one thermistor lead, while the other thermistor lead goes to ground. IF you diy your own hardware, you will figure out all these parts, and i think you will see its basically a lot simpler than it sounds. You could check out RDB - diy electronics, which is just a simple board that takes out all these basic functions pins and exposes them for you to wire them to arduino or to headers of whatever other development board you could think of.

Edited 1 time(s). Last edit at 04/09/2015 02:34AM by NoobMan.
Re: DIY project: homemade electronics?
May 16, 2015 04:39PM
Hey Noobman and others,

Thank you so much for giving these advices! And I have used them! But i get an error while uploading when I try what Noobman told me to, here is the error:
Maybe you can see what is wrong because I don't know... To me it looks like a maze of thousand crazy codes.

Quote
Error message
Arduino: 1.6.3 (Windows 8.1), Board:"Arduino Uno"

In file included from Marlin_main.cpp:30:0:

Marlin_main.cpp: In function 'void gcode_M119()':

fastio.h:25:27: error: 'DIO67_RPORT' was not declared in this scope

#define _READ(IO) ((bool)(DIO ## IO ## _RPORT & MASK(DIO ## IO ## _PIN)))

^

Marlin.h:72:49: note: in definition of macro 'SERIAL_PROTOCOLLN'

#define SERIAL_PROTOCOLLN(x) do{ MYSERIAL.print(x),MYSERIAL.write('\n'); }while(0)

^

fastio.h:65:19: note: in expansion of macro '_READ'

#define READ(IO) _READ(IO)

^

Marlin_main.cpp:3502:25: note: in expansion of macro 'READ'

SERIAL_PROTOCOLLN(((READ(Y_MIN_PIN)^Y_MIN_ENDSTOP_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));

^

fastio.h:25:54: error: 'DIO67_PIN' was not declared in this scope

#define _READ(IO) ((bool)(DIO ## IO ## _RPORT & MASK(DIO ## IO ## _PIN)))

^

Marlin.h:72:49: note: in definition of macro 'SERIAL_PROTOCOLLN'

#define SERIAL_PROTOCOLLN(x) do{ MYSERIAL.print(x),MYSERIAL.write('\n'); }while(0)

^

fastio.h:25:49: note: in expansion of macro 'MASK'

#define _READ(IO) ((bool)(DIO ## IO ## _RPORT & MASK(DIO ## IO ## _PIN)))

^

fastio.h:65:19: note: in expansion of macro '_READ'

#define READ(IO) _READ(IO)

^

Marlin_main.cpp:3502:25: note: in expansion of macro 'READ'

SERIAL_PROTOCOLLN(((READ(Y_MIN_PIN)^Y_MIN_ENDSTOP_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));

^

fastio.h:25:27: error: 'DIO59_RPORT' was not declared in this scope

#define _READ(IO) ((bool)(DIO ## IO ## _RPORT & MASK(DIO ## IO ## _PIN)))

^

Marlin.h:72:49: note: in definition of macro 'SERIAL_PROTOCOLLN'

#define SERIAL_PROTOCOLLN(x) do{ MYSERIAL.print(x),MYSERIAL.write('\n'); }while(0)

^

fastio.h:65:19: note: in expansion of macro '_READ'

#define READ(IO) _READ(IO)

^

Marlin_main.cpp:3510:25: note: in expansion of macro 'READ'

SERIAL_PROTOCOLLN(((READ(Z_MIN_PIN)^Z_MIN_ENDSTOP_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));

^

fastio.h:25:54: error: 'DIO59_PIN' was not declared in this scope

#define _READ(IO) ((bool)(DIO ## IO ## _RPORT & MASK(DIO ## IO ## _PIN)))

^

Marlin.h:72:49: note: in definition of macro 'SERIAL_PROTOCOLLN'

#define SERIAL_PROTOCOLLN(x) do{ MYSERIAL.print(x),MYSERIAL.write('\n'); }while(0)

^

fastio.h:25:49: note: in expansion of macro 'MASK'

#define _READ(IO) ((bool)(DIO ## IO ## _RPORT & MASK(DIO ## IO ## _PIN)))

^

fastio.h:65:19: note: in expansion of macro '_READ'

#define READ(IO) _READ(IO)

^

Marlin_main.cpp:3510:25: note: in expansion of macro 'READ'

SERIAL_PROTOCOLLN(((READ(Z_MIN_PIN)^Z_MIN_ENDSTOP_INVERTING)?MSG_ENDSTOP_HIT:MSG_ENDSTOP_OPEN));
Re: DIY project: homemade electronics?
May 16, 2015 05:10PM
For starters, you say you have an Arduino Mega 2560, but the error log shows the compile for an Uno, which may well not have the same IO setup. Correct the board type and retest. . . frequently is will correct massive otherwise inexplicable error situations like this.

- Tim
Re: DIY project: homemade electronics?
May 17, 2015 07:49AM
Hey,

I knew someone would tell me this, because I forgot to tell that I actually used an uno yesterday. But is it possible that marlin can't handle the uno? Because I have never heard of someone using the uno...

Still hope someone can help me out!

Niben
Re: DIY project: homemade electronics?
May 17, 2015 03:53PM
The Uno has neither enough flash nor enough RAM to run Marlin.



Large delta printer [miscsolutions.wordpress.com], E3D tool changer, Robotdigg SCARA printer, Crane Quad and Ormerod

Disclosure: I design Duet electronics and work on RepRapFirmware, [duet3d.com].
Re: DIY project: homemade electronics?
May 17, 2015 07:57PM
Lookup teacup as I think it will run on a Uno or get a mega2560.
Re: DIY project: homemade electronics?
June 07, 2015 06:50AM
Interesting thread!

I was looking for a thread on how to build your own electronics / a stepper driver. I now understand that it's practically trivial with the pololu and A4988 compatible stepper drivers. Simply connect step / dir pin high or low. Works with 3.3 or 5V. But what I don't understand is why there is a capacitor in all the DIY electronic boards with these stepper drivers. Where does it connect to and why do I need one?

I think here it is answered... So is it simply to filter the motor input voltage?
Stepper Motor Basics
Quote

Ecellent text, and really needed. What could be added is that power supplies should be unregulated with a filter/reservoir capacitor with a value of:

Some other info to use them with the teensy:
[www.pjrc.com]
Sorry, only registered users may post in this forum.

Click here to login