During the college days, we were thought how to use the 8051 microcontroller, as a student our biggest problem is how to burn our hex file to our chip. Until these days, this is still the problem of students in my school so I came up with an idea making a simple programer using my Gizduino (Arduino clone in the Philippines) lying around and writing a simple C# application to process the hex file. The 89s52 is the most common available in our place and the good thing is it can be programmed via its SPI port without needing high voltage to enter programming mode.

Programming the chip is not that difficult, we just need to issue series of commands as stated in the datasheet, the c# app will parse the hex file and what the gizduino will do is just to translate it to SPI commands, then voila we have our 8051 programmed in no time. The prototype is done using my general purpose digital trainer.

The Atmega 328/168 in the arduino is overkill for these purpose, I will port this later to a smaller and cheaper microcontroller.

The fun part Testing!

Since I was introduced to Class D amplifiers, I built several low power amps based on TI TPA3122D2 and TPA3123. I’m very satisfied with the results, one is used on our desktop PC and one on my brother’s motorcycle. There was a group buy at electronicslab.ph/forum of the DR100W Kit from 1DiyCentre and there are two excess kits, since my LM1875 was put to rest a few days back, I decided to take one of the two.

Here is my Project Log during the Assembly of the Kit

The PCB and Components

The surface mount components was presoldered on the board

The TDA8920BTH is in HSOP24 package, the pitch is not so tight still pretty easy to solder.

All components soldered except for potentiometer since I will use digital controls for these one.

Finally the heatsink installed

Testing and first impression of this amp will follow

I revived my old programmer for the AT89C2051 when a colleague asked help to program a device that requires this MCU. I made it first with a vero board, but I decided to give it a new look and put it on a PCB.

Single Sided Version

I made this programmer on a single sided PCB only with both thru hole and surface mount components which I have lying around.  This was originally made by Wichit Sirichote a few years back for his students but on a double sided PCB.

More info can be found on his website

My Project files including the firmware, loader, PDF, and Eagle Files can be downloaded here

One of the problems on building this programmer is how to solve the chicken-egg problem, because the master MCU needs to be programmed first. You must find a friend who owns a programmer or have it programmed somewhere else. If you are from the Philippines I may help you build this programmer. Enjoy!

The Microchip Pickit2 is one of the most hobby friendly PIC programmer in the market. It lets you program the chip within MPLAB and the most important feature is its USB connectivity. I used a JDM based programmer which confines me of programming with my desktop until I had my PIKIT2, electronicslab.ph version of the original pickit2. At work I am using a PICSTART plus programmer which annoys me because I cannot do on the fly update on the development board because I always have to remove the IC from the board then put it in the programmer back to the board so I made this quick simplified pickit2 from the parts I have.

Prototype

The original pickit2 requires a  680uH inductor and a 20Mhz clock, but I only have a 220uH inductor and a 12Mhz crystal so i gave it a try. I programmed the PIC18F2550 with the PICSTART within MPLAB, to use the 12Mhz crystal the PLL prescaler selection bit must be modified to divide by 3. This version of the pickit2 is a strip down version intended for hobbyist and students that do not require the progammer to go feautres, also DO NOT use this pickit2 version on 3.3V PICs since the part for adjusting target VDD is also taken out.

I tested it with another PIC18F2550 and voila! this programmer works like a charm even with a 12Mhz crystal and a 220uH inductor on the VPP circuit. This programmer was also tested with PIC16F628A, PIC12F609 and PIC10F202 without problems.

Schematic

The firmware of the PIC used in the programmer can be found on Program Files\Microchip\MPLAB IDE\PICKit2\PK2V023200.hex. The JDM programmer can also be used to program the PIC18F2550 for the first time, just dont forget to change the PLLDIV to divide by 3 when using a 12Mhz crystal, but when a 20Mhz crystal is used no need to changed anything on the PICkit2 firmware.

The serial port on our computers are with us for quite sometime now. It is more favored than the parallel port for interfacing with the outside world because it require lesser wires and can go farther distance and can even be used with newer technologies such as Bluetooth using its serial port capability. In this tutorial is a quick start guide in communicating with the serial port using VB.net without any previous knowledge.

