Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: Daanii on November 18, 2010, 07:14:43 PM

Title: Using a microcontroller in place of a throttle
Post by: Daanii on November 18, 2010, 07:14:43 PM
I'm still new at electronics. My project has a golf-cart motor controller that I want to control with a microcontroller. I will be using a 0 to 5V PWM output pin on the microcontroller instead of a 0 to 5V Hall sensor throttle that people usually use.

The problem is that the output pin can put out only 40 milliamps, and I need at least 50 milliamps. The +5V line on the microcontroller can put out plenty of current, though.

I understand that I can use a transistor to switch the voltage on the +5V line from 0 to 5 Volts, using the PWM output pin as a signal. But I don't know the circuit and components I would need. Can anyone help with that circuit? I can read a simple schematic.
Title: Re: Using a microcontroller in place of a throttle
Post by: Soeren on November 18, 2010, 08:09:17 PM
Hi,

This is made for a good hard shifting - if you need it to be as lean running as possible instead, I'll change the resistors.
(http://That.Homepage.dk/Img/I_O_Booster.png) (http://That.Homepage.dk/Img/I_O_Booster.png)
The reason for using both an NPN and a PNP is to keep the polarity unaltered, if that is of no concern, a single transistor will do of course.

If you wanna run the transistors at 12V, R2 and R3 needs to be increased to around 12/5 times their values.
Both ends of the circuit is referenced to a common ground.
Title: Re: Using a microcontroller in place of a throttle
Post by: Daanii on November 18, 2010, 11:26:58 PM
Soeren, thanks very much, that's exactly what I needed.

One more question. Do you think I will need to filter the signal going into the motor controller? It expects an analog input, and the PWM may be too noisy. Can I add a capacitor and resistor to make a low-pass filter, and solve that problem?
Title: Re: Using a microcontroller in place of a throttle
Post by: Soeren on November 19, 2010, 12:47:50 PM
Hi,

Do you think I will need to filter the signal going into the motor controller?
Hard to say. Have you got any data on the motor controller?


It expects an analog input, and the PWM may be too noisy.
You'd have to test it to make sure.


Can I add a capacitor and resistor to make a low-pass filter, and solve that problem?
Maybe...
What frequency is the PWM signal?
If it isn't decided yet - higher is better when you want to integrate it with a simple RC filter.

It has to be a low resistance (and hence a larger capacity than otherwise), as you still need the current into the controller... Or do you? Sounds a bit odd that an input should need 50mA - did you verify it? If so, what causes it?
Title: Re: Using a microcontroller in place of a throttle
Post by: Daanii on November 19, 2010, 02:46:44 PM
Thanks for your reply. You ask some good questions.

Do you think I will need to filter the signal going into the motor controller?
Hard to say. Have you got any data on the motor controller?

I don't have much data on the motor controller. It's an Alltrax AXE 4384, designed for use on golf carts and forklifts. The wiring diagram here http://www.alltraxinc.com/files/Doc100-049-A_DWG-AXE-Taylor-Dunn-wire-dia.pdf (http://www.alltraxinc.com/files/Doc100-049-A_DWG-AXE-Taylor-Dunn-wire-dia.pdf) gives as much information as I could find on the Alltrax website. But it's not too helpful.

It expects an analog input, and the PWM may be too noisy.
You'd have to test it to make sure.

I'll wire up what you gave me and test it next week over our Thanksgiving holiday here.

Can I add a capacitor and resistor to make a low-pass filter, and solve that problem?
Maybe...
What frequency is the PWM signal?
If it isn't decided yet - higher is better when you want to integrate it with a simple RC filter.

The signal comes from an Arduino. It's hard to tell what the frequency is for the Arduino's PWM. But I'm guessing a cutoff frequency of about 1 kHz would work well.

It has to be a low resistance (and hence a larger capacity than otherwise), as you still need the current into the controller... Or do you? Sounds a bit odd that an input should need 50mA - did you verify it? If so, what causes it?

A technical support person at Alltrax told me that the signal to Tab 2 needs 50 milliamps to work properly. I'm not sure why -- he did not say.


Thanks for all your help.

Title: Re: Using a microcontroller in place of a throttle
Post by: Soeren on November 19, 2010, 09:04:49 PM
Hi,

The wiring diagram here [Snip] But it's not too helpful.
Oh, it shows the control voltage range, so it helps a lot.


I'll wire up what you gave me and test it next week over our Thanksgiving holiday here.
Since we don't know the controllers innards, it's hard to say for sure, I would not do it directly.

Instead, test this circuit - with the Arduino alone for starters, to see how it plays out.
(http://That.Homepage.dk/Img/I_O_Booster2.png) (http://That.Homepage.dk/Img/I_O_Booster2.png)
Forgot to put it on the schematic, but R4 peaks at 3.7W, but it's just for a small part of the period and the average dissipation is less than 1W. For easy of mind, use a 2W resistor (or larger).
R5 should be around 1W (3 x 560R/0.25W in parallel would work for the test phase).

Add R5 while testing, but when used with the controller, the input impedance of the controller should be adequate pull down (so remove it after testing), if the 50mA input goes to a more or less ohmic impedance.

If the controller doesn't load it properly down (to discharge the cap), add something not below 180 Ohm to assist.

If you have access to a 'scope, check the output with that - else use a DMM in both 20VDC to get the approximate average and in 20VAC (2VAC?) to see the amplitude of the "triangle-ish" waveform.


The signal comes from an Arduino. It's hard to tell what the frequency is for the Arduino's PWM. But I'm guessing a cutoff frequency of about 1 kHz would work well.
The schematic should give a period of around 1.5ms give or take (a lot) due to tolerances in electrolytes and the slightly discomforting connect-to-black-box approach, but it's very easy to change, should the timing raise any issues.


A technical support person at Alltrax told me that the signal to Tab 2 needs 50 milliamps to work properly. I'm not sure why -- he did not say.
OK, he/she should know.

Just in case this shouldn't work, or work in a flawed way, an alternative method would be an 8 bit serial D/A-Converter followed by a buffer able to supply at least a bit more than the 50mA - this would work with 100% guarantee.

Analog feedback to the Arduino about the exact voltage could be used to keep the voltage at the motor controller input steady (if needed).


The most possible failure mode (if any) I can imagine with the simple PWM buffer/integrator circuit is a tendency to "vibrate" the speed, sort of speaking, but the motor should have ample inertia to counter that - I would however keep check on the temperature of the motor controller when smoke testing - just in case.
Title: Re: Using a microcontroller in place of a throttle
Post by: Daanii on November 19, 2010, 09:35:16 PM
Thanks for the updated. Very helpful.

I did make one big mistake. I forgot to mention that the Alltrax controller wiring diagram I sent you to is a little different from the one I plan to use. It shows a +6 to 10.5V throttle. I plan to use a 0 to +5V throttle signal. That is one of the options that Alltrax lets me program as a controller input signal.

The reason I plan to use +5V is because I have that source available from the Arduino. A +12V source will be harder to come by.

But Alltrax lets me program in several different options as Throttle Input:
  ITS (inductive)
  Resistive 0-5K ohm (+/-10%) (2-wire and 3-Wire)
  Resistive 5K-0 ohm (+/-10%)
  0-5Volt
  6-10Volt

Since the analog output pin on the Arduino gives me 0 to +5V, I thought the 0 to +5V option would be best.

Sorry about the mistake. I know the resistor values will change depending on the voltage. For testing purposes, I may just wire up the circuit as you have drawn it. I have a +12V source for testing.

I won't be able to wire this up until next week, but I'll give it a try then. Thanks again for the detailed instructions.
Title: Re: Using a microcontroller in place of a throttle
Post by: Soeren on November 20, 2010, 07:19:12 PM
Hi,

The reason I plan to use +5V is because I have that source available from the Arduino. A +12V source will be harder to come by.
Isn't the motor itself run from 12V?
If so, you can tap that - if not, I'll change it, but it may be harder to get really close to both extremities with the RC-circuit on the output.

How do you feel about the D/A-C solution?
Title: Re: Using a microcontroller in place of a throttle
Post by: Daanii on November 23, 2010, 01:05:19 PM

How do you feel about the D/A-C solution?


That solution sounds interesting. As you say, it might work better. Do you have a circuit to suggest?

UPDATE:

Was this something like what you had in mind? http://www.avrfreaks.net/modules/FreaksFiles/files/424/DN_033.pdf (http://www.avrfreaks.net/modules/FreaksFiles/files/424/DN_033.pdf)
Title: Re: Using a microcontroller in place of a throttle
Post by: Soeren on November 23, 2010, 07:40:11 PM
Hi,

That solution sounds interesting. As you say, it might work better. Do you have a circuit to suggest?
How many bits of resolution (or number of steps from zero to full speed) do you need?


UPDATE:

Was this something like what you had in mind? http://www.avrfreaks.net/modules/FreaksFiles/files/424/DN_033.pdf (http://www.avrfreaks.net/modules/FreaksFiles/files/424/DN_033.pdf)
No, I was thinking of using an external serial D/A-C.
You send it a value and it keeps the output at that value, without a need for constant adjustment, until it receives a different value.

The one in the PDF is cheap and simple though, so might be a possible candidate. However, a sample D/A-C from eg. Maxim would be just as cheap and if the controller you are using has to handle other stuff, besides translating the speed parameter, I would go for an external D/A-C.

But...
Since the motor controller can be controlled by a resistance of 0 to 5kOhm as well, there's a third option that you should consider as well.
Something like the MAX5387 (http://www.maxim-ic.com/datasheet/index.mvp/id/6412) - a dual 256 step digital potentiometer - get a sample of the 10kOhm variety (MAX5387LAUD) and put the two pots in parallel (or use a single one with just 128 steps, which should be ample for a smooth speeder). It's a 14 pin TSSOP and you use IIC to control it.


As a side note, the method used in the .pdf is the opposite of how we did back in the days when A/D-C's were scarce and very expensive - Clocking up a D/A-C (often made with discrete resistors or LASER trimmed arrays) and shoving this into one input of a comparator and the analog voltage of interest into the other input - when the D/A-C clocked to a step higher than the analog voltage, the comparator output (connected to an I/O line) toggled and the analog voltage was represented by the D/A value. Slow and taking up PCB real estate, but you work with what you have ;D
Title: Re: Using a microcontroller in place of a throttle
Post by: Daanii on November 23, 2010, 08:14:41 PM

How many bits of resolution (or number of steps from zero to full speed) do you need?


I would like to have 8 bits of resolution -- so that 0 is no throttle (0V) and 255 is full throttle (+5V). But if that is hard to do, I could live with something lower. The idea is to get something working, and then improve it if need be.



The digital potentiometer is a good suggestion. It seemed easier to go with the voltage. But maybe it will be easier to stay with the 0 to 5k Ohm throttle scheme and use the potentiometers like you suggest.

I'll be working on getting the motors hooked up to the wheels this holiday weekend (the Thanksgiving holiday here in the United States). That connection still needs to be done, and will take a lot of work. Once I get that working, I'll return to this. Thanks again for all your help.
Title: Re: Using a microcontroller in place of a throttle
Post by: Daanii on November 24, 2010, 09:18:03 AM
One more piece of information. Someone asked Alltrax for more information about what is inside their controller. They found a problem. http://lithiumate.elithion.com/php/alltrax.php (http://lithiumate.elithion.com/php/alltrax.php) It looks like a digital potentiometer is the best bet.
Title: Re: Using a microcontroller in place of a throttle
Post by: Soeren on November 24, 2010, 01:19:31 PM
Hi,

One more piece of information. Someone asked Alltrax for more information about what is inside their controller. They found a problem. http://lithiumate.elithion.com/php/alltrax.php (http://lithiumate.elithion.com/php/alltrax.php) It looks like a digital potentiometer is the best bet.
Ouch, good that you found that page.
The digital potentiometer cannot handle above 5.5V, so any which way, it needs some protection, keeping the voltage down - I'll study the page a bit more and find a solution.

For a simple solution, a real 5k potentiometer could be driven by a motor. A stereo potentiometer could use half of it for feedback into an A/D-C line.

I'll see if I can find a way to limit to around 5V without interfering noticeable with the control.