Arduino oddity - Page 1
Forum section: electronics / projects

author: dannyf
author_rank: Super Contributor
timestamp: January 27, 2014, 12:03:14 am
content: I was looking to see if I could take advantage of the various lcd shields to re-purpose them for my ESR/milliohm meter. To do that, I would need to have the schematic to know which pins are used by the shield and which are available.Then I came up on this schematic, from sainsmart:http://www.sainsmart.com/sainsmart-1602-lcd-keypad-shield-for-arduino-duemilanove-uno-mega2560-mega1280.htmlUnder "Sample Code Download", it provides the schematic in pdf file, re-attached here.See where D10 is connected. D10 is a pwm output pin so I think the original intent might be to use analogWrite() to control the backlight intensity - It probably works (thanks to wimpy current drives) but what happens when D10 goes high?Those sainsmart people are anything but smart,I haven't checked other lcd shields - I suspect that they have the same problem. There is a (newer?) version out there that inserted a resistor between D10 and that transistor's base.Don't get me started on the use of '.16 spacing on an otherwise '.10 board.

author: Rerouter
author_rank: Super Contributor
timestamp: January 27, 2014, 12:07:44 am
content: While it is not a healthy thing for the chip, the outputs are current limited by there own impedance, so it would likely end up dumping about 50mA to ground through that pin,

author: dannyf
author_rank: Super Contributor
timestamp: January 27, 2014, 12:11:27 am
content: I think the stock analogWrite() will still work - except that D10 is being pushed outside of its specs.There are a few ways to fix it via hardware changes.The software fix would be to write your own pwm output for that pin. Initialize the pin as input and output a '0' on it - yes, you need to initially output a '0' on an input pin.In the isr, flip the DDR bit: so the pin goes from input (when D10 is being pulled high by the pull-up resistor, turning on the led), to output (then the '0' in the data register gets written to the D10, turning off the transistor). Aka quasi-OC output mode.

author: Rerouter
author_rank: Super Contributor
timestamp: January 27, 2014, 12:16:38 am
content: In my head the software fix would be to copy the analog-write function into your main code and swap it to an input. so when its set to 1, it turns on a 20K pullup, when its set to 0 it get pulled down by the transistor leakage,

author: dannyf
author_rank: Super Contributor
timestamp: January 27, 2014, 12:18:18 am
content: QuoteHow does it pull down the transistor when it is set as an input pin?

author: Rerouter
author_rank: Super Contributor
timestamp: January 27, 2014, 12:44:15 am
content: Your using a BJT there not a FET, so when you stop providing a liftup the few pF of parasitic capacitance gets pulled down to under 300mV by the base-emitter junction which complelty turns it off, then leakage takes it the rest of the way, all of this happens in uS so there is no issue,if you want to be paranoid, then it should be set up correctly with a base resistor, in which case making that board and sourcing a sip LCD ends up about the same cost,

author: graynomad
author_rank: Regular Contributor
timestamp: January 27, 2014, 01:08:21 am
content: Quite typical of the crap circuits you see in many "professional" offerings.QuoteI've tackled them a couple of times about this, Massimo even offered me a free Due to shut me up (it never arrived BTW).The official story is something like, "We had 100 made before we noticed." Bollocks, who makes 100 boards straight up. You have 1-3 iterations of prototypes. Then "it was too late as people were using the boards by then", bollocks again. As I understand it the first boards were freebies so they get what they paid for, they were essentially beta testers and as such should expect changes to be made. If they really did do 100 production boards with no prototyping then words pretty much fail me, except to say bight the bullet, tell the original users that there will be a change, and fix it. Spend less time deciding on the silly shape of the board and more time getting the engineering right.And anyway at that point there can't have been many (or indeed any) shields so what did it matter if you fix the spacing.Don't get me started...oh, it's too late

author: dannyf
author_rank: Super Contributor
timestamp: January 27, 2014, 01:15:53 am
content: QuoteI have to say that I cannot make any sense out of that, to explain how an "input" pin can output a '0' with a pull-up resistor + base-emitter off of it.But I readily admit that it is my fault.QuoteLooks like that free Due is overdue.

author: Jay_Diddy_B
author_rank: Super Contributor
timestamp: January 27, 2014, 01:17:30 am
content: Hi,DF Robot got it right.http://www.dfrobot.com/index.php?route=product/product&product_id=51#.UuWzCSyEiShTheir schematic is:Jay_Diddy_B

author: NiHaoMike
author_rank: Super Contributor
timestamp: January 27, 2014, 01:59:28 am
content: I guess it was designed for a MOSFET, then someone changed it to bipolar to cut costs.Also, not all LCDs have built in current limiting for the backlight.

author: dannyf
author_rank: Super Contributor
timestamp: January 27, 2014, 11:01:45 pm
content: Another potential fix is to cut the external pull-up and use the internal pull-up.it assumes that the OCx module writes to the port register to effect output.its down side is small and device-dependent current sink capability.

author: Rerouter
author_rank: Super Contributor
timestamp: January 28, 2014, 01:14:23 am
content: Sorry you are right, the software fix would be to write a 0 to the pin and then PWM the direction register,

author: dannyf
author_rank: Super Contributor
timestamp: January 28, 2014, 01:38:49 am
content: QuoteNo go. I suspect that analogWrite() forces the pwm pins to output. A fool-proof but limiting way of doing things.