Before we start, VB.net 2010 must be installed. The installer can be freely downloaded from Microsoft.

Start Visual Basic 2010 Express and you will be prompted with the Start Page Window

Select on New Project and select Windows Form Application and give the Project a name, in this case I named it Serial Port Interface.

A blank form will be displayed named Form1. This is the main form which will contain all other controls.

Click on the toolbox to show the  controls, you may want to click on the pin to disable the autohide feature

Click on the form and change its name to frmMain (for easier identification specially when adding more forms). Also, change its name, in this case VB.net Terminal – Philrobotics. This name will be the one that will be displayed on the title bar.  Since this program is only a small program, we can disable the Maximize button by setting MaximizeBox value on the form’s property to false.

Let’s start to add some controls to our form. From the common Controls, add (2) two labels, (2) two combo box and (2) two buttons. Change the text of the first label to “Com Port:” and the second one to “Baud Rate:”. For the combo box change its name to cmbPort and cmbBaud for the purposes of easier identification when we will add the codes to our controls. Also, change the text of the two buttons, the first to “Connect” and the second to “Disconnect” and change their name to btnConnect and btnDisconnect. As you can see, I use cmb and btn prefix to refer to combo box and button same reason as above, for easier identification.

Next, from the Containers add two Group box and change its text to “Transmit Data” and “Received Data”. Inside the Transmit Data group box, add a textbox and a button. Change the name of the textbox to txtTransmit and the button to btnSend, also change its text to Send. On the Received Data group box, add a Rich Text Box and change its name to rtbReceived. Lastly and the most important, add the SerialPort from the components.

Now, we come to the next part, adding the instructions to our program. To start coding double click the form or press F7 to view the code. To add a code to individual controls just go back to the designer view or press Shift+F7 and double click a control to add code into it.

For instance if we double click on the Send button on the designer view the Code Editor will take us to

Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click

On this Part is where we enter our codes.

End Sub

To complete our program put the following codes to the code editor:

‘Serial Port Interfacing with VB.net 2010 Express Edition
‘Copyright (C) 2010  Richard Myrick T. Arellaga

‘This program is free software: you can redistribute it and/or modify
‘it under the terms of the GNU General Public License as published by
‘the Free Software Foundation, either version 3 of the License, or
‘(at your option) any later version.

‘This program is distributed in the hope that it will be useful,
‘but WITHOUT ANY WARRANTY; without even the implied warranty of
‘MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
‘GNU General Public License for more details.

‘ You should have received a copy of the GNU General Public License
‘ along with this program.  If not, see <http://www.gnu.org/licenses/&gt;.

Imports System
Imports System.ComponentModel
Imports System.Threading
Imports System.IO.Ports
Public Class frmMain
Dim myPort As Array  ‘COM Ports detected on the system will be stored here
Delegate Sub SetTextCallback(ByVal [text] As String) ‘Added to prevent threading errors during receiveing of data

Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
‘When our form loads, auto detect all serial ports in the system and populate the cmbPort Combo box.
myPort = IO.Ports.SerialPort.GetPortNames() ‘Get all com ports available
cmbBaud.Items.Add(9600)     ‘Populate the cmbBaud Combo box to common baud rates used
cmbBaud.Items.Add(19200)
cmbBaud.Items.Add(38400)
cmbBaud.Items.Add(57600)
cmbBaud.Items.Add(115200)

For i = 0 To UBound(myPort)
cmbPort.Items.Add(myPort(i))
Next
cmbPort.Text = cmbPort.Items.Item(0)    ‘Set cmbPort text to the first COM port detected
cmbBaud.Text = cmbBaud.Items.Item(0)    ‘Set cmbBaud text to the first Baud rate on the list

btnDisconnect.Enabled = False           ‘Initially Disconnect Button is Disabled

End Sub

Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click
SerialPort1.PortName = cmbPort.Text         ‘Set SerialPort1 to the selected COM port at startup
SerialPort1.BaudRate = cmbBaud.Text         ‘Set Baud rate to the selected value on

