New STM32F103ZET6 development board with 3.2″ TFT Touch LCD

New development board have just arrived. Thought it would be nice to push things more towards ARM cortex-M3 playground.

Continue reading

Running multiple FreeRTOS tasks on AVR

In previous post we just run a single task. Running RTOS with single task has no meaning at all. This can be easily done with conventional program. But what if we need to have more separate functions. To execute them at exact timing would require separate timer or interrupt. But microcontroller cannot guarantee an interrupt for every tasks. This way it is hard to make code modular and testing can be painful. Using RTOS solves this kind of problem. It allows programming each task as endless loop. Kernel scheduler takes care of assuring each task gets it’s chunk of processing time. Additionally it does bearing the priority systems – more important tasks are executed prior to less important ones.

Let us go further with our example code and add more tasks to our FreeRTOS engine. We already have LED flashing task that toggles LED every second. Additionally we are going to create another task that checks button state. Also we are going to send some information to LCD. As always lets take care of drivers for all of them. Continue reading

SMD soldering tutorial

SMD has entered hobby market long time ago, but there are still many people who afraid to push their projects to SMT level. Once you try it appears to be very easy – even easier than through hole PCB technology. Dave from eevblog have published series of PCB soldering tutorials where he goes through tools needed to make quality soldering, then through hole soldering tips and finally SMD component soldering.

In this video Dave carefully explains what main techniques (individual pin soldering, well based and drag) can be used to successfully solder SMD parts and what odds are awaiting for inexperienced players. If you don’t want to solder with iron, then you’ll see how it is easy to do this with solder paste and hot air gun.

So, take your time and see how it’s easy.

Using FreeRTOS kernel in AVR projects

FreeRTOS is known as Real Time Operating System. Probably it would be too dare call it real-time-os, rather a real time scheduler where applications can be split in to independent tasks that share full processor resources by switching them rapidly it looks like all tasks are executed in parallel. This feature is called multitasking.

There are lots of debates on using RTOS on AVR microcontrollers as they are arguable too small for running scheduler. The main limitation is small amount of ram and increased power usage. If you are gonna use lots tasks in application, probably you will run out of ram that is used for saving context when switching between tasks. Consider FreeRTOS only if you use larger scale AVRs like Atmega128 or Atmega256. Surely you can find smaller schedulers that are specially designed for smaller microcontrollers even tiny series. In other hand if you master FreeRTOS it can be used with multiple types of microcontrollers like ARM, Cortex, PIC and multiple compilers including IAR, GCC, Keil, Rowley, Attolic. And main reason to keep eye on it – its free.

Probably it would take lots of time and space to go through RTOS theory. Some great information can be found on FreeRTOS website itself. In this series of posts we are going to focus on practical side of using RTOS on AVR microcontroller. We will go through several steps from single task application to more complex solutions. Continue reading

Can and LIN bus interfaces in automotive electronics

Modern cars have more electronics than you can think of. Almost every important part has tons of sensors on it that has a dedicated computer called ECU (Electrical Control Unit). Usually there are from several up to hundreds of ECU’s on a single car. Especially luxury ones. All modules has to work as on organized unit. So this is where reliable connection interface needed.

Probably you’ve already heard of CAN bus (Controller Area Network). It is common bus interface used in most vehicles where board computer communicates with separate control ECUs taking care of engine, gearbox, climate, security alarm, safety bags. Talking of physical interfacing CAN devices are connected by using twisted pair signal wires that are resistant to noises. Signals usually operate at 5V level. Transmit/receive can be 1Mb/s for 40m cable lengths. Engineers have put lots of thought in to CAN protocol. It was designed to be flexible reliable and robust. There can be more than one master CAN device on same buss. So there can be situation when several masters would start communication. In this case there is a message priority used to determine which one will have right to transmit data. CAN nodes act as independent units and can receive any message and take act if needed. This feature is called ‘multicast’. This allows adding new CAN devices to existing bus without need to reconfigure existing setup.

