HOME

PROJECTS

TUTORIALS

C FUNCTIONS

PROGRAMS

PRODUCTS

VIDEOS

FORUM

COMPANY

SPANISH

                   

C18 compiler complete list of libraries and functions available for Bolt 18F2550 system:

 

Library/function

Devices/Description

18F2550BOLT.h

LCD, KEYPAD, DELAYS, EEPROM

init_bolt( ) Initializes ports, to use the relay, the LEDs and the microswitches in Bolt. Requires C18 standard library <delays.h>
c=microsw( ) Reads the binary value of the 4 microswitches. Function returns a decimal value from 0...15 and assigns it to the variable c.
InitLCD( ); Sends commands to initialize the LCD. The cursor is set to position (0,0).
ClearScreen( ); All 16 cells in LCD are blank.
GotoXY(1,5); Positions cursor in row 1, cell 5 of LCD
PrintString(wob); The function accepts a string as parameter, in this example named "wob". Write on LCD string content. Maximum 8 characters.
PutLCD('*'); Writes to LCD the indicated character in position where the cursor is.
PutLCD(53);   Writes to LCD ASCII code of number 5 (decimal value is 53)
PutLCD(x);   Writes to LCD, the value of variable x (x must be an ASCII code)
delay_us(100); Delay of 100 microseconds. Value between 0...255. Must include <delays.h>
delay_ms(100); Delay of 100 miliseconds. Value must be between 0...30,000. Must include <delays.h>

w=GetBot( );

Waits fot a key stroke. Function returns value of ASCII code of key pressed and assigns it to variable w.

SetBot( );

Gets up to 7 characters from keypad and accommodates them as a string in an array named always "bot[ ]", which is already defined in this function as global. If user enter fewer than seven characters, must end with "F". Sends Echo to LCD after each keystroke.
WrtBot( ); This function complements the previous one. Writes on the LCD, starting at the position where the cursor is, the string contained in the array "bot[ ]", defined in this function as global.
writeeeprom(60,BOR); Writes to the EEPROM at the address 60, the contents of the variable "BOR". Valid addresses and data values must be between ​​(0...255).
BOR=readeeprom(2);

Reads the contents of the address 2 in EEPROM, and assigns it to the variable "BOR". Valid addresses and data must be between values ​​(0...255).

ADC-BOLT.h

A/D CONVERTER

open_bolt_adc( ); Initializes Channel 4 of A/D converter in Bolt system. Requires C18 standard library <adc.h>
z=bolt_adc( ); Function performs 10 bit A/D conversion on Channel 4 (pin RA5 of 18F2550), returns a decimal integer from 0...1023 assigned to variable z. At the end of the conversion, it disables the converter A/D. The analog signal must have a range of 0...5 volts and must enter the Bolt module through its auxiliary port on pin 2.

SERIAL-PORT-BOLT.h

SERIAL PORT

activa_serial( ); Initializes the serial port. The speed is 9600 bps, 8 data bits. Requires library <usart.h>
z=timed_getc( ); Function with timeout. Wait for a character in the receive buffer for 100 ms and returns. If no data, z=0. If a character is received, z takes the value of data. User may change the timeout from 100 ms to any other value.
z=getcNOECO( ); Reads a character from the serial port. Value is assigned to the variable z. No Echo.
z=getcECO( ); Reads a character from the serial port. Value is assigned to the variable z. Sends Echo.
getsUSART(ray,13); Waits and reads 13 characters from the serial port, and acomodates them in the array named "ray". There is no Echo nor timeout. Must include C18 standard function <usart.h>
putsUSART(x) C18 standard library. Sends the string stored in the array x. Requires <usart.h>
putcUSART(65); putcUSART(wobi); putcUSART('A');

3 ways to send an ASCII character through the serial port. C18 standard function. <usart.h>

ONEWIRE-BOLT.h

DS18B20 TEMPERATURE SENSOR

z=ds1820_read( ) z must be defined previously as a floating point variable. The function returns the value of the temperature in degrees Celsius, read from sensor DS18B20, as 2 whole values and 1 decimal.
 

C18 COMPILER ANSI C STANDARD  (please see manual for complete list)

putsUSART(x) C18 standard library. Sends the string stored in the array x. <usart.h>
getsUSART(ray,13); Waits and reads 13 characters from the serial port, and acomodates them in the array previously defined as ray. There is no Echo nor timeout. Must include C18 standard function <usart.h>
putcUSART(65); putcUSART(wobi); putcUSART('A'); 3 ways to send an ASCII character through the serial port. C18 standard function. <usart.h>
printf( ); Sends through serial port, a string with the specified format. This is a function of multiple formats. Please see more information of printf( ) in C18 manual. Important: in C18 this function handles only integer signed or unsigned variables. <stdio.h>.
y=atoi(ray);

y=atol(ray);

converts the string stored in the array previously defined as "ray" to an integer of the type "int" or "long int". <stdlib.h>.
z=atof(ray); converts the string stored in the array "ray" to a floating point value. <stdlib.h>
sprintf(ray,"%u",a); sprintf(ray,"%lu",a); sprintf(ray,"%3d",a); converts the variable "a", which may be floating point (f), integer (u), long integer (lu), decimal (d), to a string that is stored in the array called "ray". This function is used to prepare a string which is then sent to the LCD display. The format is similar to that used in printf( ). In C18 this function handles only integer signed or unsigned variables <stdio.h>
LEN=strlen(wob); LEN variable takes the value of the length of the string "wob". <string.h>
strcpy(leo,"AMIGOS");

stores in the array "leo" a string with the given text, in this case "AMIGOS". To use this function you must include <string.h>

>>>>>>>

Download All C18-Bolt-Template-and-Libraries-in-one-single-file.zip !

Folder with complete set of template and libraries for Bolt 18F2550 system