Compatibility between UNO and IC

Hi

Recently I bought Arduino Uno to control 2 electric motor’s that I have ( 1x24V and 1x36V, if this goes well I will try to do more advanced things :slight_smile: ).
I never did this before, but I already read some previous post’s, and I believe I will need 1 IC like this one:

and a power H-Bridge to be able to control motor speed/direction.

My main doubt is related with the fact that this IC is controlled by simple 0V to 1V Analog Input, and I don’t know the output voltage of arduino uno pwm pins.
For instance, if the output voltage is 5V, does that mean it’s not possible to use this IC with Arduino Uno?

Thanks.

Why do you want to use this chip?

It is a voltage controlled pulse width modulator. The arduino has 6 pulse width modulator outputs already so why use this chip?

I'm going to enumerate the reasons:

  • I think it will be more efficient if I use my arduino as a "central controller", that would only give an analog signal reference to the chip (duty cycle and direction);
  • For example, if I want to control more than 6 motors, it wouldn't be possible with 1 arduino uno (I'm not planning on doing that at the moment, but I prefer to leave that door open);
  • The code would be more simple, because I wouldn't have to programme arduino's timers to generate a frequency between 15Khz and 20Khz (I think it's the advised frequency);
  • The chip is very cheap, and I would only have to buy 3 resistances and 2 NOT gate's (page 26 of the datasheet);
  • Basically I prefer to work with electronics :)

It's the first time I'm trying to do something like this. I read a lot of things on the internet and this seemed a good path to follow, do you think it will work? My only concern is the fact that this IC is controlled by 0V to 1V Analog Input, and I believe that arduino's output voltage pins is greater that that..

How will you create the 0-1V DC output? Have a bunch of I2C or SPI interface DACs that you will send voltage level info to? For example: http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en024016 with a shift register for selecting 1 of 8 or 2 shift registers for selecting 1 of 16 chips

Logan20:

  • I think it will be more efficient if I use my arduino as a “central controller”, that would only give an analog signal reference to the chip (duty cycle and direction);

Trouble is … Arduino doesn’t have any analog outputs.

Logan20: - For example, if I want to control more than 6 motors, it wouldn't be possible with 1 arduino uno (I'm not planning on doing that at the moment, but I prefer to leave that door open); - The code would be more simple, because I wouldn't have to programme arduino's timers to generate a frequency between 15Khz and 20Khz (I think it's the advised frequency);

With SoftPWM you can do 20.

https://code.google.com/p/rogue-code/wiki/SoftPWMLibraryDocumentation

And you don't have to do the programming yourself.

Thanks for your help! ;)

Trouble is ... Arduino doesn't have any analog outputs.

You're right fungus. Although, I think crossroads has given me an answer for that. By using a digital to analog converter, I would be able to create an analog input for my IC.

Have a bunch of I2C or SPI interface DACs that you will send voltage level info to?

Honestly I had to search information about I2C or SPI, because I don't know much about it. They have the disadvantage of adding extra CPU cycles, which would be slower than programming the internal registers of my Arduino, but I don't know if that would interfere with something..

With SoftPWM you can do 20.

https://code.google.com/p/rogue-code/wiki/SoftPWMLibraryDocumentation

And you don't have to do the programming yourself.

Thanks for the suggestion. However, by reading function descriptions I didn't understand how I would change the frequency.

The idea I'm getting is that there aren't many advantages of using this IC, in order to simplify the code.. And with Arduino (in this case arduino UNO) I can easily control more than 1 or 2 motors without an external PWM module.

Logan20: - Basically I prefer to work with electronics

The whole point of programmable microcontrollers is to replace non - programmable electronics. So if you prefer to do electronics, why are you using an Arduino? :)

They have the disadvantage of adding extra CPU cycles, which would be slower than programming the internal registers of my Arduino,

Programming the internal registers is a once only process. It does not slow anything down. Using the internal PWM is the fastest it can be because there is no CPU overhead when it is running.

I understand your comment dc42 :stuck_out_tongue: However, if I use this voltage controlled pulse width modulator IC chip, I will still have to programme.

I have already seen some code examples from arduino’s tutorials. With a pot./joystick I will give an analog signal to my arduino UNO, that depending on the ‘case’ it will send a pwm signal with a certain duty cycle. Something like this:

int pinA = 3;

