0
118
이전
다음
위로

일반제품상담전화:010-5917-7859 파킹세일 모든 상품은 부가세포함, 배송비 별도입니다.
시안 전용메일 : 0707507@naver.com  대량구매/세금계산서 발행 문의 : 010-5917-7859

①주차|도로용품
②안전용품
③안내간판|반사지|표지판
④생활용품|생활안전|차량용품
⑤사무용품|가구
⑥공구|산업용품
⑦철물|건설|건축|토목
⑧출입|방송|CCTV|방범
⑨영상처리|자동인식
⑩전기|자동제어
⑪전자|콘트롤러|지능형홈
⑫기계|기계요소
⑬개발상품|기타결재
 [Exso] 핫멜트 글...
16,500원
 [DM] 자야 글루건...
4,500원

PROGRAMMABLE LOGIC CONTROLLER
PROGRAMMABLE LOGIC CONTROLLER with embedded BASIC interpreter
  상품번호                  43107
  판매가격         원 (VAT포함)  
  제조/판매 마노기술
  원산지 한국
  재고 판매중
  구매수량

개  
  가격 원(VAT포함)
  총가격 원(VAT포함)
 상품 최종 수정일 : 2009-05-27 23:59:35
  
게시글을 twitter로 보내기 게시글을 facebook으로 보내기 게시글을 Me2Day로 보내기 게시글을 요즘으로 보내기 게시글을 구글로 북마크 하기 게시글을 네이버로 북마크 하기
제목 없음

PROGRAMMABLE LOGIC CONTROLLER
with embedded BASIC interpreter

CONTENTS

1. INTRODUCTION
2. AVR BASINT, COMMANDS & FUNCTIONS
2.1 INPUT/OUTPUT CONSOLE
2.2 PROGRAM CONTROL
2.3 DATA
2.4 INTERRUPTS AND OPCODE SUPPORT
2.5 DEFINE AND USE CONTROLLER’S PINS
2.6 INTERNAL RESOURCE ACCESS
2.6.1 16-bit registers access
2.7 MATH ROUTINES
2.8 SOME BASIC EXTENTIONS
2.9 TWO WIRE INTERFACE
2.10 DIAGNOSTIC
3. PRE-PROCESSOR
4. PROGRAM DOWNLOADING

1. INTRODUCTION

Controller with embedded Basic interpreter (PLC-BASINT) is a compact device that can operate as a PLC (program logic controller) for home automation, control, etc. For example, this one can dial-up by modem to the remote computer and send the status of the controlled system, can control some processes, temperature regulation, battery charging, can be used for educations and hobby purposes.

PLC-BASINT has analogue and discrete input/output and an RS232 interface to communicate with other devices and to reflash a control program. The control program is a text version of BASIC language. The main task of the controller is to interpret BASIC commands. The TBC version of the BASIC language has commands to operate with discrete I/O, ADC and PWM. The view of controller PCB is shown below in the figure 1.



Figure 1

The main feature of this controller is that users do not need any special hardware and software tools. For program writing they can use any text editor, NotePad for example. HyperTerminal is enough for program downloading. Both of these programs are standard MS Windows applications. The interpreter BASINT converts the user Basic program to the internal format at the download stage. That allows reduce program size and get fast speed interpreting.

Technical details:

1. Number of discrete optocoupled inputs 5..15V 8
2. Number of discrete relay outputs 8
3. Number of analogue inputs 0…5V 4
4. LEDs for user purpose 4
4. DIP-switch. bits for user purpose 7
5. Communications: 2xRS232 or
    1xRS485 and 1xRS232

7.The language of embedded interpreter

Basic BASINT

8.Size of user program area, kilobytes, more than 32
9. Simple command operating time, less than uSec    150
10 Basic program storage place Program Flash

Schematic in PDF format

Controller external connections:



Figure 2


4. PROGRAM DOWNLOADING

HyperTerminal or another terminal application must be set up as shown below:

Baud rate 57600 bps
Data/Stop bits 8/1
Parity None
Flow Control Hardware
Terminal emulation ANSII / VT100
Add sent CR with LF



Figure 3

There are two ways to download.
The first one is by using the text file sending option of the terminal.
The second way is downloading using paste from the clipboard if you are using Windows HyperTerminal, for example.

1.Make sure that write protect jumper is open.
2.Connect the controller to PC by RS232 cable.
3.Power it up.
4.Start terminal application.
5.Press the reset button on the controller.
The start page appears in the terminal window.
6. Press menu option 2 to force the controller be waiting for input text.
7. Send a program by using the text file sending option of the terminal or paste text from the clipboard.
8. Press menu option 1 to list the downloaded program.
9. Press menu option 3 to run the downloaded program.
10. Close write protect jumper. It alows:

- protect program;
- diasable start page screen;
- automatically sart program when the controller is powered up.

This is starting page on HyperTerminal with controller connected to PC serial port.



Figure 4


2. AVR BASINT. COMMANDS AND FUNCTIONS

There are some features of BASINT. - Program lines don’t have numbers. Line numbers are using only for label’s mark.
Numbers:
All numbers are the signed integers in a range from -32767 up to +32767.
There are three forms of numbers representation:

- Decimal;
- Hexadecimal, numbers have a prefix &H;
- Binary, numbers have a prefix &B;

Variables:
There are 26 variables denoted by the letters A through Z. These are represented internally as 16-bit, two's-complement integers.
There are up to 26 one-dimensional arrays. Size of arrays must be defined before using. Maximum size depends of current free memory. The array elements are accessible by an index in the parentheses. For example: A(0), B(18). Note that A an A(n) are the different variables.

Operators
Arithmetic:

+ addition
- subtraction.
* multiply
/ integer division (note that 14/5 = 2
MOD - remainder from division (14 MOD 5 = 4).
AND – bit-wise logical AND (3 AND 6 = 2)
OR – bit-wise logical OR
XOR – bit-wise logical XOR

Compare:(using only with operator IF):
= equal
<> (or ><) not equal
> more
< less
>= (=>) more or equal
<= (=<) less or equal

Expressions:
Expressions are formed with numbers and variables with arithmetic operators between them. Operators of comparison cannot be used in expressions. Parentheses can be used to alter the order of evaluation.
Labels:
Label is a number from 0 to 32767. Labels must be set before line that is a point to jump or is a start line of subroutine. It is not recommended to number all of the lines the labels table is limited up to 64 labels.

 

 

 BASINT KeyWord Description Can be used
in PLC-BASINT

ABS

Returns absolute value Yes

ADC

Reads meassured value from the current channel ADC Yes
AT Sets the position of the printing symbol for PRINT operator Yes
ATTR Sets the console output attributes Yes
BCD Puts to the console a value in BCD form Yes
BIN Puts to the console a value in BIN form Yes
CHR Sends symbol to the console by symbol code that is result of expression.
CHR is an element of the output list for PRINT operator
Yes
CLEAR Sets pin logic level to zero Yes
CLS Clears the screen and move cursor to top left corner Yes
DATA Specifies constant values to be read by READ operator Yes
DEFPIN AS Defines the pin function of the controller pins No
DELAY Forms delay Yes
DELETEVECTOR Disconnects the a handler code from vector and disables corresponding interrupt Yes
DIM Defines an array size Yes
DISABLE Disables interrupts Yes
ENABLE Enables interrupts Yes
END Finishes the program execution Yes
FOR TO NEXT Loop operator Yes
GETATOMIC Gets value from a variable used in an interrupt Yes
GOTO Unconditional branch Yes
GOSUB Calls subroutine Yes
HEX Puts to the console a value in hexadecimal form Yes
HIGH Returns high byte of expression result Yes
IF THEN ELSE Condition branch operator Yes
INK Sets the symbol color Yes
INKEY Checks the console buffer for the received symbols Yes
INLINE Creates block of machine code Yes
INPUT Waits for input value Yes
INTERRUPT Creates the block of a machine code at a stage of program loading.
Connects a code to a vector at a stage of execution
Yes
LASTERROR Returns last error or critical situation code Yes
LOW Returns low byte of expression result Yes
PAPER Sets the background color Yes
PEEK Reads byte from memory or I/O port Yes
POKE Writes byte to memory or I/O port Yes
PRINT Prints the messages and the values on the console Yes
PULSEIN Returns pulse width on the controller pin Yes
PULSEOUT Forms pulse on the pin Yes
PUTATOMIC Assigns value of variable used in interrupt subroutine Yes
PWM Puts a digital value out to the PWR channel No
READ Reads DATA and moves pointer to next point Yes
READEEPROM Reads byte from the address in EEPROM Yes
REM Comments line. Interpreter skips the rest of code in this line Yes
RESTORE Allows read the DATA block more than one time.
Sets the pointer at the needed labeled block of data
Yes
RETURN Returns from subrouting Yes
ROL Shifts value of variable left. The LSB is set to 0 Yes
ROR Shifts value of variable right. The MSB is set to 0 Yes
SCALE Performs the scaling of variable Yes
SETADMUX Sets the analog multiplexer up Yes
SET Sets pin logic level to one Yes
SHIFTIN Returns the incoming sequence of bits No
SHIFTOUT Outputs contents of a variable as sequence of bits No
STOP Stops the program execution, clears receiving buffer,
starts after getting new symbol in the input buffer
Yes
TEST Reads pins logic level Yes
TOGGLE Switches pin logic level to the inverted state Yes
TWIINIT Iinitializes TWI (I2C) No
TWIREAD Reads byte from TWI (I2C) device. ACK/NACK generate No
TWISTOP Generates STOP condition on SDA and SCL pins No
TWIWRITE Sends byte to TWI (I2C) device No
WAITKEY Is waiting for a single symbol. Returns the code of received symbol Yes
WRITEEEPROM Writes byte to the address in EEPROM Yes

 

2.1 CONSOLE INPUT/OUTPUT

CLS

Action:
Clears the screen and move cursor to top left corner
Syntax:
CLS

PRINT

Action:
Prints the message on the console
Syntax:
PRINT [output list]

The elements of the output list can be separated by semicolon that allows output more than one variables or strings at one line without spaces between the elements. Semicolon at the end of the line cancels adding CR and LF.
The elements of the output list can be separated by comma that inserts number of spaces to set output to the next position of tabulation. Comma at the end of the line cancels adding CR and LF.

Examples:

PRINT Line feed
PRINT “This message” printed: This message
PRINT “X=”;X; “ Y=”;Y; printed: X=(value of X) Y=(value of Y)
PRINT X,Y,Z,

(value of X)     (value of Y)      (value of Z)

 

AT

Action:
Sets the position of the printing symbol for PRINT operator
Syntax:
PRINT AT(x,y);[list]
x – row position (from 1 to 80)
y – column position (from 1 to 24)
Example:

PRINT AT(35,12);“This msg”; AT(1,1); Print "This msg" in the center of the screen and set cursor to the left/up corner

 

CHR

Action:
Sends symbol to the console by its code that is result of expression. Using with PRINT operator
Syntax::
PRINT [list1; or ,] CHR(val)[; or , [list2]]
val – symbol code from 0 to 255. All another integer values will be got as a low byte of word
Example:

FOR I=32 TO 127
     PRINT I,CHR(I)
NEXT
Print symbol codes and symbol itself

 

HEX, BCD, BIN

Action:
HEX – puts to the console a value in hexadecimal form,
BCD - puts to the console a value in BCD form,
BIN - puts to the console a value in BIN form.
Functions HEX, BCD, BIN are the elements of output list for PRINT operator.
Синтаксис:
PRINT [list1; or ,] HEX(value, digits)[; or , [list2]]
PRINT [list1; or ,] BCD(value, digits)[; or , [list2]]
PRINT [list1; or ,] BIN(value, digits)[; or , [list2]]

value – value or expression
digits – number of printed digits

Example:

10 INPUT X
     PRINT X,HEX(X,4);BIN(X,16)
GOTO 10
Print value in different formats
ATTR

Action:
Sets the console output attributes
Syntax:
ATTR  expression

An expression defines output attributes:

0 – standard brightness
1 – more light brightness
4 – underscore
5 – blinking
7 – color inverting
8 – set color of symbol and background the same

INK, PAPER

Action:
Sets color attributes for console output
INK – sets the symbol color
PAPER – sets the background color
Syntax:
INK  expession
PAPER  expession

An expession defines the color

0 – black
1 – red
2 – green
3 – yellow
4 – blue
5 – magenta
6 – cyan
7 – white

Note. Using AT, CLS, ATTR, PAPER, INK allows change attributes on ANSI terminal, as console. Most terminals program can support this mode.

 

INPUT

Action:
Waits for input value. Puts value to the variable after receiving CR
Syntax:
INPUT ["Invite msg",] variable
Examples:

INPUT X Print “?” and wait for value
INPUT “X=”,X Print X= and wait for value

 

INKEY

Action:
Checks console buffer for the received symbols. Return –1 if empty and symbol’s code if not.
Syntax:
Variable = INKEY()
Examples:

A=INKEY() Read buffer

10  C=INKEY()
      IF C=-1 THEN GOTO 10

Wait for a symbol


10 C=INKEY()
IF C<>-1 THEN GOTO 20
REM Do some background task
GOTO 10
20 REM Do something upon received symbol
GOTO 10

Waiting for symbol and doing something background

 

WAITKEY

Action:
Is waiting for a single symbol. Returns the code of received symbol.
Syntax:
Variable = WAITKEY()
Examples:

     A=INKEY() Wait for symbol

 


2.2 PROCESS CONTROL OPERATORS

IF / THEN / ELSE

Action:
Condition branch operator
Should be written in one line only.
Syntax:
IF condition THEN operator1 [ELSE operator2]
Examples:

IF X<10 THEN X=X+1 If true then expression

IF X=0 THEN GOTO 100 ELSE GOTO 200

 

IF Z=65 THEN GOSUB 200

If true then call subroutine on label 200

 

FOR / TO / NEXT

Action:
Loop operator
Syntax:
FOR Variable = expression1 TО expression 2
some repeating actions
NEXT
Note. Step = 1 always
Examples:

FOR I=32 TO 127
     PRINT CHR(I),I
NEXT

Print symbols with code from 32 to 127

 

GOTO

Action:
Unconditional branch
Syntax:
GOTO label
Example:

GOTO 100

 

 

GOSUB

Action:
Calls subroutine
Syntax:
GOSUB label
Example:

GOSUB 100  

 

RETURN

Action:
Returns from subrouting
Syntax:
RETURN
Example:

100 PRINT X
       RETURN

 

 

END

Action:
Finishes the program execution
Syntax:
END
Examples:

IF Z=0 THEN END

 

 

STOP

Action:
Stops the program execution, clears receiving buffer, starts after getting new symbol in the input buffer
Syntax:
STOP
Examples:

IF Z=0 THEN STOP

    

 

REM

 Action:
Comments line. Interpreter skips the rest of code in this line.
Syntax:
REM [any string]
operator : REM [any string]
Examples:

REM any text

Do nothing in this line of program

A=10: REM any text Does only operator before REM

 

DELAY

Action:
Forms delay 1..65535 mSec
Syntax:
DELAY expression
Examples:

DELAY 100

Forms delay 100 mSec

 

2.3 DATA

DIM

Action:
Defines an array size
Syntax:
DIM list
Note:
Maximum size of array depends of available memory and controller type

 

Small

Mini

Maxi

Base crystal

ATMEGA16

ATMEGA32

ATMEGA64

Size of available memory

140 bytes/
70 elements

1000 bytes/
500 elements

To be defined

        
Examples:

DIM A(10),B(20)

Array A – reserved memory for 10 elements
Array B - reserved memory for 20 elements

 

DATA

Action:
Specifies constant values to be read by READ operator. Note that max length of data line cannot be more than 64 symbols per 1 line. Max lines of data limited only of available flash memory.

Syntax:
DATA list
Pointer sets to begin of first data block when program starts
Examples:

DATA 9999, -1, 23456  

 

READ

Action:
Reads DATA and moves pointer to next point
Syntax:
READ list
Example:

READ A,B,C  

 

RESTORE

 Action:
Allows read the DATA block more than one time. Sets the pointer at the needed labeled block of data.
Syntax:
RESTORE [label]
RESTORE without parameters sets pointer to begin of the first data block.
Examples:

100 DATA 1,2,3,4,5,6
       DATA 7,8,9
110 DATA 555,777,888
….
RESTORE 110

 

 

 

Set pointer to DATA value 555

 

 RESTORE Set pointer to DATA value 1

 

WRITEEEPROM

Action:
Writes byte to the address in EEPROM
Syntax:
WRITEEEPROM address, byte

READEEPROM

Action:
Reads byte from the address in EEPROM
Syntax:
Variable = READEEPROM(address)

 

Small

Mini

Maxi

Base crystal

ATMEGA16

ATMEGA32

ATMEGA64

Size of EEPROM, byte

512

1024

2048

 

2.4 INTERRUTS and MACHINE CODE

ENABLE

 Action:
Enables interrupts
Syntax:
ENABLE

DISABLE

 Action:
Disables interrupts
Syntax:
DISABLE

INLINE

 Action:
Creates block of machine code on program downloading stage. A few lines of INLINE in any place of program create consequtive block of a code in special area of memory. If the block of a code is formed by several lines INLINE, it is necessary to take care, that interpreter will look only on first of them. The rest of INLINEs should be hidden after operators RETURN or GOTO
The block of a code should be issued as the subroutine, last operator should be operator RET.
Communication with BASIC variables is simple, registers R16, R17 contain the pointer to variable A. A principle of formation of the address of any of 26 (from A up to Z) scalar variables following:
Address = value of R16R17 + 2 * (symbol code - 65)

Синтаксис:
  INLINE opcode1, opcode2….
Example:

10  INLINE opcode1, opcode2….

Simple case, code block is formed by single operator INLINE

10  INLINE opcode1, opcode2….
      RETURN
      INLINE opcoden, opcoden+1….

Block of code is formed by two operators INLINE, so the second operator is hidden after RETURN.

Note. It is possible to automate process of creating INLINE blocks. Just use bin2line.exe to convert machine code to INLINE operators.
It is shown below:

avrasm32 -fI -l %1.lst -o %1.hex %1.asm
hex2bin %1.hex %1.bin
bin2line -i %1.bin -o %1.bas

This is a command file that starts process of conversion from asm code to INLINE code. Avrasm32.exe is an assembler from AVR STUDIO. This one assembles to code directly. For example, we will create procedure to access to 16-bit registers of AVR micro. Value of variable A is writing to register OCR1A.

.include "m64def.inc"
mov r30,r16
mov r31,r17
ld  r18,z+
ld  r19,z+
cli 
out OCR1AH,R19
out OCR1AL,R18
sei
ret

INLINE block after conversion:

INLINE 12256,12273,37153,37169,38136,48443
INLINE 48426,38008,38152

You need put it in BASIC program, add label before the first INLINE and write RETURN or GOTO (as you need) after the first INLINE

200   INLINE 12256,12273,37153,37169,38136,48443
RETURN
INLINE 48426,38008,38152

INTERRUPT

Action:
Creates the block of a machine code at a stage of program loading.
Connects a code to a vector at a stage of execution.
If code of interrupt handler does not fit in one line, it is possible to continue in next line, but using INLINE operator. The line with INTERRUPT should be separated from other code by one of operators RETURN, GOTO as you need. At a stage of execution the line with INTERRUPT should be interpreted once for interrupti initialization. Requirements on registration of the block of a code same as well as for operator INLINE. Can be simultaneously used up to 10 vectors. It is impossible to set interruptions For UART0 and TIMER0 as they are used by system.
Syntax:
INTERRUPT vector, opcode1, opcode2….
Example:


INTERRUPT  vector, opcode1, opcode2…

 

200  INTERRUPT  vector, opcode1, opcode2…
         RETURN
         INLINE  opcoden, opcoden+1…

The simpliest case is when the handler takes only one line

The operator INTERRUPT gets the start address of the code block and binds it with needed vector.

 

 

DELETEVECTOR

Action:
Disconnects the a handler code from vector and disables corresponding interrupt.
Syntax:
DELETEVECTOR vector

PUTATOMIC

 Action:
Assigns value of variable used in interrupt subroutine. During this action interpreter disables interrupts to provide complete (atomic) updating a two-byte variable. It is necessary, as operation of giving contains a chain of several commands which could be broken off by the interrupt, providing access to the same variable..
Syntax:
PUTATOMIC var, value

GETATOMIC

Action:
Gets value from a variable used in an interrupt. During this operator executing interrupts are disabled.
Syntax:
some_var = GETATOMIC(var)

2.5 CONTROLER’S PINS ASSIGNMENT AND USE


Pin
number

Main function

Alternative
function

0

PA0

ADC0

1

PA1

ADC1

2

PA2

ADC2

3

PA3

ADC3

4

PA4

ADC4

5

PA5

ADC5

6

PA6

ADC6

7

PA7

ADC7

8

PB0

 

9

PB1

 

10

PB2

 

11

PB3

 

12

PB4

 

13

PB5

 

14

PB6

 

15

PB7

 

16

PC0

 

17

PC1

 

18

PC2

 

19

PC3

 

20

PC4

 

21

PC5

 

27

PD3

 

28

PD4

PWM0

29

PD5

PWM1

30

PD6

 

31

PD7

 


DEFPIN

Action:
Defines the pin function of the controller pins.
The controller pins have numbering from zero up to some maximum value that depends on the type of controller. The Sets of additional pin functions depends on type of the controller too. See table to reference.

 

Small

Mini

Maxi

Type

ATMEGA16

ATMEGA32

ATMEGA64

Available pins

26

26

 

Pins allowed to change direction function DIN/DOUT

0..21, 27..31

0..21, 27..31

 

Pins allowed to set analog mode AIN

0..7

0..7

 

Pins allowed to set PWM function

28,29

28,29

 

Syntax:
DEFPIN pin AS type

Note.

type

function

DIN

Discrete input

DOUT

Discrete output

AIN

Analog input

PWM

Pulse width modulation

Example:

DEFPIN 8 AS DOUT

Sets pin #8 to operate as a discrete output

CLEAR

Action:
Sets pin logic level to zero
Syntax:
CLEARBIT pin

SET

Action:
Sets pin logic level to one
Syntax:
SETBIT pin

TOGGLE

Action:
Switches pin logic level to the inverted state
Syntax:
TOGGLE pin

TEST

Action:
Reads pins logic level
Syntax:
var = TESTPIN(pin)

PWM

Action:
Puts a digital value out to the PWR channel
Syntax:
PWR pwm_pin, value

SETADMUX

Action:
Set the analog multiplexer up
Syntax:
SETADMUX value
Note.
value = reference source + channel number

Reference source

 

0

pin AREF

64

pin AVCC

192

internal 2.56 volt

 

ADC

Action:
Reads meassured value from the current channel ADC
Syntax:
var = ADС

 


2.6 ACCESS TO INTERNAL RESOURCE OF MICROCONTROLLER

 

POKE

Action:
Writes byte to memory or I/O port
Syntax:
POKE adr, val

PEEK

Action:
Reads byte from memory or I/O port
Синтаксис:
var = PEEK(adr)



Note: You should reference to avr datasheet to get the address of register. Remember there are two addresses: I/O and memory. PEEK and POKE operate with memory address and and you need to add 32 to get I/O address.

2.6.1 Access to the 16-bit registers

Access to the 16-bit registers of avr micro has features. It uses hardware temporary 8-bit register. From the program point of view, there are some rules to access:
1. Use IN and OUT assembler operators.
2. For write: access to the highest register is first.
3. For read: access to the lowest register is first.

This is an example of two subroutines for access register OCR1A using BASIC variable A:

REM .include "m64def.inc"
REM    mov r30,r16
REM    mov r31,r17
REM    ld  r18,z+
REM    ld  r19,z+
REM    cli 
REM    out OCR1AH,R19
REM    out OCR1AL,R18
REM    sei
REM    ret

REM   WRITE to OCR1A
200   INLINE 12256,12273,37153,37169,38136,48443
RETURN
INLINE 48426,38008,38152

REM  .include "m64def.inc"
REM    mov r30,r16
REM    mov r31,r17
REM    cli 
REM    in R18,OCR1AL
REM    in R19,OCR1AH
REM    sei
REM    st  z+, r18
REM    st  z+, r19
REM    ret

REM   READ from OCR1A
300   INLINE 12256,12273,38136,46378,46395,38008
RETURN
INLINE 37665,37681,38152


2.7 MATH ROUTINES

HIGH

Action:
Returns high byte
Syntax:
var = HIGH(expression)

LOW

Action:
Returns low byte
Syntax:
variable = LOW(expression)

ABS

Action:
Returns absolute value
Syntax:
variable = ABS(expression)

ROL

Action:
Shifts value of variable left. The LSB is set to 0.
Syntax:
ROL variable, number of shifts

ROR

Action:
Shifts value of variable right. The MSB is set to 0.
Syntax:
ROR variable, number of shifts

SCALE

Action:
Performs the scaling
Syntax:
SCALE Variable, multiplier, divider
Examples:


SCALE X,100,Y

Calculates percent of number X from number Y. First X * 100 and put result into 32 bit temporary variable M32, then M32 / Y and put result into X

SCALE X,1000,Y

The same, but 10 times more precision


2.8 SOME BASIC EXTENTIONS

PULSEIN

Action:
Returns pulse width on the controller pin unit that are approximately 1 uS at frequency of quartz 14.745 MHz
Синтаксис:
var = PULSEIN(pin, option, timeout)
Note


option

 

0

Waiting for raise edge and measurement pulse width

1

Waiting for fall edge and measurement of pulse width

 

PULSEOUT

Action:
Forms pulse on the pin
Syntax:
PULSEOUT pin, duration

pin – pin number
duration - duration in uSec for resonator 14.745 MHz

SHIFTIN

Action:
Returns the incoming sequence of bits
Syntax:
var = SHIFTIN(data_pin, clock_pin, bits, delay, option, timeout)
Note:


data_pin

incoming data

clock_pin

Synchro, mode defined in option

Bits

number of bits

Delay

Delay in uSec for resonator 14.745 MHz

Option

Mode of synchronization:
clk_pin – output:
0 – the highest bit the first on rising edge
1 – the highest bit the first on falling edge
2 – the lowest bit the first on rising edge
3 – the lowest bit the first on falling edge
clk_pin – input:
option = option + 4

timeout

Time in mSec on which expiration function returns a zero and variable LASTERROR accepts value 1. Value timeout is actual when clk_pin works as synchro_input

 

SHIFTOUT

Action:
Outputs contents of a variable as sequence of bits
Syntax:
SHIFTOUT var, data_pin, clock_pin, bits, delay, option
Note:


Var

Variable contains a value to be converted to consecutive code

Data_pin

Output consecutive data

clock_pin

Synchro, mode defined in option

Bits

number of bits

Delay

Delay in uSec for resonator 14.745 MHz

Option

Mode of synchronization:
clk_pin – output:
0 – the highest bit the first on rising edge
1 – the highest bit the first on falling edge
2 – the lowest bit the first on rising edge
3 – the lowest bit the first on falling edge

 


2.9 TWO WIRE INTERFACE

TWIINIT

Action:
Iinitializes TWI (I2C)
Syntax:
TWIINIT bps, prescale

bps – number for bps needed
prescale - can be defined from equation:

SCL frequency = CPU Clock frequency / (16 + 2(bps) * 4^prescale)

TWISTART

Action:
Generates START condition on SDA and SCL pins
Syntax:
TWISTART

TWIWRITE

Action:
Sends byte to TWI (I2C) device
Syntax:
TWIWRITE байт

TWIREAD

Action:
Reads byte from TWI (I2C) device. ACK/NACK generate
Syntax::
var = TWIREAD(ack)
Parameter ack:
0 – NACK
1 – ACK

TWISTOP

Action:
Generates STOP condition on SDA and SCL pins
Syntax::
TWISTOP

 Example:

  print "***************************"
print "*    DS1339U TWI TEST     *"
print "***************************"
DIM A(16)
TWIINIT 16,2
TWISTART
rem DS1339U Slave address to write
TWIWRITE &HD0
rem Trickle Charger Register (10h)
TWIWRITE &H10:TWIWRITE &B10100101
TWISTOP
10    A=0:TWISTART:TWIWRITE &HD0:TWIWRITE A:TWISTOP
TWISTART:TWIWRITE &HD1
FOR i=0 to 5
A(i)=TWIREAD(1)
NEXT
A(6)=TWIREAD(0):TWISTOP
PRINT "Year:";
if (A(5)AND 128)=0 then print "19";else print "20";
print bcd(a(6),2);
print " Month:";bcd(a(5) AND 127,2);
print " Date:";bcd(a(3),2);" Day:";bcd(a(3),2);
print " ";bcd(a(2),2);":";bcd(a(1),2);":";bcd(a(0)
GOTO 10

2.10 DIAGNOSTICS

At execution of the program there can be situations at which the interpreter stops the work and sends the message on an error in which the code and number of a line is underlined.

Error code

Error

0

Syntax error

1

Unbalanced parentheses

2

No expression present

3

Equals sign expected

4

Not a variable

5

Label table full

6

Duplicate label

7

Undefined label

8

THEN expected

9

TO expected

10

Too many nested FOR loops

11

NEXT without FOR

12

Too many nested GOSUBs

13

RETURN without GOSUB

14

Array not defined

15

Duplicatearray definition

16

Out of memory

17

Array index out of range

18

Pointer out of DATA

20

Can not assign more vectors

LASTERROR

Action:
Returns last error or critical situation code
Syntax:
var = LASTERROR()
Note::

Error code

Error

0

No errors

1

Timed out (PULSEIN, SHIFTIN)

2

TWI error

 

 


3. PRE-PROCESSOR

BASIC language is an extremely simple language, but it is difficult to write big programs by BASIC because the variables length is too short. The best case is when the possible length allows to write “selfcomment” variables. But, long variables, labels could be the cause of slow speed interpreting and resource consuming. A special program-converter can help to resolve this coflict. Our interpreter will still working with short names, but we will work with long names by placing the lines with the preprocessor instruction DEFINE in the program text as shown below:

DEFINE some_long_name = D ‘ defines self comment variable
DEFINE one_more_long_name = 100 ‘ defines constant or label

You can use the apostrophes to start a comment line. At the end you will get something like the program shown below:

 

 

'--------------------------------------------------------
'  TBC GROUP                                        2006
'                    SHIFTOUT TEST
'
'--------------------------------------------------------
' Clock options
define  MSB_FIRST_POSITIVE = 0 ' the highest bit first at raise edge
define  MSB_FIRST_NEGATIVE = 1 ' the highest bit first at falling edge
define  LSB_FIRST_POSITIVE = 2 'the lowest bit first at raise edge
define  LSB_FIRST_NEGATIVE = 3 'the lowestest bit first at falling edge

define  TotalBits  = N ' Количество бит от 1 до 16
define  SrcData    = A ' variable with a source wordvalue
define  DataPin    = D ' data pin number
define  ClockPin   = C ' clock pin number
define  Options    = B ' options
define  PulseDelay = 100 ' defines pulse width that is 2 * PulseDelay
define  MainLoop   = 10  ' Just a name of label 10
CLS
    PRINT "*******************************"
    PRINT "*       SHIFTOUT TEST         *"
    PRINT "*******************************"
    input "DATA PIN=",DataPin
           DEFPIN DataPin AS DOUT:SET DataPin
    input "CLOCK PIN=",ClockPin
           DEFPIN ClockPin AS DOUT:CLEAR ClockPin
MainLoop
    input "TOTAL BITS=",TotalBits
        input "options=",options
          input "data=",SrcData
        shiftout SrcData,DataPin,ClockPin,TotalBits,PulseDelay,Options
GOTO MainLoop

 

 

 

This text needs to be cnvereted before downloading into controller. First we save text of program as shift.bas for example . Then in a command line we can type:
BASPREP.EXE –I shift.bas –O shift.out

Note. BASPREP.EXE must be placed in the same catalogue or be visible of a current arrangement. You can put to C:WINDOWS for example.

We will get something like shown below as a result of conversion.

 

 

CLS
PRINT"*******************************"
PRINT"*       SHIFTOUTTEST         *"
PRINT"*******************************"
INPUT "DATA PIN=",D
DEFPIN D AS DOUT:SET D
INPUT "CLOCK PIN=",C
DEFPIN C AS DOUT:CLEAR C
10 INPUT "TOTAL BITS=",N
INPUT "options=",B
INPUT "data=",A
SHIFTOUT A,D,C,N,100,B
GOTO 10

 

 

The preprocessor eliminates all of the comments and substitute the long names for theirs short values.

 



입금확인 후 평균 3일 이내로 배송됩니다.
(단, 주문상품, 수입품, 대량주문에 따른 재고부족의 경우 2주 이상의 시간이 요구되는 경우도 있습니다.)
제작 혹은 수입에 1주일 이상 소요되는 제품의 경우 주문시 상품대의 70%이상이 입금되어야 주문이 가능하며, 주문취소가 불가능하므로 주의를 요합니다. 토요일/공휴일은 배송기간에 포함되지 않습니다.
도서/산간지역은 2∼3일 정도 추가 소요됩니다.
불가항력적 (일시품절, 제조사 상품수급 문제, 천재지변 등)인 사유로 배송이 늦어질 수 있습니다.
인쇄가 포함되는 간판류의 배송일은 디자인 시안 확정후 5~7일정도 소요되며, 배송이 지연될 경우 별도의 연락을 드립니다.
 
: 전국 (일부지역 제외)
 

배송비 포함이 명시되어 있지 않은 모든 상품은 착불로 발송됩니다.
안전용품, 산업용품의 경우 사이즈 및 중량을 확인하고 주문전 배송비를 상담하여 주시기 바랍니다.

상품에 따라 물품구입비용 보다 배송비가 높게 책정되는 경우도 있으며, 배송비 관련 크레임이 간혹 발생합니다.
특히, 배송비 안내시 “파킹세일이 화물 운송비를 부담한다”는 의미는 고객님의 인근 화물 취급소까지만 배송비를 부담한다는 것을 의미하며, 고객님께서 요청하신 화물 취급소에서 제품을 직접 인수하여야 합니다.
만약 고객님께서 원하시는 위치까지 배송을 원하는 경우 배송비(화물연계 택배비)는 고객님께서 직접 부담하셔야 합니다.
판매자가 다른 상품이거나 상품의 카테고리가 다른 경우 혹은 묶음 배송시 손상우려가 있는 상품은 묶음배송이 되지 않습니다.

공장 직접출하 품목은 소형상품인 경우에도 박스당 배송비가 일반적인 경우보다 2배 이상 부가될 수 있습니다.
석재, 고무제품, 중량물 등의 경우에는 화물, 용달, 다마스 배송이 택배나 기타의 배송비 보다 저렴할 수 있습니다.
석재볼라드, 부스 등의 주문시 하차를 위해서는 안전을 위하여 지게차를 준비하셔야 합니다. 지게차 비용은 고객님 부담입니다.
도서, 산간, 오지등 교통이 불편한 지역 배송시 배송비가 추가 될 수 있습니다.

 
 

파킹세일에서는 별도로 A/S 기간이 정해진 제품을 제외한 나머지 제품들은 1년간A/S를 보장하며, 출장 A/S는 설치의뢰가 함께 요청된 상품을 제외하고는 실시하지 않습니다.(즉, 제품만 구매한 경우에는 출장 A/S를 실시하지 않습니다.)

특히, 소비재 상품(소모성상품)의 경우에는 구매 확정후에는 A/S가 불가능합니다.
만약 출장 A/S를 원하는 경우 위너기술㈜에서 정한 기준에 따라 소정의 A/S출장비[출장인건비 및 부품비]를 지불하셔야 합니다.

제품 구매 인수 후 7일 이내의 제품은 초기 불량에 한해 1:1 상품 교환 또는 환불이 가능합니다. 단, 제품의 박스 및 구성물이 전부 정상 상태에서만 가능 합니다. 교환의 경우 동일 상품으로 1:1 교환은 가능하나 다른 상품으로 교환은 불가능합니다.

특히, 주문 생산된 상품, 대량으로 물품을 주문한 후 불용자재가 되어 환불요청/물품교환 등이 불가능하므로 특히 주의를 요합니다.
구매한 상품을 환불받으시기 위해서는 제품의 포장상태와 내용물이 훼손되지 않아야 하며 스티커, 테이프를 붙여서 제품의 박스 포장이 훼손되면 환불이 불가합니다.제품 교환, 환불에 대한 내용을 정확히 확인하시고 주문하시기 바랍니다.

청약철회 : 소비자의 단순 변심에 환불은 제품의 포장상태가 처음과 같아 재판매가 가능할 때에 7일 이내에 가능합니다.(운송료 소비자 부담)
그러나 주문제작품, 대량 생산주문 상품은 교환이나 환불이 불가능하므로 주의하여 주십시오.

소프트웨어 상품일 경우, 제품의 개봉 후엔 교환/환불이 절대 불가합니다.
소비자 과실에 의한 파손인 경우에는 유상 A/S 처리가 되며 경우에 따라 A/S가 불가능할 수 있습니다.
천재지변에 의하여 제품에 손상이 있는 경우엔 A/S처리가 불가능할 수 있습니다.
제품 구매 인수 후 7일 이내의 제품 불량 발생시 A/S에 관한 택배 운임비는 전액 파킹세일이 부담합니다.

단, 7일 이후에 발생하는 모든 배송에 관한 운임비는 소비자분께서 부담하시게 되므로 유의하시기 바랍니다.

파킹세일에서 자체적으로 제작한 기능상품의 경우 1년 동안 무상 A/S처리가 됩니다.
단, 파킹세일 상품의 부속품 중 단종이 된 상품은 해당 서비스 업체의 처리 기준에 의해 보상됩니다.
파킹세일에서 판매하는 상품 중 소프트웨어는 A/S항목에 포함되지 않습니다.

파킹세일 쇼핑몰의 주문 유효 기간은 주문 후 7일이며 이후 입금이 되지 않는 주문은 삭제 처리됩니다.
파킹세일에 표기된 모든 가격은 부가세가 포함된 금액이며, 배송비는 대부분 별도입니다.

[교환 및 환불의 일반조건: 배송비 파킹세일 부담]
-. 주문한 내용과 다른 상품을 배송한 경우
-. 상품의 유효기간이 경과한 상품을 배송한 경우
-. 상품의 파손 및 손상된 상품을 배송한 경우
[교환 및 환불이 안되는 조건]

-. 고객님의 요구에 따라 주문 생산된 상품, 인쇄물이 포함된 상품, 철재 혹은 비철 가공품
-. 표준 상품이지만 대량생산 요청하여 생산이 완료된 경우
-. 고객님의 요구에 의하여 해외로부터 수입된 상품
-. 고객님의 책임있는 사유로 상품이 분실 또는 훼손된 경우
-. 포장을 개봉하였거나 포장이 훼손되어 상품가치가 상실된 경우
-. 이용자의 사용 또는 일부소비에 의하여 상품의 가치가 현저히 감소한 경우
-. 시간의 경과에 의하여 재판매가 곤란할 정도로 상품의 가치가 현저히 감소한 경우
-. 상품의 라벨 및 포장의 개봉 후 상품 가치가 훼손된 경우

[환불안내]
-. 선결제한 주문을 취소한 경우에는 배송출발 전이면 주문 취소 후 조건에 따라 이체 수수료 공제후 환불
-. 반품의 경우에는 파킹세일에서 반품 상품이 도착한 후 조건에 따라 이체 수수료 공제후 환불
-. 신용카드로 결제한 경우 카드사로부터 대금청구가 되었다면 현금으로 입금(조건에 따라 이체 수수료공제 후)
   카드사로부터 대금청구가 되지 않았다면, 카드결제 승인취소(카드결제 대금이 청구 되지 않음)
-. 실시간 계좌이체로 결제한 경우 - 승인취소 또는 현금으로 환불
 
 

전화상담은 월~금 오전 9:00부터 오후 5시까지입니다.
온라인 주문 접수는 24시간 주문 접수는 가능하나 택배 배송 서비스는 오후 4시 30분까지이며, 화물은 오후 3시,퀵 서비스는 오후 5시입니다.
지정된 시간 이후에 주문 확인이나 입금 확인 된 주문은 다음날 발송처리 됩니다. 단, 토요일, 일요일, 공휴일은 휴무입니다.

 
 
- 제품 생산공장 운영자, 수입 및 수출업자, 제품의 설치와 시공지원이 가능한 개인 및 법인을 수시로 모집하고 있습니다.
- 우수한 제품을 가지고 판매망이 없어 고민하신다면 관련분야 1위 파킹세일에서 귀사의 상품을 판매하신다면 이미 절반의 성공을이루신 것입니다.
-

파킹세일에 등록된 제품 중 품질이 우수한 제품은 선별적으로 영어, 일본어, 러시아어, 중국어로 번역되어 제품이 소개되어 바이어 유치를 지원하며, 특히, 일본의 경우 전문 유통 협력사를 통하여 일본전역에 직판되는 기회를 함께 누릴 수 있습니다.

- 파킹세일에 새로운 서비스를 제안해 주십시오. 열린생각과 시각으로 고객님과 함께 상생할 수 있는 비즈니스 파트너가 되겠습니다.
- 파킹세일에서 배너광고를 시작하여 보십시오. 안전용품/산업용품관련 최다 회원을 확보하고 있으며, 최고의 Page View를 자랑합니다.
- 파킹세일 회원을 대상으로 이벤트 제휴제안을 받습니다. 경매, 공동구매, 할인쿠폰, 영화예매권 등을 이용한 이벤트 제안 내용이 있으시면 문의하여 주십시오.
- 위탁판매, 제휴, 설치 및 시공 협력사 문의는 info@parkingsale.com입니다.