## Arduino Tutorial: Digital scale

In the previous post has been written about the calibration of load cell sensor for measuring the thrust ofpropeller and the motor/engine. In a posting has been found a constant magnitude of the sensor output voltage per gram about 0.267012014. So every 1 gram increase in weight of load will raise the output voltage of the sensor about 0.267012014 mV.

In my project, this output voltage must be converted into digital numbers using the ADC on the Arduino Nano. Henceforth, the data is sent serially to the PC to be displayed in the monitor. PC programs used in visual basic 6. As a development, in terms of measuring the thrust, required the measurement results are presented in graphical form.

## What about the working principle of the Arduino program ?

1. At just the Arduino turn on, will assume the load is 0.
2. Arduino will sent periodically value of ADC to the PC every 200mS.

As written in previous posting, I will design and make a test equipment to measure the thrust of propeller and the motor/engine in aeromodelling parts. This measure will help to design rc model, such as fixed wing and multicopter. Before designing a total airframe, need to know first the characteristics of the motor/engine and matching propeller size. I used the load cell with specifications was written on this posting. My load cell is 15Kg of full scale with output voltage about 2mV/V. I used the amplifier capable to gained up to 1000x with source 5V for load cell reference voltage. This mean will give output about 10mV in full scale of 15Kg load.

## How to a simple calibrate  ?

Since I do not have the standard weight of high-priced, this way is simple to use a digital scale which has an accuracy of about 0.1gram and can measure up to 1Kg. Next, weigh any load with digital scale, record the result. Then move to the load cell and measuring with a digital voltmeter on the load cell amplifier output voltage.

 Photo of digital scale Photo of Load cell 362.2 gram 105.1 Volt 528.5 gram 151.8 Volt 63.5 gram 19.8 volt 275.9 gram 80.7 volt 34.1 gram 11.7 volt 14.7 gram 6.1 volt 30.2 gram 10.6 volt 130.2 gram 39.1 volt 40.4 gram 13.2 volt 101.2 gram 30.7 volt

Plot data using SCILAB

The commands to plot the datas using SCILAB as follow:

->weight = [362.2,528.5,	63.5,275.9,34.1,	14.7,30.2,130.2,	40.4,101.2]
weight  =

362.2    528.5    63.5    275.9    34.1    14.7    30.2    130.2    40.4    101.2

->volt=[105.1,151.8,19.8,80.7,11.7,6.1,10.6,39.1,13.2,30.7]
volt  =

105.1    151.8    19.8    80.7    11.7    6.1    10.6    39.1    13.2    30.7

->size(weight)
ans  =

1.    10.

->size(volt)
ans  =

1.    10.

->plot(weight,volt,'ro-.')

->xgrid

->ylabel("Loadcell amplifier output (mV)")

Will result a graph as follow:

## How much’s the output voltage of amplifier at zero load ?

On zero load output voltage at zero load is 2.8mV. My amplifier can not adjust to 0.0 volt, because there null offset voltage. On arduino using 10bit adc with 5V ref, will convert into (2.8/5000)*1024 =  0.57344 less than 1, or will known as 0 decimal.

## How to calculate voltage per Kg or mV/Kg ?

From the above data, I would find the average value using Microsoft Excel, will be obtained as follows:

So output voltage of amplifier will be: 0.267012014 mV/gram or 267.012014 mV/Kg.

The output amplifier according to specifications from 0 up to 4.3 volts. So that the maximum load that can be read are: 4300/267.012014 = 16.104Kg, near specification of loadcell about 15Kg.

| Tagged , , | 2 Comments

## Servo BMS-385DMAX on tricopter replaced with MG945 servo

Tail servo on tricopter using airframe of version 3 , which has been written here,  actually can not work normally because of an accident as I have written here. I’ve replaced the servo of BMS-385DMAX with the MG945 servo from towerpro.

Actual size of the servo is too big and strong torque. But since I have had it before, I have to put it on tricopter. I still maintain to use a mechanical thrust vector system, because it has proven very robust and sturdy. This mechanical system uses direct coupling. Later I will add the coupling between the servo and mechanical axis, servo axis is not easy to shake. Thus if an accident occurs on the tail tricopter, the servo will not be exposed to strong pressure.

