Arduino
The design for a rotary table needed floating point so that the required number of steps for the gear teeth might be calculated. Doing this in assembler was not something I wanted to undertake - so an Arduino UNO board was bought from ebay, a little prototype board shield was built and the keypad (5x4 matrix) hooked up (See photo below).
The following keypad sketches read the following:
PS: Seasoned software pro's would find better ways of writing this software - so be it! I wrote it for my own use, it works and does what I want it to. If you find it useful too, that's great.
The following keypad sketches read the following:
- 3 digits for gear teeth number, at the moment up to a maximum of 499 teeth per gear
- 5 digits for the number of steps one might require to rotate the table, up to 71999 steps.
- up to 6 digits with a decimal point to input the number of degrees required with a 0.005 degree resolution = 18 seconds per step.
PS: Seasoned software pro's would find better ways of writing this software - so be it! I wrote it for my own use, it works and does what I want it to. If you find it useful too, that's great.
Arduino 3 digit number keypad entry
Create a folder with the same name as the file and copy this file into that folder - or have Arduino s/w do it or you
The sketch will give you a 3 digit number from a 5x4 keypad - as it is written here. A 4 x 4 keypad means removing one of the rows - and the corresponding row in the software as well as removing options in the code for that row. The software serial emulation is used in this sketch - this comes as standard in Arduino V1.0. Just place - #include <SoftwareSerial.h> at the beginning of the sketch
This sketch is used to control a rotary table via a stepper motor to provide dividing functions for a milling machine - primarily to enable me to make gears.
The 3 digits entry keypad part of the software enables a tooth value for a gear to be entered. The maximum allowed is 499 teeth, hence the 3 digits.
The sketch will give you a 3 digit number from a 5x4 keypad - as it is written here. A 4 x 4 keypad means removing one of the rows - and the corresponding row in the software as well as removing options in the code for that row. The software serial emulation is used in this sketch - this comes as standard in Arduino V1.0. Just place - #include <SoftwareSerial.h> at the beginning of the sketch
This sketch is used to control a rotary table via a stepper motor to provide dividing functions for a milling machine - primarily to enable me to make gears.
The 3 digits entry keypad part of the software enables a tooth value for a gear to be entered. The maximum allowed is 499 teeth, hence the 3 digits.
keypad_number_sketch_3_digits_jan30a.ino | |
File Size: | 13 kb |
File Type: | ino |
Arduino Keypad, shield and serial display
This is the keypad, Arduino, development shield and serial LCD display.
The display is reading "Menu D" and a blinking cursor - the solid block next to the D. (looks like a smudge on the screen)
The display is reading "Menu D" and a blinking cursor - the solid block next to the D. (looks like a smudge on the screen)
Arduino 5 digit number keypad entry
The sketch provides a 5 digit number from a 5x4 keypad
The 5 digits entry keypad part of the sketch enables a step value to be entered to rotate the table by that number of steps. The maximum allowed is 71999 teeth for my table, hence the 5 digits.
This 5 digit keypad sketch demonstrates how to extend the sketch to obtain keypad entry for different number of digits by comparing this sketch with the 3 digit version.
Further details as for the 3 digits sketch
The 5 digits entry keypad part of the sketch enables a step value to be entered to rotate the table by that number of steps. The maximum allowed is 71999 teeth for my table, hence the 5 digits.
This 5 digit keypad sketch demonstrates how to extend the sketch to obtain keypad entry for different number of digits by comparing this sketch with the 3 digit version.
Further details as for the 3 digits sketch
keypad_number_sketch_5_digits_feb02a.ino | |
File Size: | 14 kb |
File Type: | ino |
Arduino Floating point number entry
The rotary table needs a floating point entry system for degree values - the maximum number allowed is 359.995 degrees, 1 step short of a complete revolution. However it is quicker to select counter/anti clockwise and enter a value up to 179.995 degrees.
This sketch is more involved than the other two as we have to capture the digits and decimal point if it is entered. Then determine where to place that decimal point. On the keyboard we may enter, XXX.xxx or .xxx or 0.xxx or anything in between e.g. 0.x, .x, 0.xx, .xx, xx.x, xxx.xx etc. It is interesting to determine where the floating point will end up with some of these entries.
The sketch incorporating the 3 digit, 5 digit and floating point number entry for the rotary table has been written and works well - the extracted code relevant to the floating point entry from the sketch is included below as a download.
The sketch produces a floating point number in the range 000.000 to 999.999, and provides that floating point number. The sketch can be extended for larger numbers and smaller mantissas. But the current design rotary table only needs numbers up to 359.995.
The sketch does not allow for exponent entry.
It may not be the neatest way of generating a floating point number from a keypad but it does work.
This sketch is more involved than the other two as we have to capture the digits and decimal point if it is entered. Then determine where to place that decimal point. On the keyboard we may enter, XXX.xxx or .xxx or 0.xxx or anything in between e.g. 0.x, .x, 0.xx, .xx, xx.x, xxx.xx etc. It is interesting to determine where the floating point will end up with some of these entries.
The sketch incorporating the 3 digit, 5 digit and floating point number entry for the rotary table has been written and works well - the extracted code relevant to the floating point entry from the sketch is included below as a download.
The sketch produces a floating point number in the range 000.000 to 999.999, and provides that floating point number. The sketch can be extended for larger numbers and smaller mantissas. But the current design rotary table only needs numbers up to 359.995.
The sketch does not allow for exponent entry.
It may not be the neatest way of generating a floating point number from a keypad but it does work.
floating_point_keypad_entry_feb03.ino | |
File Size: | 17 kb |
File Type: | ino |