Generate a Numeric Value

CRP

Member
Join Date
Feb 2013
Location
St. Neots
Posts
6
Hi

Can anybody tell me how to generate a numeric value from digital inputs?
I have 10 inputs each equating to a number so for example input 0 when high (1) is 0 and when input 4 is high (1) will be 4.
Then inputs cannot be set to make the numeric value but will be input as a sequence as the inputs are connected to a key pad, so when input 1 is high my numeric value will be 1 then if input 4 becomes high the value needs to be 14 and so on.
 
I think the method that you need to use will depend totally on your device. Is this a PLC (my guess because this is a PLC site)? If it is a PLC, then what brand and model?

Also, there are special digital input modules that can be added to most PLCs that will convert On/Off inputs into numbers. TTL modules and thumbwheel inputs are examples. Does your keypad have a BCD (Binary Coded Decimal) number output?

Even if your keypad outputs only produce a 1 or 0 for each press, then you can write internal PLC logic that will look at a string of key presses (you will need an END key such as "Enter" to signal the end of the string) and convert to the desired number.

Before writing such logic, you will have to give us some more details of your actual situation and your equipment used.

This old thread on decoding PLC outputs to drive a 7-segment LED display might help some:

http://www.plctalk.net/qanda/showthread.php?t=78695&highlight=decoding&page=2
 
Last edited:
i am using either a micrologix or compact logix plc depending on the amount of code i need to write.

The key pad is a home made unit due to the layout and buttons required so the numbers will be digital (1 or 0).

The number generated also requires to handle two decimal places as well as positive and negative numbers.

once the number is entered it will be confirmed by a digital input.

Thanks,
 
I think a MicroLogix model 1100, 1200, 1400, or 1500 will be plenty to do this program. You should try to get a model that has the Floating Point numbers (File type F8), such as a ML1100 or ML1400. Otherwise your decimal fractions will have to be stored in separate integer numbers. Probably a few of the ASCII String Control commands in RSLogix 500 will be needed.

A few more questions should allow a starting program to be written.

