Author Topic: Arduino oddity  (Read 6367 times)

0 Members and 1 Guest are viewing this topic.

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Arduino oddity
« on: January 27, 2014, 12:03:14 am »
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.html

Under "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.
================================
https://dannyelectronics.wordpress.com/
 

Offline Rerouter

  • Super Contributor
  • ***
  • Posts: 4720
  • Country: au
  • Question Everything... Except This Statement
Re: Arduino oddity
« Reply #1 on: January 27, 2014, 12:07:44 am »
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,
 

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Arduino oddity
« Reply #2 on: January 27, 2014, 12:11:27 am »
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.
================================
https://dannyelectronics.wordpress.com/
 

Offline Rerouter

  • Super Contributor
  • ***
  • Posts: 4720
  • Country: au
  • Question Everything... Except This Statement
Re: Arduino oddity
« Reply #3 on: January 27, 2014, 12:16:38 am »
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,
 

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Arduino oddity
« Reply #4 on: January 27, 2014, 12:18:18 am »
Quote
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,

How does it pull down the transistor when it is set as an input pin?
================================
https://dannyelectronics.wordpress.com/
 

Offline Rerouter

  • Super Contributor
  • ***
  • Posts: 4720
  • Country: au
  • Question Everything... Except This Statement
Re: Arduino oddity
« Reply #5 on: January 27, 2014, 12:44:15 am »
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,
 

Offline graynomad

  • Regular Contributor
  • *
  • Posts: 54
  • Country: au
Re: Arduino oddity
« Reply #6 on: January 27, 2014, 01:08:21 am »
Quite typical of the crap circuits you see in many "professional" offerings.

Quote
Don't get me started on the use of '.16 spacing on an otherwise '.10 board.
I'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 :)
Graynomad, AKA Rob Gray www.robgray.com
 

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Arduino oddity
« Reply #7 on: January 27, 2014, 01:15:53 am »
Quote
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,

I 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.

Quote
I've tackled them a couple of times about this, Massimo even offered me a free Due to shut me up (it never arrived BTW).

Looks like that free Due is overdue.

================================
https://dannyelectronics.wordpress.com/
 

Offline Jay_Diddy_B

  • Super Contributor
  • ***
  • Posts: 2987
  • Country: ca
Re: Arduino oddity
« Reply #8 on: January 27, 2014, 01:17:30 am »
Hi,

DF Robot got it right.

http://www.dfrobot.com/index.php?route=product/product&product_id=51#.UuWzCSyEiSh


Their schematic is:



Jay_Diddy_B
 

Offline NiHaoMike

  • Super Contributor
  • ***
  • Posts: 9792
  • Country: us
  • "Don't turn it on - Take it apart!"
    • Facebook Page
Re: Arduino oddity
« Reply #9 on: January 27, 2014, 01:59:28 am »
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.
Cryptocurrency has taught me to love math and at the same time be baffled by it.
Cryptocurrency lesson 0: Altcoins and Bitcoin are not the same thing.
BTC: 18813fu8LQEdDwH9YLM1ABed3XwCfeSeFi
 

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Arduino oddity
« Reply #10 on: January 27, 2014, 11:01:45 pm »
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.
================================
https://dannyelectronics.wordpress.com/
 

Offline Rerouter

  • Super Contributor
  • ***
  • Posts: 4720
  • Country: au
  • Question Everything... Except This Statement
Re: Arduino oddity
« Reply #11 on: January 28, 2014, 01:14:23 am »
Sorry you are right, the software fix would be to write a 0 to the pin and then PWM the direction register,
 

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Arduino oddity
« Reply #12 on: January 28, 2014, 01:38:49 am »
Quote
Another potential fix is to cut the external pull-up and use the internal pull-up.

No go. I suspect that analogWrite() forces the pwm pins to output. A fool-proof but limiting way of doing things.
================================
https://dannyelectronics.wordpress.com/
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->