Bit mask Arduino Uno


I’m new to this platform and also not very familiar with the Arduino software.

I did build a plotter to write and draw and everything is working perfect.

my only and big problem is that all my writings are 45° rotated.

this is because I use the GRBL code.

in this code: (on the bottom of this question)

you can see that every stepper motor has a pulse and direction.

the only problem is i’m not using X,Y,Z.

I need postieve X and negative Y to draw a straight line otherwise it’s shifted 45°

I tried adding up the bits from X and Y command by using 2,!3 for the steps or 2 && !3 but is doesn’t seem to work.

how can I set up this code so when the code drives the X axis the Y axis also rotates in the other direction? meaning driving step digital output 2 and 3 and direction puls 5 postieve and 6 negatieve.

the last one I might be able to skip because it’s a low.

so how to active two bits (2 outputs) with one command.

thnak you for you help.

#define X_STEP_BIT 2 // Uno Digital Pin 2
#define Y_STEP_BIT 3 // Uno Digital Pin 3
#define Z_STEP_BIT 4 // Uno Digital Pin 4
#define STEP_MASK ((1<<X_STEP_BIT)|(1<<Y_STEP_BIT)|(1<<Z_STEP_BIT)) // All step bits

// Define step direction output pins. NOTE: All direction pins must be on the same port.
#define X_DIRECTION_BIT 5 // Uno Digital Pin 5
#define Y_DIRECTION_BIT 6 // Uno Digital Pin 6
#define Z_DIRECTION_BIT 7 // Uno Digital Pin 7
#define DIRECTION_MASK ((1<<X_DIRECTION_BIT)|(1<<Y_DIRECTION_BIT)|(1<<Z_DIRECTION_BIT)) // All direction bits

1 Like