repetier / Repetier-Firmware

Firmware for Arduino based RepRap 3D printer.
812 stars 734 forks source link

spare i/o's? #795

Open emetss opened 6 years ago

emetss commented 6 years ago

Hi all, I have an Arduino mega 2560 with ramps 1.4 and a repetier firmware for a 3d printer. I want to add some features to control some additional things (additional fans, and so on). Do I have spare (free) I/Os, which i can use? Also what's the mapping between the mega 2560 and the ramps 1.4 ? I should "define" the pins as their numbers in the arduino but it's not like that. They are defined with different numbers.

Thanks

repetier commented 6 years ago

RAMPS uses the same arduin pin numbers. In reprap.org wiki you have a pinout whcih pin has whcih number. In general you can use any pin with any function ifthere are no special requirements. For analog inputs you always need a analog pin of course. In config tool just enter the digital pin number you used instead.

emetss commented 6 years ago

Many thanks for your reply. I'm still confused. I have protos 3d printer which has SD and LCD features used. I don't have the schematics but I have the Firmware. I don't have a configuration tool but I have configutation.h in the reptier Firmware. I searched in the internet and found the attached pictures for the schematics. You see as the pictures tell that AIN0 is D54 ?. Also I looked in the Firmware "reptier" for the Protos and under pins.h I found the following:

define RAMPS_V_1_3

// #define RAMPS_V_1_0

ifdef RAMPS_V_1_3

define ORIG_X_STEP_PIN 54

define ORIG_X_DIR_PIN 55

define ORIG_X_ENABLE_PIN 38

define ORIG_X_MIN_PIN 3

define ORIG_X_MAX_PIN -1 //2 ----------------------------------------------------------------------------------------------------------

define ORIG_Y_STEP_PIN 60

define ORIG_Y_DIR_PIN 61

define ORIG_Y_ENABLE_PIN 56

define ORIG_Y_MIN_PIN 14

define ORIG_Y_MAX_PIN -1 //15 ---------------------------------------------------------------------------------------------------------

define ORIG_Z_STEP_PIN 46

define ORIG_Z_DIR_PIN 48

define ORIG_Z_ENABLE_PIN 62

define ORIG_Z_MIN_PIN 18

define ORIG_Z_MAX_PIN -1 //19 ---------------------------------------------------------------------------------------------------------

define ORIG_E0_STEP_PIN 26

define ORIG_E0_DIR_PIN 28

define ORIG_E0_ENABLE_PIN 24

define ORIG_E1_STEP_PIN 36

define ORIG_E1_DIR_PIN 34

define ORIG_E1_ENABLE_PIN 30

define SDPOWER -1

define SDSS 53

define SDCARDDETECT 49

define LED_PIN 13

define ORIG_FAN_PIN -1 //8 ---------------------------------------------------------------------------------------------------------------

define PS_ON_PIN 12

define HEATER_0_PIN 10 // e0->t0 ---------------------------------------------------------------------------------------------------------

define HEATER_1_PIN 9 // e1->t18 // 8 //hb->t2

define HEATER_2_PIN 8 // hb->t29 // 9 //e1->t1

define TEMP_0_PIN 13 // t0

define TEMP_1_PIN 14 // t1

define TEMP_2_PIN 15 // t2

define E0_PINS ORIG_E0_STEP_PIN,ORIG_E0_DIR_PIN,ORIG_E0_ENABLE_PIN,

define E1_PINS ORIG_E1_STEP_PIN,ORIG_E1_DIR_PIN,ORIG_E1_ENABLE_PIN,

My problem is that I don't know how to read these numbers. Does -1 mean that the pin is not used? How about the other numbers? And Also very important question: How to find an unused pin (digital input in my case) and how to choose it. I want it to be called by M code in the GCode.

Many many thanks in advance

arduino mega 2560 pinouts_ arduinomegapololushieldschematic

repetier commented 6 years ago

For ramps better use this to see pin numbers: https://reprap.org/wiki/File:Arduinomega1-4connectors.png

AIN0 is analog pin 0 if used as analog pin and D54 = pin 54 if used as digital pin. That is all. -1 is not defined as pin number, so it would do nothing.

emetss commented 6 years ago

Thanks for your kind reply. I checked the schematics you sent to me. There're still some numbers that can't be seen in the schematics. From the definitions below (in the repetier Firmware) I could only find the following pins: D3, D2, D14, D15, D18, D19, D53, D9, D12, A13, A14 Could you tell me where to find D54, D55, D38, D60, D61, D56, D46, D48, D62, D26, D28, D24, D13, D12 in the schematics?

// For RAMPS 1.4

define X_STEP_PIN 54

define X_DIR_PIN 55

define X_ENABLE_PIN 38

define X_MIN_PIN 3

define X_MAX_PIN 2

define Y_STEP_PIN 60

define Y_DIR_PIN 61

define Y_ENABLE_PIN 56

define Y_MIN_PIN 14

define Y_MAX_PIN 15

define Z_STEP_PIN 46

define Z_DIR_PIN 48

define Z_ENABLE_PIN 62

