Home

UNIVERSAL KEYPAD MODEL

This short tutorial covers the creation of Keypad devices.

In many cases it may be simpler to decompose an existing keypad and modify it to your needs but for completeness we have detailed the process in its entirety. The following links will direct you to the appropriate area of the help documentation.

  • Drawing the Graphics

  • Placing the Pins

  • Keypad Specific Properties

  • Making the Device

  • Troubleshooting

This file last modified 13th May 2010.


Drawing Graphics

DRAWING THE GRAPHICS

Start by selecting the 2D graphics icon and (in most cases) the rectangle icon and place a 2D Graphics object in of the approximate size of the keypad on the schematic. If you want to change the appearance of the object right click and then left click on the border of the object and configure the resulting dialogue form to your preference.

Now place another smaller square inside the original graphic to represent a button. It is easiest at this point to take a little time to ensure that the dimensions of the button are reasonable and to position it accordingly. The best way to do this is to set a false origin by keying ‘O’ with the mouse properly positioned. The position of the false origin should be at the top left of the original graphic ( as this is the origin used by the keypad model ). You will know when you have set the origin as the co-ordinate display at the bottom right of the Editing Window will change colour to Magenta and (0,0) will be the point over which the mouse was at the time of setting the origin.

Having sized and positioned the original button simply copy all other buttons of the same dimension. You can also place circles and rectangles to represent buttons on the keypad.

Finally place any appropriate text inside the buttons using the text icon in 2D graphics mode. You should now visually have your completed keypad.


KEYPAD PROPERTIES

Before we make the device we need to note the positions of all the buttons relative to our false origin. In particular we want the co-ordinates of the center of each button and the size of the button. These will be used in properties which we will introduce when making the device. The format of these properties for the different button types is given below.

  • Square Buttons : SQUARE, x-co-ordinate, y-co-ordinate, length/width.

  • Oblong Buttons: OBLONG, x-co-ordinate, y-co-ordinate, length, width.

  • Circular Buttons: ROUND, x-co-ordinate, y-co-ordinate, diameter.

Note that an additional parameter can be added to the end of any of the above property definitions which will specify a keyboard key associated with that button on the keypad. For example, adding the digit 1 as an extra parameter would mean that keying the digit 1 on the keyboard would activate that button on the keypad.


MAKING THE DEVICE

Having drawn the part and noted all the relevant information we can now proceed to make the device.

Right click and drag a box around the entire keypad to highlight everything and then select the Make Device option from the System Menu. This will generate a three tab dialogue form. We will deal with each tab separately below:

General

Enter the name and reference prefix for your keypad and also highlight the library into which you want to store the device. Note that the name must start with the namestem you specify in the Active Model Section of this dialogue form.

Properties

This is the area where we want to specify all the necessary properties of the keypad.

We will start with the PRIMITIVE property which tells the simulator what type of device the keypad is. Click on the New button and select Primitive from the resulting drop down list. The only field we need edit here is the default value. Change this to DIGITAL.

Next we need to specify what model will run the keypad. Click on the New button again and select the MODDLL option. Again the only field we need edit is that for the default value. Change this to be KEYPAD.

Finally we need to enter all the information about the buttons. Click on the New button again but this time select the Blank Item option. Enter A1 in the Name field and A1 in the Description field. This tells the Keypad model that all information in this property definition pertains to the button in Row A and Column 1. The only other field we need to change is that for the default value. Here we enter the information on the type, position and size of the button as previously explained. An example entry would be :

SQUARE, 0300,-300,300

This would represent a square button with center at 300,-300 ( from the top left of the keypad ) and of length/width 300.

Repeat the above process for every button on the keypad.

Active Model

Here we need to enter the namestem for this model. We have used KEYPAD as the namestem. Note that whatever you enter here must also be the stem of the name you enter in the General tab of the dialogue form.

Finally, set the number of states to be 0 and make sure the Link to DLL box is checked. Click OK and exit the dialogue form. You should now find the Keypad device in the appropriate library.


Placing Pins

PLACING THE PINS

You need one pin for each row and one pin for each column. The keypad model imposes the following naming convention for the pins:

  • Pins representing rows must be named alphabetically. i.e. A,B,C…..

  • Pins representing columns must be named numerically. i.e. 1,2,3….

This allows us to say, for example, that button B3 is in the second row and is the third button from the left.


TROUBLESHOOTING

Following are some of the more likely reasons why a keypad model you created does not work correctly.

Pins are not named correctly

It is important that you follow the convention explained above for the pin names. Also check that you have entered this information in the name field and not the number field.

False origin was incorrectly positioned

You must set the false origin at the top left corner of the keypad as this is the point from which the keypad model will calculate positions on the keypad.

Co-ordinates are incorrect

Co-ordinates for buttons must be at the center of the button. If not the chances are nothing will happen when you press the button.