can someone tell me if an arduino can do this level of motor control and multitasking
rwgast_logicdesign
Posts: 1,464
so im planning to have my bot obviously mainely use a prop but ive been looking at arduino code and man is it super easy peasy kinda like the rad of microcontrollers, im sure picaxe is the same but i have atmega chips around and can easily program the arduino bootloader on them.
so this is what im thinking, im gonna throw an atmega168 on a piece of protoboard with a l293e. i want to use the atmega/arduino to be controlled via serial, this way i can interface to it via prop or terminal (for quick testing). I want the avr to be able to set speed and direction of two motors independentaley, i also want it to run pedetermined run left, right, forward, backward, and drive at angles like 45 degrees, using a pid loop based off the wheel encoders. the other point of the the arduino is monitor voltage and current on the motors and correct stalls, and then flip a boost regulator when the battery voltage goes low and i need more power. the motors need ever go over 18v 1.3amps.
so i guess what im really getting at is #1 is there any functionality found in commercial motor control boards that im missing and should add. #2 is the amount of multitasking im talking about, uart, dual pwm, reading encoders for a pid, and voltage/current feedback whithin the realm of an arduino using an 8mhz internal oscillator or even a 16mhz crystal? its just a cheaper more compact solution than a propeller, and i want the motor control done on a different mcu than all the robots brain work.if it is how do i pick resistors for the voltage divider and current shunt? the other reason i dont want to use a prop here is becuase i have a feeling id need an adc to do this as sigma delta and dip props dont mix well
so this is what im thinking, im gonna throw an atmega168 on a piece of protoboard with a l293e. i want to use the atmega/arduino to be controlled via serial, this way i can interface to it via prop or terminal (for quick testing). I want the avr to be able to set speed and direction of two motors independentaley, i also want it to run pedetermined run left, right, forward, backward, and drive at angles like 45 degrees, using a pid loop based off the wheel encoders. the other point of the the arduino is monitor voltage and current on the motors and correct stalls, and then flip a boost regulator when the battery voltage goes low and i need more power. the motors need ever go over 18v 1.3amps.
so i guess what im really getting at is #1 is there any functionality found in commercial motor control boards that im missing and should add. #2 is the amount of multitasking im talking about, uart, dual pwm, reading encoders for a pid, and voltage/current feedback whithin the realm of an arduino using an 8mhz internal oscillator or even a 16mhz crystal? its just a cheaper more compact solution than a propeller, and i want the motor control done on a different mcu than all the robots brain work.if it is how do i pick resistors for the voltage divider and current shunt? the other reason i dont want to use a prop here is becuase i have a feeling id need an adc to do this as sigma delta and dip props dont mix well
Comments
I believe that what you describe, including an A/D (sigma delta) function can readily be done inside a single propeller; no extra chips required, just some power transistors.
But you will need to do the programming, and hence will benefit by learning how to implement multitasking.
Not so much "easy peasy", but a TON of fun.
Cheers,
Peter (pjv)
If an arduino is not up to this task im looking at the dip format arm chip with the basic compiler that erco posted, the thing with arduino is have plenty of atmegas on hand and plenty of recourse from books to pre written librarys for the h bridge
i have some blank avr i keep around but no xtals or feedback caps. id planned to just program the arduino bootloader on a 168 and us the internal 8mhz oscillator, if it will be fast enough for me, mostly to save space and do less soldering. then i was gonna hook up the l293 and a boost boost regulator, along with whatever resistors to divide voltage and shunt current, call it a day. i originally wanted to do this with a bs2 but found out a single pwm would lock the whole module leaving no room for any other tasks, so thats why im leary of just soldering an arduino into my motor control, i want to make sure its capable of doing all this stuff at once, and id like to just get the hardware out of the way.
i would be very grateful if you could tell me the best way to do the analog pin work. i dont want the voltage divider or current shunt using to much power, as im thinking of cutting my system from 18 to 16v anyways.. i know the voltage divider should be in the k ohms region, but as far as a current shunt idk what the best way to do this is, i was thinking 1ohm resistor but ive read some stuff that confused me more, i should probably just go to the duino forums but i figured someone here would probably know
So yes, Arduino and AVRs can do what you want.
I suspect an Arduino can do it, but so might a PIC or even a BasicStamp.
If it is all about using AVR or ATmega stuff you have on hand and needing support about their ADC, go to.....them, AVRfreaks or whatever.
You might use a tiny Propeller packaged chip - there are the Propeller Proto Board, the SchmartBoard Propeller board, and a lot of other very compact Propeller formats that are both cost effective and smaller - even a Propeller that supports Arduino shields.
If it is about space, it doesn't mean that you have to abandon a Propeller. You may just have to abandon DIP packaging.
And then there is AmForth on the ATmega chips. Where do you want go is about what do you want to learn.
A double Propeller board might be the best fit.
I do understand that we all buy stuff out of curiosity and then feel that we should use it, but if it isn't a Parallax product - you aren't not really in the right place to ask for informed support.
http://www.microchip.com/pagehandler/en-us/technology/motorcontrol/
Working backwards from what you have on hand, is simply working backwards. It may or may not get the job done. And you may have to buy more to make it work than having a direct approach. Nobody knows as your design process is rahter hidden.
I like to use ADCs and I really don't like to construct them in software on the Propellera or any other chip. I am eagerly looking forward to Propeller 2 as I have always been attracted to chips that included ADC and possibly included RTCs as well.
If you want to know why I don't like to construct ADCs on the Propeller, the few parts that are required have to be placed extremely close to the i/o pins and I am not sure I can consistently build these correctly. So, I'd much rather use a PIC or an AVR or an ATmega with built-in ADC or use a real ADC chip with the Propeller.
OBEX has objects for using ADC chips with the Propeller. If you have doubts that 8 cogs is enough, maybe 16 cogs and an ADC chip will be comfortable.
These days, I am beginning to think that I need two Propellers for just about everything new that I want to do. I guess that once you learn the Propeller, this is a reality. So look for or build a two Propeller system - either with two EEPROMs or with one being a EEPROMless Propeller and some other way to load software.
as i said above i knew a prop could handel this but i wanted to keep my prop free of motor code so it could focus on more exotic things, and i learned a new platform in a few hours including interupts it was a win win . using a second prop for this task would have also meant i would have needed an adc too most likely so not only am i not wasting power and silcon on an overkill chip but i only used 48 pins of space instead of around 70. granted leons solution may be the best and ill look into it, although im not sure i wanna change my design after the work put in.
A few of my robots have a couple Propeller chips on board. I just embed a small/cheap USB HUB and with that I can download new code to either one.
For my larger projects that would have a PC or Raspberry Pi for the highest level control then that same USB link can be used to send serial commands to each one and receive data.
If you're just running with only propeller boards then just use a couple I/O pins on each one so they can directly talk to each other.
If you want to learn more about motor control you may want to join the OSMC group on Yahoo. They have years of experience designing motor controllers and when you start getting into higher frequency control there are other issues like inductance of the motor you may have to start dealing with that may not be a factor at a lower frequency. Some links to review are:
http://www.seattlerobotics.org/encoder/200011/pwm.html
http://www.electro-tech-online.com/robotics-mechatronics/19246-suitable-pwm-frequency-motor-control.html
http://forums.parallax.com/showthread.php?131700-Best-Frequency-for-PWM-DC-motors
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=printview&t=52972&start=0
http://inst.eecs.berkeley.edu/~ee40/calbot/pdf/ChapterFive/ChapterFive.pdf
http://en.wikipedia.org/wiki/Pulse-width_modulation
http://ww1.microchip.com/downloads/en/appnotes/00893a.pdf