background preloader

Secrets of Arduino PWM

Secrets of Arduino PWM
Pulse-width modulation (PWM) can be implemented on the Arduino in several ways. This article explains simple PWM techniques, as well as how to use the PWM registers directly for more control over the duty cycle and frequency. This article focuses on the Arduino Diecimila and Duemilanove models, which use the ATmega168 or ATmega328. If you're unfamiliar with Pulse Width Modulation, see the tutorial. PWM has several uses: Dimming an LED Providing an analog output; if the digital output is filtered, it will provide an analog voltage between 0% and 100% . Simple Pulse Width Modulation with analogWrite The Arduino's programming language makes PWM easy to use; simply call analogWrite(pin, dutyCycle), where dutyCycle is a value from 0 to 255, and pin is one of the PWM pins (3, 5, 6, 9, 10, or 11). Probably 99% of the readers can stop here, and just use analogWrite, but there are other options that provide more flexibility. Bit-banging Pulse Width Modulation Using the ATmega PWM registers directly

CapacitiveSensor by Paul Badger Download Download CapacitiveSensor04.zip This updated CapacitiveSensor version 05 adds support for Arduino Due and other non-AVR boards. Overview The capacitiveSensor library turns two or more Arduino pins into a capacitive sensor, which can sense the electrical capacitance of the human body. Version 04 adds support for Arduino 1.0, and fixes an obscure possible race condition with Tone, Servo and other libraries that perform I/O in interrupt context. Version 03 has been updated to C++ and supports multiple inputs. Applications Capacitive sensing may be used in any place where low to no force human touch sensing is desirable. A capacitive sensor covered with paper or other insulator also acts as fairly good (human touch) pressure sensor with an approximately logarithmic response. How it works The capacitiveSensor method toggles a microcontroller send pin to a new state and then waits for the receive pin to change to the same state as the send pin. Library Methods Resistor Choice

TinyGPS | Arduiniana A Compact Arduino GPS/NMEA Parser TinyGPS is designed to provide most of the NMEA GPS functionality I imagine an Arduino user would want – position, date, time, altitude, speed and course – without the large size that seems to accompany similar bodies of code. To keep resource consumption low, the library avoids any mandatory floating point dependency and ignores all but a few key GPS fields. Usage To use, simply create an instance of an object like this: Feed the object serial NMEA data one character at a time using the encode() method. You can then query the object to get various tidbits of data. Statistics The stats method provides a clue whether you are getting good data or not. chars – the number of characters fed to the objectsentences – the number of valid $GPGGA and $GPRMC sentences processedfailed_checksum – the number of sentences that failed the checksum test Integral values Values returned by the core TinyGPS methods are integral. Using Floating Point Date/time cracking Download

NewSoftSerial | Arduiniana A New Software Serial Library for Arduino News: NewSoftSerial is in the core! Starting with Arduino 1.0 (December, 2011), NewSoftSerial has replaced the old SoftwareSerial library as the officially supported software serial library. NewSoftSerial is the latest of three Arduino libraries providing “soft” serial port support. Without interrupts, your program’s design is considerably restricted, as it must continually poll the serial port at very short, regular intervals. Improvements NewSoftSerial offers a number of improvements over SoftwareSerial: It inherits from built-in class Print, eliminating some 4-600 bytes of duplicate codeIt implements circular buffering scheme to make RX processing more efficientIt extends support to all Arduino pins 0-19 (0-21 on Arduino Mini), not just 0-13It supports multiple simultaneous soft serial devices. *But see below for an important caveat on multiple instances. Using Multiple Instances What does this mean, exactly? Signal Inversion Library Version

