From zero To hero

After a month of troubleshooting and testing. Some of motherboard need capacitor replacement. At last we have 6 computer that can be use to teach our student about Arduino programming. Hope they will survive to serve about 150 students. 13 to 15 student at a time. Really tight schedule I know.

We have no choice. That the only thing we have.  Six unit of "2003 NEC" pcs with dozen of illness. Most of hardisks from this unit are in very bad shape. some of them cannot be detected by Bios. Some of them cannot be boot by Cds (damage due to high humidity here in malaysia) . So we need to interchange the working cdrom just to boot the OS in RAM. We really need OS that can run without hard drive. Sad but true.  So we use Puppy Linux. The smallest OS for old PCs just to run Arduino 1.05. For almost no cost. Personally almost cried to witness LED blinking on arduino after compile and upload without problem. Unbelievable.

WDC 65C02

W65C02SXB - Single Board Computer By WDC

We decide to move ahead by stepping inside to the best MPU ever created by human. If not mistaken the first schematic are made by hand. (there is no computer back then). Just amaze how solid and powerful of logic and digital knowledge they have to get there. Remember that before Apple 1 there is no "personal computer" term. Never. The 6502 create by Chuck Peddle and Bill Mensch (mastermid of 6800 MPU by motorola) .  This microprocessor gained popularity because it was low price and became the hearts of some early personal computers including Apple II and Commodore 64COMDEX 96 honored the 6502 as the first of only seven microprocessors having the most impact on the Information Technology industry over the previous 25 years. Mr. Mensch, WDC’s Founder, was a recipient of this prestigious award on behalf of the 6502. The 65C02 is a low cost, general-purpose 8-bit microprocessor (8-bit registers and data bus) with a 16-bit program counter and address bus. The variable length instruction set and manually optimized core size are intended to make the 65C02 well suited for low power system-on-chip (SoC) designs. The first 6502 was introduced around 1975. If you wish to learn computer science deep into assembly and machine coding. This is the must have mpu in your lab. 

The following is a list of some of the pioneering products that the 65xx technology is remembered for:

Commodore KIM–1 Single Board Computer
Personal Computers    Apple II, Apple IIc, Apple IIe and Apple IIgs
    BBC Acorn Computer , Commodore PET, VIC20.

Video Games 
    Atari, Nintendo, Super Nintendo
    Hand–Held Electronic Publishing
    Franklin 's Digital Book System

    Rockwell modems
    General Instrument analog set–top boxes
    Micronas closed caption digital TV chip sets

    Micronas dashboard controllers

    Embedded Microprocessor Defibrillator’s

Introduction and Features
The W65C02SXB is an educational and industrial strength Engineering Development System based around the world renowned W65C02S 8-bit microprocessor.

With its vast, I/O provided by the on board W65C22 VIA, W65C21 PIA, and W65C51 ACIA peripheral ports the W65C02SXB provides the user with easy access to the vast flexibility while providing an open faced platform for teaching the relationship between Microprocessors and Peripheral IC’s. Students can explore I/O components and how to control them by applying real world Electrical Engineering principles. These principles will allow students to understand technology at a level which spans across all technologies.

All of the SXBs have built-in 32K bytes of SRAM for program and data storage and 128K bytes of FLASH memory organized as 32K byte blocks for easy switching between applications, tasks, or saving precious data. Unlike the Apple, Commodore, and Atari systems, no floppy or hard drive is needed. You are free to use the low power solid state memory in ways you only might have dreamed of before.

The FLASH can be written right in the socket or pre-programmed in a FLASH chip programmer. The memory contained in these small boards are equal to or greater than the memory of some of your favorite legacy systems that used the 6502 microprocessor.


W65C02SXB Tutorial 

We decide to make  step by step guide on how to setup this board. Yup nothing better than "hello world" by blinking of LED. The code are base on David Gray example "SIM_8LED_CCAH.asm". This is real challenge even if you are computer nerd and it took us 5 hour just to make this board blink. Actually they are not that tough and pretty simple. But we take wrong direction just for first 4 hour.

Before we go further please remember this guide are base on our computer setup as below
-Windows 10 (64Bit)
-Intel i5(7th gen)
-Ram 8GB

Step 1.
 Download WDCTools  2.1  (fill the form and they will send tools by email) and install the tools on drive C:/wdc

Step 2
Now take a look at TIDE.exe normally place inside --->  C:\wdc\Tools\bin. Before you click open TIDE (Terbium IDE ) make sure that you are running on compatibility mode. How to do that? Right click>properties>compatibility... set as below

Step 3
Do the same step on WDCDB.exe (Debuger and simulator).  The application that you watch in my video above.

Step 4
follow this video by WDC

CAD Trainee 2017

Technical Drawing Class
Just amaze how 14 years old student in technical class. Isometric drawing quite tough topic in this subject. They must use high level thinking to convert Orthographic to Isometric drawing.

Prototype testing with new improved code for fast respond. Sorry for poor video quality. :) pretty hard to bring all tools in the field test. cannot find a suitable tool yet. we lost the Hex screwdriver and one plier already..(found 5 days later. rusted already.. )

Testing a small prototype of 4AZ-UGV. Good luck guys!!

We are successfully track our robot on the field. Try to understand NMEA code from this gps click module from mikroelektronika. Very good signal reception when combined with active antenna. This board only use 3.3V. must be very careful. all pin are well labeled. We only need 4 pin out Rx, Tx, Gnd and 3.3v. Ship in well package with active antenna, header and colorful user manual. We plan to power up this UGV with Sabertooth motor driver from DimensionEngineering

Twelve student involve in Innovation and Design competition on september 2014. The competition encourages students to use higher order thinking (Hots), creativity and various strategies to design and build a great robot to compete with opponents.One of the biggest co-curricular activities under the Ministry of Education that emphasizes creativity and innovation among students through experiential learning interesting and fun. This is our UGV (unmanned ground vehicle) named  4AZ-UGV

Thanks David Jones for this amazing piece of technology. Ucurrent Gold. precision op-amp circuit designed specifically for measuring ultra-low currents. Design by David Jones from EEVblog. Ucurrent Gold will be used to help us to measure current for our  Ultra Low Current Flasher project.  Here is pre-test result for Ucurrent with our circuit..Guest what dang!!!! 15.2uA on sleep mode..our goal is to get <10uA on sleep mode.

Blinker is powered by two button cell. Here is the code in Mikrobasic

program blink_12f1840
' Declarations section 
TRISA = 0         ' set direction to be output
porta =0
  while TRUE
  LATA.b4 = 1
  Delay_ms(1)  ' 1 second delay
  LATA.b4 = 0
  Delay_ms(45)  ' 1 second delay
  LATA.b4 = 1
  Delay_ms(10)  ' 1 second delay
  LATA.b4 = 0
  Delay_ms(45)  ' 1 second delay
  LATA.b4 = 1
  Delay_ms(15)  ' 1 second delay
  LATA.b4 = 0
end asm
  wend              ' Endless loop

Mac 2 2014
Ultra Low Current Flasher with PIC12F1840. This is small scale project that only need 4 components. Its sound stupid maybe. But when it come to make LED blink for a few months or years. That is the great challenge.
Microchip Study area :
1. Sleep mode
2. Wake up from sleep
3. Deep sleep?
4. Watchdog timer
5. SMD for low weight and slim design
6. The best LED for this job?
7. 1.8V or 3V?
8. bellow 10uA average working current (how to measure that accurately)

hand sketch schematic

Proteus Drafting
 Dec 4th 2012

Here is the test without opto-isolator. if anything goes wrong I will fry my computer. first test for motor..very silent and working great.

We start to plan the next new project for more  professional quality simulator. Here is the 30% finish drawing.

May 28 2012
If you have a problem to download (as reported) you can e-mail me. thank you.

May 13th 2012
Budu 2dof v1.5 a.k.a Kubing 2dof v1.5 uploaded. Budu is the codename for this project when it first release 2 years ago. You can use same hardware schematic v1.4. For educational use only. read Disclaimer first.  You can use Kubing 2dof v1.5.hex as inverted pendulum controller if you like (stand alone without PC). Good luck!!---kubing 

Windows take about 2.09 milisecond to send 8 bit binary signal to controller at 19200 baudrate. even with  pause = 1 ms on USO software. That is the Windows hardware restriction for uart communiaction. 

April 15th 2012
Fix a few bugs in Budu 2dof v1.4. So the next release of Budu 2dof v1.5 will be here soon. Download link not available until the next release of firmware. Thank you for support and email. We are planning to start a new project to make it usable with android phone and tablet very soon. 

Dec 20th 2011

Here is my version of joystik/panel controller  

figure 1-1

PCB circuit figure 1-1 was created using Eagle Layout Editor that can be downloaded for free from CADSoft. However, this project used two layer pcb automatically generated using this software. There is still room for improvement to make the best controller. by adding a few expander port in the near future. Expander port is a type of chips produced by the Microchip company that is able to add up to 16bit switch. we can connect this chip using SPI or I2C. imagine if it is connected to 8 chip expander we get 8 x 16 = 128 switches can be controlled separately. Separate means we do not need a diode or a matrix column row system. each switch will be controlled by a separate bit. whether the toggle switch or push button switch.

Rotary encoder, widely known as a shaft encoder, is an electro-mechanical device that converts the angular position or movement to digital. Incremental encoder output provides information about the motion of the shaft is usually processed elsewhere in the information such as speed, distance, RPM, and position. In flight the rotary encoder is used in the autopilot controller, radio communication and so on. For now BuduFsx1643 has four rotary encoder input only. And will be added to the 16 channel according to current needs. I use the rotary encoder EC16B2410408 ALPS brand available at RScomponent or Element14 store. In addition BuduFsx1643 has 16 digital inputs and 3 analog input. This chip has an analog input 12bit resolution or 4095 step. 

I have Logitech GT wheel which only has throttle and brake pedals. so with 3 analog inputs of this controller. I can take advantage of it to build a clutch pedal with 12bit resolution.

Here is Another great microchip project link

NOV 13th 2011

Figure 1-2a

Figure 1-2b

The Figure 1-2a shows a 2dof v1.4 project. It use USB connection directly without any converter chip such as FTDI or MAX232. It is the result of very extensive code modifications from the original project. This project uses PIC18f2550 and some other components. Very easy to build and requires only 30 minutes to solder. There are three variable resistor which is used to adjust Proportional, Intergral and Derivative. Included with two LEDs on board. red light indicates a connection established and the blue led to show incoming data. I think a simple circuit will reduce the risk of connection errors.

As I have stated all the MCU requires special programming tools to enable us to burn the code into its memory. I use pickit3 or icd3. you can also make your own programmer if you have time, but are advised to buy at any electronics store like mouser or rscomponent. USB programmer for as low as USD20 is 10 times better than the DIY programmer. Do not misunderstand. Because this is only based on my experience

PID algorithm inside kubing controller

What is PID? Old day technology use On Off switching to control the system. The on-off controller is the easiest possible way of control. Many technical systems use it, not limited to controlling a motor.  Refrigerator, heater, water pump usually use this system. But more complicated system its not going to work as we aspect by using this technique. The idea behind feedback control is very simple. We have a target speed, specified by the user or the computer program, and we have the current actual speed, measured by the sensor (hall, encoder, pot, etc). Measurements and actions according to the measurements can be taken very frequently(t).

The easiest way of control is not always the end of the story. A more sophisticated of controller and industry standard is the PID controller. It base on proportional, an integral, and a derivative control part. The controller parts are introduced in the following sections individually and in combined operation.

Proportional is the simplest term. The error is multiplied by the proportional gain,The amount of correction applied to the system is directly proportional
to the error.
'kP term....
              P1 = Kp * DIFF

P math in C code (embedded)

1    e_fungsi = v_target - v_drive; // error function //
2    z_motor = Kp*e_fungsi ; //motor output

Integral term is calculate the "historic" error in the system in fixed period of time. How long the motor need to move from point A to B? How to set the timer overflow in microcontroller is not as easy as in P and D term. If we set the timer overflow too fast from what they need to compensate the error and the system will not going to stable. The integral gain must be thoroughly tested before implementation to any PID systems. Its not as simple as I term =  gain * sum.
output = (kp * error_value) + (ki * integral) + (kd * derivative); 

The idea for the I controller is to reduce the steady-state error of the P controller. With an additional
integral term, this steady-state error can be reduced to zero.

I math in C code (embedded)

3 e_fungsi = v_target - v_drive;
4 z_motor = r_old + Kp*(e_fungsi - e_old) + Ki*(e_func+e_old)/2;

Derivative term is based on the rate at which the system is changing. Sometime it can be extremely aggressive when it is acting on the error of the system. In my case I make it adjustable to reduce the aggressiveness of this term. Similar to the I controller, the D controller (derivative controller) is rarely used by itself, but mostly in combination with the P or PI controller. The idea for adding a derivative term is to speed up the P controller’s response to a change
of input
'kD term......             

errdelta = DIFF - errprev
d1 = kd * errdelta
drive = d1 + p1

15 sept 2011 

Understanding DOF in simulation system (long story short)

In three dimensions, the six DOFs of a rigid body are sometimes described using these names:
  1. Moving up and down (heaving) = The yawing along the vertical Z-axis;
  2. Moving left and right (swaying);
  3. Moving forward and backward (surging) = Rolling along the longitudinal X-axis;
  4. Tilting forward and backward (pitching) = Sway along the lateral Y-axis.;
  5. Turning left and right (yawing);
  6. Tilting side to side (rolling).
All movement will be measure accurately with motionnode sensor like the one we use here. motionode hardware provides real-time orientation, accelerometer, gyroscope, and magnetometer data. you can study the source code by downloading the Software Development Kit (SDK).

Sept 9th 2011
Figure 1-3

The Green board on Figure 1-3 is pololu motor driver. It has the VNH2SP30-E chip full bridge motor driver intended for a wide range of automotive applications. The device incorporates a dual monolithic High-Side drivers and two Low-Side switches. The High-Side driver switch is designed using STMicroelectronic’s well known and proven proprietary VIPower™ M0 technology that allows to efficiently integrate on the same die a true Power MOSFET with an intelligent signal/ protection circuitry. This package, specifically designed for the harsh automotive environment offers improved thermal performance thanks to exposed die pads. Moreover, its fully symmetrical mechanical design allows superior manufacturability at board level. The input signals INA and INB can directly interface to the microcontroller to select the motor direction and the brake condition.

Sept 7th 2011 

Finally Kubing 2DOF with USB CDC (virtual com) done. Using a PIC18F2550. Instruction shown below are for Windows Vista. Just Follow a yellow guide for setup.


Kubing 2dof USB Setup finish. Sometime X-sim can't detect virtual comm so you need to manually add "\com1"  or "\comx" in the listbox above. 

Kubing 2dof V1.3b (June 9th 2011) The new and improve version come with status Rx led and much faster motor respond. Its should work well without limit switch.

*Gear indicator with F1 style rpm indicator for rfactor MMG..code and schematic Uploaded. Click here
Inverted Pendulum Project

Inverted pendulum on buggy 

The derivative term is crucial in order to bring the inherently unstable system into stability. In any PID control the derivative terms acts as an anticipator. By checking the current error against the previous error, the controller
can tell if the error term is getting bigger or smaller. If the error term is getting larger, the derivative term
adds to the output of the controller much like that of the proportional and integral terms, but to a lesser effect. If
the error term is getting smaller, this term will subtract from the output of the control in anticipation of an overshoot
condition. Without the derivative term the system will always be unstable because there is no way to compensate for the overshoot condition.

KUBING 2DOF V1.1 (March 31th 2011)

After a month of testing and tuning on my inverted pendulum buggy I have found that by adding suppression caps to the POTs will drastically reduce the noise problem. This update applicable to all pots in my schematic. But only VR1 and VR2 shown.

kubing controller on test


Pict. Above. Old Oscilloscope shows PWM output response to X-sim sofware. Will upload more accurate reading by using PicoScope 3200.

2dof setup and schematic

Download 2DOF hex code.. 
Kubing 2dof V1.3b (June 9th 2011) Code available upon request. I wish to have a respond from the users of my project. So that I can improve the code to get a better result. You can contact me for that. The new and improve version come with status Rx led and much faster motor respond. Its should work well without limit switch.

More info about programmer and usb

PIC-Ready1 with ftdi chip from Mikroelektronika seems to be a great choice since they have a great support forum and discussion about the board they produce. You also can use this board for various of project.

OR Built your own using this schematic

compitable with polulu motor driver..
more info about wiring here.
* Improve circuit with noise supression here

Click on image to enlarge. With adjustable kD schematic. Video show you how important adjustable kD in simulator and how they overcome oscillation problem in high kP setting.

Overview of methods

There are several methods for tuning a PID loop. The most effective methods generally involve the development of some form of process model, then choosing P, I, and D based on the dynamic model parameters. Manual tuning methods can be relatively time consuming, particularly for systems with long loop times.

The choice of method will depend largely on whether or not the loop can be taken "offline" for tuning, and on the response time of the system. If the system can be taken offline, the best tuning method often involves subjecting the system to a step change in input, measuring the output as a function of time, and using this response to determine the control parameters

While PID controllers are applicable to many control problems, and often perform satisfactorily without any improvements or only coarse tuning, they can perform poorly in some applications, and do not in general provide optimal control. The fundamental difficulty with PID control is that it is a feedback control system, with constant parameters, and no direct knowledge of the process, and thus overall performance is reactive and a compromise. While PID control is the best controller in an observer without a model of the process, better performance can be obtained by overtly modeling the actor of the process without resorting to an observer.

PID controllers, when used alone, can give poor performance when the PID loop gains must be reduced so that the control system does not overshoot, oscillate or hunt about the control setpoint value. They also have difficulties in the presence of non-linearities, may trade-off regulation versus response time, do not react to changing process behavior (say, the process changes after it has warmed up), and have lag in responding to large disturbances.

The most significant improvement is to incorporate feed-forward control with knowledge about the system, and using the PID only to control error. Alternatively, PIDs can be modified in more minor ways, such as by changing the parameters (either gain scheduling in different use cases or adaptively modifying them based on performance), improving measurement (higher sampling rate, precision, and accuracy, and low-pass filtering if necessary), or cascading multiple PID controllers.
only one channel for beta testing...I want to hear feedback from you..picture attachment would be nice. (you need microchip programmer...)

Unfortunately there is no telling how it will change other then it will not be the same model used in the iPad 2. This isn’t much of a story as the iPad 3