I rewrote the code to program the MCP2307 extender so that it works with both the hardwareI2C and the software I2C.
Inside the file you will find many useful functions with instructions for use.
Enjoy yourselves.
The previous demos included in version 0.98.02 can be used.
The library supports I2C and HI2C.
I'm out of Rome (my city) and I'll be back around September 10th.
Until that date I can not prepare demo files.
In the title of the discussion I was wrong to write the name of the circuit, MPC instead of MCP.
If someone is able to correct it .....
Last edit: jackjames 2018-08-11
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have not had time to try your MCP2307.h
In latest gcb release MCP23017.h uses i2c yet my servo robot demo I posted uses hi2c.
I am also confused as to what include is which.
I have this code snippet but was before latest gcb release.
note it's hi2c..and useful servo motor example maybe.
#chip mega328p,16#include<MCP23017.h>#option Explicit#define HI2C_DATA ' This is required when using hardware I2C#define hI2C_MODE Master#define HI2C_BAUD_RATE 400#define hI2C_DATA PORTC.4#define hI2C_CLOCK PORTC.5#define MCP23017_addr 0x4eMCP23017_sendbyte(MCP23017_addr,MCP23017_IODIRA,0);makeportaoutput#define forward 1#define reverse 255#define stop 0dimint_speedasworddimlmotdir,lmotor,rmotdir,rmotor,lmotval,rmotvalasbyte;lmotdir=1:lmotor=1lmotor=1:rmotor=1#define slow 63036 ;50Hz#define fast 64286 ;100Hzint_speed=fastdirportb.0out;scope;interruptdrivesmotors'AddthehandlerfortheinterruptOnInterruptTimer1OverflowCallmotorsInitTimer1Osc,PS_1_64StartTimer1SetTimer1,int_speed;;-------------------------MCP23017_sendbyte(MCP23017_addr,MCP23017_GPIOA,0);setportaoffwait2s;dolmotdir=reverse:rmotdir=reversewait2slmotdir=stop:rmotdir=stopwait2slmotdir=forward:rmotdir=forwardwait2slmotdir=stop:rmotdir=stopwait2slmotdir=reverse:rmotdir=forwardwait2slmotdir=stop:rmotdir=stopwait2slmotdir=forward:rmotdir=reversewait2slmotdir=stop:rmotdir=stopwait2sloop;-----end'ThiswillbecalledwhentheTimeroverflowsSubmotorsSetTimer1,int_speed;resettimer;portb.0=!portb.0;scopepin;leftsteppermotoriflmotdir<>stoptheniflmotdir=forwardThenlmotor++iflmotor=5thenlmotor=1else;reverselmotor---iflmotor=0thenlmotor=4endif;whichphaseleftmotorselectcaselmotorcase1lmotval=b'10010000'case2lmotval=b'11000000'case3lmotval=b'01100000'case4lmotval=b'00110000'EndSelectElselmotval=0;stop=offendif;rightsteppermotorifrmotdir<>stopthenifrmotdir=forwardThenrmotor++ifrmotor=5thenrmotor=1else;reversermotor---ifrmotor=0thenrmotor=4endif;whichphaserightmotorselectcasermotorcase1rmotval=b'00001001'case2rmotval=b'00000011'case3rmotval=b'00000110'case4rmotval=b'00001100'EndSelectelsermotval=0;stop=offendifMCP23017_sendbyte(MCP23017_addr,MCP23017_GPIOA,lmotval+rmotval);setsportatolmotval+rmotvalEndSub;----------
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Good work. I use the chip for driving 2 stepper motors using the gcb include.
I'll check yours.
seems the gcb version was i2c and I just used hi2c.
jackjames,perry&venn
nice chip, I have no prob driving 2 servos on interrupt with this chip. Really useful device.
Last edit: stan cartwright 2018-08-08
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
No functional changes were made by the old version of MCP23017.h.
The possibility of using HI2C has also been added.
Library routines make calls to old and working (I2c and HI2C) MCP23017_SendByte and MCP23017_ReadByte.
I think there are no compatibility issues with previously written software.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I noticed that the definition of the registers of the MCP23017 in my library is different from the include file.
But there are no problems because these registers are called from the routines inside the library and are not necessary for the use of the routines by the program.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This is the final library file ready to be used and, if you want, combined with the next version of the compiler.
I modified the header with the standard wording of the libraries.
If something is incorrect please the administrators to make the appropriate changes.
The test files used in the old version of the library can be used.
Currently I am very busy for work and unfortunately I do not have time to write test programs of the various routines.
I know for sure that they work because I have used them (written for another compiler) in other programs.
I rewrote the code to program the MCP2307 extender so that it works with both the hardwareI2C and the software I2C.
Inside the file you will find many useful functions with instructions for use.
Enjoy yourselves.
Last edit: jackjames 2018-08-08
@jackjames. Great job.
Questions:
Thank you,
Anobium
The previous demos included in version 0.98.02 can be used.
The library supports I2C and HI2C.
I'm out of Rome (my city) and I'll be back around September 10th.
Until that date I can not prepare demo files.
In the title of the discussion I was wrong to write the name of the circuit, MPC instead of MCP.
If someone is able to correct it .....
Last edit: jackjames 2018-08-11
I have not had time to try your MCP2307.h
In latest gcb release MCP23017.h uses i2c yet my servo robot demo I posted uses hi2c.
I am also confused as to what include is which.
I have this code snippet but was before latest gcb release.
note it's hi2c..and useful servo motor example maybe.
Good work. I use the chip for driving 2 stepper motors using the gcb include.
I'll check yours.
seems the gcb version was i2c and I just used hi2c.
jackjames,perry&venn
nice chip, I have no prob driving 2 servos on interrupt with this chip. Really useful device.
Last edit: stan cartwright 2018-08-08
No functional changes were made by the old version of MCP23017.h.
The possibility of using HI2C has also been added.
Library routines make calls to old and working (I2c and HI2C) MCP23017_SendByte and MCP23017_ReadByte.
I think there are no compatibility issues with previously written software.
This is mcp23017.h latest gcb
I noticed that the definition of the registers of the MCP23017 in my library is different from the include file.
But there are no problems because these registers are called from the routines inside the library and are not necessary for the use of the routines by the program.
This is the final library file ready to be used and, if you want, combined with the next version of the compiler.
I modified the header with the standard wording of the libraries.
If something is incorrect please the administrators to make the appropriate changes.
The test files used in the old version of the library can be used.
Currently I am very busy for work and unfortunately I do not have time to write test programs of the various routines.
I know for sure that they work because I have used them (written for another compiler) in other programs.
Cheers Jack. Added to the next release, as follows:
544 Fix MCP23017 Revised library for general release.