Industrologic SBC-1 and SBC-1-AD12

Single Board Computer/Controller

Reference Manual

version 4/26/07



Industrologic, Inc.
3201 Highgate Lane
St. Charles, MO
63301
USA

Phone: (636) 723-4000
WWW: http://www.industrologic.com
Email: info@industrologic.com




Trademark and Copyright Information

SBC-1 is a Trademark of Industrologic, Inc. 1998-2007

This document is Copyright (c) 1998-2002 by Industrologic, Inc.
All rights reserved.

No part of this manual may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying or scanning, for any purpose other than the personal use by the purchaser of this product. Industrologic, Inc. reserves the right to revise this document at any time without obligation to notify any person of such revision. Industrologic, Inc. assumes no responsibility for any errors that may appear in this document.

The software distributed with and the firmware contained in this product is Copyright (c) 1998-2002 by Industrologic, Inc.


Warning/Disclaimer

Whereas effort has been made to make the information in this document as useful and accurate as possible, Industrologic, Inc. assumes no responsibility for the application, usefulness, or completeness, of the information contained herein. Under no circumstance will Industrologic, Inc. be responsible or liable for any damages or losses including indirect or consequential damages or losses arising from either the use of any information contained within this manual or the use of any products or services referenced within this manual.

Industrologic, Inc. reserves the right to change any product's features, specifications, documentation, warranties, fee schedules, and conditions at any time and without notice.

Industrologic products are provided as printed circuit board level assemblies. Some Industrologic products may include mechanical packaging assessories which are provide for the purchaser's convenience, and are not intended to be final assembly enclosures.

Industrologic products are provided with the understanding that the purchaser will determine fitness for any particular application as well as achieve compliance with any particular specifications or regulations as required or desired for that application.


Warranty

Industrologic, Inc. products are warranted to be free from defects in workmanship or material under normal use and service for a period of one year from date of purchase. Industrologic's warranty is to the original purchaser only, but is extended to you by the Distributor or OEM from whom you purchased the product.

Industrologic's obligation under this Warranty is limited to replacement with a new or repaired unit to the original purchaser. The unit must be returned, and replacements obtained from Industrologic, Inc. or the Distributor or OEM from whom it was purchased.

This warranty will not apply if, in the judgment of Industrologic, Inc., damage or failure of the product has resulted from accident, alteration, misuse, abuse, connection to or operation with incompatible signals or power sources, or improper installation.

Under no circumstances shall Industrologic, Inc. be liable to purchaser or any third party for any loss of profits or other direct or indirect costs, expenses, losses, or consequential damages arising out of or as a result of any defects in or failure of Industrologic products or any part or parts thereof.

THIS WARRANTY IS IN LIEU OF ANY OTHER WARRANTY, EITHER EXPRESSED OR IMPLIED, AS TO DESCRIPTION, QUALITY, MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE OR USE, OR ANY OTHER MATTER.


Return and Repair Policy

Products purchased in single piece quantities may be returned, if in resellable condition, for a full refund of the purchase price only, to the original purchaser, within 30 days of purchase.

Products must be returned by original purchaser with a Return Materials Authorization (RMA) number issued by Industrologic, Inc. or the Distributor or OEM from whom it was purchased, authorizing its return. Current repair or replacement fees and procedures will be related during the issue of the RMA number.

Warranty or repair units must be returned with postage and insurance paid by purchaser. Industrologic, Inc. is not responsible for damages or loss during shipment.






Industrologic SBC-1 and SBC-1-AD12

Single Board Computer/Controller

Section 1
4/26/07

The Industrologic SBC-1 was designed to provide an industrial control system that is economical, configurable, and one that allows the user to choose between uploading their own 80C51 assembly language code, or uploading the compiled result of a higher level language such as BASIC or "C". The unit can also be programmed with a version of TinyBASIC interpreted language specially enhanced for the SBC-1, which is provided with the unit in ROM.



picture of SBC-1



Summary of Features

Hardware features:

Based on an Intel 80C51 microcontroller operating at 11.0592 MHZ.

Self-contained printed circuit board assembly with no wiring or connections necessary except those required to connect power, communication, and user signals.

Watchdog timer that resets the controller if a program ceases to execute properly for a preset period of time (approximately 1/2 second).

LED indicators for selected functions: Power, serial port transmit and receive, test voltage.


Power supply features:

Operates on 11 to 14 volts DC (or 9 to 11 volts AC) and therefore can be used in applications involving mobile and battery operated equipment. It can be operated from an "alarm" style power supply and will run from the float-charged 12 volt battery when the power fails.


Serial port features:

Contains a shared serial port that provides 2 physical ports on the controller.

Serial Port 1 is reserved for system set up, diagnostic control, and program upload and download. The connector and pin assignment of this port is designed for easy connection to the serial port of an IBM PC or equivalent computer with a male to female, pin to pin 9 pin cable.

Serial Port 2 is provided for interface to man-machine interfaces such as LCD displays, video display terminals, or "smart sensors" and data acquisition devices, or can be used to slave one SBC-1 to another and act as a master/slave system. The connector and pin assignment of this port is designed to emulate a serial port of an IBM PC or equivalent computer.


Software and Firmware features:

The SBC-1 contains an on-board firmware monitor system for setup and service. Diagnostic input status and output control are available to technical personnel without affecting the user program.

Special commands are available to allow the SBC-1 to be used as a "slave" unit to another RS-232 device and to use its I/O as an extension of the "master", or controlling device.

The TinyBASIC language interpreter can read and write EEPROM locations using a special command. This memory allows you to write a given memory cell up to 10,000 times before the device is depleted, and so a user program can be written that allows for "learning" and storage of "learned" data. This can also be used as an debugging aid.

A Year-2000 compliant real-time clock is implemented in hardware and firmware, and is available to TinyBASIC in the form of special commands, as well as to assembly language programs.

Two task timers are available (separate from the real-time clock) that keep track of system Hours (0-255), Minutes (0-59), Seconds (0-59), and Ticks (0-99). (Ticks are .01 seconds each). These timers can be set to a specified amount of time and will set a flag which is available to the user program on completion of their assigned timing tasks.

Many of the assembly language routines required by the system software in ROM are available as callable modules that allow you concentrate on the code for your application instead of developing an entire "system" for the unit.


The SBC-1 interfaces the following signals:


Digital inputs and outputs to rack I/O:

The 24 digital inputs and 24 digital outputs are available to be jumpered to a 50-pin 0.1" double-row header for easy connection to industry standard 24 channel digital I/O "racks" (mounting boards for opto-isolated modules), typical of Potter and Brumfield 2IO-24 and Gordos PB-24 racks. This provides the option of having all 24 modules assigned as input, all 24 modules assigned as outputs, or any combination of 24 inputs or outputs.

Note: Instead of jumpering only 24 signals for use with the 50-pin header connector, all 24 inputs and all 24 outputs can be used in one of two ways:


The following signals connect to screw terminals for quick discrete connection:


Quick Start

How to power on and start your SBC-1, check it out, and make it run - Quick!


Mechanical specifications

Double-sided .062" FR-4 glass epoxy printed circuit board.
P.C. Board assembly has 6 holes available for mounting to enclosure or #6 standoffs.
P.C. Board Dimensions: 5.00 inches by 8.00 inches<


P.C. Board Mounting:

mechanical drawing of SBC-1



Electrical specifications

Power Supply:

Power supply voltage: 9 volts to 11 volts AC, 11 volts to 14 volts DC, regulated or unregulated
Power supply current: 110 to 400 ma (depending on outputs driven)

Special note on power supplies:
These specifications are for actual measured voltages at the SBC-1. Be advised that all unregulated wall pack power supplies produce their rated voltage only at their specified current, and will actually produce a much higher voltage at lower current drains. For example, a 12 volt unregulated supply rated at 800 ma may actually produce 20 volts when connected to the SBC-1. Use either the wall block power supply provided with the SBC-1, or one you have measured with a meter and know to be an appropriate voltage.

On-board LED's:
The red power LED1 indicates power applied to SBC-1. The green LED2 is driven by the serial port transmit line and will flicker when data is transmitted. The yellow LED3 is driven by the serial port receive line and will flicker when data is received. The red LED4 is available for testing purposes and can be used to check for signals or voltages at various points on the board. Jumpers are available to connect the ends of the LED to +5 and/or ground, giving you the ability to check signals that either source or sink current.

Power available at the screw terminals:
The +5 volt supply used on-board the SBC-1 is made available at discrete screw terminals to allow quick interfacing to certain devices requiring power without having the need to provide separate power supplies. However, the current drawn from these terminals should not exceed 100 milliamperes.

Operating Environment:
Temperature: 0-50 degrees Celsius (32-122 Fahrenheit)
Humidity: 30 to 80 percent, non-condensing
Optional conformal coating as a special order item.
(Contact Industrologic, Inc. for more information.)

Interrupt Inputs:
(10K pull-up resistor to +5)
Voltage input high: 2.2 volts minimum
Voltage input low: 0.8 volts maximum

Digital Inputs:
(10K pull-up resistor to +5)
Voltage input high: 2.2 volts minimum
Voltage input low: 0.8 volts maximum

Digital Outputs:
(Isolated open-collector transistors.)
Voltage switched: 36 volts DC
Current sink: 100 ma maximum

Note:
Total current sink for all digital outputs combined should be limited to 800 ma.

Analog Inputs:
Voltage range: 0 to +5 volts
Input capacitance: .01uf
Input Impedance: 5000 ohms or less for best results
Accuracy: +/- 1 LSB (or +/- 2 LSB bits with SBC-1-AD12)
Resolution: 8 bits (or 12 bits with SBC-1-AD12)


On-Board Configuration Jumpers

The SBC-1 uses plastic jumpers or "shunts" placed on pins on the printed circuit board to select various board options.

Test LED: As an aid in troubleshooting wiring connections and to quickly demonstrate signal operation, the two jumpers associated with the TEST LED allow the LED to be used to monitor signals that either source or sink current. With the LED- jumper installed, a signal that sources current can be connected to LED+. With LED+ jumper installed, a signal that sinks current can be connected to LED-. With both jumpers installed, the TEST LED becomes a +5 volt power indicator.

Program Write Protect: Beginning with printed circuit board revision B the SBC-1 has an additional 3 place jumper labeled EEWRITE. This jumper allows the EEPROM used for program storage to either be written in the normal fasion when the jumper is in the WR position, or write protected when in the PROT position.

Digital Input/Output Selection: The group of jumpers called IOSEL are used to select whether a particular digital I/O signal sent to the 50-pin rack I/O connector and screw terminal is used as an input or output. All 24 input signals are available on the top row of 24 pins, and all 24 output signals are available on the bottom row. To set a particular I/O signal to the connectors as an input, place the jumper between the top pin and center pin, or as an output, between the bottom pin and center pin.


Using all 48 Digital I/O Signals

The SBC-1 has a total of 24 digital input signals and 24 digital output signals. Normally only 24 of these signals are used by jumpering them to the 50-pin header connector as described above, however, by making connections to the top and bottom rows of pins of IOSEL, all 24 inputs and all 24 outputs can be used. There are three ways that this can be done:

1. By using an SBC1-TB48 terminal block board to allow all 48 I/O signals to be available at screw terminal blocks. Remove all of the IOSEL jumpers and install the SBC1-TB48 as shown in the picture below, which makes connection from the terminal blocks to all 48 signals on the IOSEL jumper pins. Note: With the jumpers removed from the IOSEL pins, the eight terminal block connections IO1 through IO8 on the SBC-1 are no longer connected to the I/O signals, are isolated from each other, and are available as general purpose connections.

SBC1-TB48

2. By using an SBC1-I24 adapter board to add a second 50-pin header connector. Set the IOSEL jumpers to select all 24 digital outputs on the SBC-1 50-pin header connector. Then install the SBC1-I24 as shown in the picture below, which makes connection from its 50-pin header to all 24 inputs on the remaining IOSEL jumpers. Connect wires from the screw terminal block connections to +5 and ground if needed. A cable can then be plugged into the 50-pin header on the SBC1-I24 that can go to a digital input board.

SBC1-I24

3. By connecting an additional cable to the IOSEL jumpers directly. Set the IOSEL jumpers to select all 24 digital inputs on the SBC-1 50-pin header connector. As shown in the picture below, place the connector of the second cable so that pin 1 of the connector is going to IOSEL position 24 and pin 47 of the connector is going to IOSEL position 1. The other end of the cable can be connected to a digital output board, (but will not have the +5 and ground connections available as in a normal RACKIO connection.)

SBC-1 48 I/O utilization



External Signals

Digital Inputs:
The 24 digital input signals DI1-DI24 are available for connection to the RACKIO connector selection with jumpers IOSEL0 through IOSEL23. These signals are connected to 74HC251 chips and include 10K pullup resistors to +5. Bringing these inputs "low" will turn "ON" an input. In addition, signals DI1-DI8 are available at the terminal block connectors if so selected. Inputs 1-8 are associated with U17, inputs 9-16 with U18, and inputs 17-24 with U19.

Digital Outputs:
The 24 digital output signals DO1-DO24 are available for connection to the RACKIO connector selection with jumpers IOSEL0 through IOSEL23. These signals are connected to discrete open-collector NPN transistors. Turning "ON" an output will turn on the associated transistor and cause it to sink current at the output. In addition, signals DO1-DO8 are available at the terminal block connectors if so selected. Outputs 1-24 are associated with transistors DOQA-DOQX respectively.

Interrupt Inputs:
The 2 digital interrupt input signals I1 and I2 are available at the terminal block connectors and are connected directly to the INT0 and INT1 pins of the 80C51 processor chip (U1). These signals include 10K pull-up resistors to +5.

Serial Ports:
There are 2 physical ports on the SBC-1 that provide RS232-C compatible transmit and receive signals. They are driven by a MAX-232 charge pump transceiver chip (U7) and exhibit + or - 10 VDC signal levels when not loaded. Port #1 is a DB9F and is designed to connect directly to a PC serial port with a pin-to-pin male-to-female cable, and Port #2 is a DB9M and simulates a PC serial port for use with devices wired for connection to a PC serial port.

Analog Input:
The analog input signal A1 is available on the terminal block connectors and is connected to the input of the A/D converter chip (U11).


Serial Port Cabling Guide

The SBC-1 features an internal switching arrangement that allows 2 physical serial ports on the unit to be served by the one physical port of the 80C51 processor. In this way units may have a user display that is updated with appropriate user information during execution of application software while retaining the other serial port to talk with other serial data capable devices, including personal computers, "smart" gages and sensors, and data communications equipment such modems.

The SBC-1 Serial Port 1 and its pinout matches the 9-pin serial port of IBM PC compatible computers and can be easily connected to these computers using a pin-to-pin, male-to-female cable. The SBC-1 does not require hardware handshake signals and can be used with only the transmit, receive, and ground signals connected. Certain programs, however, may require that some of the input handshake signals be asserted going into the PC. In order to make this easier, the SBC-1 has the common PC handshake signals looped back on the board, so that when a 9-wire cable is used, the signals are asserted without further connection. The connector and pin assignment of Serial Port 2 is designed to emulate a serial port of an IBM PC or equivalent computer. If you hook up to some other form of serial port device you may have to consult the data from it's source or manufacturer to determine the interface cabling requirements.

The following is a pinout of the serial ports:

Serial port 1 - DB9 Female                    Serial Port 2 - DB9 Male

Description  Pin    signal on a PC            Description  Pin

             1      DCD in                                 1
transmit     2      receive                   receive      2
receive      3      transmit                  transmit     3
             4      DTR out                                4
ground       5      ground                    ground       5
             6      DSR in                                 6
             7      RTS out                                7
             8      CTS in                                 8
             9      RI in                                  9

On both Serial Port 1 and 2 connectors, pins 1, 4, and 6 are tied together,
and pins 7 and 8 are tied together.

50 pin RACKIO connector pinout

The 24 digital I/O signals on the SBC-1 connect to a 50-pin 0.1" double-row header for easy connection via a 50 pin ribbon cable to industry standard digital I/O "racks" (mounting boards for opto-isolated modules), available from a variety of manufacturers.

The following is a pinout of the connector.

digital I/O #24    1    2    ground
digital I/O #23    3    4    ground
digital I/O #22    5    6    ground
digital I/O #21    7    8    ground
digital I/O #20    9   10    ground
digital I/O #19   11   12    ground
digital I/O #18   13   14    ground
digital I/O #17   15   16    ground
digital I/O #16   17   18    ground
digital I/O #15   19   20    ground
digital I/O #14   21   22    ground
digital I/O #13   23   24    ground
digital I/O #12   25   26    ground
digital I/O #11   27   28    ground
digital I/O #10   29   30    ground
digital I/O #9    31   32    ground
digital I/O #8    33   34    ground
digital I/O #7    35   36    ground
digital I/O #6    37   38    ground
digital I/O #5    39   40    ground
digital I/O #4    41   42    ground
digital I/O #3    43   44    ground
digital I/O #2    45   46    ground
digital I/O #1    47   48    ground
+5                49   50    ground


The SBC-1 I/O Expansion Buss

This expansion buss is a 16 pin (8 positions by 2 rows) 0.1" header that is meant to connect the SBC-1 to peripheral devices by use of a 16 conductor ribbon cable.

Pin #  Name         Function                        Remarks

1      BITO         data output bit                 TTL
2      STB          strobe output                   TTL
3      BITI         data input bit                  TTL
4      TXD          serial transmit                 RS232-C
5      BAD0         bit address 0                   TTL
6      RXD          serial receive                  RS232-C
7      BAD1         bit address 1                   TTL
8      +UNREG       power to external device        500 mA max!
9      BAD2         bit address 2                   TTL
10     +5V          power to external device        100 ma max!
11     DAD0         device address 0                TTL
12     RST          high true reset                 TTL
13     DAD1         device address 1                TTL
14     COMMON       common
15     DAD2         device address 2                TTL
16     COMMON       common






The following is a drawing of the SBC-1 P.C. board showing the jumpers and connections:

SBC-1 P.C. board drawing




Monitor and System Software Reference

Section 2
version 4/27/02

The following menu is obtained from Serial Port #1 of the SBC-1 by using a communication program or terminal set to 9600 baud, no parity, 8 bits, and 1 stop bit, and pressing the enter key on the keyboard. You will notice that the monitor will prompt you as to what number of digits are required to enter and inform you of what to do. Hitting the ESCAPE key will usually get you out of a function without having to do any further operation. If the AUTOBOOT function is enabled you must hit a key or enter within the first 2 seconds after powering up the controller to stay in the Monitor program instead of going to the program in EEPROM space. (User application, TinyBASIC language, etc.) The text in parentheses is explanatory and does not appear on the SBC-1 command menu or commands.

A - set Autoboot on/off                (User program auto load and run on reset)
C - real-time Clock                    (Display/Set the real-time clock)
D - Download program using XMODEM      (Dump EEPROM to file on PC)
E - edit External memory               (Edit EEPROM or RAM Memory)
F - Fill external memory               (Fill memory with specified byte)
G - Goto user program (EEPROM)         (Jump to EEPROM and execute code there)
H - or ? or RET = Help                 (Re-displays this menu)
I - edit Internal memory               (Edit the memory inside of the 80C51)
J - Jump table                         (Display system callable code routines)
K - Goto BASIC                         (Jump to TinyBASIC interpreter)
M - memory Map                         (Display a map of all memory space)
N - dump iNternal memory               (Dump the 80C51 internal memory + SFRs)
O - change Output terminals            (Turn outputs on or off directly)
P - serial Port 2 test                 (Momentarily transmit and receive on Port 2)
Q - display relative time clock        (Displays the relative time since reset)
T - display I/O Terminals              (Display the status of all I/O terminals)
U - Upload program using XMODEM        (Load from the PC to EEPROM your code)
V - display Variable input (A to D)    (Display results of A to D converter)
X - dump eXternal memory               (Dump the hex and ASCII equivalent)
Note that you can temporarily stop the display by hitting the space bar, and then pick up where you left off by hitting the space bar again. The following shows most of the commands as they appear from the system monitor prompt on the SBC-1.

>A Autoboot is now ON
Run your uploaded program on power up?
1 = YES, 0 = NO, ESC exits.

>C
YEAR    MONTH   DAY   DAY OF WEEK   HOUR   MINUTE   SECOND
1999     12      31       6          23      59       59

S to set RTC, C to read again, all other keys exit
S
(Century is not entered, but is determined by year).
Type 2 numbers for year (00-99):
Type 2 numbers for month (01-12):
Type 2 numbers for day (01-31):
Type 1 number for day of week (1-7, 1=Sunday):
Type 2 numbers for hour (00-23):
Type 2 numbers for minute (00-59):
Time will be set when next key is hit. (Seconds are always set to 00).

>D
Download the contents of the EEPROM chip on the SBC-1 to the host terminal
(personal computer) using the XMODEM format. (In this manner the contents of
one SBC-1 can be saved to a file on the host system and then downloaded to
another SBC-1 to replicate one SBC-1 to another.) 
 

>E    Edit external memory. Enter start address.
xxxx  ESC to exit editing.

>F    Fill external memory. Enter start, end addresses and fill byte
xxxx-yyyy,zz

>G
(Jump to user program in EEPROM. If this area contains a stored BASIC
program, the SBC-1 will automatically run TinyBASIC and execute this
BASIC program.)

>H
(redisplays menu)

>I    Edit internal memory. Enter start address.
xx    RET for next, ESC to exit.

>J
Jump Table Offset   Function
33H                 Serial character input
36H                 Serial character input with echo
39H                 Serial status, carry set if no character
3CH                 Serial character output
3FH                 Serial string output (NULL terminated)
42H                 Send CR,LF to serial port
45H                 Delay for number of milliseconds in ACC
48H                 Delay for number of seconds in ACC
4BH                 Input/Output bit scan
4EH                 Select serial baud rate
51H                 Select serial port 1 or 2
54H                 Start user timer
57H                 A/D conversion
5AH                 Strobe watchdog
5DH                 EEPROM write
60H                 Write to external LED Display
63H                 Jump to TinyBASIC interpreter
66H                 Read real-time clock
69H                 Write real-time clock

>K
(Jump to TinyBASIC in ROM)

>M
====================== Memory Map =======================
0000H -- 1FFFH     1st 8K of EPROM
2000H -- 3FFFH     2nd 8K of EPROM (27C128)
4000H -- 5FFFH     3rd 8K of EPROM
6000H -- 7FFFH     4th 8K of EPROM (27C256)
8000H -- 9F7FH     User EEPROM (8064 bytes) *Code/Data*
9F80H -- 9FFFH     System Use EEPROM (128 bytes)
A000H -- BFFFH     unused
C000H -- DDFFH     User RAM (7680 bytes) *Code/Data*
DE00H -- DFFFH     System UseRAM (512 bytes)
E000H -- FFFFH     unused
=========================================================

