Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

Wednesday, 3 September 2014

This is a sample circuit for PIC16F84A and YAMAHA YMZ294

logo-en

logo_rsf

This is a sample circuit for PIC16F84A and YAMAHA YMZ294

 

[caption id="attachment_598" align="alignnone" width="181"]ym2294-pic (Reference: YAMAHA YMZ294 datasheet)[/caption]

 

This is a sample circuit for PIC16F84A and YAMAHA YMZ294.

 

This is form YAMAHA YMZ294 datasheet.

 

We are making this circuit on Breadboard.

 

We only left to connect D0 - D7.

 

(Reference: YAMAHA YMZ294 datasheet)

 

(R.S.F. toshiki speed news press, Agence France-Presse, 3 Wednesday September 2014 The Roman)

 

Sunday, 31 August 2014

BASIC programs

logo-en

logo_rsf

BASIC programs

 

 

We want to return to learn BASIC programming language.

 

There are, SIN, COS, TAN, in BASIC programming language.

 

ATN (Arc TAN), ASN (Arc AIN), ACN (Arc COS), COT (Co TAN), too.

 

Basically, BASIC programming language has, SIN, COS, TAN.

 

 

10 REM SIN

20 PRINT SIN(PI)

30 END

 

Then run,

 

Answer is 0.

 

10 REM COS

20 PRINT COS(PI)

30 END

 

Then run,

 

Answer is 1.

 

TAN = SIN / COS.

 

10 REM TAN

20 PRINT TAN(PI)

30 END

 

Then run,

 

Answer is 0.

 

 

10 REM SIN version 2

20 INPUT I

30 PRINT SIN(I)

40 END

 

We can calculate SIN.

 

 

PI is The ratio of the circumference of a circle to its diameter (Apple Dictionary), 3.14159276.....

 

 

Do you know this ?

 

sin^2(theta) + cos^2(theta) = 1

 

 

Let us try !

 

10 REM SIN+COS

20 PRINT ((SIN(PI))^2 + (COS(PI))^2)

30 END

 

Then run,

 

Answer is 1.

 

 

10 REM SIN+COS version 2

20 INPUT I

30 PRINT ((SIN(I))^2 + (COS(I))^2)

40 END

 

Then run,

 

This answer is always almost 1.

 

 

We used ^ in this program.

 

^ means square number.

 

10 REM SQUARE 4

20 PRINT 4^2

30 END

 

Then run,

 

Answer is 16.

 

 

Next, we want to learn GOTO.

 

10 REM GOTO

20 INPUT I

30 IF I<0 GOTO 100

40 PRINT I

50 END

100 PRINT (0 - I)

110 END

 

 

IF statement and GOTO statement exchanges program route by conditions.

 

 

We programmed this.

 

 

10 REM AI

20 INPUT A$

30 PRINT A$

40 GOTO 20

50 END

 

This program loops between line number 20 and line number 40.

 

 

Homework: Make BASIC programs for many calculations. Make all flow charts for all programs in this article.

 

 

Exercise

 

Make program and flow chart.

 

1 Add 1 to 100

 

2 Add 1 and 4

 

3 Divide 4/3

 

4 Show text "Hello"

 

5 Write this "Tomato is", I (INPUT I)

 

6 Write COS(I) calculate program (INPUT I)

 

7 Write I^2 calculate program

 

8 Write DIM (I,J), Add DIM (I fixed, J loop)

 

9 Write DIM (I,J) Add DIM (I loop, J loop)

 

10 Can you calculate how many days from your birth ? (Difficult)

 

 

Extra Exercise (Difficult)

 

Write BIORHYTHM

 

 

(R.S.F. toshiki speed news press, Agence France-Presse, 1 Monday September 2014 The Roman)

 

Sunday, 22 June 2014

BASIC programs

logo

logo_rsf

BASIC programs

 

WORLD PRESS FREEDOM INDEX 2014 was released from Reporters Without Boarders.

 

We want to calculate 0 to 100 examination point for the country.

 

 

Calculations is (1 - (Rank-1)  / 180) * 100

 

 

No.1 is Finland,

 

(1 - (1 -1) / 180) * 100 = 100

 

 

France is No.39,

 

(1 - (39 -1) / 180) * 100 = 78.88888 = 78.89

 

 

Japan is No.59,

 

(1 - (59 -1) / 180) * 100 = 67.77777 = 67.78

 

 

Spain is No. 35,

 