1. What is the maximum length of the number (how many places do you wish to use, something in the order of 12 to 14 places maybe, including the decimal point and 2 decimal places.

2. Do you have a key for the decimal point "." and the minus sign "-"? If so, which Input Numbers do you want to use for those?

3. Are there any other special keys on your keypad that have Inputs to the PLC? (You really need an Enter key for sure). Which Input number do you want to use for this? Also useful would be a Backspace or "<---" key to delete a wrong number entered. If not, how to you plan to handle keystroke errors?

4. Are your keypad keys standard keyboard-type which spring-return after released (in other words, do the inputs go away when the key is released)? If so, each key press will need to be saved to a temporary memory location.

5. Will you have a display that shows the digits as they are entered (much more complicated), or is the final number displayed? If not, how will the final number be used?
 
Last edited:
This could be a really challenging and rewarding programming and wiring experience until you get done with the hours of manual labor, head scratching, and cursing and realize you could have bought an off-the-shelf monochrome HMI for next to nothing, networked it to your PLC, set up a numeric input object, and been done in a couple of hours.
If you are doing this project for your own benefit, or for a class, then great, otherwise you are going to waste time and money reinventing the wheel. The final product may also be a nightmare for some poor technician when it goes haywire 6 months from now at 3am.

Just my $.02
 
I think you'd get more useful advice if you could state the desired final result. Are you building a calculator? A home temperature control of some sort? Or, is this just an exercise in decoding a keypad?
 
the application is for a servo driven rotary device for a machine shop with a harsh environment and the customer does not want a hmi because the operators ware gloves which can have swarf and oil on them.
The keys are spring return and there is - return and decimal point key all of which come back as digital inputs.
The number has to up to 10,000.00.
If a number is input incorrectly then the operator has to enter the number and then edit it and yes there is an edit key which again is an input.
The numeric key pad will be used to set the following, velocity, acel, decel, position, direction and move number.
The PLC will hold 99 moves so again the key pad will set which move is used.
 
This could be a really challenging and rewarding programming and wiring experience until you get done with the hours of manual labor, head scratching, and cursing and realize you could have bought an off-the-shelf monochrome HMI for next to nothing, networked it to your PLC, set up a numeric input object, and been done in a couple of hours.
If you are doing this project for your own benefit, or for a class, then great, otherwise you are going to waste time and money reinventing the wheel. The final product may also be a nightmare for some poor technician when it goes haywire 6 months from now at 3am.

Just my $.02

100% agree here.

Have a look at the Panelview Component C200 with the full 10 numerical keys.
 
the application is for a servo driven rotary device for a machine shop with a harsh environment and the customer does not want a hmi because the operators ware gloves which can have swarf and oil on them.
The keys are spring return and there is - return and decimal point key all of which come back as digital inputs.
The number has to up to 10,000.00.
If a number is input incorrectly then the operator has to enter the number and then edit it and yes there is an edit key which again is an input.
The numeric key pad will be used to set the following, velocity, acel, decel, position, direction and move number.
The PLC will hold 99 moves so again the key pad will set which move is used.

If you are committed to going down the homemade keypad route, then using an array (or string .DATA) to hold key presses like shooter suggested would be the way to go.

You could use an INT (or DINT if using CompactLogix) array to hold the ASCII character values that correlate with each digital input. Use a pointer that starts out at zero and increments after each button press and copy of the associated ASCII value into the .DATA[pointer] portion of the string that is holding the operator input. So if input_0 is pressed then MOV Key_Value_Array[0] My_String.DATA[pointer]

Then after each press set .LEN = (pointer + 1). The "back" key could be used to CLR .DATA[pointer] and then decrement the pointer.

The "enter" key could then be used to do an STOR (String TO Real) conversion. At this point you would need to do some limit checking, I imagine, on the value before loading into the move parameter.

The more I think about this, the more it sounds like you need the CompactLogix. You are basically having the operator program in moves like a recipe system. A panelview with a control list selector and pop-up screen with parameters sure would make quick work of this...

How will the operator know what move parameter he's entering? Or whether he's input a good value or not? Are you going to have pilot lights as indicators for all of that? What if the operator enters velocity, accel, position, direction, and move number, but forgets decel, for example? That's going to get tricky to explain in binary to a machine shop operator!
 
How about a prominent sign: "REMOVE GLOVES BEFORE OPERATING THE PANEL".
And a dummy camera.
And another sign "Notice: You are being recorded on video."

edit:
And use a touch-screen with a good screen-protector.
 
The more I think about this, the more it sounds like you need the CompactLogix.
He could use a MicroLogix with 2 FIFO instructions, one to accumulate the key pressed for the main number, the second for the fractional part, something like the attached picture. The final number is not generated until the "Enter" key is pressed. A Backspace removes the previous key press by subtracting 1 from the FIFO stack positon.

The number could be created in a MicroLogix without using FIFOs by using AIC (Integer to String) and ACN (combine 2 strings) for each key press. Undoing an incorrect key would be more difficult than with the FIFOs.

Numeric Keypad Inputs Converted to Number- CRP.jpg
 
Last edited:

Similar Topics

Hello Friends, I am looking for a way to take my PID Output( it is the result of my PI Algorithm in Real format) and generate a PWM Signal in...
Replies
16
Views
2,510
Does anyone know a way to dynamically generate a 2D barcode on a PanelView screen? An Activex Control maybe? If such a method is out there, it...
Replies
14
Views
2,988
Hi, I am trying to generate source file of OB1 including all dependent blocks. But i am getting a message which says-->>one or more blocks...
Replies
3
Views
1,256
Hello Everyone, I would like to know where to start when designing a HMI+PLC Allen Bradley based, that complies with CFR 21 PART 11, ALCOA...
Replies
4
Views
2,910
Hello, in iFix I want to do a boolean calculation with two values, and generate an alarm if the result is true. The calculation in my BL block...
Replies
3
Views
2,176
Back
Top Bottom