Reliable Baudrates cnc control project

Hello,

I'd like to use an Arduino for a cnc stepper motor control project. It is already finished and has been used personally for almost a year but it uses a self made ATMega1284P board at the moment which is a somewhat unhandy choice to release as open source project. It is programmed in AVR Studio Assembler and the PC frontend is a VB.NET program - so the Arduino board should basically just provide a convenient and easy to obtain hardware platform as there are not many external components needed to make it work on the hardware side.

My big concern at the moment is the following: I need to transfer quite some data - currently the project works at 230400 Baud. Unfortunately most Arduinos work at 16Mhz - so the baudrate register would be off by 8.5% in asynchronous normal mode operation or 3.5% in asynchronous double speed mode - quite unlikely to work. Also the more common 115200bps are off by 3.5 respectively 2.1%. I know this works on some Arduino but I also read about troubles and it is well outside Atmels recommendations (2% respectively 1.5% in double speed mode). Data transfer needs to be 100% reliable - the board will control cnc machines so any error is likely to cause damage or even injury - so I don't want to mess with that.

  • 100000bps would still be acceptably fast and offers 0% error - but does the windows com port driver accept this unusual baudrate without throwing an expection?
  • My second thought was to replace the crystal with a 14.7456MHz type -but then the bootloader is unlikely to work and it means modifying the Arduino itself - also something I don't like to do...

If someony already sucessfully or unsucessfully used an Arduino with 100000bps together with Windows / VB.NET I would be very glad to hear.

Thanks

Christian

I can't offer any help on the serial port side, but I'm curious to know why you require such high bandwidth. Have you delegated the real-time control elements of your machine to the PC application? I know that Arduino controlled CNC machines aren't unusual - is the approach you're taking a conventional one?

Data transfer needs to be 100% reliable - the board will control cnc machines so any error is likely to cause damage or even injury

Judging by the amount of data you seem to need to move, you're rolling your own protocol - G-code just isn't that bulky (unless maybe you're doing high res 3D contours or something, and even then 115k can drip-feed with no problems). Sounds like you need to add some error detection and handshaking.

The baud rate errors are just facts of life, as you've gleaned from the datasheet. Additionally, some arduinos (the USB models, IIRC) had a USB interface with a baud rate that was not quite right, so the arduino core was mangled to match. This can cause issues communicating at some speeds (56k, IIRC).

As best I can tell, you can either roll your own arduino with a crystal chosen to match your RS232 needs, or maybe use an external UART like this one http://www.strichlabs.com/pages/multiserial-shield that matches speeds better.

In any event, if you're shoving data around at 230kbaud, you're going to have to watch your coding to ensure you don't drop any.

-j

Hello,

timecritical things are all done by the controller (>>50000 steps per second are currently possible @18.432MHz) - the PC is only doing some preprocessing, basically the look ahead.
Every G-Code line translates roughly to 13 bytes of data + some communication overhead - so maximum capacity is about 750 lines per second for 115200 baud.
Sounds much but can be very critical in 3d and even 2d operation. If you e.g. follow a spline or arc that has been interpolated in 0.05mm steps you end up with 37.5mm per second in this example - already less than my machine usualy runs in wood. Of course this is also a question about wise or not so wise CAM settings - it is often not really necessary to interpolate things that precisely - but as I sell CAM software I know quite a lot people have the tendency to interpolate splines with 0.001mm precision and then wonder why their CAM is "soooooo slow" :wink:

Running 38400 baud would be a possible solution if I limit minimum path length to larger values - but would be step backwards from what the control is already capable to do.

Christian

It sounds as if you are looking for very fine interpolation between way points, and sending the result over a rather narrow link. Would it not be preferable to send the waypoints over the link and have the Arduino interpolate for you? Sorry if this is a daft suggestion - I have no experience at all of what you're trying to do - but the design just feels rather back heavy to me and I suspect it'd work better if you promote some of that work to the front end processor.

Christian_K:

  • 100000bps would still be acceptably fast and offers 0% error - but does the windows com port driver accept this unusual baudrate without throwing an expection?

The ability to track your baudrate request depends on the driver and the underlying hardware. If you choose a TTL/USB driver/chip that properly document how baudrate is calculated, you will be able to control and limit the difference between sender and receiveer baudrate towards zero. Below is a link to an application note from FTDI that explains how this is calculated for their drivers. Another option may be an AVR/USB chip (such as the one used by UNO) where you can refer to the datasheet for exact information.

I just gave it a try and it works very well. The windows drivers / VB.NET accept 100000 baud and data transfer to and from the Arduino Uno works perfectly.
By the way does anyone know the settings for Atmel Studio 6 to integrate Avrdude? I managed to upload .hex files manually but it would of course be much more convenient to program the device directly in Atmel Studio...

Thanks for the help and suggestions so far.