(1 - (35 -1) / 180) * 100 = 81.11111 = 81.11

 

 

10 REM PRESS FREEDOM

20 PRINT "WORLD PRESS FREEDOM INDEX 2014"

30 INPUT A

40 B =  (1 - (A - 1) / 180) * 100

50 PRINT "THE POINT FOR THE COUNTRY = "; B

60 END

 

 

Where is your country ?

 

What point does your country get ?

 

 

Homework: Make flow chart for this program.


 


(R.S.F. toshiki speed news press, Agence France-Presse, 23 Monday June 2014 The Roman)



 

Maybe you can make another calculate program.

 

(R.S.F. toshiki speed news press, Agence France-Presse, 23 Monday June 2014 The Roman)

 

Thursday, 19 June 2014

BASIC programs

logo

logo_rsf

BASIC programs

 

This article is about arithmetical operator, mathematical operator, and character.

 

 

We already used / and +.

 

+ is plus.

 

/ is divide.

 

minus is -.

 

multiple is *.

 

Parentheses ( and ) have high priority.

 

Calculate order is multiple and divide -> plus and minus.

 

 

10 REM Calculate

20 LET I=5

30 LET J=2

40 PRINT  I+J

50 PRINT I/J

60 PRINT I-J

70 PRINT I*J

80 PRINT (I+J) * 2

90 END

 

 

Then run,

 

7

2.5

3

10

14

 

 

We used LET statement in this program.

 

LET is a statement for an announcement.

 

10 LET I=5

 

means we use I equal 5.

 

 

Computer can calculate.

 

Computer can be a calculator.

 

 

Next is A$ (What we wanted to do was not CHAR$, what we wanted to do was A$).

 

 

10 REM Character

10 INPUT A$

20 PRINT A$

30 END

 

 

Then run,

 

If you input HELLO, then computer returns HELLO.

 

 

10 REM Small AI

20 INPUT A$

30 PRINT A$

40 GOTO 20

50 END

 

 

Then run, your computer will answer the same words for you.

 

Push Control key + C key will stop this program.

 

 

10 REM You can add characters

20 INPUT A$

30 INPUT B$

40 PRINT A$ + B$

50 END

 

(Program-6-20-2014)

 

 

Then run,

 

?

HELLO

?

WORLD

 

Computer will print HELLOWORLD.

 

 

Please learn deference of number and character.

 

 

If you run Program-6-20-2014, and,

 

?

2

?

5

 

Computer will print 25.

 

 

10 REM World Cup

20 INPUT A$

30 INPUT B$

40 INPUT C$

50 INPUT D$

60 PRINT A$ + B$ + C$ + D$

70 END

 

 

Then run,

 

?

Japan

?

Colombia

?

Cote d'Ivoire

?

Greece

 

Computer will show JapanColombiaCote d'IvoireGreece.

 

 

Homework: Write many BASIC programs with arithmetic operators. Make many flow charts for programs in this article and your programs.

 

 

10 REM Area for quadrangle

20 INPUT A

30 INPUT B

40 PRINT A*B

60 END

 

This program print area for quadrangle. (A is a height, B is a width)

 

 

10 REM Area for triangle

10 INPUT A

20 INPUT B

30 PRINT A*B / 2

40 END

 

This program print area for triangle. (A is a height, B is a width)

 

 

Homework: Make BASIC programs for many area calculations and many volume calculations in mathematics. Make all flow charts for your programs.

 

 

(R.S.F. toshiki speed news press, Agence France-Presse, 20 Friday June 2014 The Roman)

 

 

Be this World Cup will good memory for you.

 

 

(R.S.F. toshiki speed news press, Agence France-Presse, 20 Friday June 2014 The Roman)

 

 

 

Wednesday, 11 June 2014

BASIC programs

logo

logo_rsf

BASIC programs

 

This article is for analysis programming beginning.

 

 

10 REM DIMENSION AND AVERAGE

20 DIM A(4)

30 FOR I=0 TO 4

40 READ A(I)

50 NEXT I

60 DATA 0,1,2,3,4

70 REM AVERAGE

80 FOR M=0 TO 4

90 J=J+A(M)

100 NEXT M

110 PRINT M

120 PRINT M/5

130 END

 

 

We set DIM A(4), we READ data, we count all sum for DIM A(4), we print all sum for DIM A(4), we print average for DIM A(4).

 

If we do not clear dimension in memory, then dimension datas are in memory.

 

We can use this dimension datas in the same program.

 

 

Then,

 

We set DIM A(1, 4)

 

 

10 REM DIM A(I, J) AND ANALYSIS

20 DIM A(1,4)

30 FOR I=0 TO 1

40 FOR J=0 TO 4

50 READ (A(I,J)

60 PRINT "A(" ; I ; "," ; J ; ") ="; (A(I,J)

70 NEXT J

80 NEXT I

90 DATA 0,1,2,3,4

100 DATA 10,11,12,13,14

200 PRINT "A SAMPLE OF ANALYSIS"

210 FOR L=0 TO 4

220 S=S+A(0,L)

230 NEXT L

240 PRINT "TOTAL OF A(0,0,) A(0,1) A(0,2) A(0,3) A(0,4) ="; S

250 PRINT "AVERAGE OF A(0,0,) A(0,1) A(0,2) A(0,3) A(0,4) ="; S/5

300 END

 

 

This program shows many messages for you.

 

This program shows total and and average.

 

 

Can you make this program for A(1,0) A(1,1) A(1,2) A(1,3) A(1,4) ?

 

Can you make this program for all A(I,J) ?

 

 

Next program is;

 

 

10 REM INPUT AND AVERAGE

20 INPUT "COUNT ?" ; I

30 DIM A(I-1)

40 FOR J=0 TO (I-1)

50 INPUT A(J)

60 PRINT "A(" ; J ; ") =" ; A(J)

70 NEXT J

80 FOR L=0 TO (I-1)

90 S=S+A(L)

100 NEXT L

110 PRINT "INPUT NUMBERS COUNT =" ; I

120 PRINT "AVERAGE =" ; S/I

130 END

 

 

Let us run this program.

 

COUNT ?

 

then

 

2

 

First

 

?

 

then

 

155

 

Next

 

?

 

then

 

167.5

 

AVERAGE = 161.25

 

 

Please try by your family.

 

 

Next is CHAR$

 

 

10 REM CHAR$

20 INPUT CHAR$(A)

30 PRINT CHR$(A)

40 END

 

 

Then run this program,

 

?

 

You can input HELLO.

 

Computer will show HELLO.

 

 

10 REM CHAR$ AND GOTO

20 INPUT CHAR$(A)

30 PRINT CHAR$(A)

40 GOTO 20

50 END

 

 

You can talk with computer ?

 

Push Control key + C key at the same time will stop this program.

 

 

We used GOTO statement in this program.

 

GOTO 20 means GOTO Line number 20.

 

 

Homework: Make flow charts for all programs in this article.

 

(R.S.F. toshiki speed news press, Agence France-Presse, 11 Wednesday June 2014 The Roman)

 

 

Friday, 6 June 2014

BASIC programs

logo

logo_rsf

BASIC programs

 

This article is dimension and READ statement.

 

 

10 REM DIM(4) AND READ

20 DIM A(4)

30 REM HERE WE SET DIM A(0) TO DIM A(4)

40 FOR I=0 TO 4

50 READ A(I)

60 NEXT I

70 DATA 0,1,2,3,4

80 END

 

 

The run,

 

A(0) is 0

A(1) is 1

A(2) is 2

A(3) is 3

A(4) is 4

 

 

Add,

 

55 PRINT A(I)

 

 

LIST is

 

10 REM DIM(4) AND READ

20 DIM A(4)

30 REM HERE WE SET DIM A(0) TO DIM A(4)

40 FOR I=0 TO 4

50 READ A(I)

55 PRINT A(I)

60 NEXT I

70 DATA 0,1,2,3,4

80 END

 

 

Then run,

 

0

1

2

3

4

 

 

We announced A(4), we read from DATA, input DATA to A(0) to A(4), and result, print result.

 

We call this type data as sequential data.

 

 

Next is loop again, double nest loop.

 

 

5 REM I LOOP

10 FOR I =0 TO 4

20 PRINT I

30 NEXT I

40 END

 

 

Then run,

 

0

1

2

3

4

 

 

I=0 to 4, print I.

 

 

Then,

 

 

5 REM J LOOP

10 FOR J =0 TO 4

20 PRINT J

30 NEXT J

40 END

 

 

Then run,

 

0

1

2

3

4

 

 

J=0 to 4, print J.

 

 

Then,

 

5 REM I LOOP, J LOOP

10 FOR I=0 TO 4

20 FOR J=0 TO 4

30 PRINT I,J

40 NEXT J

50 NEXT I

60 END

 

 

Then run,

 

0 0

0 1

0 2

0 4

1 0

1 1

 

.

.

 

4 3

4 4

 

 

I=0; Loop J=0 to 4

I=1; Loop J=0 to 4

I=2; Loop J=0 to 4

I=3; Loop J=0 to 4

I=4; Loop J=0 to 4

 

 

Then,

 

 

10 REM DIM A(I,J)

20 DIM A(4,4)

30 FOR I=0 TO 4

40 FOR J=0 TO4

50 READ A(I,J)

60 NEXT J

70 NEXT I

80 DATA 0,1,2,3,4

90 DATA 10,11,12,13,14

100 DATA 20,21,22,23,24

110 DATA 30,31,32,33,34

120 DATA 40,41,42,43,44

130 END

 

 

Then run,

 

 

A(0,0) 0

A(0,1) 1

.

.

A(4,3) 43

A(4,4) 44

 

 

Add 55 PRINT A(I,J)

 

 

LIST is,

 

10 REM DIM A(I,J)

20 DIM A(4,4)

30 FOR I=0 TO 4

40 FOR J=0 TO4

50 READ A(I,J)

55 PRINT A(I,J)

60 NEXT J

70 NEXT I

80 DATA 0,1,2,3,4

90 DATA 10,11,12,13,14

100 DATA 20,21,22,23,24

110 DATA 30,31,32,33,34

120 DATA 40,41,42,43,44

130 END

 

This will let you present readed DATA from sequential data.

 

 

0

1

2

3

4

10

11

 

..

 

41

42

43

44

 

 

You can understand how A(I,J) is changing.

 

 

Dimension and READ statement are used in economy analysis, mathematical analysis and multi valuable analysis, and many scenes.

 

 

Homework: Check ASCII code. Make all flow chart for BASIC programs in this article.

 

(R.S.F. toshiki speed news press, Agence France-Presse, 6 Friday June 2014 The Roman)

 

A(I,J) is matrix dimension.

 

For example, A(4,4) is 5 x 5 matrix dimension.

 

(R.S.F. toshiki speed news press, Agence France-Presse, 6 Friday June 2014 The Roman)

 

Sunday, 1 June 2014

BASIC programs

logo

logo_rsf

BASIC programs

 

Next is dimension.

 

The easiest dimension is DIM A(1).

 

10 DIM A(1)

20 INPUT A(0)?

 

(

 

or

 

10 DIM A(1)

20 INPUT A(0)

 

)

 

 

Then run this program,

 

?

 

If you input 2 to question, then,

 

PRINT A(0)

 

is

 

2

 

We use DIMension A(0), you inputted 2 to A(0).

 

You printed A(0).

 

 

DIM A(1) means, we use A(0).

 

If DIM A(2) then, we use A(0), A(1).

 

Can you write what DIM A(3) means ?

 

 

DIM is declaration or announcement.

 

DIM is not a command.

 

For example, direct to,

 

DIM A(1)

 

or

 

INPUT A(1)

 

will be an error.

 

 

This is the easiest dimension.

 

 

Why we use dimension ?

 

 

For example, loop programing,

 

10 DIM A(2)

20 FOR I=0 TO 1

30 INPUT A(I) ?

40 NEXT I

50 END

 

(

 

or

 

10 DIM A(2)

20 FOR I=0 TO 1

30 INPUT A(I)

40 NEXT I

50 END

 

)

 

 

(We added END for this program.)

 

From A(0) to A(1), loop INPUT.

 

 

Why many dimensions ?

 

Let us learn READ next time.

 

 

Homework: Make print program that print all A(I) in program in this article. Add this print program to dimension program.

 

 

Let us learn REM.

 

10 REM This here is nothing means

 

Then, RUN,

 

Nothing happen.

 

 

How to use REM, for example,

 

5 REM program dimension

10 DIM A(2)

20 FOR I=0 TO 1

30 INPUT A(I)

40 NEXT I

50 END

 

 

Homework: How many programs can you write from this article ? How many programs can you write ?

 

 

If this article is difficult, we will wait for you.

 

We are in the start of the long long road of Digital Science, Computer Science.

 

(R.S.F. toshiki speed news press, Agence France-Presse, 1 Sunday June 2014 The Roman)

 

Extra,

 

10 REM extra program 1

20 FOR I=1 TO 10

30 PRINT I

40 NEXT I

50 END

 

10 REM extra program 2

20 INPUT A

30 INPUT B

40 C=A+B

50 PRINT "A+B="; C

60 END

 

 

Homework: Check SPI bus. Check MCP4921 and MCP4922.

 

(R.S.F. toshiki speed news press, Agence France-Presse, 1 Sunday June 2014 The Roman)

 

Homework: Make many flow charts for many BASIC programs and BASIC programs in this article.

 

(R.S.F. toshiki speed news press, Agence France-Presse, 4 Wednesday June 2014 The Roman)

 

Thursday, 29 May 2014

BASIC programs

logo

logo_rsf

BASIC programs

 

Can you write flow charts ?

 

There are measure tool for writing flow charts.

 

This article is for BASIC programs too.

 

We must learn BASIC at first, perfectly.

 

 

10 INPUT A?

20 INPUT B?

30 C=A+B

40 PRINT C

 

(1)

 

(

10 INPUT A

20 INPUT B

30 C=A+B

40 PRINT C

)

 

(1)'

 

This program is request your input. (1) (or (1)')

 

Answer is A+B.

 

 

Then,

 

10 A=10

20 B=20

30 C= - B/A

40 PRINT C

 

Answer is -2.

 

This answer is for Ax+B=0, x=? (2)

 

 

Can you write a program for Ax^2+Bx+C=0 x=? (A is not 0) ? (3)

 

(Can you write a program that is if A=0 then error for (3) ?) (4)

 

 

Can you write programs that is mixed, (1) or (1)' and (2), (1) or (1)' and (3), ((1) or (1)' and (4)) ?

 

 

Please do not run from mathematics.

 

Physics too.

 

 

Can you write programs for basic physics ?

 

 

f (x) = x^2 + 1

 

then

 

f ' (x) = 2 * x^(2-1) = 2x

 

Can you write a program for this ?

 

Can you write this to generic ?

 

 

Homework: Make flow charts for BASIC programs in this article. Check Serial EEPROM and Serial RAM. Check I2C. How many memory address for 8-bit PIC MPU ?

 

 

A1. 8-bit = 1111 1111 = 255 (Decimal) = FF (Hex)

 

0000 0000

 

to

 

1111 1111

 

is 8-bit memory address.

 

2^16 = 65536

 

We call this as 64 Kilo bytes.

 

8-bit memory address is 64 Kilo bytes.

 

Please write image that is memory and program in memory and program runs from the start and screen and keyboard and micro computer.

 

 

Homework: Check Data bus and Address bus. How many memory address is for PIC16F84A ?

 

 

If this article is difficult, we will wait for you.

 

We are in the start of the long long road of Digital Science, Computer Science.

 

(R.S.F. toshiki speed news press, Agence France-Presse, 29 Thursday May 2014 The Roman)

 

Saturday, 24 May 2014

Flow chart and programming language BASIC

logo

logo_rsf

Flow chart and programming language BASIC

 

We had done to make CPU Board.

 

One of our try was/is TK-80 like 1 board micro computer and we had done to make CPU Board.

 

Next section is programming.

 

We choose programming language BASIC and programming language FORTRAN.

 

At first, we learn programming language BASIC.

 

And we learn flow chart.

 

Many reference books for programming language BASIC and programming language FORTRAN.

 

BASIC is not so difficult.

 

 

PRINT "PIC MPU"

 

is

 

PIC MPU

 

Show character PIC MPU, BASIC OS command is above.

 

 

10 PRINT "PIC MPU"

 

and RUN

 

is

 

PIC MPU

 

Show character PIC MPU, program is above.

 

 

FOR I=1 TO 10

 

NEXT I

 

is

 

I=1, NEXT I, I=2, NEXT I, I=3, NEXT I, I=4, NEXT I, I=5, NEXT I, I=6, NEXT I, I=7, NEXT I, I=8, NEXT I, I=9, NEXT I, I=10

 

This is loop or loop programming, we call so.

 

Change I from 1 to 10, program is above.

 

10 I=0

20 J=0

30 FOR I=1 TO 10

40 J=J+I

50 NEXT I

60 PRINT J

 

and RUN

 

is

 

55

 

Add 1 to 10, program is above.

 

 

Please read flow chart reference book or reference Internet, please make flow charts for command and programs in this article.

 

 

Homework: Make many flow charts for many BASIC programs, and check I2C and serial EEPROM. If you can work more, make many flow charts for many PIC assembler programs.

 

(R.S.F. toshiki speed news press, Agence France-Presse, 24 Saturday May 2014 The Roman)