lesthegrngo Posted December 26, 2019 Posted December 26, 2019 Guys, on the basis that the PCF8574 LCD controller uses 4 pins, two of which are 5v and GND, and the I2C displays use 5, is there any reason that DCS BIOS can control three or four LCD / OLED displays using just one Arduino? The reason for me is not cost, after all Nano's are less than the price of a beer each, but more one of packaging and reduction of complexity and wiring. For instance, the CMSC panel is small but I am using 3 0801 LCD displays so there is a very high density of components behind it in not a lot of space. As I don't want to use loads of spaghetti wiring to connect it all, being able to connect up three PCF8574 modules to one Nano will help immensely As a side note, I will be attempting to convert the LCD displays to make the letters light on a dark background, so that they conform better to the type seen in the cockpits; if it works I will post something here as a how to Cheers Les
jayyang Posted December 26, 2019 Posted December 26, 2019 I2C can use Address to differential the units, you may check the datasheet of PCF8574 or maybe the silk of the PCB of your LCD. OLED usually comes with I2C or SPI, I2C using address as well, and most of time there are pads on the Circuit board to let you choose. SPI will be much simple, each device has it's own CS(SS) pin, and share the rest of CLK/MISO/MOSI pins.
lesthegrngo Posted January 21, 2020 Author Posted January 21, 2020 (edited) All, I successfully got multiple i2c based (PCF8574 back pack) LCD displays to run from one nano. It's a lot easier than I expected, and I have three identical 0801 LCDs running off one Nano. Essentially all the boards I used had the same address as far as the arduino is concerned (0x27 from memory) so the arduino couldn't tell them apart. If you used i2cscanner it will display the address of the device that is pluged in. On each PCF back pack there are three sets of solder pads, A0, A1 & A2. By bridging the individual pairs with a blob of solder, it changes the address i2c sees. As an example, bridging the A0 pads changed the address to 0x26, and bridging the A1 pads changed it to 0x25. All the PCF contacts are wired to the same pins, so join via four rails, GND, VCC, SDA and SCK, so really simple The code was simple enough to change with references to lcd being replaced by lcd0, lcd1, lcd2 etc. I will post a sketch showing this. ****EDIT**** Here's the sketch #include <Wire.h> #include <LiquidCrystal_PCF8574.h> #define DCSBIOS_IRQ_SERIAL #include <DcsBios.h> LiquidCrystal_PCF8574 lcd0(0x27); // set the LCD address to 0x27 for a 16 chars and 2 line display LiquidCrystal_PCF8574 lcd1(0x26); LiquidCrystal_PCF8574 lcd2(0x25); int show; void onCmscTxtJmrChange(char* newValue) { lcd0.setCursor(0, 0); lcd0.print(newValue); } DcsBios::StringBuffer<8> cmscTxtJmrBuffer(0x1096, onCmscTxtJmrChange); void onCmscTxtChaffFlareChange(char* newValue) { lcd1.setCursor(0, 0); lcd1.print(newValue); } DcsBios::StringBuffer<8> cmscTxtChaffFlareBuffer(0x108e, onCmscTxtChaffFlareChange); void onCmscTxtMwsChange(char* newValue) { lcd2.setCursor(0, 0); lcd2.print(newValue); } DcsBios::StringBuffer<8> cmscTxtMwsBuffer(0x12b0, onCmscTxtMwsChange); void setup() { lcd0.begin(16, 2); lcd1.begin(16, 2); lcd2.begin(16, 2); DcsBios::setup(); } void loop() { DcsBios::loop(); lcd0.setBacklight(5); lcd1.setBacklight(5); lcd2.setBacklight(5); } Hope this helps someone Cheers Les Edited January 22, 2020 by lesthegrngo
Vinc_Vega Posted January 21, 2020 Posted January 21, 2020 By the way, the PCF8574 chips are not only used to connect displays to I2C but are real 8 bit port expanders. This is a good chip to save arduino in- and output pins. That means, for example 8 switches (2 Pos) can be wired to one PCF and use only 2 arduino pins (I2C). I think, that up to 8 PCF8574 can be connected to one I2C bus and therefore your saved inputs can by multiplyed by 8 (= 64) per arduino. You can also mix the in- and outputs of one PCF so that even a few LEDs can be lit. Regards, Vinc real life: Royal Bavarian Airforce online: VJS-GermanKnights.de [sIGPIC][/sIGPIC]
lesthegrngo Posted January 21, 2020 Author Posted January 21, 2020 Cool, great tip Vinc! Would it work with stepper motor outputs too? Cheers
Vinc_Vega Posted January 21, 2020 Posted January 21, 2020 Would it work with stepper motor outputs too? Unfortunately not. As they work with PWM output you should use stepper drivers like the "EasyDriver" boards. Regards, Vinc real life: Royal Bavarian Airforce online: VJS-GermanKnights.de [sIGPIC][/sIGPIC]
lesthegrngo Posted January 21, 2020 Author Posted January 21, 2020 Sorry, I meant as output to the stepper drivers Cheers
Vinc_Vega Posted January 21, 2020 Posted January 21, 2020 I think the I2C Bus is to slow to be used for PWM Signals. I'd rather would look for SPI expanders like the MCP23S17 to drive steppers. But I haven't yet. Regards, Vinc real life: Royal Bavarian Airforce online: VJS-GermanKnights.de [sIGPIC][/sIGPIC]
lesthegrngo Posted January 22, 2020 Author Posted January 22, 2020 Sounds like a project, after my little problems with RS485 I am willing to give it a go! Cheers
Recommended Posts