Controlling servo motor with AVR

Servo motor

Servo motors are a type of electromechanical actuators that do not rotate continuously like DC/AC motors. They used to position and hold some object. They are used where continuous rotation is not required, so they are not used to drive wheels. In contrast, they are used where something is needed to move to a particular position and then stopped and held there. The most common use is to position the rudder of aircraft and boats etc. Servos can be used effectively here because the rudders do not need to move full 360 degrees, nor they require continuous rotation like a wheel. Servos are DC motors with built-in gearing and feedback control loop circuitry. Most servo motors can rotate about 90 to 180 degrees. Some rotate through a full 360 degrees or more. Servos that can rotate 360 degrees are required mainly for building RC helicopters. Most commonly available servos have a three-wire connector. One wire supplies positive DC voltage – usually 5 to 6 volts. The second wire is for voltage ground, and the third wire is the signal wire. The receiver…

Continue reading

Accelerometer Interfacing with AVR

ADXL335 size

The article covers how to interface an accelerometer with the atmega32/atmega16. Before proceeding, the user must know the basics of ADC (Analogy to digital converter) of the AVR. An accelerometer is an electromechanical device that measures acceleration forces. These forces may be static, like the constant force of gravity pulling at your feet, or they could be dynamic – caused by moving or vibrating the accelerometer. Accelerometers are of two types Analog and Digital. In this post, we will be discussing Analog accelerometers. They give voltage as output which is proportional to acceleration. The digital one gives the PWM output or direct binary digital data

Continue reading

All you need to know about AVR fuses

avr crystal oscillator

AVR lock bits and fuses are one of the topics that may cause some confusion. If you missed something or set one bit wrong, it may lead to failure – bricking the whole AVR chip. So it is important to understand once and do things right. Even though datasheets give enough information about AVR fuses, many times, we feel somewhat unsure before executing the write command. Let us go through the main features of AVR fuses and lock bits so next time we would feel safe and get the expected results.

Continue reading

Introducing to STM32 ADC programming. Part2

After we had a quick overview of the STM32 ADC peripheral, we can dig deeper into specifics. To understand simple things, let’s go with the simplest case – single conversion mode. In this mode, ADC does one conversion and then stops. After the ADC conversion result is stored into the 16-bit ADC_DR data register (remember that the conversion result is 12-bit), then the End of Conversion (EOC) flag is set. An interrupt is generated if the EOCIE flag is set. The same situation is if the injected channel is converted. The difference is that the result is stored in the corresponding ADC_DRJx register, the JEOC flag is set, an interrupt is generated if the JEOCIE flag is set. In our example, we will measure the internal temperature sensor value and send it using USART. A temperature sensor is internally connected to the ADC1_IN16 channel. The algorithm will start a single conversion and wait for the conversion complete flag EOC. We will then read the ADC value from the ADC_DR register, which will later be used to calculate Celsius’s temperature value…

Continue reading