Author Topic: Reversing an output's polarity using a microcontroller  (Read 2396 times)

0 Members and 1 Guest are viewing this topic.

Offline danners430Topic starter

  • Regular Contributor
  • *
  • Posts: 137
  • Country: gb
  • Good at overcomplication
Reversing an output's polarity using a microcontroller
« on: September 06, 2018, 08:58:44 pm »
Hey guys,

I'm looking to control a set of points on a model railway using a microcontroller. The point motors I'm using are controlled by reversing the polarity between the two power supply terminals on the point motor. Obviously easy to do using a simple DPDT switch or a relay, but is there any other ways of achieving this?

The microcontroller runs off 5V, and the point motors off 15V.

Cheers guys

Sent from my ONEPLUS A3003 using Tapatalk

 

Online oPossum

  • Super Contributor
  • ***
  • Posts: 1472
  • Country: us
  • Very dangerous - may attack at any time
Re: Reversing an output's polarity using a microcontroller
« Reply #1 on: September 06, 2018, 09:02:10 pm »
H bridge chips like the L293D. One L293D will do two motors.

http://www.ti.com/lit/ds/symlink/l293.pdf
 

Offline danners430Topic starter

  • Regular Contributor
  • *
  • Posts: 137
  • Country: gb
  • Good at overcomplication
Re: Reversing an output's polarity using a microcontroller
« Reply #2 on: September 06, 2018, 09:11:22 pm »
H bridge chips like the L293D. One L293D will do two motors.

http://www.ti.com/lit/ds/symlink/l293.pdf
That looks sensible :-) never noticed these before! I'm guessing two things from that datasheet, firstly that they're voltage and not current driven, so the input pins can be connected directly to the MCU output, and secondly that they could also be used to drive two lead bi-colour LEDs (overkill, I know)?

Sent from my ONEPLUS A3003 using Tapatalk

 

Online oPossum

  • Super Contributor
  • ***
  • Posts: 1472
  • Country: us
  • Very dangerous - may attack at any time
Re: Reversing an output's polarity using a microcontroller
« Reply #3 on: September 06, 2018, 09:16:02 pm »
Yes and yes.
 

Offline danners430Topic starter

  • Regular Contributor
  • *
  • Posts: 137
  • Country: gb
  • Good at overcomplication
Re: Reversing an output's polarity using a microcontroller
« Reply #4 on: September 06, 2018, 09:16:38 pm »
Perfect - many thanks :D
Yes and yes.

Sent from my ONEPLUS A3003 using Tapatalk

 

Offline tooki

  • Super Contributor
  • ***
  • Posts: 13156
  • Country: ch
Re: Reversing an output's polarity using a microcontroller
« Reply #5 on: September 06, 2018, 09:21:25 pm »
Can't one do that for bicolor LEDs just by controlling the pin modes? Isn't that what charlieplexing is based on?

A bit of googling shows it really is as simple as connecting it (with current limiting resistor) between two output pins and alternating which pin is high and which is low. So one pin sources the current and the other sinks it.

https://electronics.stackexchange.com/questions/334952/control-color-of-bi-color-led-using-arduino
 

Offline danners430Topic starter

  • Regular Contributor
  • *
  • Posts: 137
  • Country: gb
  • Good at overcomplication
Re: Reversing an output's polarity using a microcontroller
« Reply #6 on: September 06, 2018, 09:24:10 pm »
Can't one do that for bicolor LEDs just by controlling the pin modes? Isn't that what charlieplexing is based on?

A bit of googling shows it really is as simple as connecting it (with current limiting resistor) between two output pins and alternating which pin is high and which is low. So one pin sources the current and the other sinks it.

https://electronics.stackexchange.com/questions/334952/control-color-of-bi-color-led-using-arduino
Aye, that's the obvious solution... However I'm working with umpteen of said LEDs, and I have a limit of 70mA output current for the entire MCU, which will really only power 3 at a time... Hence I need a way of powering them externally, using the MCU just as the switch

Sent from my ONEPLUS A3003 using Tapatalk

 
The following users thanked this post: tooki

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 20357
  • Country: gb
  • 0999
 
The following users thanked this post: oPossum

Offline tooki

  • Super Contributor
  • ***
  • Posts: 13156
  • Country: ch
Re: Reversing an output's polarity using a microcontroller
« Reply #8 on: September 07, 2018, 09:43:26 am »
Can't one do that for bicolor LEDs just by controlling the pin modes? Isn't that what charlieplexing is based on?

A bit of googling shows it really is as simple as connecting it (with current limiting resistor) between two output pins and alternating which pin is high and which is low. So one pin sources the current and the other sinks it.

https://electronics.stackexchange.com/questions/334952/control-color-of-bi-color-led-using-arduino
Aye, that's the obvious solution... However I'm working with umpteen of said LEDs, and I have a limit of 70mA output current for the entire MCU, which will really only power 3 at a time... Hence I need a way of powering them externally, using the MCU just as the switch
Have you considered using addressable LEDs instead? That'd be a lot cheaper than h-bridge IC's, I suspect…
 

Offline danners430Topic starter

  • Regular Contributor
  • *
  • Posts: 137
  • Country: gb
  • Good at overcomplication
Re: Reversing an output's polarity using a microcontroller
« Reply #9 on: September 07, 2018, 09:55:21 am »
Can't one do that for bicolor LEDs just by controlling the pin modes? Isn't that what charlieplexing is based on?

A bit of googling shows it really is as simple as connecting it (with current limiting resistor) between two output pins and alternating which pin is high and which is low. So one pin sources the current and the other sinks it.

https://electronics.stackexchange.com/questions/334952/control-color-of-bi-color-led-using-arduino
Aye, that's the obvious solution... However I'm working with umpteen of said LEDs, and I have a limit of 70mA output current for the entire MCU, which will really only power 3 at a time... Hence I need a way of powering them externally, using the MCU just as the switch
Have you considered using addressable LEDs instead? That'd be a lot cheaper than h-bridge IC's, I suspect…
I could certainly look into them... Never worked with them before, but always open to new discoveries :-) cheers for the tip!

Sent from my ONEPLUS A3003 using Tapatalk

 

Offline tooki

  • Super Contributor
  • ***
  • Posts: 13156
  • Country: ch
Re: Reversing an output's polarity using a microcontroller
« Reply #10 on: September 07, 2018, 10:33:39 am »
They're what Adafruit brands "neopixels", FYI, so lots of how-to's refer to them as that. The actual model number of the most common type is the WS2812B. They're pretty awesome. They daisy-chain (forming a physically gigantic shift register), and with the third-party arduino libraries for them, you pretty much just say "LED #[position in the chain], change to [RGB value]" and it does it. The LED itself then does the dimming/color blending on its own, with no further CPU usage, even.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf