This is the interface foundation for the BV513 which is a PIC32 based microcontroller board with built in SD card and filing system. There is a separate hardware guide for this device and that will be necessary to refer to to follow the projects in this guide.
The purpose of the guide is to help the user become familiar with the PIC32-Basic system and also how to connect the BV513 to the real world.
At this point it is assumed that you have a working BV513 connected to BV-Com and have the ok prompt thus: See also the Movies section for a demonstration of this

PIC32-Basic Prompt (version numbers
of course will be different)
If not go to the BV513 Hardware Guide and follow the instructions for getting to here.
The BV513 will run with or without an SD card, however in the above screenshot it can be seen that the card is available for this board.
PIC32-Basic roughly follows BASIC syntax and so most of what you or may have learnt using other BASIC variants will apply here. To get something out for example use ‘print’ and to get something from the user, ‘input is used. All built in basic words are called statements, keywords or commands and are entered in lower case. The case is important as this language is case sensitive, if ‘Print’ is entered for the ‘print’ statement an error will occur.
The language is also fully interactive, try this: (NOTE: 'PI'
is in upper case)
print PI*(3^2)
result: 28.274333
or
a#=log10(25)
print 10^a#
result: 25.000000
The first result is the area of a circle 6 in diameter. Most statements can be simply entered at the keyboard to get an immediate result.
The basic element of programming in this language is the function. The hello world example is here:
If the above is carefully entered it will create a function called ‘hw’. To run the function simply type hw.

This screenshot shows how it is done, note how the prompt
changes form ‘ok’ to ‘>’ when in the middle of writing a
function.
This method of programming, entering text at the console is a bit
impractical as one mistake means that the function needs re-writing. A
better method is to write the program on an attached PC using say
Notepad or another program editor PSPad is very good. See the PSPad section on how to set up
this code editor for PIC32-Basic.
It is recommended that PSPpad editor be used for programming PIC32-Basic as there is a syntax file called BV-BASIC.INI that should be placed in the syntax subdirectory where PSPad is installed. This colours the program vey nicely and also indicates at an early stage if any of the keywords are wrong.

This is what it looks like in PSPad. As you can see from this: // is
used to comment the code which is a slight departure form the normal
REM or single quote.
See the videos on how to use tload (Text Load) which may be simper then the next secion.
The following text assumes that you have an SD Card and load all programs to that first, either directly on a PC or through the various mechanisms provided. See the text on file loading that fully explaining file loading.
In this section all programs are stored to SD Card first and then loaded from there into the system RAM so it is a question of getting the program from the PC to the SD Card. This can of course be done by unplugging the card from the BV device, plugging it into the PC and then copying the file over. This would be recommended for a large number of files. But for a single file it is better to use either xload or reload.
Create the above \'hello world\' file on the PC and call it
hw.bas, type:
xload to “hw.bas”

The prompt should be as the screenshot with a slow but constant stream
of ‘C’. Now click on the xmodem icon in BV-COM (far right).![]()

Select the filename ‘hw.bas’ by using the browse button and then click
send. Press return when the above disappears which will be almost
instantly the send button is pressed.
Check that you now have the program by using dir,
this shows the directory of the SD Card. The program now needs loading
into ram from the Card. Use load to do
this, there is no need to use the .bas extension:
load hw

(note Sub is from an earlier version, this will read
Function on later versions)
To check the contents of RAM list can be used, it lists the names of
the functions in RAM (and flash, explained later). To see the actual
function itself there are two choices, the first is to use list ram hw
as shown in the screenshot and the second is to use:
type hw.bas
This ‘types’ (prints, outputs) the contents of the file ‘hw.bas’ to the screen. This can be done for any file. Now the file is in ram, simply run it by typing ‘hw’.
The above is a two stage process, loading the file onto the SD Card and then into ram before running the program. That method will also inform you if you are about to overwrite an existing file with the same name. This method will not.
Entering reload hw will also prompt you for the xmodem download but in addition to saving it on the SD Card it will also load it into RAM as well. There is also no need to use the ‘bas’ extension as this is assumed.
This is a slightly more complex program called ‘circle.bas’:
This program introduces variables. Variables do not need to be created with ‘dim’ before use but it is good practice to do so. Using dim as above means that the variables used are completely local to this function. There are a few different types of variable depending on what you wish to store. Working with microcontrollers, most of the time this will be whole numbers (integers) however in a mathematical calculation as above floating point numbers are more appropriate.
The type of variable is designated by the post fix symbol as follows:
| Variable | Symbol | Examples |
| Character | & | a& fred& ar&[3] |
| Float | # | a# fred# r#[3] |
| Unsigned | % | a% fred% r%[3] |
| String | $ | a$ fred$ r$[3] |
| Integer | a fred r[3] |
In this case ‘#’ is used to designate the variable being of type floating point. One further observation is that this language is case sensitive and ‘pi’ is in upper case ‘PI’. If lower case ‘pi’ were used the result would be 0 as it would be interpreted as a new variable.
The previous program asks the user for the diameter but suppose this was part of another larger program where the diameter was already obtained.
Here in ‘circle1’ notice that the input line has been removed
and the function definition is:
function circle1(dia#)
The function ‘circle1’ now expects the diameter to be in the
input stream, this will be collected and fed into the variable dia#. To
use this function:
circle1 5
The above is used, 5 will be the diameter of the circle.
As well as receiving data a function can also return data.
The ‘result’ keyword is used to return a value but also notice
that the name of the function ‘area#’ has the postfix ‘#’. This is
important as it will return a floating point value. The name of
functions are given the same postfix as variables when returning
values. – Try re-writing the function it with a name of ‘area’ (no
postfix) and it will return a whole number.
To use this function you need the ‘print’ keyword to see what is
returned.
print area# 5
Or alternatively assigning the returned value to a variable:
a#=area# 5
Using functions like this form the basis of the language. By writing ‘functions’ it is possible to extend the language and create a whole set of new keywords for your application. A robotics application may have keywords like move, arm, shoulder etc. These can be used in a wider program. Writing code this way may improve reliability as each element could be tested. Also a new keyword can be made of several functions, it is not necessary to restrict it to one.
Try loading this file (in the downloads section) using any method. The main function is 'go', after loading type 'go' and see what happens.
NOTE ALL KEYWORDS ARE IN lower case THE LANGUAGE IS CASE SENSITIVE.
new – clears that ram ready to start again
tload - load text into the RAM program area
load program from SD Card to RAM
reload – loads a program form the PC to SD
Card and RAM using xmodem
dir – displays SD Card directory
cd – changes to a subdirectory
type “file name” – lists the contents of a
file to screen
sys – displays system information
dump – displays contents of memory
vdump – displays contents of a variable