## Selamat datang mesin bor frais

Aku saat ini sangat bersyukur, apa yang aku inginkan untuk memiliki mesin bor frais telah terkabul. Semenjak aku memasuki bangku kuliah S3 Tahun 2008, aku nampak mencintai proses produksi metal, sehingga aku bisa melakukan pekerjaan menggunakan Mesin Bubut (Turning Machine), Milling Machine/Frais, Arc Welding, Boring/Drilling. Semua itu aku lakukan karena berharap agar proses pengerjaan disertasi tidak menghabiskan uang yang besar, karena dapat aku lakukan sendiri sesuai keinginanku.

Namun sampai saat ini Riset disertasiku tentang robot lengan industri mangkrak sejak 2011, karena putus biaya. Aku bersyukur kepada Tuhan YME, ternyata ada alumni yang peduli dan rela memberikan hadiah sebuah Mesin Bor Frais. Aku sambut dengan riang gembira, karena aku memang berangan-angan untuk memiliki mesin ini.

Mudah-mudahan dapat memperkuat riset disertasiku dan juga memperkuat hobiku tentang aeromodelling. Karena aku bercita-cita kelak dapat memproduksi pesawat aeromodelling dengan murah agar dapat dinikmati semua kalangan di negeri kita yang tercinta. Amin ya rabbal alamin.

## My tricopter design

This tricopter airframe design using wood blocks to the size 0.5cmx1.5cm. Each arm uses two beams of wood tied together with plastic spacers. Arm length about 47cm measured from the center axel of motor to the CG. To make more tricopter look beautiful, I added a canopy made of styrofoam 6mm. The addition of this canopy, from the flight test results add stability while sliding.

## Need stick trimming on tricopter

When there are not balanced lifting on tricopter when you raise the stick thrust around 50%, you need to setup an offset in the yaw , ailerons and elevator sticks on your radio. Or do the trim setup on the radio. Because on my radio use firmware ER9X, i use the offset which on the available menu of ER9X firmware.

In my case, my tricopter right arm is too strong a driving force, the channel of “AIL” necessary  offset to the right, the left arm thrust needs to be raised. But will result in ‘yaw’ towards the right, thus in the channel of  ”RUD” should be offset to the left.

## Tricopter flight testing in the field’s University of Brawijaya

This time, I tested my tricopter in field’s University of Brawijaya. I enjoyed it, and tricopter very stable. Battery capacity prevented me from playing much longer time. Less than 5 minutes tricopter flying, battery alarm was sounded, as a sign tricopter must go down to the runway. I will order the LIPO about 6000mAH, later.

## Specifications

1. Frame size:Arm size, Motor axel to center about 47Cm. Motor axel to motor axel about 82Cm. Height about 19Cm.
2. Brushless motor:3 x DT750, drive with 20A ESC.
3. Propeller:1 CW 11×4.7 + 2 CCW 11×4.7
4. Controller:KK Board ATMega 168
5. Power:LIPO Turnigy nano tech 50A, 2200maH
6. Weight:Total 1290gr

## Arduino tutorial: How to turn on/off 8 LED using visual basic 6

I will share my experience about how to turn on and off 8 leds through the widget made using visual basic 6. I am using visual basic 6 because the file is not large and light program execution.

# How its work ?

8 pieces led Arduino connected to a digital channel from D2 .. D9. Each LED in series with a resistor about 120Ohm is connected to GND. Thus each led will turn of  in a logic 1.

## Arduino program

On the Arduino board, was created a program to accept the character as a command to turn off and turn on each LED. Command of the character of 1,2,3,4,5,6,7,8, used to turn on or turn off each LED on arduino board as toggle function. Other characters as  command of “*” character serves to turn on all LED. The character “-” to order all led to turn off.

Each character as commands are sent serially to the Arduino board. Thus,  the Arduino will send back all conditions of leds in string form., for example, “10101010″. The character “0″ means the condition of the LED is die and vice versa “1″ is alive.

## Variable and serial event

