Page 1 of 1

3C : Keypad I2C

Posted: Fri May 20, 2011 4:15 pm
by Dan81
Hello

I'm still using "Customize Component Code" !

I like I2C protocol (sorry for other comms users), there are only 2 wires for this bus (and pull up) .

You can choose any keypad (allowed by Matrix, from 1x1 to 4x4, see Extended Properties).

The expander can be a MCP23008 or a PCF8574.

The only rule is to respect the schematic below :
Columns : from P4 to (P7 or less) ,
Rows : from P0 to (P3 or less).

Pull UP for rows are not needed , MCP and PCF have internal ones, Matrix Eblocks (EB-014) has pull DOWN resistor.

The simulation with Proteus is OK, as soon as the real test is done I'll post the code. I'm waiting for the keypad.
KeyPad.jpg
KeyPad.jpg (38.05 KiB) Viewed 29024 times
Daniel

Re: 3C : Keypad I2C

Posted: Fri May 20, 2011 11:06 pm
by Spanish_dude
I just want to add that you need to enable the pull up resistors first by sending 0xFF to the GPPU control register.

Cheers ;-)

Re: 3C : Keypad I2C

Posted: Sat May 21, 2011 5:52 am
by Dan81
Hello

I have created a new component macro "Init" where all the configuration of the expanser is done.
This macro must be put AFTER the "Init" of the I2C component. (the same thing like LCD I2C)

Daniel

Re: 3C : Keypad I2C

Posted: Sun May 29, 2011 4:30 pm
by Dan81
How to use I2C Keypad.

INTRODUCTION

The pinout of MCP 23008 is more interesting than PCF8574 one

The "MCP version" is hard tested on a EB016 (prototype board). "PCF version" is only simulated on Proteus 7.8.

Note : I2C Keypad address (0x21) (different from I2C LCD :0x20).


TECHNICAL

For hardware the only rule is to respect the schematic given above.
The Pull Up resistors are not needed, they are "native" on the PCF, on MCP they are enabled during initialisation.

For the Software,
Choose your keypad as usual (1x1 to 4x4), the macros are identical (and simulable).

You must also add :
- a I2C component and its init macro.
- The Keypad init (a new macro called KP_init) AFTER the I2C init macro.

Note : I2C is only "Hardware" (by default in the properties).

Note2 : It is not necessary to provide a port for the keypad connection.


Remark :
- I have done the same thing for the Switch bank and Led array.

Re: 3C : Keypad I2C

Posted: Sun May 29, 2011 4:33 pm
by Dan81
The files for PCF8574 (not PCF8574A)

Re: 3C : Keypad I2C

Posted: Wed May 16, 2012 10:06 am
by Mouine
Hello and congratulations for the work done,

I tried the i2c for the LCD and it works perfectly but is it also possible to have the macro file to the Switch bank and Led array.

Thank you very much in advance.

Re: 3C : Keypad I2C

Posted: Thu May 17, 2012 10:03 am
by Dan81
Hello Mouine

I think it is not useful to create spécial I2C macros for switches and leds.

You just have to read or write one register.

I find MCP easier to drive than PCF.

Daniel

Re: 3C : Keypad I2C

Posted: Thu May 17, 2012 6:18 pm
by Mouine
Thank you for your reply,

I tested this several times but nothing doing. I'm not arrived to switch on the LED in output.

Image


I put the register 00 in output and then I send the information to switch the LED. Is this the right way to go or I all wrong?

Thank so much.

Re: 3C : Keypad I2C

Posted: Fri May 18, 2012 2:29 pm
by Dan81
Hello Mouine

"Send_Byte_Transaction" macro is for EEPROM (with 16 bits address).
You must use "Transmit_Byte" macro.

Daniel

Re: 3C : Keypad I2C

Posted: Mon May 21, 2012 9:14 am
by Mouine
Hello,

After a hard battle, I finally managed to run the MCP23008 input and output.

As you say it, MCP is simple to managed it.

Thank you for your help.

