RS-485 interface for connecting multiple devices

RS-485 is an updated version of the RS-422 interface. It is designed to communicate between multiple devices connected to a single data line. Standard allows connecting 32 transceivers to the data line. This is achieved by using tri-stable drivers that are separately programmable. This allows only one device to work at a given time. Resistors used in the circuit are so-called termination resistors for matching the transmitter and receiver impedances to avoid reflections. The matching resistor depends on the cable used but is 120Ohm.

Continue reading

RS-422 interface basics

RS-422 is a standard for serial data transfer similar to RS-232, but it uses the difference between two lines (RS-232 uses a reference to ground). RS-422 uses twisted pair (difference pair) to represent the logic level. Such data transmission type is so-called balanced transmission as it is not referenced to ground. This is a noise-proof solution because the same noise affects both lines, which are differentiated out. This allows carrying data at much longer distances at higher data transfer rates. RS-422 can transmit data to up to 1200metters. The maximum transfer rate can be 10Mbits/s. 120Ohm resistor acts as a terminal resistor that removes reflections, that may occur during transmission over long distances. Voltage levels between twisted pair lines are 4V and between transmission lines is 12V. RS-422 can be compatible with the RS-232 interface by simply connecting the negative wire of the twisted pairs to the ground.

Continue reading

Quick start using WinARM

WinARM is a collection of GNU tools for the ARM MCU family packed by Martin Thomas that works on MS Windows. WinARM is developed by inspiration on the WinAVR project, and it is effortless to start working with it if you had a chance to try WinAVR. WinARM doesn’t depend on Cygwin, or MinGW-environment like GNUARM tools do. WinARM toolset is compiled to work with most ARM microcontrollers, including the LPC2000 series, Atmel’s ARM microcontrollers, and Analog devices ARM microcontrollers. Basically, tools should work with any microcontroller with ARM architecture.

Continue reading

Dealing with switch bounce problem

Normally any embedded system has relations with the real world. The simplest and most common way is using buttons. This is how applications interact with humans. But real-world like a human is not perfect. Practically mechanical contacts bounce (turns on and off repeatedly for a short period). And you cannot do anything about it. There is no need to look for higher quality buttons or try special button construction or even try to press the button precisely for simple applications. It is better to deal with it wisely. In digital circuits, there may be used special circuits like triggers, RC circuits, etc. But when working with microcontrollers, there is simpler to remove bouncing by adding a couple of code lines. Usually, switches bounce for less than 20ms; bigger ones may take up to 50ms.

Continue reading

Use neural sensors to build smart sensor systems using microcontrollers

Neural networks are a broad topic. But this small example demonstrates how to create a primary neural sensor that takes resistive readings from multiple sensors and multiply it by weight factor and then sum the results. Results are compared to a three-level threshold. Without going too deep into neural networks, we can say that neural cell thresholds are similar to natural biological neurons. For instance, pain levels: itch is a low pain level while burning sensations are combined with cold and warm feelings. Neural sensors can operate in the same way. Let’s take typical neural sensors, which consist of two inputs with some weights and three outputs. Depending on the threshold level that the sum of inputs gives – we have an output signal on three outputs.

Continue reading

Build your own AVR JTAG ICE clone

After unsuccessful attempts to run a few programs which drive peripherals like USART and Timers on Atmega128, I decided to make a JTAG debugger. I hope it will allow me to see what is happening may atmega128 corrupted, or something is wrong with the software or hardware. The most widely used AVR JTAGICE clone is AVR miniICE, which is compatible with the original AVR JTAGICE. AVR JTAG is mainly used for target board debugging in the real world. And of course, you also can program your AVR’s with it.

Continue reading

Function calls and stacking of parameters in embedded systems

Usually, when you write C programs for microcontrollers, you use functions that can be called any time in the main program or another function. The compiler compiles these functions as subroutines. These functions can be called from the main function or other functions – this is called nesting (nested subroutines). If you see the compiled program’s listings, you will see that subroutines are called by using the call or rcall keyword. The argument of this instruction is a subroutine address that will be executed on the next processor cycle. Call instruction also writes return address from function to the stack to continue the program after returning from the function.

Continue reading

Build Piconomic Atmega128 development board by yourself

First of all, I have ordered to make PCB by using a milling-drilling plotter. Of course, I could make the board by myself, but I wanted to save some time and nerves in case of errors. After one week my board was shipped to me: Then I bought all parts needed. One thing that didn’t go well was that I couldn’t get capacitors and resistors in SMD packages 0603, so I used 0805 to lie on the side.

Continue reading