Questions tagged [microcontroller]

A device which includes a central processing unit (CPU), memory, and (generally) an assortment of I/O peripherals (UART, ADC, DAC, general-purpose I/O, I2C, etc.) in a tightly-coupled standalone package.

Filter by
Sorted by
Tagged with
201
votes
13answers
250k views

What's the difference between a microcontroller and a microprocessor?

What's the difference between a microcontroller and a microprocessor?
46
votes
8answers
8k views

How to choose a MCU platform? [closed]

There are numerous MCU platforms and once somebody has gotten used to one, they are generally reluctant to switch to another platform. My question is: If one started using a MCU for general purpose ...
10
votes
3answers
9k views

Crystal oscillator load capacitance, again

There's a lot of seemingly conflicting information regarding how the load capacitance for a parallel resonant crystal is calculated. Faced with a lot of problems in recent years with non-oscillation ...
172
votes
16answers
93k views

Is C++ suitable for embedded systems?

A common question, here and elsewhere. Is C++ suitable for embedded systems? Microcontrollers? RTOSes? Toasters? Embedded PCs? Is OOP useful on microcontrollers? Does C++ remove the programmer too ...
13
votes
3answers
13k views

Driving DC motors with MOSFETs and a microcontroller?

I'm developing a nano quadcopter using an Atmega328 microcontroller, powered at 3.3V, and very small brushed DC motors. The average current used by these motors is about 800mA @ 3.7V. Initially, to ...
71
votes
7answers
65k views

When is a MOSFET more appropriate as a switch than a BJT?

In my experimentation, I've used only BJTs as switches (for turning on and off things like LEDs and such) for my MCU outputs. I've been repeatedly told, however, that N-channel enhancement-mode ...
31
votes
3answers
15k views

How can I detect a power outage with a microcontroller?

I have the following power supply configuration: AC MAINS -> UPS -> 24V POWER SUPPLY -> 5V VOLTAGE REGULATOR -> PCB (microcontroller). What's the best solution to detect the power outage on the mains ...
17
votes
6answers
31k views

How to read high voltages on microcontroller?

I want to read high voltages, like ~50V, using a microcontroller. I plan to put this as an input into the microcontroller's A/D line. But of course, you shouldn't have voltage that high on the input ...
12
votes
5answers
5k views

“Overclocking” an AVR

In AVR datasheets under the Electrical Characteristics section you will typically find a graph like this (this one is from the ATMega328): I've seen designs that seem to "work" but operate outside ...
8
votes
1answer
603 views

Can I use blue-green LEDs as MCU state indicators on 3.3 V power?

Modern electronics industry has developed very efficient LEDs with nice and fancy colors (“true green” , “cyan”, and “blue”) based in InGaN technology, or similar. Some of these LEDs are specified as ...
1
vote
2answers
3k views

Using AC current to trigger Triac

I am trying to simulate the operation of an optocoupler with a triac to trigger the triac using the AC current. I have come across a few circuits that are all similar: My question is regarding the ...
35
votes
5answers
44k views

Is there an ideal PWM frequency for DC brush motors?

I'll be using a microcontroller to create a PWM signal for motor control. I understand how PWM and duty cycle works, however I am unsure about an ideal frequency. I do not have my motor in yet, so I ...
19
votes
4answers
3k views

Current sensing nA to mA

I need to sense the current of a target MCU through various periods of its on/sleep/off state and then need to send this data back to another interface MCU to read out the value. They will be both on ...
11
votes
4answers
2k views

ICSP or Pre-Programmed Microcontroller

I've designed a PCB for small scale production; currently I'm hand soldering them in batches of 20 at a time. This PCB uses an ATMEGA168 microcontroller which I program before soldering to the board - ...
63
votes
3answers
118k views

Push-pull/open drain; pull-up/pull-down

I am reading the datasheet of an ARM Cortex chip, specifically the GPIO chapter. Ultimately, I want to configure various GPIO pins to use them in "Alternate Function" mode for read/write access to ...
48
votes
9answers
12k views

Using volatile in embedded C development

I have been reading some articles and Stack Exchange answers about using the volatile keyword to prevent the compiler from applying any optimizations on objects ...
23
votes
3answers
79k views

How to drive a MOSFET with an optocoupler?

What's the proper schematic for driving this MOSFET from a microcontroller pin through this or this optocoupler? The MOSFET will drive a motor @ 24V, 6A.
34
votes
4answers
14k views

Reason of multiple GND and VCC on an IC

What is the reason that most of ICs (e.g. MCU) has multiple (A/D)GND and (A)VCC pins? If it is to increase performance of an IC, how does it help to performance? or is it easier for the IC designer ...
33
votes
9answers
10k views

What happens when an embedded program finishes?

What happens in an embedded processor when execution reaches that final return statement Does everything just freeze as it is; power consumption etc, with one long ...
30
votes
6answers
14k views

Is it really a bad idea to leave an MCU input pin floating?

I've heard that leaving a pin floating on an MCU when configured as an input (vs. the default output) is bad for the pin, and can eventually cause it to fail prematurely. Is this true? N.B. in my ...
10
votes
6answers
8k views

How do I sample a -2 V to +2 V analog signal with a PIC microcontroller?

I am using a PIC micro with a 10bit ADC to take readings from an analog signal with a frequency less than 300 hz. However that analog signal is in the range of -2 V and +2 V. How can I condition the ...
32
votes
3answers
18k views

What resides in the different memory types of a microcontroller?

There are different memory segments to which various types of data are put into from C code after compilation. I.e: .text, .data,...
35
votes
2answers
30k views

Selecting a MOSFET for driving load from logic

I'm looking to drive a magnetic door lock from an Arduino. I've found a question about driving a solenoid from an Arduino, which includes a circuit that looks perfect for this kind of situtation: ...
42
votes
8answers
21k views

Why are relays so frequently driven by optocouplers?

Since the advent of the many microcontroller development boards, like Arduino, there have been a number of relay modules sold to drive mains AC loads. A lot of these seem to use an optocoupler, ...
9
votes
9answers
5k views

12V input on microcontroller pin

I'm trying to count pulses/sec. on a microcontroller pin in the ~5 to 100Hz range. The µC can operate at 5V input, so I have to get the voltage level down safely. A simple resistor comes to mind, yet ...
21
votes
4answers
11k views

Crystals and load capacitance

If a crystal has a rated load capacitance of 6 pF, is the right thing to do to put a 6 pF capacitor to GND on either leg of the crystal? I'm using it as the clock source (TOSC) for an XMEGA and it's ...
61
votes
3answers
102k views

What is a boot loader, and how would I develop one?

I've met many projects in which an AVR microcontroller uses with a bootloader (such as the Arduino), but I don't understand the concept very well. How can I make a bootloader (for any microcontroller)...
46
votes
2answers
65k views

STM32 Understanding GPIO Settings

In STM32 Standard Peripheral library, we need to configure the GPIO. But there are 3 functions which I not sure how to configure them; GPIO_InitStructure.GPIO_Speed GPIO_InitStructure.GPIO_OType ...
24
votes
7answers
38k views

Internal or external oscillator

I always use the internal oscillator that pics have as I have never found the need to run anything at higher frequency than 8 MHz (which is the fastest the pics I use tend to be able to go). Are there ...
47
votes
7answers
45k views

How do I measure a negative voltage with a ADC?

I am working with a PIC micro-controller with inbuilt 10bit ADC and want to measure a voltage in the range of -1 to -3Volts. I thought of using an op-amp in the inverting mode to make voltage positive ...
32
votes
11answers
21k views

I'd like to learn how to make my own USB gadgets

I've been writing Linux character device drivers for other people's stuff for some time. I'd like to find a new hobby and the thought of making my own USB gizmos seems really neat. I would be ...
39
votes
4answers
13k views

How to synchronize two microcontrollers to micro-second accuracy?

I need to synchronize two micro-controllers so that they can measure the speed of propagating waves. The time delay measurements need have microsecond accuracy (error less that 1/2 of a microsecond). ...
4
votes
3answers
3k views

12 hours delay with ATmega16A

I am trying to turn on a LED for 5sec every 12 hours. I tried: ...
12
votes
3answers
9k views

Control 220V AC line using MCU

I want to switch ON and OFF an incandescent bulb using MCU. Please suggest an electric switch (like relay or something) for 220V 50Hz AC line which can be used here. I would prefer something very ...
11
votes
5answers
7k views

How to Measure Power Consumption on Extremely Low Power Devices?

This might be old news in a half a decade or two but by today's means, I am referring to electronic prototypes and designs which would draw in a μA (uA) and even nA range of current. Some recent MCUs,...
5
votes
2answers
3k views

Level shift circuit MCU to MOSFET

I have a H-bridge that is being supplied by 12V and using around 10A. I am turning it on/off with a microcontroller that has an output of 0V-5V. The switching frequency is "super low" so the gate ...
6
votes
3answers
13k views

What is the best way to estimate the power consumption of an Atmega328p microcontroller?

I'm currently working with a barebone Atemga328p microcontroller implemented within a battery powered design. I've realized I'm pretty clueless on how microcontrollers are rated on power consumption. ...
79
votes
11answers
14k views

What's the cheapest way to link a few microcontrollers wirelessly at low speeds over short distances

What's the cheapest way to link a few microcontrollers wirelessly at low speeds over short distances. I'm looking to keep it ultra-cheap, use common discrete parts and keep it physically small. I don'...
37
votes
5answers
84k views

FPGA's vs Microcontrollers [closed]

I've worked on the Arduino family (specifically the Sanguino), built a few simple devices and a simple phototrope. I am thus pretty comfortable with microcontrollers - specifically Atmel's. I'm ...
19
votes
10answers
91k views

What are the cheapest microcontrollers?

What are the cheapest microcontrollers available? This would be in volumes over 1000, though hobbyist availability would be nice. I'm looking for the cheapest of all microcontrollers - my ...
49
votes
16answers
59k views

Why use PLC instead of microcontroller?

Why does everyone use PLCs in industrial environments, instead of a microcontroller based solution? For a longer task, the PLC program is as complicated as a microcontroller program. A ...
19
votes
4answers
8k views

Wear leveling on a microcontroller's EEPROM

For example: The datasheet for ATtiny2313 (as do most Atmel AVR datasheets) states: 128 Bytes In-System Programmable EEPROM Endurance: 100,000 Write/Erase Cycles Imagine a program only requires ...
37
votes
5answers
4k views

Who receives the value returned by main()?

I know that in computers, value returned by the main() function is received by the operating system. But, what happens in the ...
4
votes
3answers
44k views

Transmitting a video stream through a microcontroller's wifi

I'm working a a project that currently works well but this year we want to expand it by collecting data from it, independent of its current functions. We have set up an iPad App to control an Arduino ...
14
votes
3answers
24k views

What is the minimal set of parts for a circut with this AVR microcontroller?

My Arduino Uno has a ATMEGA328P-PU microcontroller, and bunch of other stuff on the board. I'd like to program the chip without the Arduino software, and only the minimum of other components. I want ...
9
votes
2answers
23k views

Driving LED strip from microcontroller

I want to drive a strip of LEDs from a microcontroller using PWM to control the brightness. The strip I have takes about 1.5A at 12V. I'm only familiar with purely low power digital electronics so ...
17
votes
4answers
17k views

How critical are UART frequencies?

I'm going to be using an 8 MHz crystal to run my microcontroller at 16 MIPS (PLL 4x, 2 cycle instructions.) However, 8 MHz doesn't divide into any UART frequencies AFAIK... so how critical are these ...
6
votes
7answers
12k views

Multiplexing Inputs on a microcontroller

I have a 4 way DIL switch that I use to provide input to a microcontroller, and I need to free up a port to use for something else. Is there a way to multiplex 4 inputs into 3 microcontroller ports? ...
1
vote
3answers
2k views

Driving LED with PIC 5V

I have always been taught to driver an LED using an MCP using the following method (Driving the pin high) as shown in the diagram below: However I have recently seen LED's being driven using the ...
47
votes
20answers
86k views

What is a good microcontroller for Ethernet applications?

What is a good microcontroller for doing Ethernet applications? Or do I just need a good Ethernet library to connect with an Ethernet MAC/PHY?

1
2 3 4 5
15