Pages: [1]   Go Down
Author Topic: Convert serial x y data to parallel  (Read 2764 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I constructed an xy plotter and use Processing to send mouse data serially to the Arduino, then to Easydrivers, and then to the steppers. It works fine except that being serial, I can send an "x" or a "y", but not both simultaneously. The result is that only one stepper can be moving at a time. So, I can't make a diagonal line easily or make any move that requires both steppers to move at the same time as in a circle for example. I am thinking about using a shift register to store the x and y data and feed it as parallel data allowing the plotter to move both steppers at the same time. The speed of transfer is not important at all. The thought is that a shift register conversion after the Arduino could be stored, if needed, and then fed to the Easydriver chips. I would appreciate any thoughts or suggestions about the possibility of this approach. 
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 514
Posts: 31543
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

An X Y plotter is rather similar to a CNC machine. They use a simple language called Gcode,so if you want to go to coordinates 17 and 22 then you would send:-
G2 X 17 Y 22 (carriage return)
So the arduino doesn't command the motors until it sees the carriage return and knows the command is complete.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Grumpy_Mike and I am not sure if you are suggesting that I use the G code language or that I should be looking at how I am using the code to send the data and incorporate some sort of packet command. Any clarification would help.
Logged

Copenhagen, Denmark
Offline Offline
Edison Member
*
Karma: 26
Posts: 1148
Have you testrun your INO file today?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What have you got running on the Arduino - your own software or something bundled with Processing?

If you can send very small increments to the Arduino, then you could "draw" the diagonal line in the Processing and send very small movement steps to the Arduino along the diagonal line. Same goes for circle arcs and so on.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have my own Arduino code and processing is generating the xy mouse movement and sending it to the Arduino. But, my problem is understanding how to make the packets small as you have described. Since the Processing is sending the xy data, I assume that I  can "package" the data in small pairs but I am not sure hoe. Thanks for the insight!
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 514
Posts: 31543
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I am not sure if you are suggesting that I use the G code language or that I should be looking at how I am using the code to send the data and incorporate some sort of packet command.

Either it's your project, I was just showing how this was done in other situations.
Logged

Copenhagen, Denmark
Offline Offline
Edison Member
*
Karma: 26
Posts: 1148
Have you testrun your INO file today?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, if it is your own code in the Arduino, you have to change your logic. I presume (would help if you posted som code snippets) that you do some thing like
Code:
read serial line getting one x or y coordinate
move x motor if it was x
move y motor if it was y
...and loop
How about
Code:
Read code from serial with x and y (possibly waiting until you have recieved both)
Which is the longer x or y ?
if x loop for x steps
  move x one step.
  move y so it matches (total x moved) * y / x  ( which may be no step )
  end loop
if y .. the other way round ..
Note that it is important how you calculate the diagonal position to avoid various rounding errors.

BTW, the Gcode does it like that - one command includes all axis information. The firmware then does the diagonal lines (or arcs ...)
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 6
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Msquare and that is the way to go for sure. I appreciate you reply and will revamp my logic. All replies have been helpful and gives me some new direction. Thanks all!
Logged

Pages: [1]   Go Up
Jump to: