Go Down

Topic: Convert serial x y data to parallel (Read 4801 times) previous topic - next topic


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. 


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.


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.


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.


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!


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.


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: [Select]
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: [Select]
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 ...)


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!

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131