Okay, first off, as you can tell, I’m a n00b to this. I’ve picked up what I know so far by decompiling sketches and ramming what I’ve gleaned from that together to form sketches. Now, prior to getting into microcontrolling via Arduino, I have had no prior programming experience. Keep it simple at first; I gain ground and can hold my own fast. I’ve gotten through this design!
I’ll give y’all a rundown of what I want to do, then I’ll get to the code and the errors I’m encountering.
I’m designing a CNC mill. Now, the driver area of it I’ve pretty much gotten down-pat, but I wanted to design a controller for it. That is, this CNC mill takes the brute-force approach of having to have every dimension, every movement converted into steps, dimensions, and delays and hard-coded into the software itself. That’s fine and dandy…if I’m trying to mill a square or rectangle. But for complex designs increasing the scope of the mill requires increasing the coding by exactly that much.
So I’ve gone about designing a controller. That is, a second Arduino which would have a keypad entry and 3 4-digit 7-segment displays for displaying entered values in the X, Y, and Z axes, and 5 push-buttons. Each button would essentially trigger “on” an axis - for data to be written to the X-axis screen and placed into memory as a value, the X-button has to be depressed. It’s the brute-force way of doing this, but with this mill I won’t be in any hurry to do the coding nor do I want to make the coding more complex than it has to be. Revamping it is for when I have a working device in the first place. The other two buttons are a reset button, for resetting the controller for the next command, and another button (in the code called masterButton) that triggers an analogWrite series of commands writing the X, Y, and Z axis values to pins.
Not that it’s specifically relevant, but the prevailing notion being the driver Arduino receives said values at its analog inputs and does the appropriate math to convert from inches to steps via appropriate step ratios - another reason for designing this controller is to allow me to put inputs in inches, in tangible units, not to have to back-convert every measurement via that ratio and take twice as long in the coding process. I want to use this device to generate very precision creations, and the 4-digit displays would ideally have the decimal mapped as to allow a maximum of 0 to 9.999" - that is, one integer position and three decimal positions. As the Arduino’s analog outputting capabilities are limited to 1,024 possible values, I planned on dividing that result by a factor of 10 in the output coding. It reduces accuracy but the only field I’d need thousandth-inch accuracy is mil-spec weapons manufacture, of which I think is safe to say even unspoken is out of my reach.
Without further ado:
#include <Keypad.h>
#include <SevenSegment.h>
#define CLOCK 1
#define CLOCK 4
#define CLOCK 7
#define DATA 2
#define DATA 5
#define DATA 8
#define LOAD 3
#define LOAD 6
#define LOAD 9
const byte ROWS = 4;
const byte COLS = 3;
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
byte rowPins[ROWS] = {16, 17, 18, 19};
byte colPins[COLS] = {20, 21, 22};
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
SevenSegment scrnX(1,2,3);
SevenSegment scrnY(4,5,6);
SevenSegment scrnZ(7,8,9);
int ButtonX = 10;
int ButtonY = 11;
int ButtonZ = 12;
int masterButton = 13;
int resetButton = 23;
int coordX = 14;
int coordY = 15;
int coordZ = 16;
int xmitled = 24;
int ButtonXState = 0;
int ButtonYState = 0;
int ButtonZState = 0;
int masterButtonState = 0;
int resetButtonState = 0;
int valX = 0;
int valY = 0;
int valZ = 0;
void setup()
{
scrnX.begin("M5450","8888");
scrnY.begin("M5450","8888");
scrnZ.begin("M5450","8888");
pinMode(coordX, OUTPUT);
pinMode(coordY, OUTPUT);
pinMode(coordZ, OUTPUT);
pinMode(xmitled, OUTPUT);
}
void loop()
{
ButtonXState = digitalRead(ButtonX);
ButtonYState = digitalRead(ButtonY);
ButtonZState = digitalRead(ButtonZ);
masterButtonState = digitalRead(masterButton);
resetButtonState = digitalRead(resetButton);
char key = keypad.getKey();
if ((key != NO_KEY) && (ButtonXState = HIGH))
{
scrnX.print(key);
valX = char key;
}
if ((key != NO_KEY) && (ButtonYState = HIGH))
{
scrnY.print(key);
valY = char key;
}
if ((key != NO_KEY) && (ButtonZState = HIGH))
{
scrnZ.print(key);
valZ = char key;
}
if (masterButtonState = HIGH)
{
analogWrite(coordX, valX / 10);
analogWrite(coordY, valY / 10);
analogWrite(coordZ, valZ / 10);
digitalWrite(xmitled, HIGH);
}
}
Error messages I’ve received are next. I’ve resolved the ones regarding values not being defined being a lapse in the first place, but I cannot resolve the char command errors.
sketch_may21a.ino: In function 'void loop()':
sketch_may21a:69: error: invalid conversion from 'char' to 'char*'
sketch_may21a:69: error: initializing argument 1 of 'void SevenSegment::print(char*)'
sketch_may21a:74: error: invalid conversion from 'char' to 'char*'
sketch_may21a:74: error: initializing argument 1 of 'void SevenSegment::print(char*)'
sketch_may21a:75: error: expected primary-expression before 'char'
sketch_may21a:75: error: expected `;' before 'char'
sketch_may21a:79: error: invalid conversion from 'char' to 'char*'
sketch_may21a:79: error: initializing argument 1 of 'void SevenSegment::print(char*)'
sketch_may21a:80: error: expected primary-expression before 'char'
sketch_may21a:80: error: expected `;' before 'char'
Any ideas on how to correct this?
Also, if any of you had any constructive criticism or ideas for the design conceptually, I’d be glad to hear them.
Thanks,
Eli Fedele
(djkolumbian)