Turn-key PCB assembly services in prototype quantities or low-volume to mid-volume production runs

Prepare GNUARM compiler toolchain for Windows

GNUARM is a toolchain for developing ARM microcontroller projects based on open source compiler GCC. GNUARM works on windows (requires Cygwin), Linux and MacOS. GNUARM doesn’t have any GUI, but you can adapt any GUI that supports commands from command line. One of good project is WinARM where you get all tools needed in one package. Thiswill be discussed later. GNUARM package consists of the GNU binutils, GCC compiler set and debugger (Insight for Windows and Linux, GDB only for MacOS). Newlib is used for the C library. With GNUARM yo uhave ability compile C and C++ programs.

Continue reading

Dealing with switch bounce problem

Normally any embedded system has a relations with real word. Simplest and most common way is using buttons. This is how application interact with human. 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. And for simple applications there is no need to look for higher quality buttons or try special button construction or event try to press button precisely. It is better to deal with it wisely. In digital circuits there may be used special circuits like triggers, RC circuits and so on. But when working with microcontrollers there is simpler to remove bouncing by adding a couple lines of code. Usually switches bounce for less then 20ms bigger ones may take up to 50ms. Buttons in embedded systems may cause a number of problems like: Rather reading value ‘A’ microcontroller may read ‘AAAAAA’; When button released it bounces two – this may look like button vas pressed again after release. To avoid this use simple routine: Read a pin; If switch were detected – wait for 20ms and then read pin again; If second reading confirms the first…

Continue reading

Oscillator frequency and code speed

One of important questions you ask when considering microcontroller project is wat oscillator frequency to choose. Usually it depend desired level of performance. In general application speed is directly determined by oscillator frequency. If you double the oscillator frequency, the application will rin in double speed. But wee do not compare different processors by frequency, but by other quantity – MIPS (Million Instructions Per Second). Why it is so? Because different MCU require different clock cycles for performing one operation. For instance AVR microcontrollers require 1 (some 2) clock cycles for one instructions while Intel 8051 microcontrollers require a minimum of 12 oscillator cycles. So if Clock frequency is 12MHz then 8051 microcontroller will work at performance of 1 MIPS. AVR microcontroller which uses 12MHz crystal will work at about 12 MIPS. But do we always need maximum performance? Many developers like to select maximum oscillator value that is supported by selected MCU. For instance if Atmega128 supports 16MHz frequency, then many people automatically choose values near to this value. Sometimes it is bad practice because: Many applications do not require high level of performance that microcontrollers can provide; In many CMOS based MCU there is almost linear relation between…

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 which takes resistive readings from multiple sensors and multiply it by weight factor and then sum the results. Results are compared to 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 level of pain 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 one of three outputs. Let us build real-world neuron with two inputs and three outputs. As a sensor, I will use potentiometers which can be replaced by photocells or temperature sensors. According to these two sensor readings, a neuron can have three states: low medium high This could be like low light, medium light and high light, o low temp and so on. If you decide to put neuron to your robot, this could…

Continue reading

Sample routine of working with LPT1 port under windows XP in CPP language

This is simple routine of sending and reading of byte from LPT1 port under Windows XP. LPT port has four types of pins: 8 output pins accessed via the DATA Port 5 input pins (one inverted) accessed via the STATUS Port 4 output pins (three inverted) accessed via the CONTROL Port The remaining 8 pins are grounded Now we are interested in Data pins. Set up driver according to post: Acces LPT and COM ports easily under windows NT-2000-XP. I have written and compiled example under DEV-CPP tool-set, which you can download from https://www.bloodshed.net/. Start New console project Create new cpp file and save it to project directory. Also copy porttalk_IOCTL.h and pt_ioctl.c files to project directory. These files you will find in the package portalk22.zip. Test program: Compile this program and run it. You should see results like this: Now it is time to connect your microcontroller and start experimenting. Good luck. Test routine project files for DEV-CPP are here:LPT1 Sample Project

Continue reading

Program LPT and COM ports easily under windows NT-2000-XP

If you are working with embedded projects usually you have concerned about how directly control computer ports like LPT or COM. Basically no one wants to mess up with driver writing or reading tons of documentations in order to send some bytes via IO port to your target board. Earlier when DOS, win95 and win98 operating systems were popular accessing I/O ports was easy as there weren’t any protections – simple code could do the job. Under NT/2000/XP situation is different. These operating systems has strict control of I/O ports. Read more about this here: www.beyondlogic.org. If you will try to access ports directly under windows XP, then you will get error mesage: How to solve this problem without writing your own driver and without rewriting old DOS or win98 programs. Well there is a solution that allow you to run programs under windows 2000/XP and talk to ports directly. Download PortTalk program from www.beyondlogic.org. Now you have two ways of running programs – but don’t forget to read porttalk.pdf which is included in package. Solution No.1 Download portalk22.zip and unzip it in separate folder somewhere. Then copy allowio.exe directly to the directory where is you program which you want…

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 JTAG debugger. I hope it will allow me to see what is happening may atmega128 corrupted, or something is wrong with the software or with hardware. The most widely used AVR JTAGICE clone is AVR miniICE, which is compatible with original AVR JTAGICE. AVR JTAG mainly is used for target board debugging in the real world. And of course, you also can program your AVR’s with it. To build this board is very ease as its schematic is simple: AVR_JtagICE Schematic List of materials you will need: Amount-Type-Title 2-470R-R1, R2 1-10K-R3 2-22p-C7, C8 6-100n-C1,C2,C3,C4,C5,C6 1-LED-G-D1 1-LED-R-D2 1-ATmega16L-DD1 1-MAX3232-DD2 1-7.3728 MHz-Q1 All secret in its firmware, but don’t worry – it is ready to go. AVR MiniICE has the following properties: Is compatible with AVR JTAG ICE; It is capable of debugging and programming Atmega microcontrollers with JTAG interface; Real-time debugging support; Regular updates of firmware to support new types of AVR; Upgrades can be done directly from AVR Studio; Power supply from 2.6 to 6V; Connects to AVR Studio through COM port; Two LED indicators (Power and Connect). Now…

Continue reading