>N    Dump internal memory. Enter start, end addresses.
xx-yy

>O
Bank # (1-3)?      (Bank #1 = outputs 1-8, Bank #2 = 9-16, Bank #3 = 17-24)
Channel # (1-8)?
On = 1, Off = 0?

>P
Test Port 2 Select baud rate or press ENTER for 9600
1) =  300
2) =  600
3) = 1200
4) = 2400 ?

>Q    Elapsed time since reset/powerup = Hours:00 Mins:13 Secs:48 Ticks:55
User timers available: 2
 
>T
Bank  I/O    CH1    CH2    CH3    CH4    CH5    CH6    CH7    CH8    INT1   INT2
01    In     0      1      1      1      1      1      1      0      1      1
02    In     0      0      0      0      0      0      0      0
03    In     0      0      0      0      0      0      0      0
01    Out    0      0      0      0      0      0      0      0      wdtimer = 0
02    Out    0      0      0      0      0      0      0      0
03    Out    0      0      0      0      0      0      0      0
Press letter "O" to change outputs, 'T' to refresh status

>U
Upload a binary file on the PC to the EEPROM chip on the SBC-1 using the XMODEM format. 


With 8 bit A/D:
>V    Variable input value (in decimal) = 255
This numeric value multiplied by .01953 = the approximate voltage 0 to 5 volts

On SBC-1-AD12 with 12 bit A/D:
>V    Variable input value (in hexadecimal) = 0FFF
This numeric value multiplied by .001221 = the approximate voltage 0 to 5 volts


>X    Dump external memory. Enter start, end addresses. xxxx-yyyy
SPACE to pause, ESC to exit



Commands for Slave Operation

The commands listed below are intended to allow the SBC-1 to be slaved, or driven by a data acquisition or control program and serial port of another device. This can be another SBC-1 set up as a master, or it can be a personal computer or other processor equipped device.

Slave commands are implemented in displayable ASCII codes where the 8 bit decimal values 0 thru 255 decimal will be sent and received as a hexadecimal value represented by two ASCII characters. For example, 0 decimal will be sent as 30H 30H (00 on the screen of the terminal) and 255 decimal will be sent as 4AH 4AH (FF on the screen of the terminal).

Slave commands sent to the SBC-1 do not need a carriage return or line feed following the command, but will be acted on whenever the last required character is sent to it. Responses from the SBC-1 will be followed by 0DH 0AH 0AH 3EH (carriage return, 2 line feeds and a "greater than" or character which is the monitor prompt character).

Slave commands include a checksum, which is transmitted along with output commands and received with input commands, to enable the host device to ensure that data transmission is correct to and from the SBC-1. The checksum is another 8 bit decimal value represented by two ASCII characters that comes after the end of the command values (but before any carriage return/line feed sequence). Check sum calculations must be implemented in the acquisition or control program on the host device.

>S Get status of all inputs and outputs
Data returned: xxyyzzttuuvvwwcs0D0A0A3E, where xx is inputs 01-08 represented by bits 7 through 0 respectively, yy is inputs 09-16, zz is input bits 17-24, tt is interrupt inputs I1 and I0 represented by bits 1 and 0 respectively, uu is outputs 01-08, vv is outputs 09-16, ww is outputs 17-24, cs is the checksum, 0D is carriage return, 0A is line feed and 3E is the "greater than" or > character.

The checksum for this command is calculated by doing a two's complement (inverting and adding one) of the sum of the 8 bit values, (ignoring the overflow or carry past 8 bits on each addition). Examples: The checksum for FF FF FF 03 00 00 00 would be 00 (FF + FF + FF + 03 + 00 + 00 + 00 = 00 ignoring the overflow, 00 hex inverted is FF hex, FF hex + 01 hex = 00 ignoring the overflow). The checksum for FE FF FF 03 00 00 00 would be 01 (FE + FF + FF + 03 + 00 + 00 + 00 = FF ignoring the overflow, FF hex inverted is 00 hex, 00 hex + 01 hex = 01).

>Bxxyycs Set output bit
Where xx is the output bit 01 through 24 and yy is 00 or 01 (representing 0 for off and 1 for on).

The checksum for this command is calculated by doing a two's complement (inverting and adding one) of the decimal sum of the two 8 bit decimal values (but treated as hexadecimal in this case). Examples: The checksum for 01 01 would be FE ( 1 + 1 = 2 decimal , 2 is treated as 02 hex, 02 hex inverted is FD hex, FD hex + 01 hex = FE). The checksum for 24 01 would be DB ( 24 + 01 = 25 decimal, 25 is treated as 25 hex, 25 hex inverted is DA hex, DA hex + 01 hex = DB).

>Y Get A/D converter value
Data returned:
With the 8 bit A/D converter xxcs0D0A0A3E, where xx is the 8 bit value 00 through FF, cs is the checksum, 0D is carriage return, 0A is line feed and 3E is the "greater than" or > character.

On the SBC-1-AD12 with the 12 bit A/D converter xxxxcs0D0A0A3E, where xxxx is the the 12 bit value 0000-0FFF, cs is the checksum, 0D is carriage return, 0A is line feed and 3E is the "greater than" or > character.

The checksum for this command is calculated by doing a two's complement (inverting and adding one) of the 8 bit value. Examples for 8 bit A/D: The checksum for the value 00 would be 00 (00 hex inverted is FF hex, FF hex + 01 hex = 00). The checksum for 44 would be BC (44 hex inverted is BB hex, BB hex + 01 hex = BC).

>R Reset all outputs to logic 0.
Outputs cease to sink curent.



Programming Information


Programming in 8051 Assembly Language, Compiled BASIC, and "C".


The steps to develop a machine language program are as follows:


Machine language development requires:


Notes:


TinyBASIC Interpretive Language:

A specially modified and enhanced TinyBASIC interpretive language exists in ROM on the SBC-1 and includes commands added to the language to read and write the special hardware on the board. This language allows you to program directly on the SBC-1 from communication software and save the results to SBC-1 EEPROM! This language is ideal for demos, simple applications, and for having the program be in a simple, self documenting language. With this programming language anyone who can connect to the SBC-1 with a terminal will be able to list, trace, edit, and resave the software without any other references or materials. The program can also be written in your favorite word processor and saved as a text file.

Using a communications software package while the SBC-1 is at the prompt and running the TinyBASIC interpreter, you can simply upload ASCII to the SBC-1 as though it was being typed manually, and then type in SAVE so that the SBC-1 will save the "automatically typed" file to EEPROM.



Interrupts on the SBC-1 system

Interrupts available on the 80C51 processor are available and used as follows:

Memory Map of the SBC-1

The Intel 80C51 processor used in the SBC-1 features 2 separate 64K byte pages of memory with one reserved for CODE space (to store the software run by the processor) and the other one reserved for DATA space available to store and retrieve DATA during the execution of programs. The SBC-1 uses hardware to make several areas in the memory area capable of both CODE and DATA usage.

0000H-7FFFH is the first 32K bytes of memory space and is reserved for CODE storage only. The first part of this area is normally used by the System PROM.

8000H-9FFFH is used for an 8K byte EEPROM of which 8064 bytes can be used for storage of uploaded user programs including TinyBASIC programs. This memory can be written to up to 10,000 times before the part requires replacement, but may be read an unlimited number of times. This part is capable of being both CODE and DATA space. The area from 9F80H to 9FFFH is system use area.

A000H-BFFFH is undefined space at this time

C000H-DFFFH is used for an 8K byte static RAM part that is used for both CODE and DATA space. The area from DE00H to DFFFH is system use area.

