Thread: Which microcontroller to use?

  1. #1
    Registered User
    Join Date
    Sep 2015
    Posts
    6

    Which microcontroller to use?

    Hi everyone,

    We're making an RC 4x4 project at school which needs to have several features, so i was wondering what microcontroller you'd recommend (simplest possible please, I'm only a noob )

    What it needs to do is the following
    - Sound a buzzer when tilt sensors are activated
    - Turn front light on in "dark" conditions (needs the option of fine tuning of course, which is the main reason for doing it using a microcontroller)
    - turn on the rear 'brake' lights when power is disengaged

    I know it seems like a very small project, probably not even worthy of the microcontroller, but I'd like to give it a shot. As of yet i can use C to quite a full extent, hence preferably the language used would be embedded C. Perhaps a member of the PIC family would work? Let me know

    Thanks in advance
    Last edited by Poffman; 09-09-2015 at 04:49 PM.

  2. #2
    Registered User
    Join Date
    May 2003
    Posts
    1,619
    Well, pretty much every microcontroller could do this.

    Do you have a programmer for the PIC series? Those can be expensive relative to the cost of the microcontroller, but it's a one-time cost ($20-$70 depending on whether you build your own, buy a kit, or get a top-end programmer). Once you have a programmer, then any PIC that you can program with that hardware is fine - just get something that meets your needs. I.e. consider if you want through-hole (DIP) or surface mount, etc. A PIC is going to require a few external components (bypass caps, crystal, voltage regulator, etc.)

    The other major option is an arduino. Price outlay is about the same as a top-end PIC programmer, but you can reuse this on a lot of different projects, and it has a lot more functionality compared to the relatively simple PIC chips. It's also a fully assembled board, so if you're less on the engineering side, it's an easier entry point.

    That said, I'd use whatever PIC controllers I have laying around on my bench, but that's me.
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

  3. #3
    Registered User
    Join Date
    Sep 2015
    Posts
    6
    Is there a difference in how easy they are to program though? I'd expect a chip with relatively few functions to be somewhat less complicated.

    I did consider the arduino, but as the project is for a competition it needs to sound as complicated as possible. Besides I'd do it for the experience of how microcontrollers are actually programmed, as I'm kind of hoping to study for a degree in the subject.

    So, is there any particular one with which you've had experience with, or should i just get any particular one?

  4. #4
    Registered User
    Join Date
    May 2010
    Posts
    4,632
    We're making an RC 4x4 project at school which needs to have several features, so i was wondering what microcontroller you'd recommend
    I would suggest you talk to the instructors to see what they recommend. Since you're a novice you would be better off picking something that your instructors are familiar with in case you run into trouble. Integrating sensors to micro-controllers can be tricky because it can be hard to determine if problems are being caused by a defective sensor, wiring mistakes, faulty micro-controller configuration, timing errors and many many other potential sources of problems. Having someone that is familiar with the hardware you are using can sometimes be a lifesaver.

    My next suggestion would be to check out the sensor manufacturers web site to see if they have application notes showing how to connect and interface their sensors to micro-controllers. You have mentioned at least three different sensors or actuators to check out. The tilt sensors, the buzzer, ambient light sensor, and possibly a "power" sensor. Before you select a micro-controller you should know what type of signals each of your sensors produce including the input and output voltages. I

    By the way all of the functions you mentioned could be done using strictly analog circuitry without a micro-controller, however using a micro-controller is probably a better choice.

    Jim

  5. #5
    Ticked and off
    Join Date
    Oct 2011
    Location
    La-la land
    Posts
    1,728
    If you want weird/hard-sounding, consider using an ESP8266 WiFi module, replacing the servos with an OpenServo digital ones, a beefy high-current brushed DC motor driver board for the motor(s), a combined acceleration + gyroscope digital sensor, and some glue parts (DC-DC converter for the digitals, a 7-segment LED driver chip for the car lights, and so on).

    No analog RC control: drive it using your laptop, tablet, or phone, via WiFi. (You'll have to write the control program, too, though.)

    For me, the hardest part would be to start with the actual RC car. There are so many options. For example, the motor can be a brushed DC motor, a brushless DC motor, or a continuous rotation servo. They all need completely different control circuitry. The physical size might be important for a really small RC model. (Common boards fit in a 1:32 model, but it's already small for a standard-sized Arduino board. A 1:64 is tiny, and hard to fit anything in; the RC ones are really packed in tight with no room to spare.) The battery would have to be Li-ion, since the extra stuff (lights and buzzer in particular) consume additional power. The logic stuff isn't really power-hungry, except for WiFi stuff (~ 350 mA @ 5V).



    If I just wanted to trick up an analog RC car, I'd use a Teensy LC, a Gyro + IMU board for tilt and acceleration sensing, a LED driver for individual control of all indicator lights, a small speaker and a mini mono amplifier for sounds. Assuming the car has a 7.2V battery pack, I'd also add a DC/DC step-down converter for the logic supply conversion; otherwise a separate, small Li-poly battery and charger is needed. All in all, the budget should be less than $100, including S&H.

    The Teensy is programmed using the Arduino IDE, but that's just C++. (Arduino .ino files are just C++ with an implied #include <arduino.h> at the beginning.) I'd use the IMU to measure acceleration; lighting the brake lights whenever the car is slowing down. The gyroscopes could be used for not just the tilt buzzer, but also turning lights (in lieu of turn signals). Add some sense wires, and you could even generate "motor growl" that depends on the power applied to the motor.

    (Without RC comms to the Teensy, your remote control options would be very limited. I'm sure you could light the brake lights whenever brakes are applied, and turn signals if turning hard enough, even without the Gyro+IMU, and do things like sound a "motor growl" if you quickly pulse the motor twice or thrice in a row, and stuff like that. Others have done it, with much simpler microcontrollers.)

    Best of all, you can do this using a laptop or computer -- the Teensy is programmed directly via a micro-USB cable, no separate programmer is needed. So, you could develop the electronics separately, without the RC car at all, with just the abovementioned parts.

    Adding an ESP8266-12E module ($10 or less) would add a WiFi connection to the Teensy LC. (The ESP8266-12E modules are microcontrollers in their own right, and you might be able to replace the Teensy with it, instead of using both. I like the Teensies for their ease of use, and the sheer number of stuff they provide, in such a small package.) A simple app on your laptop/tablet/phone, using standard WiFi (at 2.4GHz), could then be used to turn on/off the lights on the car, perhaps even work as a PA system (from your laptop mic to the car).

    The problem many folks seem to run into, is not separating the motor power from the logic power, and frying their microcontroller. A DC-DC step-down converter (from typical 7.2V RC car battery to 5V) is essential; you always want to make sure you don't feed your logic circuits too high a voltage.

  6. #6
    Registered User
    Join Date
    Sep 2015
    Posts
    6
    Quote Originally Posted by Nominal Animal View Post
    If you want weird/hard-sounding, consider using an ESP8266 WiFi module, replacing the servos with an OpenServo digital ones, a beefy high-current brushed DC motor driver board for the motor(s), a combined acceleration + gyroscope digital sensor, and some glue parts (DC-DC converter for the digitals, a 7-segment LED driver chip for the car lights, and so on).

    No analog RC control: drive it using your laptop, tablet, or phone, via WiFi. (You'll have to write the control program, too, though.)
    Certainly sounds like a great idea. Problem is that we made the actual car last year, and so now we're just trying to improve certain aspects. The initial design was totally custom made, so replacing certain parts is not really possible anymore. We do have facilities to design circuit boards and what not though, which is why I'm kind of keen to keep to the microcontroller idea. Also because if we do something wrong and fry some chips, replacing home made board is easier than a factory produced one.

    I would suggest you talk to the instructors to see what they recommend. Since you're a novice you would be better off picking something that your instructors are familiar with in case you run into trouble. Integrating sensors to micro-controllers can be tricky because it can be hard to determine if problems are being caused by a defective sensor, wiring mistakes, faulty micro-controller configuration, timing errors and many many other potential sources of problems. Having someone that is familiar with the hardware you are using can sometimes be a lifesaver.
    There are no instructors. It's a stand alone project, without the help of any teachers/instructors. Which on second thoughts is why it's maybe a better idea to go with a Arduino or something similar with which a lot of online help is avaliable...

    That said, I'd use whatever PIC controllers I have laying around on my bench, but that's me.
    Wish I was in your situation

  7. #7
    Ticked and off
    Join Date
    Oct 2011
    Location
    La-la land
    Posts
    1,728
    (Note that OpenServo is actually a replacement for the circuitry on a standard servo; not a whole new servo unit.)

    Quote Originally Posted by Poffman View Post
    we made the actual car last year, and so now we're just trying to improve certain aspects.
    That's not a problem, it is just a good starting point! What kind of battery voltage are you using? 7.2V? Is steering servo-based, or something else? How do you control your motor? Did you build your RC stuff yourselves, or did you use off the shelf stuff? Do you have any free channels on your RC controller and receiver?

    One interesting option to consider, would be to use a microcontroller like Teensy to monitor and to override the RC controls if necessary. You know, for tricks and giggles. (I don't know if parallel parking an 4x4 RC car is useful, but it certainly would be doable on a Teensy.) If you have at least one extra RC channel available, it'd open up lots of options without making any changes to the existing hardware, just additions.

  8. #8
    Registered User
    Join Date
    Sep 2015
    Posts
    6
    Yep, 7.2v is the idea. We're thinkiing of increasing this to 7.4v though, just to give a bit more power. There is one high torque servo (not sure what the rating is, but it's defo overkill for a 4x4) to control the steering, then there is a kind of differential-based drive system. The motor is controlled via a standard ESC i believe, and the rest of the circuitry is off the shelf. It's more the mechanical stuff we focused on making last year, so now it's the electronics' turn. And i think the RC is 2.4Ghz, so plenty of channels there. Not entirely sure how many channels we've still got free on the controller though. There should hopefully be one free but i haven't looked at the car for a while...

    So you can program a Teensy to override the ESC? That'd certainly be bundles of fun

  9. #9
    Ticked and off
    Join Date
    Oct 2011
    Location
    La-la land
    Posts
    1,728
    Quote Originally Posted by Poffman View Post
    7.2v [...] to 7.4v, servo [...] steering, [...] motor [...] standard ESC i believe
    Typical electronic speed controllers on RC cars take servo inputs, too, so this sounds pretty doable to me.

    Quote Originally Posted by Poffman View Post
    So you can program a Teensy to override the ESC? That'd certainly be bundles of fun
    You currently have servo control signals going from the car radio to the servo and the ESC. I was thinking of putting the microcontroller between the car radio and the servo and ESC.

    There are several ways of doing it: you could use a multiplexer chip to select whether the radio or the microcontroller supplies the control pulses to the servo and ESC, or you could feed the pulses to the microcontroller, and have it duplicate them during normal operation. (Pin state change interrupts make that quite easy, on most microcontrollers: you get an interrupt whenever the input pin state changes, and you just copy their state to outputs.)

    Mostly, I'd worry about not frying the microcontroller; the radios and servos and ESC in an RC car might generate pulses and such that are "expected and normal" in an RC car, but might fry the sensitive microcontroller. I'd probably use optoisolators between the radio and the microcontroller, and between the microcontroller and the servo and ESC.

    (Also, that should make it safe enough to keep the microcontroller connected to your computer, while the outputs are connected to the car battery, ESC, and servo. Makes development and testing much easier and safer.)

    I'd probably use some kind of connector pair, so that you could easily detach the microcontroller, but keep the car working.

    So, yeah, you could have a go with a Teensy LC, two optoisolator boards, a regulator plus filter caps, plus whatever wire etc. you need. You could use any number of other microcontrollers, too; I just happen to like the Teensys. You might wish to take a look at the PJRC forum, what others have done with them.

  10. #10
    Registered User
    Join Date
    Sep 2015
    Posts
    6
    Quote Originally Posted by Nominal Animal View Post
    There are several ways of doing it: you could use a multiplexer chip to select whether the radio or the microcontroller supplies the control pulses to the servo and ESC, or you could feed the pulses to the microcontroller, and have it duplicate them during normal operation. (Pin state change interrupts make that quite easy, on most microcontrollers: you get an interrupt whenever the input pin state changes, and you just copy their state to outputs.)


    I'd probably use some kind of connector pair, so that you could easily detach the microcontroller, but keep the car working.

    So, yeah, you could have a go with a Teensy LC, two optoisolator boards, a regulator plus filter caps, plus whatever wire etc. you need. You could use any number of other microcontrollers, too; I just happen to like the Teensys. You might wish to take a look at the PJRC forum, what others have done with them.
    There's defo a lot of stuff on there. Amazing really what you can do with a few lines of code.

    Anyhow, it's certainly a good suggestion. Only thing im worried about is when something goes wrong - there's a heap of components there, which doesn't make troubleshooting easy. Might be better to just start off with a Teensy and have it on there seperate to the RC system. Some lines of code to set lights and whatnot shouldn't be too bad to at least start with.

  11. #11
    Ticked and off
    Join Date
    Oct 2011
    Location
    La-la land
    Posts
    1,728
    Quote Originally Posted by Poffman View Post
    Only thing im worried about is when something goes wrong - there's a heap of components there, which doesn't make troubleshooting easy.
    Exactly, which is why I recommend a modular approach. For example:
    Code:
    ╭──────────╮      (battery voltage & ground)       ╭─────╮
    │ RC radio │          ║                ║           │ EMC │
    ╰───╥──╥───╯         ╭╨─╮╭──────────╮╭─╨╮          ╰──╥──╯
        ║  ╚═ Connector ═╡Op╞╡  Teensy  ╞╡Op╞═ Connector ═╝ ╭───────╮
        ╚════ Connector ═╡to╞╡ (any µC) ╞╡To╞═ Connector ═══╡ Servo │
                         ╰─╥╯╰─────╥────╯╰╥─╯               ╰───────╯
                           ╚═══════╬══════╝
                                   ║
                  (voltage regulator & digital ground)
    See the four connectors (connector pairs)?

    The idea is that you could bypass Teensy altogether. Also, the optoisolators allow you to power the Teensy/microcontroller (and the optoisolator low sides) from your USB, with smallish risk of burning out your USB port on your computer.

    For testing and development, you could get a small servo that you could connect to (instead of the actual car servo and EMC), and power the servo using e.g. four AA rechargeables, to minimize risks.

    Whatever you do, do make sure you get a good voltage regulator (that can take voltage spikes), and sufficient filtering. Microcontrollers tend to be pretty sensitive.

  12. #12
    Registered User
    Join Date
    Sep 2015
    Posts
    6
    That makes total sense. Teensy, opto's and regulator ordered as well an ATmega32U2 for a different project. Thanks a lot

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Microcontroller id
    By freddarkomf in forum Tech Board
    Replies: 3
    Last Post: 08-20-2012, 06:50 AM
  2. microcontroller to C++
    By ticrou in forum C++ Programming
    Replies: 10
    Last Post: 02-05-2011, 07:04 AM
  3. Microcontroller ??
    By Cpro0 in forum Tech Board
    Replies: 7
    Last Post: 09-17-2010, 04:07 PM
  4. MP3 player to C51 microcontroller.
    By elvar88 in forum C Programming
    Replies: 4
    Last Post: 11-17-2009, 11:17 AM
  5. C for microcontroller
    By phernyt in forum C Programming
    Replies: 2
    Last Post: 12-08-2001, 01:01 PM