Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to connect stepper to CNC shield v3? #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Images/IMG_20150325_220904.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/IMG_20150325_220919.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/IMG_20150325_223348.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/IMG_20150325_223515.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions Marlin/Marlin.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

544 changes: 272 additions & 272 deletions config.h → Marlin/config.h

Large diffs are not rendered by default.

663 changes: 352 additions & 311 deletions cpu_map.h → Marlin/cpu_map.h

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion defaults.h → Marlin/defaults.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,4 @@
#define DEFAULT_HOMING_PULLOFF 1.0 // mm
#endif

#endif
#endif
300 changes: 150 additions & 150 deletions eeprom.c → Marlin/eeprom.c
Original file line number Diff line number Diff line change
@@ -1,151 +1,151 @@
// This file has been prepared for Doxygen automatic documentation generation.
/*! \file ********************************************************************
*
* Atmel Corporation
*
* \li File: eeprom.c
* \li Compiler: IAR EWAAVR 3.10c
* \li Support mail: [email protected]
*
* \li Supported devices: All devices with split EEPROM erase/write
* capabilities can be used.
* The example is written for ATmega48.
*
* \li AppNote: AVR103 - Using the EEPROM Programming Modes.
*
* \li Description: Example on how to use the split EEPROM erase/write
* capabilities in e.g. ATmega48. All EEPROM
* programming modes are tested, i.e. Erase+Write,
* Erase-only and Write-only.
*
* $Revision: 1.6 $
* $Date: Friday, February 11, 2005 07:16:44 UTC $
****************************************************************************/
#include <avr/io.h>
#include <avr/interrupt.h>
/* These EEPROM bits have different names on different devices. */
#ifndef EEPE
#define EEPE EEWE //!< EEPROM program/write enable.
#define EEMPE EEMWE //!< EEPROM master program/write enable.
#endif
/* These two are unfortunately not defined in the device include files. */
#define EEPM1 5 //!< EEPROM Programming Mode Bit 1.
#define EEPM0 4 //!< EEPROM Programming Mode Bit 0.
/* Define to reduce code size. */
#define EEPROM_IGNORE_SELFPROG //!< Remove SPM flag polling.
/*! \brief Read byte from EEPROM.
*
* This function reads one byte from a given EEPROM address.
*
* \note The CPU is halted for 4 clock cycles during EEPROM read.
*
* \param addr EEPROM address to read from.
* \return The byte read from the EEPROM address.
*/
unsigned char eeprom_get_char( unsigned int addr )
{
do {} while( EECR & (1<<EEPE) ); // Wait for completion of previous write.
EEAR = addr; // Set EEPROM address register.
EECR = (1<<EERE); // Start EEPROM read operation.
return EEDR; // Return the byte read from EEPROM.
}
/*! \brief Write byte to EEPROM.
*
* This function writes one byte to a given EEPROM address.
* The differences between the existing byte and the new value is used
* to select the most efficient EEPROM programming mode.
*
* \note The CPU is halted for 2 clock cycles during EEPROM programming.
*
* \note When this function returns, the new EEPROM value is not available
* until the EEPROM programming time has passed. The EEPE bit in EECR
* should be polled to check whether the programming is finished.
*
* \note The EEPROM_GetChar() function checks the EEPE bit automatically.
*
* \param addr EEPROM address to write to.
* \param new_value New EEPROM value.
*/
void eeprom_put_char( unsigned int addr, unsigned char new_value )
{
char old_value; // Old EEPROM value.
char diff_mask; // Difference mask, i.e. old value XOR new value.
cli(); // Ensure atomic operation for the write operation.
do {} while( EECR & (1<<EEPE) ); // Wait for completion of previous write.
#ifndef EEPROM_IGNORE_SELFPROG
do {} while( SPMCSR & (1<<SELFPRGEN) ); // Wait for completion of SPM.
#endif
EEAR = addr; // Set EEPROM address register.
EECR = (1<<EERE); // Start EEPROM read operation.
old_value = EEDR; // Get old EEPROM value.
diff_mask = old_value ^ new_value; // Get bit differences.
// Check if any bits are changed to '1' in the new value.
if( diff_mask & new_value ) {
// Now we know that _some_ bits need to be erased to '1'.
// Check if any bits in the new value are '0'.
if( new_value != 0xff ) {
// Now we know that some bits need to be programmed to '0' also.
EEDR = new_value; // Set EEPROM data register.
EECR = (1<<EEMPE) | // Set Master Write Enable bit...
(0<<EEPM1) | (0<<EEPM0); // ...and Erase+Write mode.
EECR |= (1<<EEPE); // Start Erase+Write operation.
} else {
// Now we know that all bits should be erased.
EECR = (1<<EEMPE) | // Set Master Write Enable bit...
(1<<EEPM0); // ...and Erase-only mode.
EECR |= (1<<EEPE); // Start Erase-only operation.
}
} else {
// Now we know that _no_ bits need to be erased to '1'.
// Check if any bits are changed from '1' in the old value.
if( diff_mask ) {
// Now we know that _some_ bits need to the programmed to '0'.
EEDR = new_value; // Set EEPROM data register.
EECR = (1<<EEMPE) | // Set Master Write Enable bit...
(1<<EEPM1); // ...and Write-only mode.
EECR |= (1<<EEPE); // Start Write-only operation.
}
}
sei(); // Restore interrupt flag state.
}
// Extensions added as part of Grbl
void memcpy_to_eeprom_with_checksum(unsigned int destination, char *source, unsigned int size) {
unsigned char checksum = 0;
for(; size > 0; size--) {
checksum = (checksum << 1) || (checksum >> 7);
checksum += *source;
eeprom_put_char(destination++, *(source++));
}
eeprom_put_char(destination, checksum);
}
int memcpy_from_eeprom_with_checksum(char *destination, unsigned int source, unsigned int size) {
unsigned char data, checksum = 0;
for(; size > 0; size--) {
data = eeprom_get_char(source++);
checksum = (checksum << 1) || (checksum >> 7);
checksum += data;
*(destination++) = data;
}
return(checksum == eeprom_get_char(source));
}
// This file has been prepared for Doxygen automatic documentation generation.
/*! \file ********************************************************************
*
* Atmel Corporation
*
* \li File: eeprom.c
* \li Compiler: IAR EWAAVR 3.10c
* \li Support mail: [email protected]
*
* \li Supported devices: All devices with split EEPROM erase/write
* capabilities can be used.
* The example is written for ATmega48.
*
* \li AppNote: AVR103 - Using the EEPROM Programming Modes.
*
* \li Description: Example on how to use the split EEPROM erase/write
* capabilities in e.g. ATmega48. All EEPROM
* programming modes are tested, i.e. Erase+Write,
* Erase-only and Write-only.
*
* $Revision: 1.6 $
* $Date: Friday, February 11, 2005 07:16:44 UTC $
****************************************************************************/
#include <avr/io.h>
#include <avr/interrupt.h>