‘Other Serial Port Property
SerialPort1.Parity = IO.Ports.Parity.None
SerialPort1.StopBits = IO.Ports.StopBits.One
SerialPort1.DataBits = 8            ‘Open our serial port
SerialPort1.Open()

btnConnect.Enabled = False          ‘Disable Connect button
btnDisconnect.Enabled = True        ‘and Enable Disconnect button

End Sub

Private Sub btnDisconnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisconnect.Click
SerialPort1.Close()             ‘Close our Serial Port

btnConnect.Enabled = True
btnDisconnect.Enabled = False
End Sub

Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
SerialPort1.Write(txtTransmit.Text & vbCr) ‘The text contained in the txtText will be sent to the serial port as ascii
‘plus the carriage return (Enter Key) the carriage return can be ommitted if the other end does not need it
End Sub

Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
ReceivedText(SerialPort1.ReadExisting())    ‘Automatically called every time a data is received at the serialPort
End Sub
Private Sub ReceivedText(ByVal [text] As String)
‘compares the ID of the creating Thread to the ID of the calling Thread
If Me.rtbReceived.InvokeRequired Then
Dim x As New SetTextCallback(AddressOf ReceivedText)
Me.Invoke(x, New Object() {(text)})
Else
Me.rtbReceived.Text &= [text]
End If
End Sub

Private Sub cmbPort_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbPort.SelectedIndexChanged
If SerialPort1.IsOpen = False Then
SerialPort1.PortName = cmbPort.Text         ‘pop a message box to user if he is changing ports
Else                                                                               ‘without disconnecting first.
MsgBox(”Valid only if port is Closed”, vbCritical)
End If
End Sub

Private Sub cmbBaud_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbBaud.SelectedIndexChanged
If SerialPort1.IsOpen = False Then
SerialPort1.BaudRate = cmbBaud.Text         ‘pop a message box to user if he is changing baud rate
Else                                                                                ‘without disconnecting first.
MsgBox(”Valid only if port is Closed”, vbCritical)
End If
End Sub
End Class

After putting all the codes we are now ready to compile our project. To do this go to, Debug -> Build SerialPortInterface.  If there are no errors, It will indicate Build Succeeded at the status bar.

The executable file of the compiled project is usually located at the bin\Release of the project folder.

To test if our program is working, short the TX and RX pin of your serial port and  press F5 or click on the green triangle. Each data that we send must also be received by our program. In my setup I’m using a USB-to-Serial Converter and is allocated at COM18.

[Updated] Downlink link for project source

Getting started with mobile robots, we definitely need a platform where we can fit the electronics of our robot and make it move. In this tutorial we will be making a cheap mobile robot platform from a toy commonly called as tumbling car here in the Philippines. It can be bought almost anywhere specially on Chinese discount stores at 40-50 pesos.

The Materials:

2 – Tumbling car

1 – Small screwdriver

1 – Side Cutter or small saw

1 – Super glue

 

Let’s get started:

First, unscrew the top cover by removing the two screws at the bottom side of the toy

Toys with top cover removed

Next, remove the wheels opposite the motor and the gearbox as shown

Trim down the shaft for proper alignment

Put super glue all around on one of the cars

 

Align and put them together

You may add a plastic or metal link for more strength and ruggedness against bumps like the one shown below

Wait for the superglue to dry and voila!, you now have a less than 200 Pesos robot platform in less than 30 minutes

A few months ago, members of electronicslab.ph conceptualize a Filipino Version of Robot Wars the D-Wars –>> Filipino Version of Robot Wars, open to students, enthusiast hobbyist and everyone else who is interested. Thus, I came up building my own autonomous sumo bot later I named Nemesis.

Specifications:

Processor: PIC16F628 at 8Mhz

Sensors: 2 E-gizmo IR Proximity Sensor Kit for enemy detection

2 IR reflective  Sensors for line detection

Powersource: 4x AA for Motors

1x9V for processor and sensors

Motors: Tamiya TwinGearbox Motors 204:1 Gear Ratio

Motor Driver: L293D

Front IR  Sensor Testing

Bottom IR Sensor Testing

The software is still in the infant stage and still many things to add specially on how it will attack its enemy.