define Z_MIN_PIN 18

define Z_MAX_PIN 19

define E_STEP_PIN 26

define E_DIR_PIN 28

define E_ENABLE_PIN 24

define SDPOWER -1

define SDSS 53

define LED_PIN 13

define FAN_PIN 9

define PS_ON_PIN 12

define KILL_PIN -1

define HEATER_0_PIN 10

define HEATER_1_PIN 8

define TEMP_0_PIN 13 // ANALOG NUMBERING

define TEMP_1_PIN 14 // ANALOG NUMBERING

Many thanks in advance for your kind reply

repetier commented 6 years ago

Hi, Am Mi., 13. Juni 2018 um 02:46 Uhr schrieb emetss <notifications@github.com

:

Thanks for your kind reply. I checked the schematics you sent to me. There're still some numbers that can't be seen in the schematics. From the definitions below (in the repetier Firmware) I could only find the following pins: D3, D2, D14, D15, D18, D19, D53, D9, D12, A13, A14 Could you tell me where to find D54, D55, D38, D60, D61, D56, D46, D48, D62, D26, D28, D24, D13, D12 in the schematics?

As you see these are hard wired to components like stepper drivers and therefor do not appear in the external list. These are preset with the symbolic definition in pins.h as you already found out.

Yours Roalnd Littwin

// For RAMPS 1.4

define X_STEP_PIN 54

define X_DIR_PIN 55

define X_ENABLE_PIN 38

define X_MIN_PIN 3

define X_MAX_PIN 2

define Y_STEP_PIN 60

define Y_DIR_PIN 61

define Y_ENABLE_PIN 56

define Y_MIN_PIN 14

define Y_MAX_PIN 15

define Z_STEP_PIN 46

define Z_DIR_PIN 48

define Z_ENABLE_PIN 62

define Z_MIN_PIN 18

define Z_MAX_PIN 19

define E_STEP_PIN 26

define E_DIR_PIN 28

define E_ENABLE_PIN 24

define SDPOWER -1

define SDSS 53

define LED_PIN 13

define FAN_PIN 9

define PS_ON_PIN 12

define KILL_PIN -1

define HEATER_0_PIN 10

define HEATER_1_PIN 8

define TEMP_0_PIN 13 // ANALOG NUMBERING

define TEMP_1_PIN 14 // ANALOG NUMBERING

Many thanks in advance for your kind reply

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/repetier/Repetier-Firmware/issues/795#issuecomment-396778491, or mute the thread https://github.com/notifications/unsubscribe-auth/AA5AH7WbQObNDmjwLJblVLzWO7fcZk67ks5t8GD_gaJpZM4UfJqH .

-- Mit freundlichen Grüßen

Roland Littwin


Hot-World GmbH & Co. KG Knickelsdorf 42 47877 Willich Deutschland

Tel.: 02154-606518 Fax: 02154-606519

Geschäftsführer: Marcus Littwin Handelsregister: Amtsgericht Krefeld HRA 5325 Umsatzsteuer-Identifikationsnummer: DE213748632 Persönlich haftender Gesellschafter: Hot-World Medien GmbH mit Sitz in Willich Handelsregister: Amtsgericht Krefeld HRB 10800

Googliola commented 6 years ago

Stumbled upon this nifty piece of hardware, which enables you to add more peripherals via i2c, but also makes programming a bit tougher (I am giving it a shot for my LED extensions): https://learn.sparkfun.com/tutorials/sx1509-io-expander-breakout-hookup-guide

repetier commented 6 years ago

Good luck. Do not block interrupts for longer communications and send data only in main thread not from an interrupt. Should work well if done right.

emetss commented 6 years ago

Many thanks for the answers. I checked my card and found that I have Aux-2 and Aux-1 all free. So let's say I want to use the D63 (from Aux-1) as an digital output by adding a special gcode line (M999 for example). Firstly I have to define the new pin in the pins.h: #define device1_Trigger_Pin 63 Secondly in the Printer::Setup() I have to define it as an output: SET_OUTPUT(device1_Trigger_Pin); Thirdly, in the Commands::executeGCode(GCode *com), I have the line: else if(com->hasM()) // Process M Code { switch( com->M ) { //I can add this: case 999: WRTITE(device1_Trigger_Pin,HIGH); .......

Is it correct and enough? Will the gcode accept the new parameter "M999"? Or should I define it elsewhere?

Many thanks for your kind reply

repetier commented 6 years ago

No that would be enough except M999 already exists to resume from fatal errors.

The better solution would be to do all this with our events. There is a event for M codes and also for init. Defining pin numbers in pin.h is not really required. You can also define it in your events or directly use your number. See teh sample event systems in the github repository. For the felix printer I use events for all extensions of the printer including M codes.

netpipe commented 6 years ago

https://github.com/tecan/PCF8574-SWire-Arduino.git adds 8 new i/o ports https://github.com/tecan/Adafruit_SSD1306-SWire-Arduino

both have the ability to use any of the digital io pins for i2c on arduino mega and due

repetier commented 6 years ago

But you can not address them like normal io ports, so you have to modify the code changing these pins.