/* These EEPROM bits have different names on different devices. */
#ifndef EEPE
#define EEPE EEWE //!< EEPROM program/write enable.
#define EEMPE EEMWE //!< EEPROM master program/write enable.
#endif

/* These two are unfortunately not defined in the device include files. */
#define EEPM1 5 //!< EEPROM Programming Mode Bit 1.
#define EEPM0 4 //!< EEPROM Programming Mode Bit 0.

/* Define to reduce code size. */
#define EEPROM_IGNORE_SELFPROG //!< Remove SPM flag polling.

/*! \brief Read byte from EEPROM.
*
* This function reads one byte from a given EEPROM address.
*
* \note The CPU is halted for 4 clock cycles during EEPROM read.
*
* \param addr EEPROM address to read from.
* \return The byte read from the EEPROM address.
*/
unsigned char eeprom_get_char( unsigned int addr )
{
do {} while( EECR & (1<<EEPE) ); // Wait for completion of previous write.
EEAR = addr; // Set EEPROM address register.
EECR = (1<<EERE); // Start EEPROM read operation.
return EEDR; // Return the byte read from EEPROM.
}

/*! \brief Write byte to EEPROM.
*
* This function writes one byte to a given EEPROM address.
* The differences between the existing byte and the new value is used
* to select the most efficient EEPROM programming mode.
*
* \note The CPU is halted for 2 clock cycles during EEPROM programming.
*
* \note When this function returns, the new EEPROM value is not available
* until the EEPROM programming time has passed. The EEPE bit in EECR
* should be polled to check whether the programming is finished.
*
* \note The EEPROM_GetChar() function checks the EEPE bit automatically.
*
* \param addr EEPROM address to write to.
* \param new_value New EEPROM value.
*/
void eeprom_put_char( unsigned int addr, unsigned char new_value )
{
char old_value; // Old EEPROM value.
char diff_mask; // Difference mask, i.e. old value XOR new value.

cli(); // Ensure atomic operation for the write operation.

do {} while( EECR & (1<<EEPE) ); // Wait for completion of previous write.
#ifndef EEPROM_IGNORE_SELFPROG
do {} while( SPMCSR & (1<<SELFPRGEN) ); // Wait for completion of SPM.
#endif

EEAR = addr; // Set EEPROM address register.
EECR = (1<<EERE); // Start EEPROM read operation.
old_value = EEDR; // Get old EEPROM value.
diff_mask = old_value ^ new_value; // Get bit differences.

// Check if any bits are changed to '1' in the new value.
if( diff_mask & new_value ) {
// Now we know that _some_ bits need to be erased to '1'.

// Check if any bits in the new value are '0'.
if( new_value != 0xff ) {
// Now we know that some bits need to be programmed to '0' also.

EEDR = new_value; // Set EEPROM data register.
EECR = (1<<EEMPE) | // Set Master Write Enable bit...
(0<<EEPM1) | (0<<EEPM0); // ...and Erase+Write mode.
EECR |= (1<<EEPE); // Start Erase+Write operation.
} else {
// Now we know that all bits should be erased.

EECR = (1<<EEMPE) | // Set Master Write Enable bit...
(1<<EEPM0); // ...and Erase-only mode.
EECR |= (1<<EEPE); // Start Erase-only operation.
}
} else {
// Now we know that _no_ bits need to be erased to '1'.

// Check if any bits are changed from '1' in the old value.
if( diff_mask ) {
// Now we know that _some_ bits need to the programmed to '0'.

EEDR = new_value; // Set EEPROM data register.
EECR = (1<<EEMPE) | // Set Master Write Enable bit...
(1<<EEPM1); // ...and Write-only mode.
EECR |= (1<<EEPE); // Start Write-only operation.
}
}

sei(); // Restore interrupt flag state.
}

