Re: more i2c and mcp23017
The chip powers up with the IOCON register = 0, so you need to use the "IOCON.BANK=0" column of table 3-1 for the register addresses.
That puts GPIOA at address $12, not $09.
Re: more i2c and mcp23017
Quote:
I'm using the same setup I had for Arduino that worked, so I know this setup works.
a largely meaningless statement, an Arduino lib could do all sorts of unmentionable things to anything it comes into contact with
it needs to be
I'm using this <library> found here <link to lib> with this setup init() function connected this way <schematic or description>
eg
Code:
#include <RFM12B.h>
// By default the SPI-SS line used is D10 on Atmega328. You can change it by calling .SetCS(pin) where pin can be {8,9,10}
#define NODEID 1 //network ID used for this uniy
#define NETWORKID 99 //the network ID we are on
//lib https://github.com/LowPowerLab/RFM12B
radio.Initialize(NODEID, RF12_433MHZ, NETWORKID);
1 Attachment(s)
Re: more i2c and mcp23017
I'm using this library: Centipede, found here: http://macetech.com/store/index.php?...products_id=23, with this setup: (this code for 5 different boards). PCB board layout attached.Attachment 8677 I have 5 of these RGB boards using the code below without issue, but I can't get a simpler version (the PBP code) with monochrome LEDs working.
/*PointsRGBTEST This is working copy.
RGB test BF29April2018
Code to check new RGB Points PCB as precursor to the big Star.
Test of matrix RGB activation. Uses MCP23017 I2C port expanders
at addresses 20 to 24 and special RGB Star point model. Sequences
through 7 colors (see below) for 16 lights. Does all one color
for 16, then next color for same 16. Note RED overwhelms other colors
so blue or green mixed in show red, instead of magenta and yellow.
*/
#include <Wire.h>
#include <Centipede.h>
Centipede CS;
const int pins[3] = {//9,10,11 are DIO pins for RGB transistors. Active high turns transistor on.
9, 10, 11 //use 9, 10, 11 because these are PWM pins on UNO
};
int x = 50;//delay between LEDs on/off //
int i;
byte b;
byte p;
const byte rgb[7] = {0x02, 0x04, 0x08, 0x05, 0x06, 0x0C, 0x0E,}; //00000010= 0x02
//Red overpowers other lights when lit in combination, eg with green or blue.
/*const byte Red = ~0x02; //0B00000010 Red on PB1 pin 9 of Uno invert bits 1 here is on, but must be zero for relay
const byte Green = ~0x04; //0B00000100 Green on PB2 pin 10
const byte Blue = ~0x08; //0B00001000 Blue on PB3 pin 11
const byte Magenta = ~0x05; //0B00001010 red and blue
const byte Yellow = ~0x06; //0B00000110 red and green
const byte Cyan = ~0x0C; //0B00001100 blue and green
const byte All = ~0x0E; //0B00001110 all lights should be white
const byte Seg0 = ~0x01; //0B00000100 Segment 0 on PD0, pin 0 of UNO
const byte Seg1 = ~0x02; //0B00001000 Segm*/
void setup() {
Wire.begin(); // start I2C
CS.initialize();
for (byte p = 0; p < 5; p++)//initialize all 5 port expanders
{ CS.portMode(p, 0x00);} //
// initialize the I/O pins as outputs
for (int i = 0; i < 3; i++) {
pinMode(pins[i], OUTPUT);
}
}
void loop()
{
for (byte b = 0; b < 7; b++)
PORTB = rgb[b]; //cycle 7 colors on pins 9,10,11
for (int p = 0; p < 16; p++)//16 needed to display LED 15
{CS.portMode(1, 0x00);
CS.digitalWrite(p, HIGH);//toggle light ON
delay(x);
CS.digitalWrite(p, LOW); //turn light OFF
delay(x);
}
}
Re: more i2c and mcp23017
Yeah, I saw that but $12 didn't work either. Output just won't go low. I measure 3.5 volts or so with my DMM on all GPA pins.
1 Attachment(s)
Re: more i2c and mcp23017
Attachment 8678
This is what I get on SDA and SCL with that short program.
Re: more i2c and mcp23017
I put a label at the end of my i2C write statement to flash an LED if there is no acknowledge from the chip.
there is NO acknowledge...the LED is flashing. So that's a result I will work with. I have extra port expanders (all pretested) and 16F887s.
Update:
Changed out port expanders: no change
Changed out 16F887: no change
Changed SDA and SCL port from PortC.4 and PortC.3 to PortA.5 and PortA.4: works. Acknowledge led is OFF>
Any insight into why PortC didn't work but PortA does? ON the LabX1, C.4 and C.3 are designated for I2C.
Re: more i2c and mcp23017
for what its worth
this works for me
Code:
sda VAR PORTA.1
scl VAR PORTA.2
trisa.5=0
' pause 2000
' Debug "Start",13 ,10
addr var byte ;mcp control address
reg var byte ;mcp register
da var byte ;gpioa data
da=$f8
addr = $40
reg=0
I2CWRITE SDA,SCL,addr,reg,[$00] 'set gpioa all output
reg=9
LOOOP:
I2CWRITE SDA,SCL,addr,reg,[da]
pause 500
da=da+1
GOTO LOOOP
Re: more i2c and mcp23017
Despite the superiority of PBP and Mecanique IDE, working with the i2c commands is a bear! Struggled for a week on it, still no go. Went back to Arduino, and still cursing at all the syntax. However, a quick hookup and I have 80 LEDS spread across 5 boards (PCB above), running all kinds of patterns in COLOR without issue. It's basically the code I submitted (for Arduino) except the CS.digitalWrite is repeated 5 times, once for each board. I've got 20 pages of code done in Arduino, couldn't get one light to light up consistently with PBP.
Thanks anyway. Going to the Arduino forum now to find out how to create functions (subroutines) to make my code trim and proper.
Re: more i2c and mcp23017
Quote:
working with the i2c commands is a bear!
would you care to provide some code to demonstrate a i2cread/write command that exhibits some problem
I find it always works as documented .
I suspect that you have no idea of what the centipede library actually does behind the scenes and that
you are attempting pbp code based on that total lack of understanding. maybe if you posted some code
help would be offered all we have seen so far is just totally wrong.
good luck with your endeavours on the Arduino forum , they just love posts with no code
Re: more i2c and mcp23017
Quote:
Originally Posted by
richard
good luck with your endeavours on the Arduino forum , they just love posts with no code
I also found that they get arsy if you give them too much. I didn't get much joy from the three arduino forums I posted on when porting my thermostat code to the platform. They also don't provide code for you if you're stuck, they expect you to work that part out when they've told you what to do, and if you are new to the platform and still find the syntax strange.
I found the guys on this forum a lot more friendlier and supportive. It's just a shame that PBP lacks the native support for most modern things - but I2C is one of the basics and I've never had issues when using it to talk to LED driver chips etc.