Showing posts with label practical. Show all posts
Showing posts with label practical. Show all posts

Modbus anyone ???

written by Antabax | 4:17:00 PM | | 0 comments »

Anyone ever heard of Modbus ? Basically, Modbus is a communication protocol developed by Modicon systems. It is a way of sending information between electronic devices. The device requesting the information is called the Modbus Master and the devices supplying information are Modbus Slaves. In a standard Modbus network, there is one Master and up to 247 Slaves, each with a unique Slave Address from 1 to 247. The Master can also write information to the Slaves. It is typically used to transmit signals from instrumentation and control devices back to a main controller or data gathering system. Modbus is transmitted over serial lines between devices. The simplest setup would be a single serial cable connecting the serial ports on two devices, a Master and a Slave.

Ok now, the thing is, my boss asked me to analyze this VB program that he gave me. It is used to send data from the master (pc) to the slave and also to receive data from slave to the master. I was like err wtf ?? I never learn anything about it even in MMU. Frankly speaking, I know nothing on communication thingy using VB. He said after I managed to understand it, he will ask me to do stuff that are related to this Modbus thingy. OMFG !! I guess I'll try to understand Modbus first before I say to my boss, "Sir, don't give me things that are so freaky and weird like this. Please give me some other stuff to do please."

To know more about Modbus, you can click here and here.

Today is my first time to see our boss, Mr. Wong. He just came back from Alor Setar, Kedah. He instructed me to install Visual Studio 6 (finally) and asked me to familiar myself with it before doin a documentation on how to install and use it. With all the free time I have, I managed to create a simple calculator limited to only two operands. The background colour will also change everytime the user click on an operation.


























Note that this is just a simple calculator and everyone with zero knowledge can do this if they take the time to learn VB. I've uploaded the program incase anyone want to try it. You can download it here.

A very basic BASIC calculator

written by Antabax | 4:29:00 PM | | 3 comments »

Finally, on the 3rd day of my training, I managed to figure out the calculator thingy. The coding looks something like this :-
(A short note, it is just a normal direct code hence a beginner's style)


Dim a As Single, b As Single, d As Single
Dim c As String, z As String

Print ""
Print "A simple 2
input Basic Calculator by Azmeer"

Do

Print ""
Input "Please choose a number : ", a
Input "Please choose another number : ", b
Print ""

Print "Choose an operation from the list below"

Print "1. Add"
Print "2. Subtract"
Print "3. Multiply"
Print "4. Divide"
Print ""


Input "Your choice is : ", c


If c = "1" Then
d = a + b
Print "The result of addition is: "; d
End If


If c = "2" Then
d = a - b
Print "The result of subtraction is: "; d
End If


If c = "3" Then
d = a * b
Print "The result of multiplication is: "; d
End If


If c = "4" Then
d = a / b
Print "The result of dividing is: "; d
End If


Print ""
Print "Would you like to calculate again ?"


Print "1. Yes"
Print "2. No"
Print ""


Input "Your choice is : ", z


If z = "1" or z = "Yes" Then
Print ""


ElseIf z = "2" or z = "No" Then
Print ""
Print "Press any key to EXIT"
Exit Do


Else
Print "Invalid choice entered"
Print "Press any key to EXIT"
Exit Do
End If


Loop
Sleep


The basic of BASIC

written by Antabax | 3:17:00 PM | | 0 comments »

Not much happened today in the office except that I've learned the basics of basic, lol ? The Visual-Basic uses the Basic language as it's main language. Example to say Hello World! in c++ is something like this:-

cout << ”Hello World”;


But in Visual-Basic it looks like this:-


print “Hello World”


and it doesn't need the ; to end a line and a simple declaration using strings will look like this:-


Dim a As String, b As String, text As String

a = "Hello"
b = "World"
text = a + " " + b + "!
Print text

To compile the coding, I need to find an easy, fast, free and suitable compiler on the net. Its quite hard to find because almost everyone is using Visual Studio (Visual Basic 6 or Visual Studio 2005). I finally found a compiler that is still under development/support. It is called FreeBASIC. It is a typical MS-DOS application. Not that hard to use because the guide on their homepage is quite straight-forward. But for a typical MS-DOS app, u need to type to get things around and the mouse hardly have any function here.


Currently, I am trying to code a simple calculator involving only 2 integers, A and B with 4 operations that is add, subtract, multiply, and divide. It involves loop, declarations and the input and print function. If I managed to do this, then I can say 'takde hal' to the basic of basic, lol.


Translation
takde hal = no problem(s)


Read more about Basic here.
Download FreeBASIC here.

The first day of my practical, Monday, 4th of June, was not that bad. When I first arrive at the office, it was around 8:35 AM. I am suppose to arrive there at 8:30 AM or earlier. Luckily the boss, the one who appointed us trainees, is not around. A girl staff (Ee-Sun, software engineer) arrive shortly after and welcome me and the others to the company. My first task was to fill up the employment form (as an industrial trainee) and the Non-Disclosure Agreement form. Then after settling down at my table, another staff (Kuhan, r&d) , a guy this time, came in and greet us. We were then told to wait for Mr Aizat (system engineer) to come and brief us about the company. Later we were assign to a specific task that best match our skills. The choice was:-

  1. C-language / Embedded Visual-C / Visual C

  2. Visual-Basic / Embedded Visual-Basic

  3. Web Programming / VB Script / ASP / Java Script

It was obviously clear that I am only familiar with the option no 1 minus the embedded thingy. Later on I decided to take the challenge and choose option no 2 which I have never put my hands on before. It was claimed easy by some, so I might just have a go on it. Soon after that, our last task for the day is to format the pc and install Windows 2000 and Open-Office. We were reminded that for the first week, we need to learn/recap our task that we were assigned to because they might be a test on it this friday. Back to school I guess.