As a global variable is “charCmd” defined as byte to hold a character as a command that sent from the PC. Variable of ccmdOk defined as boolean is a flag to mark that character just received from PC. The special variable is stateLED defined as char. This is for holding the state of 8 LEDs in bit for each LED.

The serialEvent() function is event interrupt of microcontroler. This function by default on arduino will call automatically if just completely receive a char from RX pin. If the character has been received from PC, the result will be stored in the variable of “charCmd”, then flag of “cmdOk” is set to “true”.

## Functions

Two functions are made to treat the LED on the Arduino board are:

1. setLED()
Serves to turn on or turn off each LED corresponding to logic of each bit in the variable conditions of stateLED. Line 28, is looping to get each bit of stateLED variable. Every bit of stateLED variable, is tested using bitRead function(). Thus, written to digital channel of arduino. The status of each led is sent to serial and received by PC as hanshaking or display status.
2. invertLED()
This function serve to invert the logic of each bit on stateLED variable, indexed  by n variable. This function have one passing parameter to point each bit on stateLED variable.

## Setup() function

This initialization are open serial using 115200baud and making D2 to D9 as output, also all LEDs turn off. For shortened codes, i used loop of for() statement and variable of d is used as index of digital channels that to be connected to LEDs.

## Loop() function

The loop functio () checks if there are characters that is sent by the PC. If the variable cmdOk = true, then there are characters received from the PC is stored in the variable of charCmd. Next tested whether the character is ’1′ to ”8′, ‘*’ or ‘-’. If the character are  ’1 ‘to ’8′, will call the function of invertLED, means reversing the logic of each bit on variable of stateLED. If the character is ‘*’, stateLED will be assigned to 255 (all LEDs will be turned on), ‘-’ stateLED will be assigned to 0 (all LEDs will be turned off).

## Widget of visual basic 6

I made this widget by using Visual Basic 6. You can install directly to a computer to download the setup program by clicking here. Or you can download the source program by clicking here. Do not forget to include the name of program creator, and web link on your project.

## Demo

Posted in Arduino, Tutorial | Tagged , , | 14 Comments

## Arduino tutorial: 8 LED simple flasher using lookup table

This program is a development of previous post. This uses the table as a data storage pattern of the LED and the constant of the delay.

To save the patterns and the delay led to use of variables and dataDelay dataFlasher as a array of byte and integer. This table will be placed in the microcontroller program code permanently.

DataFlasher variable is a data sequence of LED patterns, written in binary format for ease verification of the pattern. While the variable  of dataDelay is a data constants of each led patterns as passing parameter for the function of delay(). As dummy load, on the end of data of dataDelay variable is set as null. This is for mark that no data after it.

Inside the function of loop() get any data for led pattern, which is in dataFlasher variables to be sent to each bit of LED (D2 to D9). On line 49 is masking of lsb of current dataFlasher and sent to led with d variabel as channel of digital port. Next on line 50, variable of i to be right shifted for the next bit.

The next data is taken, until dataDelay = 0.

Posted in Arduino, Arduino, Tutorial | Tagged , | 4 Comments

## Arduino tutorial: 8 LED simple flasher using looping

Examples of Arduino program here that has just been posted here. Simplified the program by adding a loop instruction that is: for ().
Because the digital pin to 8led is D2 .. D9, then the instruction pinMode (), digitalWrite, and delay () can be inserted into the looping of for() instruction.
More programs like the following:

Program can be explained as follow:

1. On setup(), using looping for() defined n variables as series 2,3,4,5,6,7,8,9. thus, Inside looping of for(), function of pinMode() and digitalWrite() instructions executed for pin of digital as number of 2,3,4,5,6,7,8,9.
2. Inside function of loop(), each led of digital pin turn on about 100ms. Thus do not need to write down instructions repeatedly, for each LED.

Once the compiled binary code becomes smaller when compared to the previous tutorial.

Having executed the same result as the following video.

## Arduino tutorial: 8 LED simple flasher

Here I will explain how to make a simple 8 LED flasher. Of course the program is made very simple logic, using very little instruction as the lesson.
Instructions used are:

