Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: Mike88 on January 20, 2011, 02:38:07 PM

Title: Desperately need a microcontroller recommendation!
Post by: Mike88 on January 20, 2011, 02:38:07 PM
I know these posts get written alot but I have searched everything and have been unsuccessful in finding anything.

I am looking for a microcontroller to control a small hybrid electric vehicle. The absolute minimum requirements are fairly simple:
- At least 5 digital inputs
- At least 3 analog inputs
- Output a 0-5V signal to two different motor controllers:
Specifically this one:
http://kellycontroller.com/kdc7260124v-72v600a-pm-with-regen-p-424.html (http://kellycontroller.com/kdc7260124v-72v600a-pm-with-regen-p-424.html)
- Control a servo or stepper motor to control the engine throttle.
- Run simple calculations and conditional statements based on the digital inputs.
- Must be responsive, rugged, and able to withstand reasonable amounts of heat and vibration.

My budget is about $500 (however I would prefer if it was under this amount). I also have very limited knowledge in programming microcontrollers so I would prefer the software and wiring be as user friendly as possible.


I originally was going to purchase the MIT Handyboard but realized that it did not have an analog D/A output.

Could anyone suggest a microcontroller that could satisfy these requirements?

Thank your for any replies.

Mike
Title: Re: Desperately need a microcontroller recommendation!
Post by: rbtying on January 20, 2011, 03:44:07 PM
You could get just about any controller, and then add an external DAC (I2C, perhaps).  Suggested ones on this forum are ATMega328/644/1280, or PIC controllers.  If you need an integrated DAC, you could try the Cypress PSoC controllers, which have DAC on all pins. 
Title: Re: Desperately need a microcontroller recommendation!
Post by: waltr on January 20, 2011, 04:51:51 PM
Quote
I originally was going to purchase the MIT Handyboard but realized that it did not have an analog D/A output.

Very few MCUs have a DAC output.
As rbtying said add one externally.
Title: Re: Desperately need a microcontroller recommendation!
Post by: Mike88 on January 20, 2011, 05:17:06 PM
Thanks for the replies guys,

For the situation I'm in its more need than want. And yes its desperate.

So could I add an external analog output to the handy board?

Is this simple to do? How would I go about doing this?
Title: Re: Desperately need a microcontroller recommendation!
Post by: waltr on January 20, 2011, 07:23:54 PM
Do you have a link to the Handy board documents?
Since I've never heard of this board I can't guess on how to connect anything to it.

DACs come in two basic interface flavors, parallel or serial. The common serial interfaces are SPI and I2C.
What does the Handy board support?
Many of the common u-controllers used by hobbyist support both.

The common u-controller boards used by people on this forum are the Arduino and the Axon. Others here use PIC, ATmega and AVR processors but build their own boards.
Title: Re: Desperately need a microcontroller recommendation!
Post by: Mike88 on January 20, 2011, 09:35:46 PM
I apologize. I am very new to this, I thought the handy board was a very popular board (guess not). Its used alot for education purposes (or so I am told).
http://gleasonresearch.com/prod.php?sku=HB (http://gleasonresearch.com/prod.php?sku=HB)

I was leaning towards it simply because it is programmed in interactive C and seemed like the easiest and most user friendly to use. I did however contact the company and they stated that adding a DAC would be possible but no easy task.

Honestly, I have almost no experience with micro-controllers. I have could spend up to $1000 on this controller, I just need it to work (ie have a DAC connector) and be easy to program  and install.
So is there a micro-controller out there that can do this?
Title: Re: Desperately need a microcontroller recommendation!
Post by: john bond on January 21, 2011, 04:37:10 AM
Some quick thoughts

You got the first part right – ask, ask, ask. Use that annoying trick the Japanese (and 3 year old children) always use, keep asking “but why?...”

First a health warning – I am not a Robotics nerd so listen to the Robotics experts comments first. I play more with Mecatronics but find this site VERY useful.

Now my observations - Choosing microcontrollers is mainly about the learning curve, the power and the cost.

Learning Curve
Learning to use a microcontroller is great fun but can also be quite daunting. Not just the software but also the electronics and all those strange special features and wrinkle that make each one unique AND VERY FRUSTRATING!
Tips

Power
This is almost self explanatory. In the hobbyist market, the cost of the chip is usually almost insignificant in the overall cost so it is usually safe to over-specify. Ask yourself, why don’t inexpensive MCUs come with analogue outputs. This is because it is easy to add this on using PWM or resistance ladders. There are also D2A chips available if you need accurate, very repeatable outputs.
Tips

Cost
This isn’t what you think. The cost of microcontrollers has plummeted so the cost of the chip is becoming insignificant. This is about the overall results you get for both your time and your money. Even if you are playing in your workshop, your time is worth a lot. Using gears where a stepper motor would work can cost lots on getting the right gears.
Tips
   
Learning to use a microprocessor is loads of fun but also hard work. I assure you it is worth the effort.

If there is just one overriding tip, it is choosing a system that many other people in your field use. Your goal is to build a robot, not experiment with microcontrollers to see which one is best able to perform the line following algorithm with PID control (whatever that is  :D ).


Regards from Kwa Dukuza – lost somewhere in Darkest Africa...

