0
\$\begingroup\$

Sadly i am not really experienced with electronics, i have recently obtained an Arduino and a motor driver and i am trying to hookup some lego motors. My motor driver outputs 2 signals, one for direction (high/low) and one for speed (PWM). My lego motor (Power functions medium) has 2 inputs for PWM signals, one forward and one reverse. So i was thinking i could connect these by sending my PWM signal from the motor driver to one of the two inputs based on the direction signal voltage from the motor driver. What kind of component could do this job? I have been looking into using a transistor as a switch but i am not sure if i will be able to make it work like i want.

\$\endgroup\$
  • \$\begingroup\$ A transistor could work, otherwise could you just use two separate PWM ports on the Arduino? If you can not use two separate ports, something like a digital switch IC or demux would work well, they take a single input and have multiple outputs. and you can select just with pulling address pins high or low what input goes to an output. \$\endgroup\$ – MadHatter Dec 28 '15 at 15:18
  • \$\begingroup\$ As RedHatter already said, maybe it would be the easiest to PWM from two arduino pins. One for forward and one for backwards. \$\endgroup\$ – fredrik.hjarner Dec 28 '15 at 15:21
  • \$\begingroup\$ Please post a link to the motor driver. \$\endgroup\$ – gbulmer Dec 28 '15 at 16:31
  • \$\begingroup\$ Indeed, your question is quite unclear. A motor "driver" would not typically have pwm and direction signals as outputs, rather those would be its inputs. \$\endgroup\$ – Chris Stratton Dec 28 '15 at 18:19
  • \$\begingroup\$ Yes i am sorry to say i misread the datasheet so actually it all worked just fine when running from battery power instead the arduino usb. \$\endgroup\$ – Han Dijk Dec 28 '15 at 21:25
1
\$\begingroup\$

So upon looking at that motor, I believe you can not power it directly with Arduino PWM power, you need to buffer the signal because the PWM is directly powering the motor.

The problem here is that digital pins on an Arduino (Atmega 328p and all other microcontolers) are designed to only provide a small amount of current (typically < 20mA). What you really want is an H Bridge system, this is a chip or device that typically takes a single PWM signal and a direction signal. An example of one that would work for you is the L293, Sparkfun and Adafruit have both information and motor control boards based on these chips. The good news is that they still are made in DIP packages so you can buy some and drop them in a bread board.

Here is an example using the L293 chip mentioned:

enter image description here

\$\endgroup\$
  • \$\begingroup\$ I'll note before someone feels the need to point out that I knowingly simplified what an H bridge is... \$\endgroup\$ – MadHatter Dec 28 '15 at 15:24
  • \$\begingroup\$ It's not presently clear what functionality the poster really needs, but while conceptually simple, bipolar bridges like the L293 and L298 generally yield very dissapointing results unless used in a fairly high voltage (6 volts minimum, better 9 volts and up), low current applications. Most projects are better served by MOSFET bridges. \$\endgroup\$ – Chris Stratton Dec 28 '15 at 18:23
  • 1
    \$\begingroup\$ I have only used these years ago back in college, do you have a more modern IC part? I also agree it is unclear what the op is looking for. \$\endgroup\$ – MadHatter Dec 28 '15 at 18:45
  • \$\begingroup\$ I think TI has one, the DRV8xxx? I have used the Rohm BD6221F in several projects as well -- supports direction control, PWM inputs and is a simple SOIC-8. That model is single channel, but is part of a family with various options: farnell.com/datasheets/610152.pdf \$\endgroup\$ – Krunal Desai Dec 28 '15 at 19:56
  • \$\begingroup\$ L293 on 5V I don't think so but: electronics.stackexchange.com/questions/108686/… \$\endgroup\$ – Andy aka Dec 28 '15 at 23:55
0
\$\begingroup\$

Assuming these PWM outputs are 5v TTL-like on both the Arduino and Lego sides, I'd go for something like a 4016 transmission gate with an inverter arranged so that with your direction line high, the PWM signal will be routed to this motor; with it low, it'll get routed to that motor.

This will leave the 'inactive' motor with a floating input, which may not be what it's expecting.

I'd advise that you get the Arduino/Lego interface working in one direction to start with (using just one of the motors and ignoring the direction line) before trying to get a bidirectional circuit going.

\$\endgroup\$
0
\$\begingroup\$

Hopefully I interpreted your question correctly.

It can be made with "logical gates" (shown at the top),

or it can be built from scratch with N-channel MOSFET transistors (shown at the bottom).

image of the circuit

Link to interactive circuit on Falstad

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.