XCSB samples and circuits


 
home download demos platforms restrictions help

 

XCSB LITE is available
free of charge
for personal non-commercial use.

 

XCSB is a Structured PIC BASIC language. For more infomation on the language and compiler click here

Below is a list of contributed material and sample programs which can be downloaded directly from this site (links to other related web sites can be found here)

 

LCD circuit using 6-wire interface.

The program lcd-01.hex will run directly on this circuit without software modification. When you have built this circuit use the program lcd-01.hex to test it. Once you have a working circuit use lcd-01.bas as a quick starting point to developing code for it.

The circuit has additional resisters between the PIC and the LCD to allow in-circuit programming of the PIC using a programmer such as the wisp628 available from www.voti.nl/wisp628 Connection points are clearly marked.

 

3 wire RS232 interface to 16f628 using MAX232 chip.

This circuit will directly connect to the LCD circuit shown above without the need to modify the LCD circuit. Combine these 2 circuits together and use the program rs232-03.hex to allow data entered on a computer or terminal to apear on the LCD attached to the PIC.

 

Switch inputs.

This circuit shows how to connect switches to the digital inputs of a PIC

The XCSB program led-02.bas show how simple it is to read the switches using the XCSB debounce functions.

 

PIC Servo Controller.

This circuit shows the use of the XCSB servo library to control 4 RC servos. The demo runs on a 16f628 using the internal 4MHz oscilator. It uses 1 push button to select between servos and 2 push buttons to change the selected servos position. A 16x2 character LCD gives operator feed back while controlling the servos. The servo library can handle upto 20 servos on a 16f876.

The circuit has additional resisters between the PIC and the LCD to allow in-circuit programming of the PIC using a programmer such as the wisp628 available from www.voti.nl/wisp628 Connection points are clearly marked.

 

3x4 keypad interface.

This circuit shows the use of a 3x4 keypad and a 16x2 LCD connected to a 16f628. The 3x4 keypad is a cheap device using 12 switches aranged as a matrix. The interface uses 7 wires and connects directly to the PIC.

The XCSB test program keypad-02.bas shows how trivial it is to read the keypad and display key presses on the LCD. A very simple modification would allow the program to accept PIN numbers and activate an electronic lock. A precompiled ready to run executable is available as keypad-02.hex

 

3x4 keypad

This diagram shows the internal wiring of a 3x4 keypad (consisting of 12 switches aranged as a matrix) and the 7 wire interface

 

Using the 16f876 ADC.

This circuit shows how to read an analog input using the built-in Analog to Digital Convertor (ADC) of the 16f876 The analog input is a 10K linear potentiometer (also know as a pot).

The XCSB test program adc-876-001.bas reads the value of the pot (R6) and displays it on the LCD.

 

Using the 16f876 PWM.

This circuit shows how to generate tones on a speaker using the built-in Pulse Width Modulation (PWM) generator of the 16f876

The XCSB test program adc-pwm-876-001.bas reads the value of the pot (R6) using the built-in Analog to Digital Convertor (ADC) of the 16f876, displays it on the LCD and uses it as the setting for the PWM generator. The speaker produces a tone corresponding to the value of the pot. Turning the pot changes the tone produced.

NOTE: the speaker is a 100 ohm speaker. An 8 ohm speaker would need a driver circuit.

 

8x8 Multiplexed LED Array

This circuit shows how to control 64 LEDs using 16 PIC outputs.

The LEDs are arranged as an 8 by 8 matrix. 8 PIC outputs are used as row selects and a further 8 PIC outputs are used as column selects (LED within row). Only a maximum of 8 LEDs are on at any given time. Each row is illuminated in quick succession giving the illusion that all 64 LEDs are constantly illuminated (this is the same persistance of vision effect that allows us to watch television).

The 64 LEDs are controlled using the XCSB led_mux library.

MPEG movies showing the LED array in operation

 

Drew's digital clock
32x8 Multiplexed LED Array

This circuit shows how to control 256 LEDs using 4 serial registers.