Title: Re: Desperately need a microcontroller recommendation!
Post by: Admin on January 21, 2011, 08:19:49 AM
http://www.societyofrobots.com/robot_faq.shtml#best_microcontroller (http://www.societyofrobots.com/robot_faq.shtml#best_microcontroller)


I'm financially motivated to sell you an Axon . . . so have a look through these links :P

http://www.societyofrobots.com/axon/axon_examples.shtml (http://www.societyofrobots.com/axon/axon_examples.shtml)
http://www.societyofrobots.com/axon2/axon2_videos.shtml (http://www.societyofrobots.com/axon2/axon2_videos.shtml)
Title: Re: Desperately need a microcontroller recommendation!
Post by: Mike88 on January 21, 2011, 08:41:53 AM
Thanks for the insightful post John Bond.

As for the Axon, does these 55 I/O ports include a digital to analog output? (One which I could get 0-5V output)?



Title: Re: Desperately need a microcontroller recommendation!
Post by: Admin on January 21, 2011, 09:04:12 AM
Thanks for the insightful post John Bond.

As for the Axon, does these 55 I/O ports include a digital to analog output? (One which I could get 0-5V output)?

DAC ports are very rare in microcontrollers, and no the Axon doesn't have any.

That said, a DAC is simply a PWM (square wave output) being applied to an RC (resistor capacitor) circuit. It's very simple to make.

See this:
http://en.wikipedia.org/wiki/RC_circuit (http://en.wikipedia.org/wiki/RC_circuit)

Where Vin is from a microcontroller digital output port with PWM, and Vc is the analog voltage:

(http://upload.wikimedia.org/wikipedia/commons/thumb/e/e0/RC_Series_Filter_%28with_V%26I_Labels%29.svg/250px-RC_Series_Filter_%28with_V%26I_Labels%29.svg.png)

Also, if you attach Vc to an ADC (analog to digital port), you can create a closed loop feedback control system that modifies the PWM to keep the analog voltage a steady constant output. ie the PWM increases or decreases to make the analog output voltage keep steady.
Title: Re: Desperately need a microcontroller recommendation!
Post by: Daanii on January 21, 2011, 11:13:28 AM
I'm doing a similar project. After a lot of back and forth with the maker of my Alltrax 4834 controller (similar to your Kelly controller), and some advice from Soeren on this board, I decided to use an Arduino microcontroller.

To control my Alltrax controller, I will use the 0 to 5 Volt signal from a digital output pin that is pulse width modulated (PWM) to simulate an analog signal. As the Admin says, you will probably need to build a simple low-pass filter, using just a resistor and capacitor, to smooth out the PWM signal. That will take away some of your range, at the top and bottom of your signal. So you will just go from, say, 0.1 Volts to 4.9 Volts instead of the full 0 to 5.

I have found the Arduino very easy to work with. I program it in C using the Arduino Sketchpad. Then download the program using a USB cable.
Title: Re: Desperately need a microcontroller recommendation!
Post by: Mike88 on January 21, 2011, 11:34:41 AM
Thanks for the schematic admin, looks like ill have to attempt to build a DAC from a PWM digital output.

Daanii were you successful in being able to control the Alltrax controller with decent response with your set up?
Did you use a closed loop design? Or were you able to do this with an open loop circuit?
Title: Re: Desperately need a microcontroller recommendation!
Post by: Daanii on January 21, 2011, 11:58:22 AM
Unfortunately, Mike88, we have not tested the Arduino throttle system.

We will use the Arduino to control two separate motors, using two separate Alltrax controllers. We have had some trouble with shortening the half shafts and connecting them to the motors. We will not be able to test the Arduino throttle system until we have the motors installed. That will take a few more weeks.

I have breadboarded up the Arduino throttle system, and it works well. We are using it as a software differential, and when we input the desired throttle and steering, the Arduino throttle system puts out two nice-looking, smoothed 0 to 5 Volt signals that are correct. Whether the system will work in real life remains to be seen.

As an alternative, I've also built a circuit using digital potentiometers to send a 0 to 5k Ohm throttle signal to the Alltrax controllers. That has its own problems. But between the two circuits, I'm confident that we can find one that will work.
Title: Re: Desperately need a microcontroller recommendation!
Post by: Daanii on January 21, 2011, 12:17:35 PM
Let me add a couple of things.

First, to answer your question, we have not added a closed loop feature like Admin suggests. But we plan to. We will be looping the output voltage back to the Arduino for checking. We will also sense the wheel revolutions per minute and use that data to adjust our throttle signal. For now, though, we are just using as simple a system as possible to replace the mechanical throttle with an electronic one.

Second, I found this article about the low-pass filters (like Admin suggested) to be helpful: http://www.electronics-tutorials.ws/filter/filter_2.html (http://www.electronics-tutorials.ws/filter/filter_2.html)
Title: Re: Desperately need a microcontroller recommendation!
Post by: Admin on January 21, 2011, 01:25:02 PM
we have not added a closed loop feature like Admin suggests. But we plan to. We will be looping the output voltage back to the Arduino for checking. We will also sense the wheel revolutions per minute and use that data to adjust our throttle signal.
Wheel revolutions would be much better for feedback than output voltage, assuming you have encoders all set to go ;D