The purpose of this document is to show how to implement some of the most important VSCP features on a CAN bus using Atmel devices (AT90CAN32).
As I write those lines, I have never used VSCP before, therefore I will describe the process step by step as I learn how to use VSCP.
As the name of this page says, this page is intended for begginers, however you need to have some knowledge to be able to start. What you need is:
I use a Linux computer to create the code and program the devices:
You might also need those tools or the equivalents for your computer's operating system.
As an example, with the knowledge I have, I have been able to send a message on the CAN bus from one chip, receive it with another chip on the bus and print this message on a computer's screen via UART interface (all this without using VSCP yet). This is the basic skills I have at the moment.
In fact I'd like to make this documentation easy enough to follow that you only need to know how to make a LED blinking with a AT90CANXXX.
Below is what we expect from the outcome of this test.
First, according to VSCP specification, both chip A and B will start, the status LED should blink until the start-up process is completed. When start-up is completed, both status LEDs should be steady, both devices will get their nicknames and be ready to operate.
The operational functionality should be as per below:
It seems fairly simple, let's see if we'll be able to make it work
There is the hardware used for this project:
Yes, you've never seen such an ugly test board, however, it works and might be good enough to start with. We'll see later if I can make a nice SMD PCB .
VSCP specification says you need a switch on each node to start the init process for nickname discovery. Because only one node per time can perform the nickname discovery. If a nickname is already assigned, the node go direct to active state without any user interaction. Also a status led needs to be added to get visual information about the init status.
The chips are AT90CAN32, they only come in SMD packages that's why you need to have them on break-out PCBs to be able to use them on a breadboard. That's the alternative I have found, I'm sure you can find a much better solution.
You need to set the AT90CAN32 with 16MHz external crystal, in order to do so issue the following command:
avrdude -p c32 -P usb -c avrispmkII -U lfuse:w:0xEE:m
That's all we need for the hardware, let's start the fun stuff!
You need to install a git client, on the Linux distribution used in this example (Gentoo), the package is simply called 'git'.
cd /home/mamac/Electronic/ mkdir vscp
git clone https://github.com/grodansparadis/vscp_firmware git clone https://github.com/grodansparadis/vscp_software
You can go and get a cup of coffee, this takes a while.
I created a new directory ~/Electronic/vscp/vscp_firmware/avr/demo_AT90CAN32/ where I placed all necessary code for a demo program. This directory has been created based on demo_vscp_node_can128. You can find this directory in the git repository.
The VSCP project team has kindly created a bunch of headers and .c files that you should include into your project folder.
You need to create some project specific files and make a reference to common VSCP files:
In order to get the Makefile to work, you need to set global variables called VSCP_HOME, VSCP_FIRMWARE and VSCP_SOFTWARE, with Linux you can add lines in your .bash_profile:
export VSCP_HOME=~/Electronic/vscp/vscp_software export VSCP_SOFTWARE=~/Electronic/vscp/vscp_software export VSCP_FIRMWARE=~/Electronic/vscp/vscp_firmware
At this stage of the preparation you should be able to build the demo code and program the device.
Below is a command that can be used to build the code and write it onto the devices (both TX and RX devices) Using Linux with avr-gcc and avrdude:
make clean && make && /usr/bin/avrdude -p c32 -P usb -c avrispmkII -U flash:w:demo_vscp_node_can32.hex -U eeprom:w:demo_vscp_node_can32_eeprom.hex
Once programmed, the device should execute the init process, the video below show the init process of one node:
A second video shows the init process on both nodes and control of LEDs using switches:
You can move on to the PART 2 to see how to read CANbus messages on your computer using VSCP Works.