High Performance Line Follower Robot: 12 Steps AdWords We use AdWords to deploy digital advertising on sites supported by AdWords. Ads are based on both AdWords data and behavioral data that we collect while you’re on our sites. The data we collect may include pages you’ve visited, trials you’ve initiated, videos you’ve played, purchases you’ve made, and your IP address or device ID. LiveRamp We use LiveRamp to deploy digital advertising on sites supported by LiveRamp. Doubleclick We use Doubleclick to deploy digital advertising on sites supported by Doubleclick. RocketFuel We use RocketFuel to deploy digital advertising on sites supported by RocketFuel. Twitter We use Twitter to deploy digital advertising on sites supported by Twitter. Facebook We use Facebook to deploy digital advertising on sites supported by Facebook. Sprinklr We use Sprinklr to deploy digital advertising on sites supported by Sprinklr. Dstllery We use Dstllery to deploy digital advertising on sites supported by Dstllery. Marin LinkedIn Demandbase Yandex AdForm Baidu Yahoo!

Ziegler–Nichols method The Ziegler–Nichols tuning method is a heuristic method of tuning a PID controller. It was developed by John G. Ziegler and Nathaniel B. Nichols. It is performed by setting the I (integral) and D (derivative) gains to zero. is then increased (from zero) until it reaches the ultimate gain , at which the output of the control loop has stable and consistent oscillations. and the oscillation period are then used to set the P, I, and D gains depending on the type of controller used and behaviour desired: The ultimate gain is defined as 1/M, where M = the amplitude ratio, and These 3 parameters are used to establish the correction from the error via the equation: which has the following transfer function relationship between error and controller output: Evaluation[edit] The Ziegler–Nichols tuning (represented by the 'Classic PID' equations in the table above) creates a "quarter wave decay". This tuning rule is meant to give PID loops best disturbance rejection.[2] References[edit] Bequette, B.

What would be appropriate tuning factors for PID line follower robot? 7.c. Advanced Line Following with 3pi: PID Control A more advanced line following program for the 3pi is available in the folder examples\atmegaxx8\3pi-linefollower-pid. Note: An Arduino-compatible version of this sample program can be downloaded as part of the Pololu Arduino Libraries (see Section 5.g). The technique used in this example program, known as PID control, addresses some of the problems that you might have noticed with the previous example, and it should allow you to greatly increase your robot’s line following speed. The proportional value is approximately proportional to your robot’s position with respect to the line. Here is the section of code that computes the PID input values: Note that we cast the variable position to an int type in the formula for proportional. Each of these input values provides a different kind of information. The values 1/20, 1/10000, and 3/2 represent adjustable parameters that determine how your 3pi will react to the line.

PID Control Line Follower Robot Overview One feature that most rover autonomous robots need is line following. The purpose of this project is to build a line follower robot and get started on learning PID controller in a fun way. Parts The robot function properly with two motors, the Rosbot Baseboard, and a 5-Channel sensor. Robot's frame: KittenBot Anodized Aluminum Chassis Cool and solid chassis that has tons of mounting holes (4.8mm LEGO Technic), you can definitely reuse this chassis for other fun projects. Robot's brain: RosBot Baseboard An Arduino UNO based mainboard with 2x on-board dual H-bridge motor drivers. Robot's eyes: 5-Channel IR Line-following Tracker Sensor 5-Channel Infrared detector, more accurate and stable. Step 1: Assembly This robot is fairly easy to assemble, follow the instruction and it takes you about 15 minutes. First, attach your motors to the sides of chassis, simply plug in the rubber wheel. Mount the 5-Channel IR sensor to the front of the chassis. Step 2: Wring Coding

PID Controller For Lego Mindstorms Robots A PID Controller is a common technique used to control a wide variety of machinery including vehicles, robots and even rockets. The complete mathematical description of a PID Controller is fairly complex but a much simpler understanding is really all that is needed to use a PID effectively. This document is a description of how to create a PID Controller for use with Lego Mindstorms Robots using the NXT-G programming language. It will be easier if we have an actual task in mind so I will describe how to create a PID to do line following. Once created, the same PID can be used, with only minor modifications, with any other Mindstorms application such as getting a robot that can drive as straight as possible, or even for a robot that can balance with nothing but 2 wheels touching the ground like a Segway. A PID is really pretty straight forward and the typical description of a PID is easily understood by anyone that has had Calculus. Lets try to fix that. y = mx + b y = mx or using our labels

Related: