I have a problem getting the MCP23017 expander chip to function on a 184550 chip.
Wiring
Chip 1
Pins 1 thru 8 each pin is connected individually to a 10 k pull up resistor to 5v and in parallel to a switch bank which toggles 0v onto each pin respectively.
Pin 9 – 5v
Pin 10 – 0v
A 100n cap over pin 9 and pin 10
Pin 11 – NC
Pin 12 - to pin 34 on the 18f4550 and a pull up resistor of 1k to 5v, and to pin 12 on the second expander
Pin 13 - to pin 33 on the 18f4550 and a pull up resistor of 1k to 5v and to pin 13 on the second expander
Pin 14 – n/c
Pin 15– 0v
Pin 16– 0v
Pin 17– 0v
Pin18 - a 10k pull up resistor to 5v
Pin 19 and 20 – NC
21 through 28 each pin is connected to an led with a series resistor to 0v, therefore I need the output to go high when lighting up the led..
Chip 2 is the same for chip 1 except pin 16 is wired to 5v, and portb is also wired as inputs
The attached flow code file is my software as now. i have only done it to see the first input bank
The led pulses on and off each time I scan the usb port, therefore comms to the 18f4550 is OK. I have only written the flowcode to look at chip I inputs. The problem is that I get a value of 255 all the time irrespective of the inputs on the dip switches.
I simply do not know what i am doing wrong. I suspect that it is in the way we scan due to the usb slave component.
I scan every 3 seconds. My understanding is that every time a scan all comms to the expander must be done in the service macro, and initialisation of the i2c port in the main macro.
please help
MCP23017 and 18f4550 usb slave
Moderator: Benj
-
Roy Johnston
- Flowcode V4 User
- Posts: 220
- Joined: Mon Aug 24, 2009 8:38 am
- Has thanked: 2 times
- Been thanked: 34 times
- 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: MCP23017 and 18f4550 usb slave
Hello,
The first thing I noticed is that 1K pull ups on your I2C bus lines may be too little of a resistance. You may want to up these values to say 4.7K or 10K.
The I2C comms in your program appears to be correct but you are passing the value back to the USB before you have taken the I2C reading.
The first thing I noticed is that 1K pull ups on your I2C bus lines may be too little of a resistance. You may want to up these values to say 4.7K or 10K.
The I2C comms in your program appears to be correct but you are passing the value back to the USB before you have taken the I2C reading.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
Roy Johnston
- Flowcode V4 User
- Posts: 220
- Joined: Mon Aug 24, 2009 8:38 am
- Has thanked: 2 times
- Been thanked: 34 times
Re: MCP23017 and 18f4550 usb slave
I have attached an example of a code I used, it works. This is a standalone and does not have the usb slave component. This would indicate that it is not hardware.
I have tried only passing the info to the usb after reading it, it still does not work.
One thing I noticed in the attaché example that they are using register 0x13 and 0x12 to read and write . Is this correct, as the original examples do no do this. Or am I confused
I have tried only passing the info to the usb after reading it, it still does not work.
One thing I noticed in the attaché example that they are using register 0x13 and 0x12 to read and write . Is this correct, as the original examples do no do this. Or am I confused
- Attachments
-
- newbackup1.fcf
- this one works withou usbslave
- (11 KiB) Downloaded 266 times
- 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: MCP23017 and 18f4550 usb slave
Hello,
I see you are using the USB slave with the parameter set to a string. Please note that if you try to pass a 0 as one of the bytes is the string then this will in effect terminate the string and any data following this termination will not be passed through. The byte input method is good if you are passing 0 values and not ascii string data.
On the I/O expander registers 0x00 and 0x01 are the tris data direction registers, registers 0x12 and 0x13 are the port registers. Note that for this to be valid you have to setup the device in bank 0 mode.
The device datasheet should help to get you up and running with the device.
I see you are using the USB slave with the parameter set to a string. Please note that if you try to pass a 0 as one of the bytes is the string then this will in effect terminate the string and any data following this termination will not be passed through. The byte input method is good if you are passing 0 values and not ascii string data.
On the I/O expander registers 0x00 and 0x01 are the tris data direction registers, registers 0x12 and 0x13 are the port registers. Note that for this to be valid you have to setup the device in bank 0 mode.
The device datasheet should help to get you up and running with the device.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
Roy Johnston
- Flowcode V4 User
- Posts: 220
- Joined: Mon Aug 24, 2009 8:38 am
- Has thanked: 2 times
- Been thanked: 34 times
Re: MCP23017 and 18f4550 usb slave
Now i am realy confused. all i want is to simply read in the inputs into a variable every time i poll the usb.The examples given do not do this uder a service macro.
- 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: MCP23017 and 18f4550 usb slave
Hello Roy,
Im in a conferance this afternoon but I will try and remember to sort you out with an example over the weekend if I get chance.
Im in a conferance this afternoon but I will try and remember to sort you out with an example over the weekend if I get chance.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
Roy Johnston
- Flowcode V4 User
- Posts: 220
- Joined: Mon Aug 24, 2009 8:38 am
- Has thanked: 2 times
- Been thanked: 34 times
Re: MCP23017 and 18f4550 usb slave
Thks for all the help- I came right, once I figured out the behaviour of the registers is was rather simple thereafter.
Many Many thanks
Many Many thanks