I have been working on building a stamping press for several weeks but now, after finishing with all the metal work I came to a stand-still because of my lack of Arduino programming knowledge.
Here is the hardware I have for now:
arduino mega 2560
serial 20x4 Black on Green LCD code LCD-09568
4 Axis CNC controller with 24v power source and parallel port input (cannot figure out the exact pinout of the board)
2 1.3 N Stepper Motors
2 ROB-09454 Digital Line Sensor Breakout
8 pin keyboard (0-9 digits and A B C D * # keys)
Here is the working principle of the press as I have imagined it:
The press is actuated by two motors, one for fast positioning (I will call it Motor 1) linked directly to the actuating screw, and the second one (Motor 2) is connected to the screw via a 1:40 demultiplier for fine positioning.
I want to control the motors via a pedal. When I push the pedal, the rocker (I hope I called it right, English is not my native language ) must approach the part rapidly (at a speed I can set via the LCD menu) until it meets the proximity sensors (ROB-09454 Digital Line Sensor Breakout). After passing the sensors the rocker must continue it`s approach at a slow speed (which I should be able to set via a menu on the LCD screen) in order for it to be able to touch the part without damaging it. When contact appears between the part and the rocker the later must stop and wait for my input for the deepness of the stamp that needs to be done via Motor 2.
At any moment, raising my foot off the pedal should lead to the retracting of the pedal with Motor 1.
After touching the part there should be 2 alternatives:
I confirm that the position is correct and push the confirm button which leads to the input of the depth of the stamping.
I do not confirm the correct positioning and raise my foot off the pedal which raises the rocker up to the proximity sensors, not all the way up.
I`m not asking for someone to write up the entire program for me but I would really appreciate it if I could get some "Arduino for Dummies" pointers regarding the use of the CNC controller via the Arduino, LCD programming, Creating input menus, connecting the keyboard and so on.
Without wishing to be guilty of submitting to pointless safety issues, have you considered how you will prevent someone accidentally putting their hand or fingers under the power driven press when they operate the foot pedal. Industrial presses have many in-built safety features such as limit switches, photo or proximity sensors, including high integrity processors, to prevent such types of accidents. They also generally require both hands to be activating separate switches to permit the foot pedal to operate. (If the hands are busy doing something they cannot be under the press tool) You might also need to consider how you prevent the arduino from accidentally activating the press without the foot pedal being operated (such can occur due to electrical "noise")
Thank you very much for the advice jackrae. I have safety issues concerns, especially after seeing clips like these (the smart saw - YouTube), but this press I am building is fairly small and will be used for stamping marks on very small parts with thin dies, there is no danger. The stamping occurs at a very slow speed and even if something goes wrong, releasing the pedal will raise the rocker. As for the electrical noise part I will look into it, maybe using shielded cables and casings will eliminate this potential problem.
It seems to me your question is fundamentally about how to develop program structure and sequencing flow in your program. First I would suggest you don't start with trying to write the complete program. First prove to yourself that you can write small functions one at a time that can manipulate output actions, as in move motor_x forward/reverse/stop, and then small functions that prove you can input sensors and user controls properly.
You already have a good start in that you have thought out the proper sequence steps you want the press to perform, including possible alternate steps depending on user or sensor inputs. Having a program the follows a predefined sequence of steps with possible alternate steps is often done with a program flow called a 'state machine'. You might research that term to see how it might be the basis for your program development.
Again I think you should start by proving out all the individual real world inputs and outputs including the user interface controls. It sounds like a ambitious project if your a beginner at programming, but still possible if you approach it as a series of little tasks. Later you can integrate all the individual functions you have developed into a single overall program. Sound logical?
retrolefty I have to say that state machine is a great advice. I used state machine in highschool but forgot everything about it. I will search for a freeware state machine software and try to get things moving.
I know that state machine software does not do anything on the arduino, I was just avoiding doing that on paper : .
As for the CNC controller, I managed to move the motors using another controller board which had the pin-out marked (Dir_X, Dir_Y, Step_X, Step_Y etc.) with some basic code I found on this forum. Unfortunately that board got destroyed when it`s power source malfunctioned and fried the whole thing. :-[
You said that the CNC controller has a parallel interface. That constrains the pinout -- you can find the pinout for a standard parallel port here: PC Parallel Port Connector Pinout and Description, LPT port. That at least gives you a place to start figuring out the pinout if you truly cannot find documentation for it.