Kepad Development

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
User avatar
JLeith
Posts: 537
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 146 times
Been thanked: 26 times
Contact:

Kepad Development

Post by JLeith »

Hello All
I have advanced from pushbutton detection to Keypad design.
The Key pad will make my physical design more appealing.
I was able to make the Flowcode Keypad work with the ASCII values
I have a design question
1. The Flowcode Keypad looks like a "Phone Style" Not sure how it generates the ASCII values.
2. I have a Membrane Keypad - How do I integrate it into Flowcode. I don't see how I will get a ASCII output ?
Note: On the Flowcode Keypad there is really no "Connection" I see ( $PORTA )
On my Flowcode design hitting Key 1 will add a value to Home team and pressing 3 generates a value to Guest
Keys 4 & 6 Subtract 1 digit
Keys 7 & 9 Set value to Zero
My issue I can see is How will I be able to integrate the Membrane Keypad or do have to use the Phone version

Added the images of Membrane and my Flowcode Design

John
Attachments
Pitcher count Master with Keypad.fcfx
(119.56 KiB) Downloaded 274 times
3x4 Keypad.jpg
3x4 Keypad.jpg (7.25 KiB) Viewed 13380 times

User avatar
JLeith
Posts: 537
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 146 times
Been thanked: 26 times
Contact:

Re: Kepad Development

Post by JLeith »

Would this be a possible layout.

I found a image when searching more info

Not 100% sure of the Port A connections

John
Attachments
Keypad Layout.jpg
Keypad Layout.jpg (51.6 KiB) Viewed 13375 times

electron67
Posts: 311
Joined: Sat Jan 12, 2008 2:08 am
Has thanked: 104 times
Been thanked: 47 times
Contact:

Re: Kepad Development

Post by electron67 »

Hello

I think that R4, R5, R6 y R7 connected to Gnd and 100 k

Enrique

electron67
Posts: 311
Joined: Sat Jan 12, 2008 2:08 am
Has thanked: 104 times
Been thanked: 47 times
Contact:

Re: Kepad Development

Post by electron67 »

R1 R2 R3 connect to keypad to PIC direct

User avatar
JLeith
Posts: 537
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 146 times
Been thanked: 26 times
Contact:

Re: Kepad Development

Post by JLeith »

Hello Electron67

Do you know how Flowcode gets the ASCII values ?
To detect the connectins 1,2,3 to detect the 'GRD" the port would have to be set High looking for Low state via 4,5,6,7. I cant see that in the Flowcode frame work

Installed a picture
Attachments
Keypad with Ground.jpg
Keypad with Ground.jpg (54.38 KiB) Viewed 13369 times

Docara
Posts: 315
Joined: Sun Jun 23, 2013 1:29 pm
Has thanked: 28 times
Been thanked: 61 times
Contact:

Re: Kepad Development

Post by Docara »

Hi John,