void setup(){
pinMode(pinA,OUTPUT);
}

void loop(){

int actuador = A0;   
int sensorValue = 0;
  
    sensorValue = analogRead(actuador);  
}

if(sensorValue <200) {   
            analogWrite(pinA,32); // 12.5% Duty
}

In order to have an analog input for my voltage controlled pulse width modulator IC, I will use a low-pass filter (D-A converter).
After that I will just have to configure the resistance values of the IC (like it’s explained here: http://www.farnell.com/datasheets/1497330.pdf ) , to generate a frequency between 15Khz and 20Khz, that will be send to a driver. Finally, the driver will amplify the current for the motor.

The only thing I still don’t have any idea is: since the output voltage of the arduino is between 0-5V, how can I create the 0-1V output?

since the output voltage of the arduino is between 0-5V, how can I create the 0-1V output?

A potential divider. https://en.wikipedia.org/wiki/Voltage_divider

Running the 0-5V PWM thru a lowpass filter will create a smoothing effect that will appear as a lower voltage.

Thanks, now I think I can order the components. :slight_smile:

This tool helped me to size the filter: (Sample)RC Low-pass Filter Design for PWM - Result -
The specifications of the filter are R = 5000 ohm and C = 6uF. Using this values, the cut-off frequency will be approximately 5Hz, so I will have a quick response. The transient analysis shows some ripple (image attached).

Do you advise a second order filter to obtain less oscillation?

A potential divider.
Voltage divider - Wikipedia

Yes, I think this will do it: R1 = 40K and R2 = 10K

Transient analysis.png

Hi,
I was hoping the next time I would post something here, it would be the awesome results I was achieving :smiley: . Unfortunately, that’s not the case…

On my previous post I attached an image of a simulation that I was expecting to observe at the output of my second order LP filter. However, this is what the scope showed:
I also used the code I posted above, but instead of generating a pwm signal with a duty cycle = 12.5% , I used a duty cycle = 50%

I really don’t understand why the signal has so much ‘noise’ and high frequencies… and CrossRoads said:

Running the 0-5V PWM thru a lowpass filter will create a smoothing effect that will appear as a lower voltage.

But I wasn’t expecting such a difference. The voltage I was getting with 50% duty cycle was around 1.8V (shouldn’t it be more or less 2.5V, despite having the influence of the LP filter smoothing effect? )

Huh. I would have thought it would be smoother. Can you post your filter schematic & values?

Thanks for the quick reply CrossRoads

Yes I can. I just downloaded the free pspice student edition, because I didn’t have a filter schematic. Previously I used this:

This tool helped me to size the filter: (Sample)RC Low-pass Filter Design for PWM - Result -
The specifications of the filter are R = 5000 ohm and C = 6uF. Using this values, the cut-off frequency will be approximately 5Hz, so I will have a quick response. The transient analysis shows some ripple

I’ve attached the image of my second order LP filter schematic & values. But since it’s the first time I’m using this software, I cannot understand why I’m not able to simulate this circuit… Nevertheless, I believe the result would be similar to the image I posted before of the transient analysis.

Looks reasonable have you actually got the component's value right? Is it wired up correctly?

Yes Grumpy_Mike, the component’s value is right and I’m 99% sure that it’s wired up correctly.
I also took a picture of the circuit, but the quality of my cell-phone camera and my photographic skills are ridiculous :stuck_out_tongue: so I doubt you will understand…

I did a little ‘googling’ trying to find if there are other people with the same problem, and it keeps appearing information about Spectral Modeling Synthesis.To be more precise, examples about Low-Pass Filtering by FFT Convolution. Is this important and related to my problem?
The question might seem silly, but I’ve never heard of FFT…

Try adding a 10K resistor to Gnd at V to simulate a load.

FFT is Fast Fourier Transfer. More software invovled there.

I will try that CrossRoads! I bought a 10k and a 50k resistor. I'm not very optimistic, because this is a completely passive circuit. So it won't probably improve or reduce the signal 'noise', but it would definitely smooth it. I think it's almost like using a potential divider.

After reading more articles, I think the fft will help me to realize if the LP filter is actually 'cutting' the high frequency components.. That's another think I will have to check with the scope at the Arduino and filter output.

I just hope I will have different results.. there are a lot of things that I cannot explain in the image I posted previously; like having Mhz frequencies, such a high V amplitude, the noise..