E000H-FFFFH is undefined space at this time



Jump Table Description

OFFSET - DESCRIPTION

0033H - SERIAL IN
Waits for a character to be received from the serial port.
Returns: character in ACC. No other registers changed.

0036H - SERIAL IN WITH ECHO
Waits for character received, strips parity bit (MSB), sends character out
serial port.
Returns: character in ACC. No other registers changed

0039H - SERIAL IN STATUS
Gets status of serial receive.
Returns: Carry flag set if no characters received. Carry flag clear if
character available. No registers changed.

003CH - SERIAL CHARACTER OUT
Sends character out serial port.
Entry: ACC = character to send. No registers changed

003FH - SERIAL STRING OUT
Sends null terminated string out serial port
Entry: DPTR = pointer to string
No registers changed

0042H - CR, LF OUT
Sends carriage return and line feed out serial port
No registers changed

0045H - DELAY MILLISECONDS
Entry: ACC = number of milliseconds to delay
No registers changed

0048H - DELAY SECONDS
Entry: ACC = number of seconds to delay
No registers changed

004BH - I/O BIT SCAN
Update I/O bit representation in bit addressable ram
No registers changed

004EH - SELECT SERIAL BAUD RATE
Entry: ACC = 01: 300 baud
02: 600 
03: 1200
04: 2400
05: 4800
06: 9600
No registers changed

0051H - SELECT SERIAL PORT
Entry: ACC = 01 for first port, 02 for second port
No registers changed

0054H - START USER TIMER
Entry: ACC = Timer number 01, 02
R0 = milliseconds
R1 = seconds
R2 = minutes
R3 = hours
No registers changed
Upon timeout: Timer 1 - bit 32.0 set, Timer 2 - bit 32.1 set

0057H - A/D CONVERSION
Return: With 8 bit A/D converter, ACC = byte value 00 to FF hex
Return: On the SBC-1-AD12 with 12 bit A/D converter,
        B=high nibble 0-F hex, ACC=lower byte 00 to FF hex 
No other registers changed

005AH - TOGGLE WATCHDOG PORT
Toggles the strobe pin of the watchdog timer
No registers changed

005DH - EEPROM WRITE
Write one byte to EEPROM
Entry: DPTR = address to write to
ACC = byte to write
No registers changed

0060H - WRITE TO EXTERNAL LED DISPLAY
Displays null terminated string on an optional LED display connected to the
IOEXP connector on the SBC-1.
Entry: DPTR = pointer to string
No registers changed

0063H - JUMP TO TINYBASIC INTERPRETER
Jump directly to TinyBASIC
Contents of registers are abandoned

0066H - REAL-TIME CLOCK READ
Read contents of the RTC chip registers into the following memory locations
in external RAM:
Century: DFE0H
Year: DFE1H
Month: DFE2H
Day: DFE3H
Day of Week: DFE4H
Hour: DFE5H
Minute: DFE6H
Second: DFE7H

0069H - REAL-TIME CLOCK WRITE
Write the contents of the following locations in external RAM into the
RTC chip registers: (Century and Seconds cannot be written.)

Year: DFE1H
Month: DFE2H
Day: DFE3H
Day of Week: DFE4H
Hour: DFE5H
Minute: DFE6H


Internal/External RAM Description

Byte Offset 020H
Bit 32.0 Completion bit for Timer 1
Bit 32.1 Completion bit for Timer 2
Bit 32.2 Unused
Bit 32.3 Unused
Bit 32.4 Unused
Bit 32.5 Unused
Bit 32.6 Unused
Bit 32.7 Set by System Timer every 24 hours


Byte Offset 021H          Byte Offset 022H          Byte Offset 023H
Bit 33.0 Input - Bit1     Bit 34.0 Input - Bit9     Bit 35.0 Input - Bit17
Bit 33.1 Input - Bit2     Bit 34.1 Input - Bit10    Bit 35.1 Input - Bit18
Bit 33.2 Input - Bit3     Bit 34.2 Input - Bit11    Bit 35.2 Input - Bit19
Bit 33.3 Input - Bit4     Bit 34.3 Input - Bit12    Bit 35.3 Input - Bit20
Bit 33.4 Input - Bit5     Bit 34.4 Input - Bit13    Bit 35.4 Input - Bit21
Bit 33.5 Input - Bit6     Bit 34.5 Input - Bit14    Bit 35.5 Input - Bit22
Bit 33.6 Input - Bit7     Bit 34.6 Input - Bit15    Bit 35.6 Input - Bit23
Bit 33.7 Input - Bit8     Bit 34.7 Input - Bit16    Bit 35.7 Input - Bit24


Byte Offset 024H          Byte Offset 025H           Byte Offset 026H
Bit 36.0 Output - Bit1    Bit 37.0 Output - Bit9     Bit 38.0 Output - Bit17
Bit 36.1 Output - Bit2    Bit 37.1 Output - Bit10    Bit 38.1 Output - Bit18
Bit 36.2 Output - Bit3    Bit 37.2 Output - Bit11    Bit 38.2 Output - Bit19
Bit 36.3 Output - Bit4    Bit 37.3 Output - Bit12    Bit 38.3 Output - Bit20
Bit 36.4 Output - Bit5    Bit 37.4 Output - Bit13    Bit 38.4 Output - Bit21
Bit 36.5 Output - Bit6    Bit 37.5 Output - Bit14    Bit 38.5 Output - Bit22
Bit 36.6 Output - Bit7    Bit 37.6 Output - Bit15    Bit 38.6 Output - Bit23
Bit 36.7 Output - Bit8    Bit 37.7 Output - Bit16    Bit 38.7 Output - Bit24


Byte Offset 027H
Bit 39.0 I1 Bit
Bit 39.1 I2 Bit
Bit 39.2 Image of I1 Bit
Bit 39.3 Image of I2 Bit
Bit 39.4 Watchdog enabled - set if user program will update watchdog timer,
if not set System Timer bumps WDTIMER
Bit 39.5 User's watchdog timer status
Bit 39.6 unused
Bit 39.7 TX buffer flag bit - used by interrupt handler




Byte Offset 028H          Byte Offset 029H           Byte Offset 02AH
Bit 40.0 Input Image - 1  Bit 41.0 Input image - 9   Bit 42.0 Input image - 17
Bit 40.1 Input image - 2  Bit 41.1 Input image - 10  Bit 42.1 Input image - 18
Bit 40.2 Input image - 3  Bit 41.2 Input image - 11  Bit 42.2 Input image - 19
Bit 40.3 Input image - 4  Bit 41.3 Input image - 12  Bit 42.3 Input image - 20
Bit 40.4 Input image - 5  Bit 41.4 Input image - 13  Bit 42.4 Input image - 21
Bit 40.5 Input image - 6  Bit 41.5 Input image - 14  Bit 42.5 Input image - 22
Bit 40.6 Input image - 7  Bit 41.6 Input image - 15  Bit 42.6 Input image - 23
Bit 40.7 Input image - 8  Bit 41.7 Input image - 16  Bit 42.7 Input image - 24


Internal RAM - Byte Offset 00H to 030H
Variables used by monitor ROM

Internal RAM - Byte Offset 034H to 05FH
Available for user assembly language program

Internal RAM - Byte Offset 060H
Stack used by monitor ROM

External RAM - Byte Offset DE00H to DFFFH
System use and Tiny BASIC use




The TinyBASIC Language

Section 3
version 4/27/02

The SBC-1 TinyBASIC in ROM provides the SBC-1 with an interpreted BASIC language, and is specifically adapted to the SBC-1 with respect to serial port support, timer support, bit oriented I/O, and the LED display. This language grew out of creating applications during development of the SBC-1, and is for users of the SBC-1 products who desire a quick and simple high level programming environment. SBC-1 TinyBASIC allows both user programs and user data to be saved and retrieved from the EEPROM device. Users who are familiar with BASIC programming will find the structure and syntax of this language to be very easy to use.

Numbers:

All numbers are signed integers and must be between -32767 and 32767

Interpreter Variables:

There are 26 variables denoted by the letters A through Z.
These are represented internally as 16-bit, two's-complement integers.

Functions:

There are 3 functions-
ABS(X) gives the absolute value of X.
CHR(X) gives the ASCII character represented by the decimal value X.
RND(X) gives a random number between 1 and X (inclusive).
INKEY gives zero if no character is waiting at the serial port
(if no console key has been pressed), or the value of the character
(or console key pressed) if there is one.

Here is a translation table to relate these characters or keys to their decimal values:

Decimal          Control Char. Control      Decimal               Decimal
Value   Character  Abbreviation  Key        Value   Character     Value   Character
-------------------------------------------------------------------------------------------
00      NULL                NUL  ^@         45      - (hyphen)    90      Z    
01      START OF HEADING    SOH  ^A         46      . (period)    91      [ (left bracket)
02      START OF TEXT       STX  ^B         47      /             92      \ (backslash)
03      END OF TEXT         ETX  ^C         48      0             93      ] (right bracket)
04      END OF TRANSMIT     EOT  ^D         49      1             94      ^ (carat)
05      ENQUIRY             ENQ  ^E         50      2             95      _ (underscore)
06      ACKNOWLEDGE         ACK  ^F         51      3             96      ` (accent)
07      BEEP                BEL  ^G         52      4             97      a
08      BACK SPACE          BS   ^H         53      5             98      b
09      HORIZONTAL TAB      HT   ^I         54      6             99      c
10      LINE FEED           LF   ^J         55      7             100     d
11      VERTICAL TAB        VT   ^K         56      8             101     e
12      FORM FEED           FF   ^L         57      9             102     f
13      CARRIAGE RETURN     CR   ^M         58      :             103     g
14      SHIFT OUT           SO   ^N         59      ;             104     h
15      SHIFT IN            SI   ^O         60      <             105     i
15      DEVICE LINK ESC     DLE  ^P         61      =             106     j
17      DC1 X-ON            DC1  ^Q         62      >             107     k
18      DC2                 DC2  ^R         63      ?             108     l
19      DC3 X-OFF           DC3  ^S         64      @             109     m
20      DC4                 DC4  ^T         65      A             110     n
21      NEG. ACKNOWLEDGE    NAK  ^U         66      B             111     o
22      SYNC. IDLE          SYN  ^V         67      C             112     p
23      END OF TX BLOCK     ETB  ^W         68      D             113     q
24      CANCEL              CAN  ^X         69      E             114     r
25      END MEDIUM          EM   ^Y         70      F             115     s
26      SUBSTITUTE          SUB  ^Z         71      G             116     t
27      ESCAPE              ESC             72      H             117     u
28      RIGHT ARROW (on PC)                 73      I             118     v
29      LEFT ARROW  (on PC)                 74      J             119     w
30      UP ARROW    (on PC)                 75      K             120     x
31      DOWN ARROW  (on PC)                 76      L             121     y
32      BLANK SPACE                         77      M             122     z
33      !                                   78      N             123     { (left brace)
34      " (double quote)                    79      O             124     | (vertical bar) 
35      # (number sign)                     80      P             125     } (right brace)
36      $                                   81      Q             126     ~ (tilde)
37      %                                   82      R             127     DELETE
38      &                                   83      S
39      ' (single quote)                    84      T
40      ( (open parenthesis)                85      U
41      ) (close parenthesis)               86      V
42      *                                   87      W
43      +                                   88      X
44      , (comma)                           89      Y

Arithmetic, Logical, and Compare Operations:

All operations are performed to 16 bits of precision. Arithmetic operations which overflow 15 bits of magnitude will produce an error message.

The arithmetic operators are:
+ addition
- subtraction
* multiplication
/ integer division (note that 14/5 = 2)
MOD remainder from division (14 MOD 5 = 4)

The logical operators are:
NOT bit boolean not
AND bit boolean and
OR bit boolean or
XOR bit boolean xor

The compare operators are:
> greater than
< less than
= equal to
<> not equal to
>= greater than or equal to
<= less than or equal to

Arithmetic and logical operations result in a value between -32767 and 32767. (-32768 is also allowed in some cases). All compare operators result in a 1 if true and a 0 if not true.

Expressions:

Expressions are formed with numbers, variables, and functions with arithmetic, logical, and compare operators between them. Operations are performed with four levels of precedence. The first step is to perform Unary operations (+, -, NOT), then Multiplicative operations (*, /, MOD, AND), additive operations (+, -, OR, XOR), and finally, Relational operations (>, <, =, <>, >=, <=)

Within each precedence level, the value of an expression is computed from left to right. Parentheses can also be used to alter the order of evaluation. Note that compare operators can be used in any expression. For example:

10 LET A = (X>Y) * 123 + (X=Y) * 456 + (X<Y) *789
20 IF (U=1) AND (V<2) or (U>V) AND (U<99) PRINT "YES"
30 LET R = RND(100): A = (R>3) + (R>15) + (R>56) + (R>98)

In statement 10, A will be set to 123 if X>Y, to 456 if X=Y, and to 789 if X<Y. In statement 30, Y will be a random number between 0 and 4 with a prescribed probability distribution of: 3% being 0, 15 - 3 = 12% being 1, 56 - 15 = 41% being 2, 98 - 56 = 42% being 3, and 100 - 98 = 2% being 4.

Due to program stack limitations, there is a limit to the complexity of expressions you may have reason to create. Large expressions may need to be broken down into multiple simpler ones to prevent the result of the expression from exceeding the numbers allowed.

Direct Commands:

All commands must be entered in upper case. All of the real-time commands described later can be used as direct commands except the following three. They should only be used as direct commands and not as part of a statement:

RUN Will start to execute the program starting at the lowest statement number
LIST Will print out all the statements in numerical order
LIST 120 Will print all statements in numerical order starting at statement 120
NEW Will delete all statements and set variables A-Z to zero

Blanks and Abbreviation:

You may use blanks freely, except that numbers, command key words, and function names can not have embedded blanks.

Commands and Logical Operators can be abbreviated to save space in SBC-1 memory and also "squeeze" more onto each line of code. The method is as follows:

Represent the command or operator by using the shortest unique string based on the normal order of characters followed by a period. (.) Examples: GOS. = GOSUB, GOT. = GOTO, X. = XOR (there are no other X commands so one letter and the period will do.)

Note: It is up to the user to determine how many characters will be necessary to properly identify a command that has been abbreviated. If too few characters are used, the interpreter will simply find and use the command that happens to be first on its list of commands to search.

The words LET in the LET command and THEN in the IF command can be omitted. A variable name by itself will print the value of that variable on the console.

Statements:

A statement consists of a statement number (line number) between 1 and 32767 followed by one or more commands. Commands in the same statement are separated by a colon ":" "GOTO", "STOP", "FOR", and "RETURN" commands must be the last command in any given statement.


Commands:

All commands must be entered in upper case. The interpreter's real-time commands are listed below with examples. Remember that commands can often be concatenated with colons, although certain commands must be used on a line by themselves. In order to store the statement, you must also have a statement (line) number in front of the commands. The line number and the concatenation are not shown in the examples.

REM or REMARK

This command is for storing comments to be stored along with the program that afford future aid to someone trying to understand or modify the program.

Example:
REM This program was written by Ben F. on 07/04/76

LET

This command is used to set a variable to the value of an expression.

Examples:
LET A = 234 - 5 * 6
Will set the variable A to the value of the expression 234 - 5*6 (ie, 204).

LET V = (A>B) * X + (A<B) * Y
Will set the variable V to either X, Y or 0 depending on whether A is greater than, less than, or equal to B.

Sequential variables may be initialized by separating sequential expressions by commas.

LET A = 1, 2, 3, A, B * C
Will set variable A to 1, B to 2, C to 3, D to 1 (the updated contents of A), and E to 6

PRINT

This command is used to send characters and numbers to the console serial port.

PRINT when used alone will cause a carriage return (CR) and a line feed (LF).

Examples:
PRINT A * 3 + 1, "ABC 123 !@#", 'CBA'
Will print the value of the expression A * 3 + 1 (ie, 4), the string of characters "ABC 123 !@#", and the string "CBA", and then a CR-LF. Note that 'single' or "double" quote marks may be used to bracket a string.

PRINT A * 3 + 1, "ABC 123 !@#", 'CBA',
Will produce the same output as before, except that there is no CR-LF after the last item is printed. This enables the program to continue printing on the same line with another "PRINT" command. Each comma in the above examples causes one or more spaces to be printed until the cursor has reached a tabulation column, which occur every eight spaces. All spaces between variables and character strings may be eliminated by using semicolons instead of commas. (There are no spaces inserted automatically before or after numbers or strings).

PRINT , , , "X="; :X = -1: PRINT X; "!"
Will print the five characters "X=-1!" on one line, starting in column 25

INPUT

This command pauses for user input from the input device.

Example:
INPUT A,B
Will print ":" and wait to read in a number from the input device. The variable A will be set to this value. A tab and another ":" will be printed and variable B is set to the value of the next number read from the input device. A number being entered may be terminated with any non numeric character, such as a space or carriage return.

INPUT "WHAT IS THE WEIGHT", A, "AND SIZE", B
This is the same as the command above, except the prompt ":" is replaced by "WHAT IS THE WEIGHT:" and the second ":" is replaced by "AND SIZE:"

INPUT A, 'STRING'; "ANOTHER STRING", B;
The strings and semicolons have the same effect as in "PRINT"

IF

This command tests the value of expressions.

IF A < B LET X = 3: PRINT 'THIS STRING'
Will test the value of the expression A < B. If it is odd (ie, if it is true), the commands in the rest of this statement will be executed. If the value of the expression is even or zero (ie, if it is not true), the rest of this statement will be skipped over and execution continues at the next statement. The keyword "THEN" may optionally be used after the expression

GOTO

This command cause the program to jump to the specified line number.

Example:
GOTO 120
Will cause the execution to jump to statement 120.

Note: The GOTO command cannot be followed by a colon and other commands. It must be ended with a CR.

GOTO A * 10 + B
Will cause the execution to jump to a different statement number as computed from the value of the expression.

GOSUB

GOSUB command is similar to GOTO command except that the current statement number is remembered for the next RETURN command.

RETURN

When a RETURN command is encountered, it will cause the execution to jump back to the command line following the most recent GOSUB command. GOSUB can be nested. The depth of nesting is limited only by the stack space. A RETURN command must be the last command in a statement and followed by CR.

FOR and NEXT

These commands allow the construction of program loops.

Examples:
FOR X = A + 1 TO 3 * B
The variable X is set to the value of the expression A + 1: The value of the expression (not the expression itself) 3 * B is remembered. The name of the variable X and the statement number are also remembered. Execution continues in the normal way until a NEXT command is encountered.

NEXT X
The name of the variable (X) is checked with that of the most recent FOR command. If they do not agree, an error message is generated. When a match is found, this variable will be set to its current value plus 1. The updated value is then compared with the value of the TO expression also saved by the FOR command. If this is within the limit, execution will jump back to the command following the FOR command. If this is outside the limit, execution continues following the NEXT command itself. FOR can be nested. The depth of nesting is limited only by the stack space.

END

This command stops the execution of the program and returns control to direct commands from the input device. It can appear many times in a program but must be the last command in any given statement, that is, it cannot be followed by a colon and other commands. END is optional as the last line of a program.

Manually stopping program execution:

The execution or listing of the program can be aborted by pressing the Control-C key on the input device. The command in progress or line being listed will first be completed. Output to the console may be momentarily stopped by typing Control-S. Output will resume when Control-Q is typed.


I/O and Hardware Commands

This group of commands and variables are specific to the SBC-1 and have been added to the original TinyBASIC interpreter to be used with specific SBC-1 hardware.

RESET

This command will restart the interpreter from the beginning, as if a hardware reset were performed, (but does not create a physical reset signal within the controller). This command causes the controller to reinitialize completely from the beginning location of the ROM code (just like at power up). This command is especially useful to leave the interpreter and go back to the ROM System Monitor without cycling power to the controller.

DPRINT

This command is used to display characters and numbers on an optional LED display unit connected to the IOEXP connector, and is used much like the PRINT command, with certain limitations. Any characters specified that are beyond the number of characters available on a particular model of display will be ignored. Since all digits of the LED display must be processed during a single internal routine, the DPRINT command has the following limitations.

For SBC-1 TinyBASIC Version 2.5, semicolons and commas cannot be used at the end of a DPRINT command to format the displayed characters and variables, but rather, all characters and variables displayed must be specified within the same DPRINT command.

For version 2.6 and beyond, semicolons and commas can be used at the end of a DPRINT command to format the displayed characters and variables, but these characters and variables will not be displayed until a DPRINT command is used without a semicolon or comma for formatting, or until a DPRINT command with no argument is used.

INBIT1(through 24)

This command gets the current value of the specified input bit from the bit-mapped ram area serviced by the IOSCAN command. Note that this command gets the data frozen by the last IOSCAN and not necessarily the current value of the input bit.

OUTBIT1(through 24)=(0 or 1)

This command sets the specified output bit in bit-mapped ram area serviced by the IOSCAN routine. Note that this bit is transferred to the physical outputs when the IOSCAN command is executed by the interpreter.

Example:
OUTBIT1=1
Will set bit 1 on in the bit-mapped RAM area

OUTBIT1(through 24)

This command gets the current value of I1 or I2 from the bit-mapped ram area serviced by the IOSCAN command. Note that this command gets the data frozen by the last IOSCAN and not necessarily the current value of I1 or I2.

IOSCAN

This command scans all the inputs and outputs and resolves the internal boolean RAM bits manipulated by program logic with the actual state of external input and output terminals

VIN1

This command gets the conversion result from the Analog to Digital (A/D) converter and presents it as a 16 bit result minus leading zeroes. With the standard 8 bit A/D installed this command returns 0-255 decimal to the user program depending on the 0 - 5 VDC level present on the input to the controller. On the SBC-1-AD12 and its 12 bit A/D the value ranges from 0-4095 decimal.

INTIN(1 or 2)

I1 and I2 are the 2 direct processor inputs on the controller and are read directly by the interpreter without having to IOSCAN like the other inputs. Therefore, these 2 inputs will provide the best sensing performance capable with the inputs of the controller.

CTR(1 or 2)

CTR1 and CTR2 are special counters that are always enabled by the interpreter and are directly driven by the I1 and I2 signals. At the transition of the INTIN(1 or 2) signal as current is applied the counter is incremented by 1. Each time the interpreter accesses the value of CTR(1 or 2) this count is returned to the interpreter and then the stored value of CTR(1 or 2) is returned to a count of zero. This effectively gives the user 2 interrupt inputs to handle high speed or "can't miss" inputs on a real-time relieved basis. If it is a long time between accesses to CTR the values may be high (they will return to zero automatically when they reach 255 and can be lost if this is allowed to happen) and so attention must be paid during testing of programs to assure timely access.

SETTIME1(2)=H,M,S,T

This command sets a task timer (not the real-time clock) of up to 255 hours (H), 59 minutes (M), 59 seconds(S), and 99 hundredths(T). There are 2 such timers available, TIMER1 and TIMER2. Note that at least the first two units, hours and minutes, must be specified, and that any units to the right of minutes will be made zeroes if not specified. Units to the left of desired units must be specified.

Examples:
SETTIME1=1,0 would time for 1 hour
SETTIME1=0,1 would time for 1 minute
SETTIME1=0,0,1 would time for 1 second
SETTIME1=0,0,0,1 would time for .01 second
SETTIME1=1,0,0,1 would time for 1 hour and 1 hundredth second

GETTIME1(2)

This command returns a bit set to 1 if the time period as commanded in SETTIME1(2) is complete, and a 0 if not. Using the timers in this manner allows the program to continue with other tasks while occasionally checking the status of a task timer to see if it has timed-out.

PAUSE

This command suspends operation of the program for a specified time and no program lines will be operated on during that time. The amount of delay is specified with values ranging from 0 to 255 in hundreds of a second (1/100 second) increments, providing a delay of up to 2.55 seconds.

Example:
PAUSE 100 would delay for one second.

SELPORT1(2)=BAUD

This command selects one of the two physical serial ports and sets it for the desired baud rate. 10 bit frames consisting of 8 bits of data, 1 start bit, and 1 stop bit (no parity) is assumed at all times, so only the physical port and the baud rate are variable.

Example: SELPORT2=300 will select port 2 at 300 baud.

Note: When transmitting out a selected physical port, time must be allowed for the transmission to complete before switching to the other port, or data will be lost. The amount of time is dependent on the baud rate selectedand may be accomplished simply with a program delay before switching ports.

Starting with SBC-1 TinyBASIC Version 2.8 the following two commands have been added:

WATCHON

This command both turns on the watchdog timer function, and "strobes" it as required to keep the watchdog timer hardware from reseting the SBC-1. Once this command is used, it must continue to be used approximately every 500 milliseconds throughout the program or until turned off with the WATCHOFF command.

WATCHOFF

This command turns the WATCHON command off. If there are functions in your program that stop the program, (for example, when the ESCAPE character is pressed), the program must use a WATCHOFF command before the program stops, or else the SBC-1 will reset after the watchdog timeout period.


Real-time clock Commands

CLOCK

This command displays the real-time clock to the serial port console device in one of two formats. Note that CLOCK is not a variable, but is a command, and cannot be tested for a particular value.

Example:
CLOCK 0 will display the time and date in this format: Wed 10/20/1996 12:00:00
CLOCK 1 will display the time and date in this format: 10/20/96 12:00:00
CLOCK 2 will display the date only in this format: 10/20/96
CLOCK 3 will display the time only in this format: 12:00:00

The following variables can be read and represent the time in the real-time clock: CEN0, YR0, MON0, DAY0, DOW0 (day of week), HR0, MIN0, and SEC0. The time is represented as 24 hour format, and the century is calculated from the year read back from the clock chip. The century returned will be accurate from the years 1998 through 2097.

Separate variables for each register allow easy testing for time periods, for example:

10 IF HR0<6 OR HR0>20 THEN OUTBIT1=1:REM TURN ON OUTSIDE LIGHTS

The following variables can be assigned, and become the values in the real-time clock registers:

YR0, MON0, DAY0, DOW0, HR0, and MIN0. Century cannot be set, but is calculated from the year. Seconds cannot be set, but are set to zero whenever any of the other registers are set.

Example:
HR0=23 will set the clock to 11 PM (and 00 seconds).

DCLOCK

This command displays the real-time clock to an optional LED display unit connected to the IOEXP connector, and is similar to the CLOCK command. Any characters beyond the number of characters available on a particular model of display will of course not be displayed.

Example:
DCLOCK 0 will display the time and date in this format: Wed 10/20/1996 12:00:00
DCLOCK 1 will display the time and date in this format: 10/20/96 12:00:00
DCLOCK 2 will display the date only in this format: 10/20/96
DCLOCK 3 will display the time only in this format: 12:00:00


Special Commands

LOAD

This command retrieves the program stored in EEPROM (by the user) and moves it to RAM for the interpreter to run or edit.

SAVE

This command causes the entire space in interpreter memory to be stored to EEPROM memory for later usage. This command stores all of the legal user code area regardless of it's being used or not. (A small program still requires a total User area save.)

SPYON

This command causes the line number of an expression to be displayed as the interpreter runs the program. This is expressly for debugging and tracing programs.

SPYOFF

This command turns the SPYON command back off again.

HEX

This command will change the number base for the entire operation of the interpreter from decimal into hexadecimal. For example, using HEX before an INPUT command will allow entry of a number in hexadecimal, and using HEX before a PRINT command will cause the printing of a number in hexadecimal followed by an "H".

DECIMAL

This command will change the number base for the entire operation of the interpreter from hexadecimal back to decimal.

Note: Using the HEX command will cause the entire number base to change including the operations on line numbers! This means that you will almost always need to use a DECIMAL command as the last part of a line on which you use a HEX command, so that the next line number will be operated on correctly in decimal mode.

CBYTE

Locations in EEPROM (Code) from 8000H to 9F7FH can be written and read using CBYTE. TinyBASIC saves user programs starting from 8000H and continues upward. If you need to use CBYTE to access a section of EEPROM for your own special storage area, you should begin with 9F7FH and continue downward. If the TinyBASIC program you save becomes large enough it will overwrite your special storage area.

XBYTE

Locations in external RAM from C000H to DDFFH can be written and read using XBYTE. When you are editing a BASIC program TinyBASIC uses the RAM starting from C000H and continues upward. If you need to use XBYTE to access a section of RAM for your own special storage area, you should begin with DDFFH and continue downward. If the TinyBASIC program you are editing becomes large enough it will overwrite your special storage area.

Example:
To read the byte at location 9F80H you can use the following code:

10 HEX:A=CBYTE 9F80H:DEC.
(Notice the use of HEX and DECIMAL on the same line.)


Program Errors

There are only three "fatal" error conditions in the language:

(1) "Syntax Error" means the language does not understand you.

Example:
210 PTINT "THIS" (where PRINT is mistyped.)
When this line is executed, the program halts and "Syntax Error" will print.

(2) "Expression Error" means the language understands you but does not know how to do it.

Examples:
310 LET A = B * C + 2 (where B * C is greater than 32767)
410 GOTO 412 (where 412 does not exist)
If either of these lines are executed, the program halts and "Expression Error" will print.

(3) "Stack Error" means the language understands you and knows how to do it, but there is not enough memory to do it.

Note: the interpreter does not re-type the erroneous statement or indicate where the error occurred.


Error Corrections

In interactive command or line insertion mode, line editing capabilities are allowed. If you notice an error in typing before you hit CR, you can delete previously typed characters with the backspace key. (The interpreter will echo a backspace, space, and backspace for each backspace to erase the previous character.) A line may be retyped by hitting Control-R, or canceled by typing Control-X. A BELL character (beep) will be echoed when the input line buffer is full (32 characters). The backspace key is also enabled during entry to the program. When numbers are being entered during the execution of an input command, the backspace key will be echoed by a "#" and CR, the current entry will be aborted and a new number may be entered. To correct a statement, you can retype the statement number and the correct commands. The interpreter will replace the old statement with the new one. To delete a statement, type the statement number and a CR only. Verify the corrections by "LIST nnnn" and hit Control-C as soon as the printing of the line begins. (Note that the interpreter will not act on the Control-C until it completes the current line).



end of manual
log file