Archive

Archive for the ‘programming’ Category

Fixed Time Loop in Microcontrollers

March 31st, 2011 No comments

Hey.

Most of the times I am developing a piece of code for my PICs, there is a main loop in the flow. The code repeats it self indefinitely doing its thing and it is only interrupted temporarily by the hardware interrupts of the PIC. Now most of the times a simple while(1) { // code here } will do just fine. However, sometimes your need that loop to start at specific time interval for example every half second. This is pretty useful when somewhere in your maths you need a specific dt. Read more…

Incoming search terms:

  • oscilloscope screen png (1)
  • set_timer0 (1)
  • time loop in interrupt (1)
  • time loops microcontroller (1)
  • timed loop microcontroller (1)
Categories: electronics, programming Tags:

Plans for my first line following robot

November 7th, 2010 No comments

Hi there. Now that some obligations are out of the way I am back to my drawing board :)

I am thinking of building a line following robot. Hmmm “simple” you might think. Well, maybe but it depends on what you are aiming for. You see the whole concept of the line following competitions is to keep the task simple. This way, you can concentrate on building the robot doing exactly that, as good as possible. As a result, you have many robots trying to do a “simple” (its not that simple actually) task but each one is programmed differently with smart twists, in an effort to be quicker than the rest.

Moreover, you have to keep in mind that a robot is the unification of different sectors (mechanical, electronics, electrical…) into one functional unit. Every part of the robot should work as expected, in order for the robot to function correctly as a whole. For example, the chassis of the robot. How big it should be? big is heavy, small is light but not much room for your electronics. Where do the motors go on the chassis? How will you mount them? Then you have to think about what kind of motors to use, how much torque, rpm, power, consumption do the have? Then you have to think about your electronics, about motor driver, the MCU and other stuff you might need. Then comes the programming part. How can you tell a robot to follow a line? After you figure that out, how can you do this process efficiently, giving you the best result relative to speed.

Anyway, sorry if I confused you or that didn’t make much sense. I just wanted to say that building a robot (even to do a simple task) is a multi-skill process. Don’t be afraid though, I am not saying you have to be an expert to do it. Just some careful thinking before buying your components. Sit down with a pencil and a piece of paper and write how you would build such a robot. Divide your design to the sectors we mentioned above. Try to learn from the designs that other people have done (but don’t copy them, otherwise the purpose is lost) and try to isolate each problem and deal with it.

For example, I had some hard time figuring out how to build my chassis. After some looking around I decided that for now, the cheapest and quickest solution, is to make my designs on google’s SketchUp and transfer it onto thick PVC.

Sometime soon I will start my construction and I will keep you posted.

Incoming search terms:

  • line following robot plans (5)
  • how to make a simple line follower robot com (3)
  • simple line following robot blueprints (3)
  • blueprints of a line follower robot (2)
  • Blue prints of line follower robot (1)
  • simple line follower (1)
  • robot follows line plans (1)
  • plans for a line following robot (1)
  • plan line follwer robot (1)
  • My first line following robot! (1)
Categories: electronics, programming Tags:

Simple Serial User Interface on PIC

March 30th, 2010 No comments

So today I needed to control some stuff on my PIC by using the terminal on my PC through RS-232 serial. I want to control the speed on 2 motors connected to the PIC, either separately or both of them together. To do that I divided the tasks that the User Interface (UI) had to provide. So from the main menu the user should be able to choose to control

  • Motor A
  • Motor B
  • Both Motors

In each of the sub-menus shown above the user should have some choices for acting on the motors. Before complicating this stuff more, I will show you the method I used to create this simple menu on my 18F2525 PIC. It doesn’t matter if you don’t have this PIC or even any other microcontroller. The concept is the same.

If you try to tackle the problem an if-then-else structure may seem like an easy solution but I can tell you it is going to messy pretty soon! We need a more clear, robust solution. But first let’s see what we need to do.

PIC User Interface Layout

The image pretty much explains it all. If we are at Main Menu the only valid keys are 1, 2 or 3. Each leads to a new sub menu. From there, there are again three choices 0 that takes us back to Main Menu and + or - that will need to take an action (colored green). So if we implement this menu you will be able to implement more complex ones based on the same concept.

I got this idea based on Finite State Machine concept but its not quite right so we cannot call it like that! Anyway. Each of the menu item (Main Menu, Motor A, Motor B, Both Motors), is a different state in the program let assign them 0,1,2,3 accordingly. So if we are at state 0 we can go to state 1,2 or 3 with the right key pressed in the terminal. However if we are at state 1, we can only go back to state 0 or stay at the same state and complete some actions (forwards, backwards) with the right buttons pressed, once more.

So the way to implement this is by using switch/case. I think it will be much clearer if I show you the code. First let’s see how to we switch between the states. Read more…

Incoming search terms:

  • pic user interface (3)
  • 18f2525 (2)
  • serial user interface (2)
  • pic32 ui (2)
  • serial pic programmer interface (1)
  • serial interfacing of pic microcontroller in mikroc (1)
  • pic32 serial (1)
  • pic32 fsm (1)
  • pic24f user interface (1)
  • pic18 rs232 menu (1)

How to install Box2D for BlitzMax

December 11th, 2009 7 comments

Well, generally when a deadline is approaching I tend to lose focus from work :D . Well having one close deadline, today I remember to refresh my BlitzMax knowledge! BlitzMax is a 2D game development environment that I bought some years ago. If you are interested on 2D game programming you should check it out. When I was doing my research, I found it to be at the exact abstract level that I needed it to be, hiding enough details from the ‘boring stuff’ and at the same time having great flexibility. Read more…

Incoming search terms:

  • how to install box2d (30)
  • box2d install (13)
  • box2d for blitzmax (3)
  • install box2d (3)
  • box2d blitzmax (2)
  • install box2d ubuntu (2)
  • how to use box2d with blitzmax (1)
  • install 2d box (1)
  • install box 2d (1)
  • blitzmax box2d install (1)

How high is too high?

October 26th, 2008 No comments

Hello boys and girls.

A common question I come across quite often, is from a where a beginner should start his/her microcontroller programming adventure. I remember myself wondering exactly the same thing when I was starting out, not too long ago. So which is the best to program? Assembly or C or Basic or… ?

Well I am going to give you my opinion and how well it worked for me. Let’s face it, knowing what is going under the hood is the best experience anyone can get working on any kind of project. If you know exactly how the system works, then you will be able to squeeze every last drop of juice the microcontroller has to offer. Read more…

Categories: electronics, programming Tags: