Saturday, 11 August 2012

Marlin - Re-upgrade @ 250000 Baud...

Having previously upgraded Huxley #710 to Marlin, I wanted to tweak the software and perhaps add some features of my own to the software. Marlin prefers a communication rate of 250000 baud and of course to do any software modifications it would be neat to monitor the device at 250000 baud in the Arduino IDE (Integrated development Environment). Unfortunately it appears there is a disconnect between Ponterface (Python and its serial support package) baud rates and Windows operating system standard baud rates.

In performing the upgrade previously, I had issues with the upgrade process based on incorrect use of the Arduino IDE release 1.0. Having picked up a tip from the e-Maker shop forum, I switched to the Arduino 23 IDE. With version 23 of the Arduino IDE I managed to install Marlin.

So today I thought I would document the process, which includes documenting the special tweak required to allow Windows XP operation at 250000 baud which is the preferred baud rate for Marlin.

Sanity warning - Playing with the windows registry should be done with a little care and backups taken.

Configuring Windows XP For RepRap Marlin At 250000 Baud
This covers the following hardware configuration: -
  Windows XP (SP3)
  Marlin ( ErikZalm / Marlin )
  Huxley ( eMaker )
  Sanguinololu board 1.3a ( RepRap Wiki )
  FTDI application note ( AN232B )
  Arduino (version 23)
  Pronterface ( eMaker Sources )

Assumptions 
You have, or want to use, Marlin with a communications rate of 250000 baud but don't have 250000 baud as a selectable data rate in your serial communication parameters. Arduino IDE version 23 is installed. The operating system is Windows XP with Service pack 3.

Arduino Environment
Starting with the Arduino environment looking for a communication rate of 250000 baud shows a screen similar to that shown below.

Arduino IDE showing maximum baud rate of 115000 baud
Notice how in the Arduino IDE, COM3 which is connected to Huxley #710's FTDI USB to RS232 serial chip; that the maximum board rate available is 115000 kilo baud.

At first site, having previously set the data rate in a Marlin upgrade you would not be able to communicate with Marlin at 250000 baud.

Clearly the screen shot shows that Marlin has rebooted and data transmission has occurred. But the data rate is shown as 300 baud.

- Welcome to the world of data rate aliasing.

What we need to do is configure the Windows XP operating system to handle 250000 baud in some way that the Arduino IDE (and other software such as your own) can use. The Python serial software library is obviously not using the Windows registry for its serial parameters or we would not have this data rate disconnect between Pronterface and Arduino IDE.

The FTDI application note AN232B describes in some detail how this is done. Essentially you can use one of the existing Windows registry entries at a rate other than the standard rate by adjusting entries in the windows registry using REGEDIT.EXE.

If one follows the calculations for a baud rate of 250000 a setting of 0C 00 needs to replace one of the default settings in the registry. I chose the 300 baud entry as described in an example in the application note.

Example registry entry to be modified

 From the application note the calculation is
3000000 / 250000 = 12
as the values will be displayed in hexadecimal format this means that we use 0C. There is no 'sub integer divisor so we use 0C 00 00 00. This value replaces the value for 300 baud which is 10 27 00 00.

The image on the right shows the relevant key for my FTDI USB entry in the Windows XP registry which is set as COM3.
  
Typical entry: -
11,00,3F,3F,10,27,00,00,88,13,00,00,C4,09,00,00,E2,04,00,00,71,02,00,00,38,41,00,00,9C,80,00,00,4E,C0,00,00,34,00,00,00,1A,00,00,00,0D,00,00,00,06,40,00,00,03,80,00,00,00,00,00,00,D0,80,00,00

Modifed to: -
11,00,3F,3F,0C,00,00,00,88,13,00,00,C4,09,00,00,E2,04,00,00,71,02,00,00,38,41,00,00,9C,80,00,00,4E,C0,00,00,34,00,00,00,1A,00,00,00,0D,00,00,00,06,40,00,00,03,80,00,00,00,00,00,00,D0,80,00,00

Example of modified registry entry to allow aliased 250000 baud rate
 Then: -
  Reboot the computer
  Restart the Arduino software
  Select the Arduino serial monitor function
  Select 300 baud on the COM port that the FTDI chip is using (COM3 in the example)
  Reset the Sanguinololu board
  Approximately 6 seconds later the boot message should be shown (see first image in this post)

The 300 baud entry now should be running at an aliased rate of 250000 baud.
 
To upload new firmware to the Sanguinololu board: -
  Compile it in the Arduino software
  Press and hold the reset button on the Sanguinololu board
  Select the upload function in the Arduino software
  Arduino IDE display 'Uploading to I/O Board'
  When the software displays 'Binary sketch size: XXXXX bytes (of a 63488 byte maximum)'
  Release the Sanguinololu reset button
  The software will transfer the compiled code to the Sanguinololu board
  Arduino software should display 'Done Uploading'



1 comment:

  1. Thanks man, just what I was looking for!
    I hope this works on Windows 7 too, as I'm not seeing the 250000 baud option in my Arduino IDE.

    ReplyDelete