Professional Documents
Culture Documents
Version 1.1.1
User Manual
www.nextsapiens.com
Section Name
5. Precautions
6. Troubleshooting
1. Specifications and Features
Regulated 5v L 293D
Power Output Motor 2 Motor 1 ISP header
DC Jack
Max 232
Regulated
5v Power RS 232
Output
Microswitches
Sensor Sensor
Input Input
Power Switch, 7805 and Power Connector: Power Switch is used to turn on
the power supply of the board. Power will flow to voltage regulators only when
the power switch is in down position. 7805 Voltage regulators will regulate the
power supply to 5 volts. 7805 will work only when the input power is at least 7
volts.
Power supply can be given either through the Power Connector or through
the DC Jack. Be sure to use ONLY ONE power source.
Regulated 5 Volts Power Output: This connector can be used to provide power
to any external device. Taking into consideration, that the board can only
withdraw power up to 2 Amps, power output from this jack may vary.
Reset Switch: This switch is used to reset the program counter to zero and
restart the program execution. In execution mode, Reset switch is needed to be
kept in down position. While downloading the program to the chip, reset switch
should be kept in up position
LEDs: Four LEDs are provided on the board for the testing purpose. These LEDs
can be programmed to glow. Connection details of the LEDs and microcontroller
pins are given below –
LED 1 : PortC.1
LED 2 : PortC.2
LED 3 : PortC.3
LED 4 : PortD.2
S1 : PortD.7
S2 : PortC.0
When these switches are pressed, they actually short the corresponding
microcontroller pin with GND, so it is required to use internal pull up registers to
use these switches as input device.
40 Pin Base for microcontroller: This base is provided to install and remove
microcontroller chip easily. This board supports ONLY two microcontrollers –
Atmel ATmega16 and Atmel ATmega32. Both microcontrollers have exactly
same pin configuration but they differ in terms of the memory. For more
information on microcontroller, refer to the respective datasheet.
16 Pin Base for L293D Driver ICs: There are two bases provided onboard to
use L293D H-Bridge with microcontroller. This board supports ONLY L293D
Driver. No other H-Bridge IC can be installed instead of L293D. For more
information on L293D, refer to its datasheet.
MOTOR1
For Connector 1 –
PWM Channel = PWM1B
Direction Bit = PortD.3
For Connector 2 –
PWM Channel = PWM1A
Direction Bit = PortD.6
MOTOR2
For Connector 3 –
PWM Channel = PortC.6
Direction Bit = PortC.7
For Connector 4 –
PWM Channel = PortC.4
Direction Bit = PortC.5
For Connector 3 and 4, PWM is needed to be generated using port C pins 6 & 4.
Eight 3 Pin Headers for Sensors: This board provides capability to connect
upto eight sensors directly to ADC port of the ATmega16/32. ADC need to be
configured and started while working with Analog sensors whereas ADC need to
kept off while working with Digital sensor with same Port A. However both types
of sensors can be used at a time but they both should be different ports, i.e.
analog sensors should be on Port A (with ADC started) and digital sensors
should be on any other port (with that port in input mode).
Given below is the connection details of all eight headers with
corresponding microcontroller pin –
RX = PortD.0
TX = PortD.1
These pin configuration are only for the LCD which is 16 * 2 alphanumeric
display. For other type of LCD this may vary. Refer to related datasheet of the
LCD incase if you are using a different one.
3. Installation and Programming Setup
Step 2: In the Software Folder, you will find the Bascom Setup, Win Driver (drivers for
USB Programmer) and AVR Dude Folder as displayed below
Now we will start writing our Program in Bascom IDE. Programming has been explained
on page no:
Step 4: To write a new program in Bascom IDE, Click File and open a new file.
A blank page will appear on the careen as shown below:
After the user write the code in the IDE environment of BASCOM AVR , the code
should be compiled to check the errors as well as convert the high level language code to
machine code in HEX format .
Step 5: After writing the program, User will compile the program either by pressing F7 or
by clicking Program -> Compile in menu bar.
By compiling the program, .HEX file will be generated with same file name as of the
Program file name and it will be generated in the same folder/ path where the Program
file is saved (For example: Motor.Bas will generate Motor.Hex after compilation).
NOTE: - This compilation process also creates some other files like .bin, .obj and many
more.
But user don’t have to bother about these files, they are just supportive file, not concern
to user.
After compilation of Program file user have to transfer / burn / download this .hex file to
the hardware chip i.e. Atmega16 Microcontroller
Installation and Setup of AVR Dude for Burning Purpose
Step 1: Going back to the Software folder, now we will install the drivers for USB
Programmer available in “win-driver” folder.
Step 2: Win Drivers: - The Win Driver folder contains drivers for USB programmer as
shown below
- For the first time when the user connects the USB Cable provided in the kit to the
USB Port of the computer/Laptop, the computer will ask to install some
supportive drivers for programmer.
- WinDriver folder contains the file named “lilbus0.dll”.
- User simply has to browse the path of driver location to WinDriver folder and the
computer automatically installs the required drivers.
- The popup message from the taskbar appears with text :- “ The new hardware is
installed successfully and is ready to use”
Step 3: After installing the Window Drivers for USB Programmer, Now user will open
the AVR Dude Folder.
5. –p Port :- user have to choose the port name / number on which this USB
programmer is attached. With NextSapiens Atmega16 controller board,
user will leave this field as it is, as the software will automatically detect it
and configure it by itself.
6: - Flash Frame :- User have to tick on all the three check boxes i.e. write , read
and verify . This flash depicts the memory where our program will be stored.
And in the text field, user will browse the “.hex” file generated after compiling the
program in “Bascom Software”.
It should be very noticeable to make changes in this frame. As lock and fuse
bits if configured wrongly can lead to the damage to the microcontroller
(ATMEGA16). User will uncheck all the checked boxes under these specified
headings.
Note: - USER SHOULD CAREFULLY CHECK OFF ALL THE OPTIONS OF
LOCK AND FUSE BITS.
9. Options: - This column is generally for the ease and advancement of practice
to the uses like verbose, verify device signature, etc.
User is required to check the following options while all other options should be
unchecked by the user.
Option 1- “-e Perform a chip erase”
Option 2 - “ –F Verify the device signature”
10:- EXECUTE: - This button is used o transfer / burn the .hex file i.e. code to the
microcontroller (ATMEGA16).
• Now attach one side of the USB programmer to ISP header on the board and
other to USB post of the computer,
• Keep the reset button in up position and on the power button i.e. S3 switch
present on the controller board.
• Make sure that power is coming to the board and power LED is glowing.
• The board is now ready to download the program from the computer.
• Now the Board is ready to use. Switch of the power supply and disconnect the
USB programmer cable from ISP header on the board.
• Now switch on the board and press down the “Reset” button to execute the burned
program.
4.1 Overview
BASCOM – AVR is an IDE based development platform and is developed
by MCS Electronics. BASCOM uses BASIC programming language. It is very
easy to write, compile and download the program with BASCOM.
4.2 Basics
To write program with Basic language for AVR, start with following
sentences –
1. Define $regfile – instruct the compiler to use the specified register file.
Syntax
$REGFILE = "name_of_file"
“Name_of_file” - It refers to the name of register file. The register files are stored
in the BASCOM-AVR application directory with .DAT extension.
The register file holds information about the chip such as the internal registers
and interrupts addresses.
2 . $crystal – It defines the clock speed at which you want to run your
microcontroller.
Syntax
$CRYSTAL = Value
Value - A numeric constant defining the Frequency of the crystal.
Example –
a) LCD
b) ADC
c) Timer
d) Port
The Lcd provided on NEXTSAPIENS Controller Board is of size 16*2 i.e. 16 char
and double line
40 * 4,16 * 1, 16 * 2, 16 * 4, 16 * 4, 20 * 2 or 20 * 4 or 16 * 1a or 20*4A.
Syntax
ADC – It defines the Running mode. Its value can be SINGLE or FREE.
PRESCALER - A numeric constant for the clock divider. Use AUTO to let the
compiler generate the best value depending on the XTAL
REFERENCE - Some chips like the M163 have additional reference options.Its
value may be OFF , AVCC or INTERNAL. See the data sheets for the different
modes.
Syntax
CONFIG TIMER1 = COUNTER | TIMER | PWM,
PRESCALE= 1|8|64|256|1024,
PWM = 8 | 9 |10,
COMPARE A PWM = CLEAR UP| CLEAR DOWN | DISCONNECT
COMPARE B PWM = CLEAR UP| CLEAR DOWN | DISCONNECT
PRESCALE - The TIMER is connected to the system clock in this case. You can
select the division of the system clock with this parameter.
Valid values are 1 , 8, 64, 256 or 1024
With BASCOM, again it is very easy task. To generate PWM, the statement is –
Timer1 is a 16 bit timer which actually works in two parts, each one of 8 bit,
simultaneously. So the above statement is actually generating two PWMs, PWM
1A and PWM 1B. Same way timer 2 can be configured. Refer ATmega16/32
datasheet and BASCOM help for more information regarding timers and PWM
generation.
It is use to configure the port or a port pin in order to take output or provide input
to the microcontroller.
Syntax
Example
Config portC=input
or
Config pinC.7 = output
$regfile = "m16def.dat" // instruct the compiler to use the amtega16 register file.
$crystal = 4000000 //set the internal crystal to 4 MHz.
Config Adc = Single , Prescaler = Auto , Reference = Avcc // config A/D converter
Syntax
DIM var AS type
Var- Name of Variable
Type - Bit, Byte, Word, Integer, Long, Single, Double or String
Example
Dim A as Integer
Dim B as String * 8
First statement is defining A variable as integer and second one is defining B
variable as String of 8 characters long. Other than Integer and String there many
data types available in BASCOM. To know more about all data types, refer the
help provided in BASCOM.
Syntax
START device
Example –
Start ADC
Syntax/ Example –
Cls
2. Do Until Loop
Do
<statements>
Loop until (condition)
3.While Loop
While (condition)
<statements>
Wend
6.For loop
For (varname) = (starting point) To (end point)
STEP (value)
<statements>
Next
For A = 1 To 5 STEP 1
Print “Hello”
Next
7. Case – Select Statement
select case varname
case (test1 varname)
<statement>
case (test2 varname)
<statement>
case else
<statement>
End select
This command is used to take input from the analog sensor connected to the
development board.
This command retrieves the analog value from channel 0-7 of port A. The range
of analog value is from 0 to 1023.
Syntax
var = GETADC(channel [,offset])
Example
L = Getadc(2)
Here, in above example, the analog value of the input provided by the sensor
connected to pin 2 of port A is stored in variable L.
Syntax
LCD x
X - Variable or constant to be displayed on LCD
Example
Lcd a; “ hello”
Lowerline
Lcd “ Nextsapiens”
Syntax
WAITMS mS
Ms-The number of milliseconds to wait. (1-65535)
Example
Waitms 200
Syntax
PwmXX = value
xx- it is the channel of a motor
value – any integer value ranging from 0 to maximum speed .
Example
Pwm1a = 180 // refer to Page 6 for details about motor connector
Syntax
PORTX.y = value
X.y - ‘X’ as port number and ‘y’ as pin number
Value - 0 for clock rotation and 1 for anti clock rotation
Example:
Portd.3 = 1 // refer to page 6 for details about motor connector
4.13 Controlling Out put Ports
The output ports in NextSapiens Development board are defined as Motor 1 and
Motor 2.
They are use to drive the motors as well they can be used to trigger any other
event.
The speed and direction of motor can be controlled using commands defined in
4.11 and 4.12 i.e defining PWM for speed and configuring PortX.y for direction.
Example:
Pwm1b = 200 - set the speed of motor 1
Portd.3 = 0 - set the direction of motor 1
Pwm1a = 180 - set the speed of motor 2
Portd.6 = 0 - set the direction of motor 2
To move the motor into Backward direction, set PWM1a=0 and PWM1b =0.
Sample program configuring LCD, ADC, Timer and displaying the following
output on LCD screen:
Welcome to Nextsapiens
123
$regfile = "m16def.dat"
$crystal = 4000000
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 =
Portb.7 , E = Portb.3 , Rs = Portb.2
Sample program of taking input from a sensor and displaying the Input on
LCD
$regfile = "m16def.dat"
$crystal = 4000000
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 =
Portb.7 , E = Portb.3 , Rs = Portb.2
Do // loop start
A = Waitkey() // wait until a character is received
// program terminate
$regfile = "m16def.dat"
$crystal = 4000000
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portb.4 , Db5 = Portb.5 , Db6 = Portb.6 , Db7 =
Portb.7 , E = Portb.3 , Rs = Portb.2
Cls
Lcd “ Calibrate Black surface”
Lowerline
Lcd “Place ur bot on Black surface”
Waitms 10000
Cls
Lcd “configuring”
Lb = getadc(0)
Cb = getadc (2)
Rb = getadc(1)
Waitms 1000
Cls
Lcd “calculating mean”
Lm = Lw + Lb
Lm = Lm/2
Rm = Rw + Rb
Rm = Rm/2
Cm = Cw + Cb
Cm = Cm/2
Do //loop start
L = Getadc(0)
C = Getadc(2)
R = Getadc(1)
Cls //again clear screen
Lcd L ; "- " ; C ; "- " ; R //display the stored value on the LCD
5. Precautions
Here are a few things you need to take care to prevent your board being
damaged –
• Always connect the power supply with right polarity, do not interchange
them.
• Give power supply through ONLY ONE channel, either through Molex
Power connector or through DC Jack. Do not use both at same time.
• This board works perfect with current range of 1.5 – 2.0 amps on full load
conditions. So it is advised to supply the rated current.
• Do not short any pin or any soldering on the board.
• In case if you are withdrawing power from the Regulated 5 Volts Power
Output connector, make sure that you are not withdrawing more than 700
mA as well as you are supplying rated current to the board.
• When ever you connect any external device or sensor, don’t forget to
match the exact pins on both sides, i.e. Vcc, GND and Vo all should be
connected to respective pins of the sensors. You may need to refer
datasheet of the sensor or the device you are connecting with.
• Do not use motors which need more than 1.2 amps current as L293D is
capable of upto 1.2 Amps only.
• Always switch off while connecting or disconnecting ISP cable.
6. Troubleshooting
In general, if the above given precautions are being followed, there will not
be problem. However, there may be some exceptional problems. You can go
through the following points if you find your board is not working –
- The Power LED is not turning on when you switch on the power button
o Power supply may not be properly connected to the molex
connector or to DC Jack.
o Polarity may be reversed.
o Input voltage may be less than 7 volts.