// Extensions added as part of Grbl


void memcpy_to_eeprom_with_checksum(unsigned int destination, char *source, unsigned int size) {
unsigned char checksum = 0;
for(; size > 0; size--) {
checksum = (checksum << 1) || (checksum >> 7);
checksum += *source;
eeprom_put_char(destination++, *(source++));
}
eeprom_put_char(destination, checksum);
}

int memcpy_from_eeprom_with_checksum(char *destination, unsigned int source, unsigned int size) {
unsigned char data, checksum = 0;
for(; size > 0; size--) {
data = eeprom_get_char(source++);
checksum = (checksum << 1) || (checksum >> 7);
checksum += data;
*(destination++) = data;
}
return(checksum == eeprom_get_char(source));
}

// end of file
2 changes: 1 addition & 1 deletion eeprom.h → Marlin/eeprom.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ void eeprom_put_char(unsigned int addr, unsigned char new_value);
void memcpy_to_eeprom_with_checksum(unsigned int destination, char *source, unsigned int size);
int memcpy_from_eeprom_with_checksum(char *destination, unsigned int source, unsigned int size);

#endif
#endif
2 changes: 1 addition & 1 deletion gcode.c → Marlin/gcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,4 +750,4 @@ uint8_t gc_execute_line(char *line)
group 10 = {G98, G99} return mode canned cycles
group 13 = {G61, G61.1, G64} path control mode
group 14 = {M50} LDR read
*/
*/
2 changes: 1 addition & 1 deletion gcode.h → Marlin/gcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,4 @@ uint8_t gc_execute_line(char *line);
// Set g-code parser position. Input in steps.
void gc_sync_position();

#endif
#endif
2 changes: 1 addition & 1 deletion laser_control.c → Marlin/laser_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,4 @@ ISR(TIMER2_COMPA_vect)
laser_set(i, LASER_DISABLE);
}
}
}
}
2 changes: 1 addition & 1 deletion laser_control.h → Marlin/laser_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ void laser_off(uint8_t laser_bit);
void laser_on(uint8_t laser_bit);
void laser_run(uint8_t mode, uint8_t value);

#endif
#endif
2 changes: 1 addition & 1 deletion ldr.c → Marlin/ldr.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ void print_ldr(uint8_t tool){
printString(buffer);
printString("\r\n");
}
}
}
2 changes: 1 addition & 1 deletion ldr.h → Marlin/ldr.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@
void ldr_init(void);
uint16_t ldr_read(uint8_t channel);

#endif
#endif
2 changes: 1 addition & 1 deletion main.c → Marlin/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ int main(void)

}
return 0; /* Never reached */
}
}
2 changes: 1 addition & 1 deletion motion_control.c → Marlin/motion_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,4 +370,4 @@ void mc_reset()
st_go_idle(); // Force kill steppers. Position has likely been lost.
}
}
}
}
2 changes: 1 addition & 1 deletion motion_control.h → Marlin/motion_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ void mc_probe_cycle(float *target, float feed_rate, uint8_t invert_feed_rate);
// Performs system reset. If in motion state, kills all motion and sets system alarm.
void mc_reset();

#endif
#endif
2 changes: 1 addition & 1 deletion nuts_bolts.c → Marlin/nuts_bolts.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,4 @@ void delay_us(uint32_t us)


// Simple hypotenuse computation function.
float hypot_f(float x, float y) { return(sqrt(x*x + y*y)); }
float hypot_f(float x, float y) { return(sqrt(x*x + y*y)); }
2 changes: 1 addition & 1 deletion nuts_bolts.h → Marlin/nuts_bolts.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ void delay_us(uint32_t us);
// Computes hypotenuse, avoiding avr-gcc's bloated version and the extra error checking.
float hypot_f(float x, float y);

#endif
#endif
2 changes: 1 addition & 1 deletion planner.c → Marlin/planner.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,4 +426,4 @@ void plan_cycle_reinitialize()
st_update_plan_block_parameters();
block_buffer_planned = block_buffer_tail;
planner_recalculate();
}
}
2 changes: 1 addition & 1 deletion planner.h → Marlin/planner.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,4 @@ uint8_t plan_get_block_buffer_count();
// Returns the status of the block ring buffer. True, if buffer is full.
uint8_t plan_check_full_buffer();

#endif
#endif
Loading