CAN interface is quite complex interface allowing to have multiple masters what makes it robust and versatile. But due to growing cost of amount of electronics used in cars, manufacturers started looking for cheaper solutions that would complement the CAN bus and be cheaper. So they came up with LIN (Local Interconnect Network) bus. LIN bus interface is simpler standard comparing to CAN. LIN can have up to 16 slave nodes controlled by one master. It is slower and cheaper as nodes are clocked by master (no crystals for each node). LIN can be simply implemented as sub-function in CAN LIN interface USART RISC microcontroller. While CAN transceiver is complex device so it usually comes as separate peripheral or as separate chip. LIN uses single wire for communications with about 40V signal voltage level. It can reach up to19.2kbps communication speed with maximum 40m length of line.

After this short overview it is obvious that LIN interface is low band, less effective bus interface comparing to CAN. In other hand where efficiency isn’t as ‘must’ factor it serves as cheap complement to CAN network.

Fresh microcontroller projects from Cornell University ECE 4760

It’s a tradition each spring to keep checking for a new batch of microcontroller projects from Cornell University ECE 4760 class. And here they are – 31 new project with new ideas and designs.

They are still using WinAVR/GCC programming tools for their projects. So it’s still good news for hobbies to search for code snippets, implementations. Among all projects you will find projects like portable automated web-based bird trapping mechanism, cool Rock-Paper-Scissors Sensor glove game or even human tracking fan system that should be useful in upcoming summer time. So take your time, and enjoy the great work collection.

Getting hands on Arduino Ethernet Shield

 

Updated! Arduino Ethernet code

Since last Arduino Ethernet code there we several Arduino IDE releases with changes that affected the code listed in this post. Due high interest, we updated it with minor changes that makes it work as expected. The biggest occurred because Wstring.h library isn’t no longer in use, because String.h library is included in core that brings some difference in several functions used in code.

In code we need to write

readString += c; instead readString.append(c);

if(readString.indexOf(“L=1″) >0) instead if(readString.contains(“L=1″))

Also we need to re-import Ethernet.h library in order to bring along all necessary libraries like Client.h, Server.h, SPI.h, Udp.h.

The other problem occurred when program run was that LED actually never lights up when checkbox is selected. I used Serial.print(c); to track down the problem. And it seems that method GET sends two strings:

Our code was catching and analyzing both strings. We only need to take string where parameter is sent: “GET /?L=1 HTTP/1.1” and skip “GET /favicon.ico HTTP/1.1”. As our example is very simple we can see ,that second string lacks “?” symbol. So we check the string if there is a ‘?’ symbol, of not, skip whole analyze.

And last fix is applied to LED checkbox. Now it stays checked if LED is ON. Hope you find these changes useful.

Here is a code listing:

