background preloader

Arduino

Facebook Twitter

Interrupts in C++ An ideal C++ device driver would be a class containing, among other things, the ISR as a member function.

Interrupts in C++

But this is harder to achieve than many C programmers assume. One of the goals of a recent project was to evaluate the effectiveness of C++ in writing low-level device drivers. With a push to reduce time to market, we were given a budget large enough to order some nice object modeling tools. Everyone in the team was experienced in using C in embedded systems. We also had a smattering of C++ experience in non-embedded applications. We designed and coded some nifty Timer and UART drivers in C++. We ran into a snag, however, when we tried to write interrupt handlers.

Arduino

Rotary encoder interrupt service routine for AVR micros « Circuits@Home. Encoder ISR About a year ago, I posted an article about 2-channel rotary encoder interfacing with MCU using lookup table.

Rotary encoder interrupt service routine for AVR micros « Circuits@Home

With its linear program flow, inherent noise immunity and small processing requirements, this method produces extremely efficient code. The article attracted quite a bit of attention with many interesting comments and several code modifications. Today, I want to demonstrate slightly different way of reading the encoder – via interrupt service routine (ISR). I’m currently involved in a project built with QP Event-Driven Real Time Framework running on 8-bit AVR micro.

I am developing for custom built AVR-based board and all code snippets are pasted directly from project files. The code consists of two main parts – initialization and interrupt service routine. The snippet comes from 3 different parts of the code. The interrupt service routine looks very much like the one explained in the article linked to at the beginning of this post. Hardware debouncer Oleg. Reading rotary encoder on Arduino « Circuits@Home. Rotary encoder connected to Arduino Quadrature rotary encoders, also known as rotary pulse generators, are popular input devices for embedded platforms, including Arduino.

Reading rotary encoder on Arduino « Circuits@Home

Several rotary encoder code examples are posted on Arduino site and elsewhere, however, they treat encoder as a pair of switches, adding decoding/debouncing overhead. For many years, I used an algorithm based on the fact that quadrature encoder is a Gray code generator and if treated as such, can be read reliably in 3 straight step without need for debouncing. As a result, the code I’m using is very fast and simple, works very well with cheap low-quality encoders, but is somewhat cryptic and difficult to understand. Soon after posting one of my projects where I used rotary encoder to set motor speed i started receiving e-mails asking to explain the code. The hardware setup can be seen on title picture. ATTiny USI I2C Introduction - A powerful, fast, and convenient communication interface for your ATTiny projects!

I2C, it's a standard that's been around for around 20 years and has found uses in nearly every corner of the electronics universe.

ATTiny USI I2C Introduction - A powerful, fast, and convenient communication interface for your ATTiny projects!

It's an incredibly useful technology for us microcontroller hobbyists but can seem daunting for new users. This tutorial will solve that problem, first by reviewing what I2C is and how it works, then by going in-depth on how to implement I2C in Atmel's ATTiny USI (Universal Serial Interface) hardware. Guide to Arduino and AVR Communications. If you spend any time playing with Arduinos, ATtinys or looking at AVR spec sheets, you soon encounter a bewildering smörgåsbord of acronyms for various communication protocols.

Guide to Arduino and AVR Communications

With examples such as I2C, LIN, SPI, TWI, USI, etc., it can get pretty confusing. If you don’t believe me, just take a look communications column for Digikey’s listing for the ATmega series chips. Confused yet? What do these terms mean? How do you choose the chip that meets your needs? Communication Protocols The SPI (Serial Peripheral Interface) is the protocol used by the ICSP (in-circuit serial programming) facility transmitted over the ubiquitous 6-pin (2×3 pin) header used to program AVR chips.

The Serial Peripheral Interface Bus or SPI (pronounced as either ess-pee-eye, spy or simply S.P.I) bus is a synchronous serial data link standard, named by Motorola, that operates in full duplex mode. This protocol is known as both I2C (Inter-Integrated Circuit) and as TWI (two wire interface). And many more. Two Wire. NewSoftSerial  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.

This means that if you have 1.0 or later, you should not download this library. To port your code to 1.0, simply change all NewSoftSerial references to SoftwareSerial. NewSoftSerial Library, for an extra serial port. NewSoftSerial, by Mikal Hart, emulates an additional serial port, allowing you to communicate with another serial device.

NewSoftSerial Library, for an extra serial port

Download: NewSoftSerial10c.zip Hardware Requirements UART Serial should always be used, if possible. NewSoftSerial imposes substantial CPU usage requirements. Only use NewSoftSerial when a second serial port is absolutely necessary. NewSoftSerial requires pin change interrupts for reception, which are only available on certain pins. Basic Usage. Corrupt output/garbage from the ATmega328p. Hi everyone, I'm hoping someone here can help me with an issue I'm experiencing with the serial output from the ATmega328p on my GertDuino.

Corrupt output/garbage from the ATmega328p

First things first, my setup is a RPi Model B, NOOBS 1.2.1, Raspbian with a 16GB SD card. I've gone through the setup process detailed in the excellent GertDuino user manual and can successfully program and run the example programs (both raw C and Arduino sketches), see for more info. A beginner’s guide to connecting and operating the WiFly to Arduino Serially. We were working on a home automation project , we used the wifly gsx in our project .When we bought it, we thought it will be easy to communicate it like a serial modem between the arduino and PC ,,, of course we are not noobs :) but every inch in the datasheet made us feel like one :)And when we searched for a solution for even one of our countless problems we faced.... the result can be summarized in three words ...

A beginner’s guide to connecting and operating the WiFly to Arduino Serially

WIFLY NOT WORKING or we are noobs :D Of course i am kidding :) ,,we are not noobs and wifly is WORKING :o , thanks to sparkfun wifly library and We decided to start our new virtual hackerspace with this easy step by step tutorial for wifly :Please post any problem you faced with wifly or arduino . boolean initSettings() WiFly.SendCommand("set wlan auth <value>","AOK"); //WiFly.SendCommand("set wlan key <value>","AOK"); Arduino/hardware/arduino/avr/libraries/SoftwareSerial at master · arduino/Arduino.