The LEDs are arranged as a 32 by 8 matrix. 8 PIC outputs are used as row selects and a further 32 outputs are used as column selects (LED within row). The column selects are driven through 4 serial registers which are controlled by 2 PIC outputs. Only a maximum of 8 LEDs are on at any given time. Each column is illuminated in quick succession giving the illusion that all 256 LEDs are constantly illuminated (this is the same persistance of vision effect that allows us to watch television).

The 256 LEDs are controlled using the XCSB led_mux_2 library.

click here for construction, driving programs and movies of the LED array in operation

 
prime03.bas Example showing use of XCSB math, array handling and user function capabilities
 
mtask-02.bas Example showing use of XCSB multitasking capabilities
 
led-01.bas Simple flashing LED program
 
led-01.hex Simple flashing LED program ready to run on minimal 16f628 circuit with internal oscillator - machine code executable in hex format ready to run (compiled from led-01.bas source)
 
led-02.bas XCSB source file for LED flashing program with switch inputs for flash count. There is pause between flashes. Two switches are used to allow the user to select the number of flashes between pauses.
 
led-02.hex Machine code executable version of led-02.bas compiled using XCSB compiler.
 
led-07.bas Much more sophiticated version of led-02.bas using multiple tasks and background switch debouncing. Shows how to produce simple XCSB programs with very good user response.
 
led-07.hex Machine code executable version of led-07.bas compiled using XCSB compiler.
 
lcd-01.bas Simple LCD test program
 
lcd-01.hex Simple LCD test program ready to run on minimal 16f628 circuit with internal oscillator - machine code executable in hex format ready to run (compiled from lcd-01.bas source)
 
lcd-03.bas XCSB source file to show simple user interface using two switches and an LCD. The switches perform an UP/DOWN function useful for setting values to control external hardware. This program shows switch debouncing and multitasking.
 
lcd-03.hex Machine code executable version of lcd-03.bas compiled using XCSB compiler.
 
lcd-04.bas XCSB source file similar to lcd-03.bas but showing how to greatly improve switch operation (i.e. single key press and autorepeat timings) by adding an extra task.
 
lcd-04.hex Machine code executable version of lcd-04.bas compiled using XCSB compiler.
 
rs232-01.bas Simple RS232 interface test program. This program sends one character per second via an RS232 interface to a terminal (or PC running terminal emulation software). If it receives a character from the terminal (or PC) it sends that character back instead of the original. This allows both the sending and receiving side of the circuit to be tested. The program also flashs an LED to show that it is working correctly (in case data is not getting through on the RS232 interface)
 
rs232-01.hex Simple RS232 interface test program ready to run on minimal 16f628 circuit with internal oscillator - machine code executable in hex format ready to run (compiled from rs232-01.bas source)
 
rs232-03.bas This simple program accepts input using an RS232 interface and displays the input on an LCD display. Otherwise this program operates as per rs232-01.bas (including the flashing LED).
 
rs232-03.hex Simple RS232 interface test program ready to run on minimal 16f628 circuit with internal oscillator - machine code executable in hex format ready to run (compiled from rs232-03.bas source)
 
servo-07.bas XCSB source file to show simple user interface to control 4 RC servos. It uses 1 push button to select between servos and 2 push buttons to change the selected servos position. The buttons have both single step and auto repeat facility. A 16x2 character LCD gives operator feed back while controlling the servos. A counter is shown for each servo giving the position of the servo.

This demo program is useful in its own right for controlling small robots and robotic arms.

This program shows switch debouncing, LCD writing, multiple servo control and multitasking.

 
servo-07.hex Machine code executable version of servo-07.bas compiled using XCSB compiler.
 
keypad-02.bas XCSB source file to show simple user interface to allow 3x4 keypad to be read and displayed on a 16x2 LCD.

A very simple modification would allow the program to accept PIN numbers and activate an electronic lock.

The keypad library could be used as the basis for other multiplexed debounced inputs e.g game pads.

 
keypad-02.hex Machine code executable version of keypad-02.bas compiled using XCSB compiler.