1. pinMode ()
2. digitalWrite ()
3. delay ()

With three kinds of instruction can make a simple flasher 8led.

Open the program code in the Arduino IDE, the program can be described as follows:

1. First defined the digital pin for the LED 1 .. 8, using the instruction: int LED1 = 2, meaning that using a pin LED1 D1 (digital channel 1). Similarly to other LED uses the same instruction.
2. In the function setup (), define each pin as an output LED1 .. LED8 with instructions: pinMode (). Also all led made turn off using instruction: digitalWrite (LED1, LOW), as well as for the other led.
3. The loop function (), each LED is turned on for 100ms, with instruction in sequence:
digitalWrite (LED1, HIGH);
delay (100);
digitalWrite (LED1, LOW);
Same for the other led to change their variable LED2 … 8.

## How to change reponses of throttle stick on ER9X firmware for tricopter

Previously, I was driving my homemade tricopter with a linear throttle response settings. For me this is too linear response caused when the throttle is reduced, tricopter down quickly.

I tried to change the response of the throttle stick to using the curve. I am using the firmware ER9X flysky radio that has this facility.

I let the Expo remains 0%. I try to just affect the throttle response, and make it more comfortable to pilot. Rapid response is made from low throttle 0-50%, at 50% above the response is reduced.

Throttle curve setting as in the video below.

## Tricopter maneuvers testing in futsal field

This time I test my ability as a pilot of tricopter. Also aims to test the stability of tricopter made by me. I’m still too difficult to control and often disoriented when I was not behind tricopter. I tried doing the twist slowly, with a combined roll and yaw stick. Finally I can do though is often disoriented.

## Tricopter hover test

I try to test again my handmade tricopter on hover performances.

## Introduction to the Arduino

Here will be explained about Arduino for beginners. For the programming hobbyists in hardware using microprocessor or microcontroller, the Arduino is an easy choice to make the program like the computer platform programming.

On computer programming, relations with the hardware for input/output is not necessary to memorize the pin numbers of the hardware.  If you are on a microcontroller environment, must know the pin number that will be used for input/output. Furthermore it should understand the basic philosophy of how to treat the pin.

Arduino is an IDE for programming microcontroller in order to develop the software as well as computer software development environment.

Easily obtained using arduino IDE, among others:

1. The programming language used was C / C + + or combined with the assembly.
2. Microcontroller pin numbers are known as fixed by classifying digital or analog channels. Any microcontroller with a label known for Dx to digital, analog to Ax, where x is the channel number. Thus you do not need to remember pin numbers on the microcontroller used.
3. Programs that have been made using Arduino, can be easily applied to other microcontroller which is recognized by the Arduino. The program does not need to be changed, simply change the configuration of the microcontroller’s used.
4. To add a new library can be built easily by using C / C + + or combined with the assembly. To integrate with the Arduino program, with enough to include the header of library that will be used. Thus very easy to integrate libraries made by the contributors for use by other users.
5. Very easy to compile, there are two upload menu to compile and upload, verify menu to compile it. Library search process is done automatically.

### How to start ?

Learn to start applying the Arduino, I recommend to you to have an Arduino board first. Avoid advance to make an Arduino board from microcontroller chip. For first, begin to learn programming with a simple application. Many types of Arduino board, more details you can click here.

Next, you must install the Arduino IDE, you can get for free by downloading here. I assume you have a nano to use a microcontroller ATmega328 board. More details about the specifications of this board you can see here.

Connect the Arduino with a USB interface on your computer, then run the Arduino IDE by clicking on the icon’s arduino. The first time you have to choose a board that suits you use. For that, click the menu: Tools-> Board.

Every time you change the type of the Arduino board, you must change the configuration of the appropriate board in the Arduino IDE. Most important is the type of microcontroller used and the frequency used must be matched on this configuration by typing menu.

Examples of program “blink” will appear as follows:

The logic of the program can be described as follows:

1. There are two default functions, there are two setup() and loop() and must exist in the program. Setup () function as program initialization before the loop() function is executed.
2. Loop() function is a substitute for the function main() in C programming language in general. The difference of this function will perform a continuous loop when the end of code is executed.
3. The code in line 11 is initializing channel digital channel 13 (D13) as output. This channel is connected to the LED on the Arduino board type nano.
4. At block loop () there are 4 lines of program code, line 15 is writing of logic one to D13. And will turn on LED, because there are pulldown series by resistor.
5. Line 16, execution of time delay function with parameter passing 1000 as 1000ms or 1 second. This means that the LED will be turned on for 1 second.
6. Line 17 is writing of logic low to D13. And will turn off LED.
7. Line 18 similar with line 16, will executed time delay function about 1 second. This means tha LED will be turned off for 1 second.
8. Go to line 15 again, because loop() will executed as looping.

To compile and upload to the board nano is very easy just click the upload icon.

## Tricopter fitted with a canopy becomes more stable

I have tricopter flight test as it has been posted here, be fitted with a canopy. Tricopter face becomes more beautiful and graceful. Once I tried to flight test, different looks, performance becomes more stable, especially if the thrust me down became not come down quickly because there is an air cushion.

I plan to add wings to the arms in front to look more beautiful. Or may increase the stability of the aileron.

# Flight test

## Flight test of tricopter using ver. 3 airframe

In this post about tricopter testing using a airframe design of version 3. Regarding the design of the airframe of ver 3 was designed by me, I have posted here. But some  modifications has been made to reduce the high vibration, by releasing the motor protection is made of fiberglass. Furthermore, the motor is placed directly above the tip of the arm, fastened with bolts and Rivet.

This is an experience of second time as pilot, I can fly tricopter with confidence to the stable with no accidents.

## Specifications

1. Frame size
Arm size, Motor axel to center about 47Cm. Motor axel to motor axel about 82Cm. Height about 19Cm.
2. Brushless motor
3 x DT750, drive with 20A ESC.
3. Propeller
1 CW 11×4.7 + 2 CCW 11×4.7
4. Controller
KK Board ATMega 168
5. Power
LIPO Turnigy nano tech 50A, 2200maH
6. Weight
Total 1290gr

## Build the Arduino board using ATMega8/168/328 chip

This post is for who want to learn Arduino but a thin pocket to buy a relatively expensive Arduino board. Or for those who really love the person who tinkers electronic hardware. Microcontroller ATmega 8, 168 and 328 have the same number of pin is 28 for DIP packaging, microcontrollers are selling a lot of this type are relatively cheap compared with other microcontroller. By having one of the microcontroller and coupled with a few components can actually function like the original Arduino board.

## Build an Arduino board

To make the Arduino microcontroller there are many choices of which will be used. But in this post could use the ATmega 8, 168, 328. I use the ATmega 328 with larger program memory capacity is 32KB. this post could use the ATmega 8, 168, 328. I use the ATmega 328 with larger program memory capacity is 32KB.

Components are supposed to provide are:

1. IC1: Microcontroler ATMega8/168/328, it’s up to you please choose one.
2. Q1: Resonator Crystal about 8MHz or 16MHz.
3. R1: pullup resistor for reset about 1K – 10K.
4. C1 and C2 about 22pF.

You can build on perforated veroboard or breadboard. By using the breadboard pins you can connect using a single wire diameter of 0.5mm. If using veroboard, to connect between the pin, use a single 0.5mm wire soldered directly.

### Build on perforated board

VCC supply voltage is 5VDC, not to reverse the polarity, if it does then it will make the microcontroller burned.
To fill the bootloader program, usually using ICSP with 4 signal MISO, MOSI, SCK and RESET. I recommend using USBasp can be made using the ATmega8 microcontroller.
Supply voltage of 5V can disuply USBasp programmer, by taking power from the computer USB port. How to make USBasp programmer click here.

I built USBasp like the one on this link.

To upload program serially using the Arduino IDE, bootloader program should be flashed into chip ATmega328. Bootloader is used if you are uploading a program via the serial RS232 interface.  This uses pins of RX / TX’s  microcontroller, in addition to the RST pin is used to reset automatically when the upload program.

