<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://airwiki.deib.polimi.it/index.php?action=history&amp;feed=atom&amp;title=Lurch_electronics_development</id>
		<title>Lurch electronics development - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://airwiki.deib.polimi.it/index.php?action=history&amp;feed=atom&amp;title=Lurch_electronics_development"/>
		<link rel="alternate" type="text/html" href="https://airwiki.deib.polimi.it/index.php?title=Lurch_electronics_development&amp;action=history"/>
		<updated>2026-05-08T11:16:16Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.25.6</generator>

	<entry>
		<id>https://airwiki.deib.polimi.it/index.php?title=Lurch_electronics_development&amp;diff=9471&amp;oldid=prev</id>
		<title>SimoneCeriani: New page: =LURCH: electronics development=  We are currently designing a new electronic main board for the wheelchair. The idea is to base the whole system on a CANbus, allowing a complete modulariz...</title>
		<link rel="alternate" type="text/html" href="https://airwiki.deib.polimi.it/index.php?title=Lurch_electronics_development&amp;diff=9471&amp;oldid=prev"/>
				<updated>2009-11-26T21:46:51Z</updated>
		
		<summary type="html">&lt;p&gt;New page: =LURCH: electronics development=  We are currently designing a new electronic main board for the wheelchair. The idea is to base the whole system on a CANbus, allowing a complete modulariz...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=LURCH: electronics development=&lt;br /&gt;
