MetalWorkerTools / grbl-L-Mega

An open source, embedded, high performance g-code-parser and CNC milling controller written in optimized C that will run on an Arduino Mega2560. Forked from GRBL modified for use on a lathe with spindle sync threading
https://github.com/MetalWorkerTools/grbl-L-Mega/wiki
Other
16 stars 9 forks source link

Threading : Index and Sync Pins : cpu_map.h #9

Open Jimmot opened 7 months ago

Jimmot commented 7 months ago

G'day L & G's. I can't seem to trace a Y- pin on in the standard Mega part of the cpu.h file. I note the index and sync output pins on the last part of the Ramps section. The threading instructions refer to Y- limit for index and Probe for the sync in that document, but I think I'm in the wrong place (older versions?). For my part, I'm 66 years old and a novice at this installation. All the steppers and homing are working. Working on spindle activation and control now and have been doing so for 2 months. I'm now formally stumped.

Please could I have an explanation as to the working of the index and sync pins and in particular the index and sync pin connections for CPU_MAP_2560_INITIAL. If I connect the index to Pin D11, I get a limit fault. Need to get the index working before going on to sync on A15.

Also please explain the following: " // NOTE: All CONTROLs pins must be on the same port and not on a port with other input pins (limits)." There is only one USB connection from what I see. So there is uncertainty in my mind as to exactly what constitutes a port. i.e. should the common rails be split, one for analogue, one for digital and the commons taken from opposite sides of the Mega?

Using Grbl gru (Mega 5X connection) and Grbl-L-Mega-edge, all latest versions to where I was directed. Many thanks in anticipation of a response. I would not ask unless I had read and re-read all I can find (and understand). Many thanks, Jim

HuubBuis commented 7 months ago

The threading needs an Index pin but the synchronization pin is optional. Start using just the index pin to get started. In this Wiki the working of the threading code is explained.

To make things "easy" and allow the use of commercial shields, I used the Y-limit pin for the index signal and probe pin for the synchronization signal. The RAMPS shield has a different mapping. I mapped the SCL and SDA pin for index and synchronization pin. In this Wiki you find the setup for the RAMPS shield.

Internally, the controller (Uno, nano, mega) has different IO ports. The arduino Uno has 3 ports (A,B,C) and each port has a 8 pins. The mega has a lot more ports that could be used. All control pins must be mapped to the same port. You can't map the pause pin on port A and the door pin on port B. This is a limitation of the way the original grbl software was designed. Just use the grbl-L-Mega-Ramps branch without any changes, it should work. The edge branch is for using an Arduino Mega without a shield.

It seem I am a bit younger (64 years) and still going strong (i think).

Regards, Huub

Jimmot commented 7 months ago

Thanks Huub, sooo, sooo much.  My setup does NOT use a shield, so I was in the right place with edge.  I am connecting directly into the Mega.  I merely noted the presence of the SSCL SDA code in the ramps section as similar code seemed absent in the INITIAL section.  This leaves the cpu.h (INITIAL) file missing a Y- limit pin so the index pulse can be processed.   Or am I being completely dumb on this (most likely scenario)!

Or, do I just compile the ramps code and use it as is with index to SCL and sync to SDA?  With all other pins as per the INITIAL version.  I think that's what is required, if I'm reading this right. But I'm unsure.

My knowledge of coding is sweet zero.   Unlikely to fiddle with the ports in the code and the USB connection is unrelated to the ports note.  Learning.....

Finally, just a very strong word of thanks to you and to those upon whose shoulders you stand.   The grbl project in its iterations will have massively opened new worlds to many.  Including myself.   Again, massive thanks to all involved.    Ta.   Jim

On 2024/02/20 14:36:04, Huub Buis @.> wrote: The threading needs an Index pin but the synchronization pin is optional. Start using just the index pin to get started. In this Wiki [https://github.com/MetalWorkerTools/grbl-L-Mega/wiki/How-it-works]the working of the threading code is explained. To make things "easy" and allow the use of commercial shields, I used the Y-limit pin for the index signal and probe pin for the synchronization signal. The RAMPS shield has a different mapping. I mapped the SCL and SDA pin for index and synchronization pin. In this Wiki [https://github.com/MetalWorkerTools/grbl-L-Mega/wiki/Threading-setup-RAMPS] you find the setup for the RAMPS shield. Internally, the controller (Uno, nano, mega) has different IO ports. The arduino Uno has 3 ports (A,B,C) and each port has a 8 pins. The mega has a lot more ports that could be used. All control pins must be mapped to the same port. You can't map the pause pin on port A and the door pin on port B. This is a limitation of the way the original grbl software was designed. Just use the grbl-L-Mega-Ramps [https://github.com/MetalWorkerTools/grbl-L-Mega] branch without any changes, it should work. The edge branch is for using an Arduino Mega without a shield. It seem I am a bit younger (64 years) and still going strong (i think). Regards, Huub — Reply to this email directly, view it on GitHub [https://github.com/MetalWorkerTools/grbl-L-Mega/issues/9#issuecomment-1954125479], or unsubscribe [https://github.com/notifications/unsubscribe-auth/BERRPV3N7UX2OASKA6DKRADYUSKDJAVCNFSM6AAAAABDQ24L2CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJUGEZDKNBXHE]. You are receiving this because you authored the thread.Message ID: @.>

HuubBuis commented 7 months ago

If you don't use a shield (I also do not use a shield) you need the edge branch (like you did) and the connection scheme for the grbl-mega version. The Index pulse needs to be connected to the Y-limit pin and the Synchronization pulse to the probe pin. Setup the board according to the Wiki and it should work. As said before, start by using (and configuring) just the index pulse.