#include <SPI.h>
#include <Client.h>
#include <Ethernet.h>
#include <Server.h>
#include <Udp.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 0, 110 };			// ip in lan
byte gateway[] = { 192, 168, 0, 1 };			// internet access via router
byte subnet[] = { 255, 255, 255, 0 };                   //subnet mask
Server server(80);                                      //server port
byte sampledata=50;            //some sample data - outputs 2 (ascii = 50 DEC)
int ledPin = 4;  // LED pin
char link[]="http://www.scienceprog.com/"; //link data
String readString = String(30); //string for fetching data from address
boolean LEDON = false; //LED status flag
void setup(){
//start Ethernet
  Ethernet.begin(mac, ip, gateway, subnet);
//Set pin 4 to output
  pinMode(ledPin, OUTPUT);
//enable serial datada print
  Serial.begin(9600);
}
void loop(){
// Create a client connection
Client client = server.available();
  if (client) {
    while (client.connected()) {
   if (client.available()) {
    char c = client.read();
     //read char by char HTTP request
    if (readString.length() < 100)
      {
        //store characters to string
        readString += c; //replaces readString.append(c);
      }
        //output chars to serial port
        Serial.print(c);
        //if HTTP request has ended
        if (c == '\n') {
          //dirty skip of "GET /favicon.ico HTTP/1.1"
          if (readString.indexOf("?") <0)
          {
            //skip everything
          }
          else
          //lets check if LED should be lighted
        if(readString.indexOf("L=1") >0)//replaces if(readString.contains("L=1"))
           {
             //led has to be turned ON
             digitalWrite(ledPin, HIGH);    // set the LED on
             LEDON = true;
           }else{
             //led has to be turned OFF
             digitalWrite(ledPin, LOW);    // set the LED OFF
             LEDON = false;
           }
          // now output HTML data starting with standart header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
          //set background to yellow
          client.print("<body style=background-color:yellow>");
          //send first heading
          client.println("<font color='red'><h1>HTTP test routines</font></h1>");
          client.println("<hr />");
          client.println("<hr />");
          //output some sample data to browser
          client.println("<font color='blue' size='5'>Sample data: ");
          client.print(sampledata);//lets output some data
          client.println("<br />");//some space between lines
          client.println("<hr />");
          //drawing simple table
          client.println("<font color='green'>Simple table: ");
          client.println("<br />");
          client.println("<table border=1><tr><td>row 1, cell 1</td><td>row 1, cell 2</td></tr>");
          client.println("<tr><td>row 2, cell 1</td><td>row 2, cell 2</td></tr></table>");
          client.println("<br />");
          client.println("<hr />");
          //printing some link
          client.println("<font color='blue' size='5'>Link: ");
          client.print("<a href=");
          client.print(link);
          client.println(">Visit Scienceprog!</a>");
          client.println("<br />");
          client.println("<hr />");
          //controlling led via checkbox
          client.println("<h1>LED control</h1>");
          //address will look like http://192.168.1.110/?L=1 when submited
          if (LEDON)
          client.println("<form method=get name=LED><input type=checkbox name=L value=1 CHECKED>LED<br><input type=submit value=submit></form>");
          else
          client.println("<form method=get name=LED><input type=checkbox name=L value=1>LED<br><input type=submit value=submit></form>");
          client.println("<br />");
          //printing LED status
          client.print("<font size='5'>LED status: ");
          if (LEDON)
              client.println("<font color='green' size='5'>ON");
          else
              client.println("<font color='grey' size='5'>OFF");
          client.println("<hr />");
          client.println("<hr />");
          client.println("</body></html>");
          //clearing string for next read
          readString="";
          //stopping client
          client.stop();
            }
          }
        }
      }
 }

And you can download Arduino sketch ethtest.

Continue reading

Do you know all features of your scope?

Probably you found yourself in situation when you couldn’t get clear view of more complex signal on your scope. For instance it is pretty hard to synchronize packet data waveform. All you get is a mess on your scope screen. With analog scope it is almost impossible to get it while on Digital Storage Oscilloscope (DSO) you can store trace in memory and then analyze it. But this isn’t very handy. So there is a nice feature on most scopes which is called Trigger Holdoff. Check out this video tutorial from eevblog where Dave shares his thoughts about how this feature can be used in real life situations.

 

Let the robots take care of your garden

Take a look at this garden robot prototype so called Prospero. This is a pretty simple servo based hexapod robot that is equipped with gardening gear. The main idea is to develop a swarm of these robots that would perform tasks as a group. After it’s finished Prospero robots should perform series of tasks in farm starting with planting seeds, taking care and harvest. In following video you can see on phase – planting seed.

Robot is controlled by Parallax Propeller chip. Continue reading

Open Software Hardware Definition is finally here

We used to see lots of Open Software projects and they are really cool, because everyone can get involved in developing, improving and tweaking without paying a penny for right to do so. So finally we have first version of Open Source Hardware (OSHW) 1.1 definition ready. Everyone who is developing hardware project can proudly to include a logo and definition.

OSHW Eagle CAD symbols

Open Source Hardware Statement of principles sounds as follows:

Open source hardware is hardware whose design is made publicly available so that anyone can study, modify, distribute, make, and sell the design or hardware based on that design. The hardware’s source, the design from which it is made, is available in the preferred format for making modifications to it. Ideally, open source hardware uses readily-available components and materials, standard processes, open infrastructure, unrestricted content, and open-source design tools to maximize the ability of individuals to make and use hardware. Open source hardware gives people the freedom to control their technology while sharing knowledge and encouraging commerce through the open exchange of designs.

Full OSHW statement can be found here. Keep in mind that that this is a first release version of OSHW definition and there can be some amount of minor changes. Anyway base principle are clear enough to start using it. The exact logo isn’t selected yet, so there are several versions available. If you are looking one to add to your Eagle project you can check out Bens OSHW logos converted to Eagle PCB cad symbols.

Use it, Add logos to your design and be proud of making Open Source Hardware projects!

New on WinAVR Tutorial New on WinARM Tutorial