&lt;br /&gt;
We are currently designing a new electronic main board for the wheelchair.&lt;br /&gt;
The idea is to base the whole system on a CANbus, allowing a complete modularization of the on-board electronics.&lt;br /&gt;
Read more on this topics here...&lt;br /&gt;
&lt;br /&gt;
We are now evaluating the [http://en.wikipedia.org/wiki/CANopen CANOpen] standard, that provides high-level communication layers by implementing the ISO/OSI stack on top of the CANbus.&lt;br /&gt;
&lt;br /&gt;
This should ensure automatic error recognition and resolution, device addressing and packet segmentation/desegmentation.&lt;br /&gt;
&lt;br /&gt;
=Modules=&lt;br /&gt;
&lt;br /&gt;
==USB mouse by joystick module==&lt;br /&gt;
One of the modules that will be connected to the CAN bus is the USB mouse.&lt;br /&gt;
For development and debug purposes, a simple master/slave system has been put together using two [http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en010300 PIC18F4550 microcontrollers]&lt;br /&gt;
&lt;br /&gt;
[[Image:Breadboard_lurchbox.jpg|400px|thumb|center|Master/slave prototype board. The LCD (managed by the master PIC) is showing symbols indicating the successful connection to the USB host and the correct initialization of the serial port.]]&lt;br /&gt;
&lt;br /&gt;
The USB mouse is emulated by a [http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en010300 PIC18F4550] microcontroller; this unit features an on-board USB module that can be controlled by the HID (''Human Interface Device'') Library provided with the [http://www.mikroe.com/en/compilers/mikroc/pro/pic/ mikroC PRO for PIC] compiler.&lt;br /&gt;
&lt;br /&gt;
The [http://www.usb.org/developers/devclass_docs/HID1_11.pdf USB HID Class Definition] states that the device must provide the host a descriptor in which it informs the lattest on which kind of informations it will generate.&lt;br /&gt;
&lt;br /&gt;
The ''Device Descriptor'' identifies which other class descriptors are present, and indicates their size (for example, ''Report'' and ''Physical'' descriptors).&lt;br /&gt;
&lt;br /&gt;
A ''Report Descriptor'' describes each piece of data that the device generates, and what the data is actually measuring;&lt;br /&gt;
&lt;br /&gt;
A ''Physical Descriptor'' (optional) provides information about the part(s) of the human body used to operate the device.&lt;br /&gt;
&lt;br /&gt;
HID devices support a variety of protocols:&lt;br /&gt;
&lt;br /&gt;
* 0 = None&lt;br /&gt;
* 1 = Keyboard&lt;br /&gt;
* 2 = Mouse&lt;br /&gt;
* 3...255 = Reserved&lt;br /&gt;
&lt;br /&gt;
Our descriptor will use protocol 2.&lt;br /&gt;
&lt;br /&gt;
All the descriptors will be automatically handled by the HID Library, but we have to provide a valid mouse Report Descriptor, similar to the following:&lt;br /&gt;
&lt;br /&gt;
* Usage Page: 0x05, 0x01 (Generic Desktop)&lt;br /&gt;
* Usage: 0x09, 0x02 (Mouse)&lt;br /&gt;
** Collection: 0xA1, 0x01 (Application)&lt;br /&gt;
*** Usage: 0x09, 0x01 (Pointer)&lt;br /&gt;
*** Collection: 0xA1, 0x00 (Physical)&lt;br /&gt;
**** Usage Page: 0x05, 0x09 (Buttons)&lt;br /&gt;
**** Usage Minimum: 0x19, 0x01 (01) ''Button 1''&lt;br /&gt;
**** Usage Maximum: 0x29, 0x03 (03) ''Button 3''&lt;br /&gt;
**** Logical Minimum: 0x15, 0x00 (0) ''Button idle''&lt;br /&gt;
**** Logical Maximum: 0x25, 0x01 (1) ''Button pressed''&lt;br /&gt;
**** Report Count: 0x95, 0x03 (3) ''3 buttons available''&lt;br /&gt;
**** Report Size: 0x75, 0x01 (1) ''One bit per button''&lt;br /&gt;
**** Input: 0x81, 0x02 (Data, Variable, Absolute) ''Variables''&lt;br /&gt;
**** Report Count: 0x95, 0x01 (1) ''Padding''&lt;br /&gt;
**** Report Size: 0x75, 0x05 (5) ''5 bits''&lt;br /&gt;
**** Input: 0x81, 0x03 (Constant) ''Constant padding''&lt;br /&gt;
**** Usage Page: 0x05, 0x01 (Generic Desktop)&lt;br /&gt;
**** Usage: 0x09, 0x30 (X)&lt;br /&gt;
**** Usage: 0x09, 0x31 (Y)&lt;br /&gt;
**** Logical Minimum: 0x15, 0x81 (-127)&lt;br /&gt;
**** Logical Maximum: 0x25, 0x7F (127)&lt;br /&gt;
**** Report Size: 0x75, 0x08 (8)&lt;br /&gt;
**** Report Count: 0x95, 0x02 (2)&lt;br /&gt;
**** Input: 0x81, 0x06 (Data, Variable, Relative)&lt;br /&gt;
*** End Collection: 0xC0&lt;br /&gt;
** End Collection: 0xC0&lt;br /&gt;
&lt;br /&gt;
Analyzing this table one can see how a Report Descriptor is organized: it is formed by multiple items, each providing its own data size, count and type, along with the range of values that it will generate.&lt;br /&gt;
The standard mouse descriptor declares:&lt;br /&gt;
* Three ''button'' items, that take only one bit each and can assume only logic levels (0 or 1); this is obtained by setting ''Report Count'' to 3, ''Report Size'' to 1 and choosing 0 and 1 as ''Logical Minimum'' and ''Maximum''.&lt;br /&gt;
* One 5-bit padding to be added to obtain a byte (HID descriptors only accept complete bytes); a 5-bit constant value (''Input'' set to 0x06).&lt;br /&gt;
* Two ''axes'' items (''X'' and ''Y'') that take a whole byte each and whose values can range from -127 to 127; ''Report Count'' is set to 2, ''Report Size'' to 8 (bits) and the range is set by ''Logical Minimum'' and ''Maximum''.&lt;br /&gt;
&lt;br /&gt;
An appropriate descriptor was generated using the [http://www.usb.org/developers/hidpage HID Descriptor Tool] provided by the USB organization. The output of this tool was then copied into the source file we obtained from the ''HID Terminal'' provided with the compiler.&lt;br /&gt;
The result is the ''USBDsc.c'' file that we included in our project and can be downloaded here: [[Media:USBDsc.zip]].&lt;br /&gt;
&lt;br /&gt;
The HID Library is a very convenient way to handle USB communication in PIC microcontrollers; it only consists in five methods:&lt;br /&gt;
* '''Hid_Enable()''' activates the USB module and enables the USB interrupt;&lt;br /&gt;
* '''Hid_Disable()''' deactivates the USB module and interrupt;&lt;br /&gt;
* '''Hid_Read()''' populates the input buffer with data coming from the USB host;&lt;br /&gt;
* '''Hid_Write()''' sends data from the output buffer to the USB host;&lt;br /&gt;
* '''Hid_InterruptProc()''' must be called from the interrupt handling routine and automatically processes USB interrupts.&lt;br /&gt;
&lt;br /&gt;
The programmer only has to create a Report Descriptor for his device and produce/consume data to be sent/read from the bus.&lt;br /&gt;
The mikroC IDE also features an ''HID Terminal'' (similar to MS Windows HyperTerminal) that can be used to easily debug the code by sending and receiving data to/from a given HID device.&lt;br /&gt;
&lt;br /&gt;
Our firmware repeatedly polls the status of the buttons and sends appropriate data to the host in order to move the cursor and operates the two buttons.&lt;br /&gt;
&lt;br /&gt;
A simple circuit has been designed to test the mouse firmware:&lt;br /&gt;
&lt;br /&gt;
[[Image:Mouse_board_lurchbox.png|400px|thumb|center|Circuit for the USB mouse emulation firmware.]]&lt;br /&gt;
&lt;br /&gt;
All the components have been placed on a small piece of perfboard to test the circuit on different computers and operating systems:&lt;br /&gt;
&lt;br /&gt;
[[Image:Mouse_lurchbox.png|400px|thumb|center|Prototype board for the USB mouse emulation firmware.]]&lt;br /&gt;
&lt;br /&gt;
The mouse emulator was instantly recognized by all the operative systems we tested it on:&lt;br /&gt;
* Microsoft Windows XP SP2&lt;br /&gt;
* Microsoft Windows Vista&lt;br /&gt;
* Ubuntu Linux 9.04&lt;br /&gt;
* Mac OS X 10.5.8&lt;br /&gt;
&lt;br /&gt;
[[Image:Mouse_on_xp.png|400px|thumb|center|The USB mouse emulator recognized by Windows XP.]]&lt;br /&gt;
&lt;br /&gt;
[[Image:Mouse_on_linux.PNG|400px|thumb|center|The USB mouse emulator recognized by Ubuntu Linux.]]&lt;br /&gt;
&lt;br /&gt;
[[Image:Mouse_on_osx.PNG|400px|thumb|center|The USB mouse emulator recognized by Max OS X.]]&lt;br /&gt;
&lt;br /&gt;
[[Image:Mouse_on_parallels.PNG|400px|thumb|center|The USB mouse emulator managed by Parallels Desktop on Mac OS X while virtualizing Windows XP.]]&lt;br /&gt;
&lt;br /&gt;
By now, the movements of the mouse pointer are controlled by simple buttons, and the values of the X,Y axes can only be [-20; 0; 20]; in the final release, the joystick will drive the pointer with proportional values, allowing more intuitive and precise control.&lt;/div&gt;</summary>
		<author><name>SimoneCeriani</name></author>	</entry>

	</feed>