Re: 3C : Keypad I2C

Posted: Sun Dec 27, 2015 7:57 pm
by Jay Dee
Hi, I'm really struggling to get a grip with component creation etc, Dan's i2C keypad component would be great but I just cant find a way to import it or any other file on the file system ending in .fcc so I don't know where to copy it too.
Something so simple is driving me nuts ( and this was going to be a time of year to relax!! )
Any pointers much appreciated. Thanks, J.

Re: 3C : Keypad I2C

Posted: Mon Dec 28, 2015 2:37 am
by medelec35
Hi John,
Jay Dee wrote:Dan's i2C keypad component would be great but I just cant find a way to import it or any other file on the file system ending in .fcc
You can only import custom code (.fcc) with Flowcode V5 or below.
What you do is go to Misc Menu then select Custom.
A custom code icon will be added to the panel.
Right click on the custom code icon then select Custom Code.
Then you should see various options including Import.
That is how you import .fcc files

Martin

Re: 3C : Keypad I2C

Posted: Mon Dec 28, 2015 1:02 pm
by Jay Dee
Thanks for reply Martin.. for the life of me I cant find a Misc menu other that the one via component search and that does not have a custom code icon.
I found a Supplementary code tick box in project options and a C code component... but dont think its either of these.
I could not find a reference to custom code in the help.
I just upgraded to latest release.. but still no joy.

Re: 3C : Keypad I2C

Posted: Mon Dec 28, 2015 1:09 pm
by kersing
Are you using Flowcode version 5 to import the code?

Re: 3C : Keypad I2C

Posted: Mon Dec 28, 2015 1:10 pm
by medelec35
Perhaps I should have said components menu?
Misc.png
(78.84 KiB) Downloaded 18361 times

Re: 3C : Keypad I2C

Posted: Sat Jan 23, 2016 7:06 pm
by Jay Dee
Hi, I'm back looking at i2c keypad..
Hmm..I still cant find the Custom icon, I'm running the pro version of 6.1.2 with PIC and PIC16 enabled, its not in the menu martin showed.. indeed that menu icon is called tools and there is no default Misc menu.
There is no custom component listed in the component Search or under any of the tabs...seems to have been removed from this version.. ?? :?
I can place a custom C code component but it does not have any import option.
:?

Re: 3C : Keypad I2C

Posted: Sat Jan 23, 2016 7:13 pm
by medelec35
Hi John,
Jay Dee wrote:There is no custom component listed in the component Search or under any of the tabs...seems to have been removed from this version.. ??
Custom component was removed with version V6
Reason for that is to allow user custom components to be created.
Screen shot shown with Custom & Custom2 is from Flowcode V5

This is mentioned on my post on Mon Dec 28, 2015 1:37 am:
medelec35 wrote: You can only import custom code (.fcc) with Flowcode V5 or below.
Also by kersing on on Dec 28, 2015 12:09 pm
kersing wrote:Are you using Flowcode version 5 to import the code?
Martin

Re: 3C : Keypad I2C

Posted: Sat Jan 23, 2016 7:52 pm
by Jay Dee
Oh.. thanks for the clarification. I'll have another look at the custom component videos, it all seems to be a bit 'black art'...

If I understand this right, I cant open custom code in V6, so Dans component is not compatible with V6, and if I wanted the functionality it offered I would need to start from scratch and create a new component.

Re: 3C : Keypad I2C

Posted: Sat Jan 23, 2016 9:16 pm
by kersing
Jay,

A component is basically just a collection of macros. If you have C code from a custom component, just create a macro for each of the functions in the custom component code and copy the C code to a C code icon inside that macro. You will probably need to 'rename' the function arguments in the C code from the original code to match the names Flowcode generates, but as you're able to 'insert' them from the list on the right that should not be too much of an issue.

Once you have created all macro's, go to the properties, select 'Interface manager' and set all macros to type 'Downloadable'. Now go to the file menu and export the component. That is all ;-)

Good luck,

Jac