Go Down

Topic: MCUfriend TFT LCD pin re-assignment (Read 4071 times) previous topic - next topic

GeorgeC

I have recently bought a 3.5" TFT LCD (from Ebay) for an Arduino UNO, however I find that it uses nearly all the available UNO pins and in particular most of the analogue pins, 4 of which I was hoping to use as analogue inputs. As I have no intention of using the SD card slot, would it be possible to transfer 4 of the LCD control lines to the pins currently used by the SD card connector?

I have the display up and running using MCUFRIEND_kbv and UTFTGLUE.h, but when I try to re-assign the LCD pins using:

#define RS 12 //A2
#define WR 11 //A1
#define CS 14 //A3
#define RST 13 //A4
#define RD A0
   
UTFTGLUE myGLCD(0x9488,RS,WR,CS,RST,RD);

the display still works, implying that something else is controlling the pin assignment.

Physically rewiring the pins looks fairly straightforward, and even though I have rewired the RST from A4 to 13, I still can't use A4 as an anologue input - as it still appears to be assigned to something.

How can i change this, please?



david_prentice

The constructor arguments are all dummies.    MCUFRIEND_kbv is designed to run with the shields that God has designed for you.

If you really want to hack your shield for different pins,   you need to write a SPECIAL for the new pin wiring.
If you tell me the wiring,  I will write the SPECIAL for you.

Why do you want 4 ADC channels?
It is very easy to remove the LCD_RST pin and use a Software Reset.   This gives you A4, A5.
If you have a clone Uno,   most of these have A6, A7.

Hence 4 ADC channels.

David.

GeorgeC

David: Thanks for replying.

I need 4 ADCs because I'm making a 4 in one dashboard guage to display Oil pressure, Oil Temperature, Fuel Pressure and Fuel level. I've written the display part, I just need to get the (analogue)data into it.

I have already removed the LCD_RST pin, but A4 is still not functioning correctly, which is why I thought there must be something else in the software assigning pins. A5 is free and working correctly.

I have a real UNO, so only have A0-A5.

Are you saying that the LCD pin allocations are defined in MCUFRIEND_kbv.cpp? If so, I can't see where.

Ideally I would like these assignments:

#define LCD_RS   12
#define LCD_WR  11
#define LCD_CS   14
#define LCD_RST 13
#define LCD_RD   A0

George


david_prentice

From the how_to file:
Quote
7. The constructor takes no arguments (because it only works with these shields)

8. The examples are the standard Adafruit ones.   You can see my edits by searching for "kbv"

9. Any Adafruit sketch should work with the MCUFRIEND_kbv constructor() but should allow extra ID values
An Adafruit constructor(cs, rs, wr, rd, rst) IGNORES any arguments.   i.e. it only uses the shield control pins
The only reason for allowing arguments in the constructor is for convenience when porting from Adafruit or UTFT.    Since the library is designed for shields,   the wiring is KNOWN.   Hence there is no point in having arguments.

Of course you can hack your shield to pieces if that is what you enjoy doing.
I suggest that it is easier / cheaper to buy a SMD Uno clone.

But if you want to perform surgery on your shield:
1.  you test your surgery with the LCD_ID_readreg sketch.
2.  I will post a SPECIAL for you.

David.

GeorgeC


david_prentice

Pin wiring for standard Shields is in the mcufriend_shield.h file.
Pin wiring for non-standard SPECIAL wiring is in mcufriend_special.h

This library is intended to be used with Mcufriend Uno Shields plugged into regular Arduino header sockets.

You do not need to configure anything.   It will work with any controller Shield on any regular Arduino.

Yes,  it uses most of the header pins on a Uno.
A Mega2560 or Due has got plenty of spare pins.

David.

GeorgeC

David: Thanks for your help - I've decided to use a Mega2560 instead as it has all the analogue inputs I need and works fine with the TFT LCD shield.

George

GeorgeC

Just out of interest, I went back to the UNO as it is a neater solution.

I transfered 4 of the LCD control signals on the mcufriend TFT from the analogue pins to the digital pins used by SD card, and then wrote the new pin assignments into a new section in mcufriend_special.h.

That frees up 4 more analogue inputs and works well - updating the display faster than the mega2560 for some reason.

I guess the TFT rewiring could be done with an extra shield too.

david_prentice

I have made several "HOME_MADE" Protoshields.   e.g. to put the data bus on PORTC of a Mega2560.
This works very fast.

The default Shield pin mapping for a Mega2560 is random.   Hence the slow speed when you have to map all the bits differently.

I strongly advise using ready-made Shields.   Mechanically and electrically reliable.

If you want to rearrange pins,  I suggest that you do this with a Protoshield.   i.e. solder all the custom wiring.   Keep the mechanical connections.

David.

bob174

Hi David.  I am stacking a Arduino Motor Shield R3 onto a Arduino Uno R3, and then on top of that I am using the 3.5" Kuman touchscreen display with shield for the Uno.  I want to use this setup to control a fan and a vent motor with the touchscreen.  From what I can tell digging though the code (pin_magic.h) the tft is using the following digital pins: 4, 6, 7, 8, 9, 10, 11, 13.  According to the spec sheet for the motor controller, it uses digital pins 3, 11, 12, 13.  Pins 11 and 13 are common between the two shields.  The various .h and .cpp files that configure the pins for the tft are a bit beyond my skill level at this point.  What I would like your input on is whether a 'specal' could be used to reassign pins 11 and 13 for the TFT to pins 2 and 5, perhaps, in order to allow 11 and 13 to be used by the motor shield.  Or, alternatively is there a methodology by which pins 11 and 13 could be shared between the two boards?  Thanks in advance for your thoughts.

david_prentice

Please post a link to the actual shield that you have.
Make sure that photos accurately represent your device.

I need to see pcb side.

David.

bob174

#11
Dec 06, 2017, 12:30 am Last Edit: Dec 06, 2017, 12:45 am by bob174
See attached.  Thanks. Digital pin 11 on Arduino is used by SD_DI on the tft shield, and pin 13 is used by SD_SCK on the shield.  I'm not using the SD slot on the screen.

david_prentice

The wiring is Mcufriend-style.   I suspect it has an ILI9481 controller.

This should work with Adafruit_TFTLCD or with MCUFRIEND_kbv libraries.

You edit pin_magic.h for Adafruit
You edit mcufriend_special.h for MCUFRIEND_kbv

Neither task is easy for a beginner.

Personally,   I would not interfere with the display shield.
If you are not using the microSD,   you have pins 10-13, A5 available.   i.e. 4 digital, 1 analog.

I would wire the motor, sensors etc to these pins.   I would use PIN_CHANGE interrupt on pin #10 instead of INT1 (i.e. digital #3 pin)

David.

bob174

Thanks for the information.  If you would indulge me just a bit longer.  I have to use Digital pins 3 and 11 for the motor shield as it requires PWM on those pins to control motor speed.  I have some studying to do regarding interrupts.  Generally speaking, why would you use PIN_CHANGE interrupt on pin 10 instead of pin 3?

ahmetmelih

The constructor arguments are all dummies.    MCUFRIEND_kbv is designed to run with the shields that God has designed for you.

If you really want to hack your shield for different pins,   you need to write a SPECIAL for the new pin wiring.
If you tell me the wiring,  I will write the SPECIAL for you.

Why do you want 4 ADC channels?
It is very easy to remove the LCD_RST pin and use a Software Reset.   This gives you A4, A5.
If you have a clone Uno,   most of these have A6, A7.

Hence 4 ADC channels.

David.

Go Up