Hello!
I am out to build a CNC Router and i want to control it with my Arduino Board (Leonardo). My Problem is the communication between my Arduino and my computer. I have a file, where all the coordinates of the routing process are stored(x,y,z), all integers. Now I am trying to find a way to let the Arduino board always read 3 numbers of this file. After reaching the given point the Arduino board shall read the next 3 numbers and so on, until it has reached the end of the file. I suppose that the file is too big for the internal memory of the Arduino. Can I do it with the Serial Monitor or is there antoher way.
Sincerely yours
RosewoodMr
Excuse my English
Can I do it with the Serial Monitor
No, but you can do it with Serial of which the Leonardo conveniently has 2 instances, one via USB so that you could use the Serial monitor to see what is going on and one via pins 0 and 1 that could communicate with the PC.
What you need is a program on the PC to output the file via a serial port connected to the Leonardo. Then on the Leonardo you read integers into separate variables (an array is convenient) until a newline or carriage return is found depending what you are sending as a line ending from the PC. Then you can use the x, y and z values to position the 3 stepper motors controlling the Router.
Keep going until you reach the end of the file.
I am doing a similar project. I am building a PC program using Python which will create and send the numbers to my Arduino.
What code have you got on your Leonardo?
What stepper motor drivers are you using?
How often will it be necessary to send the 3 numbers to the Leonardo?
If you need to update the numbers frequently it would speed things up to send binary rather than Ascii data to the Leonardo. (I believe in getting my PC to do the hard work).
...R
Thank you very much for your responses!
I think I'll have to write one more program. Do you think, it's best to do it with "Processing". Unfortunately I can only handle C and Processing. I thought of "Processing" because of the communication between the Computer and the Leonardo. I do not use stepper motors. I'm using ordinary DC-Motors and I get the position of the Router by counting the turns of these Motors up and down using the Hall-Effect. What do you think? Is it easier to write an additional program or to put the data on a SD-Card an then read it directly with the Arduino?
Is it easier to write an additional program or to put the data on a SD-Card an then read it directly with the Arduino?
I was going to suggest using an SD card but you had specified communication rather than any other mens of data transfer. Creating a CSV file on a PC is easy as is reading it from an SD card using an Arduino. It will almost certainly be easier to do it this way not least because you can read the values when required.
As to using DC motors then do not expect great accuracy. How many pulses per revolution will the sensors provide ?
If you can put the data on an SD card it can be created with any PC program.
I hadn't considered using an SD card for my system because it would require some sort of control system on the Arduino itself - if only start/stop buttons and LEDs to indicate the state it is in. I want to have all that on my PC.
I know very little about Processing but it can probably do anything that I would be likely to do with Python.
Out of curiosity, how do you intend to generate the coordinates?
...R
Ok, I'm reliefed, because the way with the SD Card seemes to be a problem easy to handle.
I can count each quarter turn of the DC Motor, but i have got a gearbox that will provide that one turn of the motor is only 005mm of the Router. However I don't expect such a good accuracy:).
I generate the coordinates with a C program. I let it read an image an convert it into an array that consists of 0 and 1. Then I let it find a routing way. But it's only meant for 2 and a half D routing processes. I'll see if it works well and then I can start doing some more complex stuff.
Thank you all for your help!
RosewoodMr:
I generate the coordinates with a C program. I let it read an image an convert it into an array that consists of 0 and 1. Then I let it find a routing way.
I'm doing much the same thing, but with Python. Hopefully have the route actually moving my stepper motors in the next day or 2. Then I can really see all my stupid mistakes.
...R