But if you do not use this method, there are other ways to use the pin MOSI, MISO, SCK, RST of microcontroller, by using a USBasp programmer or other. The Arduino IDE of 1.0.1 version capable to program this method via this pins. In this way the bootloader certainly not required.

1. Connect the USBasp programmer to MISO, MOSI, SCK, RST of microcontroller pins.
2. You can use the 5V power supply of USB/programmer or use a separate power supply.
3. Run the Arduino IDE.
4. Select menu Tools->Board-> “Nano Arduino w / ATmega328″. Chip is recognized as a bord ATMega Nano with 16MHz crystal.
5. Select menu Tools->Programmer->USBasp. If you are using another programmer choose accordingly.

Equally important is to know the connection USBasp programming on the programming process to succeed. At USBasp There are two types of connectors and 10pin 6pin. I use the 10pin type USBasp homemade.

Programming pin on USBasp is MISO, MOSI and SCK are connected to the MISO, MOSI and SCK the target microcontroller. While RES is connected to the RESET to reset the target microcontroller into program mode. VTG is a voltage source while the +5 V from USB port of your computer. GND is the common channel. So the total that must be connected to the microcontroller board is 5 cable if you have a supply voltage of +5 V itself. If the board and do not have a +5 V supply and is obtained from a computer USB, VTG microcontroller is connected to VCC. Care should be taken not to both, to avoid damage to the computer because the voltage to be clashing.

To test whether the bootloader worked fine, tried to upload a program from existing examples on the arduino called “blink”. Connect your computer TX -> Arduino RX (pin 2), RX computer -> arduino TX (pin 3), DTR computer -> Arduino RESET (pin 1). Remember the three channels of serial computers must have a TTL logic level voltage 0 V or 5V. If you use a USB to serial in general, the output is still in its early stages RS232 voltage levels. To convert RS232 to TTL voltage levels using MAX232 IC.

## Testing of the Arduino Servo library on brushless motor’s cesna 130-46

I’ve created an Arduino ATmega328 built on a perforated veroboard. To connect between pins, I use in soldering wires directly. I use a 16MHz crystal clock and  the Arduino will recognize  as a board of “Nano Arduino w / ATmega328″.

In order board is easy to use, I added a header connector as in the rc receiver configuration is GND / +5 V / Signal. To facilitate the program upload the ISP, pin TX / RX / RST microcontroller mounted single header connectors.

RST microcontroller connected to the RTS of the serial interface using the USB dongle that works automatically reset. In addition, I added the LED on the D9 in order to test whether the Nano board can work well.

Next I will test this board for the throttle of the brushless motor. I am using the simple program that has been available in the example program.

I use a 3S lipo, 18A ESC as a 5V voltage source Arduino board. Potentiometer connected to ADC0 or A0 pin to set the throttle.

## PID applications on arduino to control the temperature of the heat exchanger plant.

Arduino library for PID controller algorithm has been made and can be applied with ease. By using the arduino PID library can be applied to various fields of control systems, here applied to regulate the temperature of the heat exchanger plant.

Plant made using nylon with 600 Watt electric heater. To know the LM35 temperature sensor plant used as it has been posted here. While signal conditioners circuit for temperature sensor has been posted here as well.

As an actuator, I use a method of switching pwm IGBT components. The pwm switching circuit I have described in posting here. As a controller, I’m using a microcontroller ATmega328 with Noano Arduino bootloader.

## PID library

To test the response of the PID used a simple program as follows:

#include

//Define Variables we'll be connecting to
double Setpoint, Input, Output;
int pwmOutput = 9;
int feedBackPin = A0;
int ComputeOk;

//Specify the links and initial tuning parameters
PID myPID(&Input, &Output, &Setpoint,1.25,4,0.5, DIRECT);

void setup()
{
//initialize the variables we're linked to
Setpoint = 500;

//turn the PID on
myPID.SetMode(AUTOMATIC);
Serial.begin(115200);
}

void loop()
{
myPID.Compute();

analogWrite(pwmOutput,Output);

double curErr = Setpoint-Input;
Serial.print(curErr);
Serial.print(" - ");
Serial.println(Output);
delay(50);

}