Friday, June 8, 2012

v-USB + I2C . debugging the debugger

8-6-2012
Going to implement the usb data link so that it can be used to debug the I2C slave device.

Learning the parts of V-USB and how to use it.

http://vusb.wikidot.com/driver-api

9-6-2012
Got an HID-keyboard device running. So, can make the program simply type out the report (for now) instead of making a program that processes the incoming data.

wrote a program using which strings and numbers can be easily "typed" through USB.


Going damn crazy trying to debug the I2C !!!!!!!!!

9-6-2012

Got it kinda working. Not sure what the exact problem was but I had forgotten put the usbpoll() into the main loop, so any excessive delays would've meant the USB lost connection. Also, converted the slave to a polled I2C system since I was worried that the interrupts might interfere with the USB timing sequences.

On the master side, the interrupt based code still seems to have some bug.

Just found another AVR usb implementation lib http://dicks.home.xs4all.nl/avr/usbtiny/
And another! http://www.fourwalledcubicle.com/files/LUFA/Doc/100513/html/main.html


Seems that the code simply refuses to jump to the ISR!

http://wiki.msoe.us/ce2810/interrupts
http://www.nerdkits.com/library/codelib_asyncI2C/

really driving me nuts!! ( 12:26 AM 10-6-2012 )

10-6-2012

TWSTA must be cleared by software!!!
TWINT must be 0 when waiting for the new data to be written to TWDR. So make sure that while you wait, ie. when TWIE is disabled, TWINT is cleared too!!!

(10-6-2012 8:19 PM)
SO HAPPY! Got the I2C to successfully send a sequence of numbers with interrupt based Master(Robot) and polled slave(USB device)

Now, have to implement a protocol by which the robot reports the data stucture that will be sent and make the slave read and print in that format. Also need to build support for sending 16 bit data across I2C.

Thursday, June 7, 2012

I2C / TWI

5-6-2012

Testing the I2C / TWI communication between the usb debugger and the target board. ( I chose I2C only because my robot board already used the serial lines as output )

Reference
http://lackawanna.hackhut.com/2011/10/10/easy-i2c/
http://www.engineersgarage.com/embedded/avr-microcontroller-projects/atmega32-twi-two-wire-interface?destination=node%2F1040 (code is wrong)

7-6-2012

Decided to write the code myself since many of the given codes are either wrong or polled. Interrupt driven is required. (reference: datasheet).

Having fun implementing interrupt driven I2C code. Lots of things to refer.

Finished the Master Transmitter. Can't test until the slave reciever is implemented. 2 new systems! Not the best idea. Will be a headache to debug if it doesn't work! :-(

http://www.atmel.com/Images/doc2564.pdf

The transmission part is acting strange even though some parts "seems" to be working. (the day has ended, so signing off).

Tuesday, June 5, 2012

V-USB intial test 1

Decided to go out and get a lot of components since I'm anyway lacking the USB connectors (which I have no idea how to hack together)

Got all the components (well almost all, had to hack together the rest). Got the example HID-Mouse example of V-USB to run properly on my Windows7 with ATMega8 running at 16MHz from a crystal.

Have to test the HID-data example or usbtool example. Setting up the host side development environment to compile the program.

Found libusb-win32 ( http://sourceforge.net/apps/trac/libusb-win32/wiki ) but have to figure out exactly how to use it.

Some more resources on HID programming
http://www.lvr.com/hidpage.htm
http://www.signal11.us/oss/hidapi/

Monday, June 4, 2012

Getting 12Mhz on ATMega8 without crystal

Working with limited resources is exceptionally challenging and definitely tends to give a headache but it sure gets the neurons firing. Trying to get an ATmega8 to run at MHz without a crystal and a limited set of resistors at my disposal.

Got a RC clock running with a 220+470 ohm (That's all I had) and the internal 36pF on an ATMega8. Have no means of checking the exact clock.

Q to Solve : How to check freq of uC without Oscilloscope?

PS. I'm planning to use "Q to Solve" to annotate questions that come up that I don't know how to solve but want to eventually.

USB debugging with ATMega32/8

USB to TTL level convertors cost around Rs 400 .

A good overview of all serial comm methods http://www.societyofrobots.com/microcontroller_uart.shtml

some basic details of how it is implemented and about the USB protocol http://www.atmel.com/Images/doc2556.pdf

Using firmware only ,there seems to be a couple of solutions.
1) V-Usb  . Seems it needs a minimum of 12Mhz clock.
         ATMega 32 can get a max of 16 Mhz with crystal. But 12 =MHz can be achieved using RC oscilator configuration
2) interface by Igor Cesko.
   Has code for ATmega8 already.



Set of useful USB data http://www.frank-zhao.com/usnoobie/downloads.php


Am going to try out V-USb since it seems more mature and has more support.

Sunday, June 3, 2012

Thus far....

I'm a student at the College of Engineering Trivandrum and this  blog is "supposed" to be a record of my journey into the wonderful world of robotics along with my team mates.

SO far, a line follower is in the making.

v1 was made using 2 sensors (IR) and a simple opamp comaparator circuit. It was fast with two  100 rpm motors and 70mm wheels. The base was made of hylum sheet and the third wheel was a small metal castor wheel.

v2 is under construction with 6 sensors,  ATMega32 as the controller and with PWM and P ( + I + D ) control.

Currently I'm looking for a way to get diagnostic data from the controller. THere is an LCD but I'm looking for the whole data from the full course run. The default method would be serial comm but my laptop doesn't have a serial port. So, am on the lookout for a simple usb to serial convertor that I could make with a mega8 or mega32 (since I have those on hand).

My other option was bluetooth or XBee. Xbee requires me to get 2 Xbee modules + a XBee USB explorer which costs around 1500 * 2 + 1000 = 4000. Bluetooth would cost me only around 2000. Since it'll take time to buy the bluetooth module and to program it, leaving that option for later when more pressing requirments arise.

Off to Search!