I2c motor driver, using 555, digital pot, l298

In my drive to fill all 112 devices on my Arduino’s i2c bus ::slight_smile: I’ve decided to try make an i2c motor driver circuit. The two i2c modules I have done so far (lcd and shift register controller) both rely on the mpc23008 so I will use that as a base.

Requirements:

  1. Cheap and easy to find ICs (subjective, in South Africa anything more complicated than a light switch is hard to find and expensive)
  2. Forward and reverse required.
  3. PWM
  4. Work with i2c only
  5. Add noise cancellation

The general idea is this:

  1. Arduino to mcp23008 on i2c. US$ 2.00 (gives 8 controllable i/o pins)

  2. A 555 based circuit to do the pwm, possibly based on the schematic here http://www.nomad.ee/micros/pwm555.html. Local cost US$ 0.50

  3. Digital potentiometer MCP42010, comes with two controllable variable resistors to replace potentiometer in schematic above to set duty cycle. US$ 2

  4. L298N as motor driver. US$ 3.60

Challenges:

  1. Emulate SPI protocol for MCP42010 via three pins on the mcp23008 … doable?
  2. Figure out L298 interface, it seems that there is two input pins per side for pwm, speed for backward and reverse? Can I use an inverter with the 555 per motor?
  3. Err ? what is noise cancellation … or can I add a cheap optocoupler in there somewhere?

Your ideas on this if you please? :slight_smile:

Err ? what is noise cancellation .

Do you mean decoupling? Look here:-
http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html

and
http://www.thebox.myzen.co.uk/Workshop/Motors_1.html

Figure out L298 interface

Four buffers with two inputs, signal and enable. Use two buffers per motor that gives two signal and one enable (it is common to two buffers). Then wire the motor across the two outputs. Enable on, Signals the same motor = off, signals different motor = on, signals different but swapped over motor = on but turning the other way. Speed PWM to enable.

Emulate SPI protocol for MCP42010 via three pins on the mcp23008 … doable?

Yes if you must.

Thanks Mike.

I did not see any references to lunacy so I’m going to give this a go! ;D

The question of which digi-pot to use is still a bit undecided, the MCP42010 includes two pots and can be daisy chained plus its relative inexpensive. Another possibility is the ad5203 which with four pots can drive four 555s. At double the price it does give double the functionality. SPI seems the only affordable option though?

Is SPI handled much the same as the 74hc595 e.g latch,data, clock, data,clock … etc etc?

Cheers for the links, they make decoupling quite clear and also the explanation of the L298. Is there an IC that provides a 0 1 output for a 0 input and a 1 0 output for a 1 input so that I only need one pin from the mcp23008 to set direction for a motor? :-?

Ok the first 555 pwm built and tested ok using a transistor to drive motor. I could not find any digi-pots thus far so I used a manual variable resistor and the motor responds well all the way from ±3 to 12 volts. I settled on the circuit here http://www.cpemma.co.uk/555pwm.html

Does anyone perhaps have experience with emulation of the spi protocol, I am just concerned with the clock speeds or is it synchronous like a shift register?

Just an update, the spi protocol on the digipot can be emulated in much the same way one would handle a 74hc595 shift register.

I did however abandon the 555 pwm generator in favour of using two op amps. It’s a much easier build but restrains the outputs to a single frequency (but individual duty cycles) for all channels. I’ll post some screenies of the workings thus far tonight.

Another update, I finally got it all to work on protoboard and will move to stripboard soon.

Just a note … the L298 requires the pwm signal to drive the 2 signal pins not the enable pin, or at least that’s what I had to do at 100Hz. Use your single pwm signal via an inverter to connect to both signal pins. This means that 50% duty cycle = stop and 1% duty cycle fast reverse and 99% duty cycle = fast forward. Hope that makes sense … :wink:

the L298 requires the pwm signal to drive the 2 signal pins not the enable pin, or at least that’s what I had to do at 100Hz.

If the motor is not under any great load then disconnecting it (PWM to enable) might not look like it is doing anything but it is. Shorting out a motor at PWM speeds is something I would not have considered doing. I don’t like the sound of it but can’t come up with why at the moment. Maybe it’s too late.

Dead right Mike, the motor was indeed under no load when tested and showed little sign of speeding up or slowing down when applying the pwm to the enable pin.
This led me to research the subject a bit and I discovered the “locked-antiphase” method of pwm control which runs an inverted signal of the pwm signal together with the pwm signal to the two signal/direction pins.
Apparently applying pwm to the enable pin is called a signed magnitude type pwm.
Best description I could find is here http://www.openservo.com/forums/viewtopic.php?t=142 (check the quote on the first post) …