Ideally you need resistors on all the lines (including A7 tied high or low. I would tie them all to VCC 5V in your case. Then each key press would go low.
You won't get ASCII directly you will have to 'force' it by using the switch input icon. The comparison values you have to use will be based on the values you receive when you press a key. Then assigning whatever ASCII value corresponds to the input byte read on PortA (in your case). Coincidentally, the ASCII values for 1to 9 are 1to9

Eg pressing the top left key (1) would give you A7=1, A6=1, A5=1, A4=1, A3=0, A2=1, A1=1, A0=0

So 11110110b = 246

Therefore 246 would = number 1 on the keyboard

Similarly 219 would = number 9

Etc etc

Regards
Matt

User avatar
JLeith
Posts: 537
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 146 times
Been thanked: 26 times
Contact:

Re: Kepad Development

Post by JLeith »

Hello Matt

I took your thoughts and retested the KeyPad

I found the formula

Picture

Now I just have to do the program of the ports to get the values

John
Attachments
Keypad with Ground Working.jpg
Keypad with Ground Working.jpg (63.28 KiB) Viewed 13359 times

User avatar
JLeith
Posts: 537
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 146 times
Been thanked: 26 times
Contact:

Re: Kepad Development

Post by JLeith »

Opps that didn't work can put the A4, A5, A6 to solid ground.

Testing last night to the early morning

Here is my salvation
Transmit the values on Port A and then read the value back and compare the read to the corresponding table
Example
A0 --- A6 Set to LOW state with a 10K resistor A7 set to High State.
Send 100010001b and if the button is pressed PortA read will match that Key 1 has been activated
Send 11000001b and if it reads it back then Key 3 was pressed.

I will place a delay in reading it back so if it is not a Key value then nothing will match and the tree will rerun.

This is the only thing I could could see would work. Off today to see if I can get it to work.

John

Docara
Posts: 315
Joined: Sun Jun 23, 2013 1:29 pm
Has thanked: 28 times
Been thanked: 61 times
Contact:

Re: Kepad Development

Post by Docara »

Jleith

What are you talking about ???
You don't send anything anywhere.

Just poll PortA as part of a loop.

If you want to be professional add diodes to create a wired OR function and connect it to an Interrupt pin which will only fire when a key is pressed leaving the processor time to do other things.

P.S. if you don't properly tie the pins to a voltage level you have the risk that they will float and give you erratic reading (at best).

Matt

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Kepad Development

Post by medelec35 »

Hi John,
You definitely should not tie and keypad connections together.
What I would do if I was you is go to matrix main website, then enter keypad in the search bar.
If you look at the results you will see

Code: Select all

EB014 Datasheet

Take a look at the circuit on page 6.

When you get hardware wired correctly, the Simulation and hardware should match.


Martin
Martin

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Kepad Development

Post by Benj »

Here's a schematic for the 3 x 4 keypad layout we use on our E-blocks. For a 4 x 4 layout simply add another column. D0-D7 are the Microcontroller Port pins on the E-block connector (not necessarily port D).
KeypadSchematic2.jpg
KeypadSchematic2.jpg (77.31 KiB) Viewed 13327 times
Also added to the Keypad page of the Wiki for reference.
https://www.matrixtsl.com/wikiv7/index. ... :_Keypads)

electron67
Posts: 311
Joined: Sat Jan 12, 2008 2:08 am
Has thanked: 104 times
Been thanked: 47 times
Contact:

Re: Kepad Development

Post by electron67 »

Hello JLeith

I always connect it as Benj shows and it works correctly

Enrique
Attachments
KEY.docx
Connection
(102.78 KiB) Downloaded 192 times

User avatar
JLeith
Posts: 537
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 146 times
Been thanked: 26 times
Contact:

Re: Kepad Development

Post by JLeith »

Hello Benj and Matt

Thank you for the picture I will print and save for many projects.

I see that the Vertical rows use Ports ( 0,1,2 ) and the Horizontal ( 4,5,6,7 )

What happens to the Port 3 ?

Off to build

John

Docara
Posts: 315
Joined: Sun Jun 23, 2013 1:29 pm
Has thanked: 28 times
Been thanked: 61 times
Contact:

Re: Kepad Development

Post by Docara »

John,

You originally used 0 to 6 (7 spare)
Matrix uses 0 to 2 and 4 to 7 giving 3 spare

If you are studying electronics you must learn how to think laterally and outside the box to solve problems

Would it worry you if I suggested using PortC 0 to 2 and PortB 2 to 5

Matt

User avatar
JLeith
Posts: 537
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 146 times
Been thanked: 26 times
Contact:

Re: Kepad Development

Post by JLeith »

Hello Matt or Benj

I modified the Drawing to correspond to the Membrane Keypad i'm using

I'm puszzeled on how to get a reading from the "Switch"

[img]
D0 to D4.jpg
D0 to D4.jpg (12.96 KiB) Viewed 13305 times
[/img]

I have tied to search for the Coding to capture the Switch action for a Keypad.
All the other devices Led & Switch are held low and 1 side is set to +5 and when the switch activtes the value is presented.

Not know when the buttons will be depressed and which one at any give point.

John

Docara
Posts: 315
Joined: Sun Jun 23, 2013 1:29 pm
Has thanked: 28 times
Been thanked: 61 times
Contact:

Re: Kepad Development

Post by Docara »

Hi John,

I getting confused over what you want from us!

Both me and Ben have given you information on ways to connect up your keypad, I have explained pretty comprehensively ONE way on how to do the maths and logic behind the scenes to achieve what you require (based on what you have posted). All you had to do was choose the appropriate icon from the left of the screen and sort out a holding variable.

FC provide components for switches (with debounce) available, there is an icon which will cater for 10 switches and lastly there is 4x3 keyboard Component Macro. Not being able to do something is one thing - we would always help if we can but you seem not to know anything about FC or willing to look around and investigated the icon and components available to you to use.

Switch Decision Box http://www.matrixtsl.com/wikiv7/index.p ... Properties
Keyboard Macro http://www.matrixtsl.com/wikiv7/index.p ... 016c092a14
Switch Array http://www.matrixtsl.com/wikiv7/index.p ... d2b4be28ff

The next stage for you is to choose how you want to read the keyboard and have a go at producing a your own chart and report back, we can help you again if need be especially if you post your chart here if it doesn't work.

EDIT:_
I have just reread the above, perhaps I have been unfair I have assumed you have used FC before, therefore I need to ask - have you used FC before - is this your first project? If you are completely stuck and have no idea let me know and me or one of us here will sort you out a basic routine.
On the hardware side I prefer to have switches going low when pressed via pull-up resistors external to the processor, this means the processor is detecting just the voltage drop when the switch is pressed not overcoming contact resistance.

Matt
Last edited by Docara on Tue Aug 15, 2017 11:30 am, edited 1 time in total.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Kepad Development

Post by Benj »

Hi John,
I'm puszzeled on how to get a reading from the "Switch"
The switches in the keypad are scanned a column at a time. We start with column 1 where we drive the pin high from the micro, columns 2 and 3 are driven low from the micro. We then check input pins A-D to see if we have a logic high. If we do then it means that the corresponding switch on the column is pressed. If none of the row pins are high then we drive column 1 low and column 2 high and repeat the input checking. This process repeats for all columns or until we have a valid switch press.

User avatar
JLeith
Posts: 537
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 146 times
Been thanked: 26 times
Contact:

Re: Kepad Development

Post by JLeith »

Hello Matt
we would always help if we can but you seem not to know anything about FC or willing to look around and investigated the icon and components available to you to use.
I have been using FC back in Version 4 and done 6 projects using RS232 and NFR905 circuts

Yes I have have been very pleased to get all the help I can and members have gone the extra steps and beyond to lend me a hand to folllow the steps in making the project work.

On the 3x4 Keypad it is a mystery in FC how say A0 comes out with ASCII 51.

I did research the world of google and read all the 390 listings for Keypad adding to circuits. There was several back in FC version 4. There was 1 project with a Solenoid ( Keypad Door Entry )

I was happy for me that I was able to take the design and modify it to work I had to do redesign the process to use the 12 keys.

The hard part is the FC is straight forward and the Keypad works 100% and all the other goodies work 100%. Great work

The glitch on my behalf is building a circuit board that works on the outside. I have designed 18 PCB and to this day I have to cut and modify to work because the hard world doesn't always match the magic of FC

Matt I'm very soory that I have wasted your time in helping me follow the FC Keypad connects outside of flowcode. I have a working FC design I just rapping my head around how I design the drive the D0 - D2 and check the D4 - D7 when I don't appear to do that in FC.

In FC I used the (Call Component Macro ) ( Keypress = Keypad_eb014::GetAscII ) and magic the AscII appears.

With the help for Benj I gather that FC behind does the setting and scanning to get the button pressed. In the outside the Keypad is a flat membrane action.

I will build the breadboard design and load the PIC and see if my program will run.

Agian I sorry for the lack of knowledge in the FC design. I did spend 35yrs looking after the faults computer boards can produce in the Telephone industry. Retired now and love building circuts to keep my mind working.

I will do more research in Google and FC. Going forward. I guess my fault is I look at the Video for flowcode and they are back in FC4 & 5 and yes they do show the actions and how to use the FC products but not how the building of the circuit after FC. Like in a simple on off switch. FC adds the Switch and the user sets HI or Low when activated. And in FC you read the swich and magic the LED lights.
In the build you add +5 to one side of a swith and connect the Led in the corrrect path to GRD and it lights.
I was spending hours and hours to see how adding a Keypad in the build and getting the wiring correct to read what I see as a single switch in a matrix.
I can follow the FC on reading a single switch ON/OFF know I just have wrap my mind on how to tell FC to send a High and Read the results. Maybe the (Call Component Macro ) ( Keypress = Keypad_eb014::GetAscII ) will do that magic in the build.

John

electron67
Posts: 311
Joined: Sat Jan 12, 2008 2:08 am
Has thanked: 104 times
Been thanked: 47 times
Contact:

Re: Kepad Development

Post by electron67 »

Hello

I hope you have served my 2 answers, I made them during work hours and maybe the drawing of the diagram with pencil were not very pretty ! :(

THANK YOU
Enrique

Docara
Posts: 315
Joined: Sun Jun 23, 2013 1:29 pm
Has thanked: 28 times
Been thanked: 61 times
Contact:

Re: Kepad Development

Post by Docara »

Hi John,

Right thanks for the info and you haven't wasn't my time - but I was beginning to feel you might be :D :wink:


I think this is a case of trying to stop you over thinking - you're winding yourself up in knots lets rewind a bit!!!

First off stop thinking about ASCII this or ASCII that. Lets get down to basics Do you know how to 'properly' read a logic level on a digital PIN
Here is a quick link of some basics on pull up resistors which you will find useful. http://www.electronics-tutorials.ws/log ... istor.html

In practice (unless things don't work :? ) you will find that resistor values between 10KOhms and 100KOhms will be used

I find that it is easier to 'think' with Pull-ups especially as things like Interrupts and Resets are active low, which means (basically) you can forget about the specific levels until you need to drop them to activate something as it is a clear transition. These pins are marked with a line across the top and they are referred to as 'active low', but please bear in mind that this is just my preference and you will notice that the schematic supplied rom Ben that there are Pull-Down resistors which keep the lows pulled low -I have always had a problem visualising and using this arrangement.

Lets consider one push to make switch which is to be read from on a microprocessor (uP) pin. If we connected this switch directly across the positive (+ve) and negative (-ve) lines when the switch was pressed it would short out - pop a fuse whatever because there is no limiting factor to the huge rush of current that will flow. So to stop this we need to connect a resistance (resistor) in place. No doubt you have seen the usual positive>resistor>switch>negative(gnd) with the centre point between the resistor and switch connected to the uP Pin. If you look at a circuit diagram for this you will notice that the -ve is not connected to anything so the uP would 'see' only the +ve line, or more correctly logic 1. Because you are, effectively, supplying power to the uP Pin YOU don't need to 'SEND' anything out (using your terms) you just sit back and 'look' at this pin when you want to. (Yes you can 'send' a logic 1 from one pin to an other and read the response but it can get messy and complicate which is what I think you are trying to do).

In Ben's schematic he is looking for pins to go high on D4-D7 (because R4-R7 are making sure these lines are at 0V (logic 0) in there normal state. What Matrix are doing is sequentially sending D0-D2 high Logic 1 - you have to keep everything in sync to work properly but noticed there is a voltage divider formed between a R10K and a R100K resistors when a key is pressed so the resistor values must be carefully chosen to give correct voltage levels at the uP pins.

Like I said in a previous post, for now whilst you're learning, just wire them up a seven individual switches and read the whole 7 lines as one Byte with the 8th tied high or low BUT TIED SOMEWHERE.

Lets us know how you get on

Matt

User avatar
JLeith
Posts: 537
Joined: Wed Nov 14, 2012 7:49 pm
Location: British Columbia Canada
Has thanked: 146 times
Been thanked: 26 times
Contact:

Re: Kepad Development

Post by JLeith »

Helllo Matt

Thank you for the info I have printed off the conversations and added to my knowledge binder for futrue.

Yes I did wire up the Key pad per the layout and to my shock it was the ( Keypress = Keypad_eb014::GetAscII ) that does the work to get the results.

The world of breadboarding is 100% in the green and looks amazing.

Thank you all for putting up with my lack of understanding how to get the Value of the Keypad.

All the best

I have attached my program.

John

Just need to double check my Delays to cleanup
Off to design a PCB.
Attachments
Pitcher count Master with Keypad Aug 14.fcfx
FC Build
(167.22 KiB) Downloaded 202 times

Docara
Posts: 315
Joined: Sun Jun 23, 2013 1:29 pm
Has thanked: 28 times
Been thanked: 61 times
Contact:

Re: Kepad Development

Post by Docara »

Hi John

Which layout did you use in the end?

Yeah breadboard is great but don't forget it, like veroboard, can suffer from timing issues and cross talk due to capacitance so don't try and put a high frequency across it or you might chase your tail trying to find problems.

I strongly suggest you look into connecting some diodes up in a wired OR configuration, the output of which can drive an interrupt freeing the processor up by not polling the keyboard all the time.

Brilliant news on the project good work bud at ti e of writing it's midnight here (London time) I'll have a look at your chart tomorrow

Matt

Post Reply