by on Dorkbot

&& ! != ~

There are those days when I am pretty sure I cant program my way out of a brown paper bag.

And then there are those days when I don’t care.

Thanks to ax for showing me how to connect midi to PD.

by on Dorkbot


Motorboard Buildout. from Donald Delmar Davis on Vimeo

To build out the motorboards from the workshop requires placing and soldering the the two vias the H-Bridge driver, the capacitors and any connectors you want to use to connect the board to the motors and the Arduino or DorkBoard. The parts layout is below.

To connect the ground plane from the top of the board requires two “via”s or wires which can be cut from the tails of the capacitors in the kit. When I put these together I looped the capacitor tails through the holes. Also please note that the ground side of each capacitor is also acting as a via so solder both top an bottom on the leads as indicated by the arrows in the diagram below.

The center 4 pins on the chip serve as a “heat sink” which is one reason that there is so much copper left on the upper side of the board.

I connected a female header to the input side of the board so I could jumper the pins from my dorkboard and a Male header on the power end.

`

Using the motorboard is simple.

One end of the board connects to your arduino on the other end of the are the connections for the high voltage (4-35V) and the motors. The ENable pins turn the motors on and the DIRection pins determine the motor direction. If you use pins 9 and 10 for the en you can set the speed using the arduinos built in pwm as in the code below which was a modification of the “fading” example.

// Modified Fading Example for motor controll

int value = 0;                            // variable to keep the actual value
int motor1dir = 8;
int motor1pwm = 9;
int motor2dir = 11;
int motor2pwm = 10;

void setup()
{
  pinMode(motor1dir,OUTPUT);
  pinMode(motor1dir,OUTPUT);
  digitalWrite(motor1dir, HIGH);
  digitalWrite(motor2dir, LOW);
}

void loop()
{
  for(value = 0 ; value <= 255; value+=5) // fade in (from min to max)
  {
    analogWrite(motor1pwm, value);           // sets the value (range from 0 to 255)
    delay(30);                            // waits for 30 milli seconds to see the dimming effect
  }
  for(value = 255; value >=0; value-=5)   // fade out (from max to min)
  {
    analogWrite(motor1pwm, value);
    delay(30);
  }
  for(value = 0 ; value <= 255; value+=5) // fade in (from min to max)
  {
    analogWrite(motor2pwm, value);           // sets the value (range from 0 to 255)
    delay(30);                            // waits for 30 milli seconds to see the dimming effect
  }
  for(value = 255; value >=0; value-=5)   // fade out (from max to min)
  {
    analogWrite(motor2pwm, value);
    delay(30);
  }
}

by on Dorkbot

I am regularly sending ordinary people to look a the application sections of the datasheets for several electronic parts if they want to know how a part should be used. As I was laying out the motor boards for the weekends workshop I came across the following in the datasheet for the L239(not d) clone that Texas Intruments puts out.

Can you tell where the chip begins and the diagram ends? Can you tell that the diodes are (not really) included in the chip or would you add them to your parts count.?

I nearly panicked and relayed out everything with 8 general purpose diodes and ordered the parts before I was able to ascertain (incorrectly) that the diodes in the diagram above are actually integrated into the chip.

by on Dorkbot


Note: This work is ongoing see the Benito info page for current info…

Introduction

This is a first take on using the Benito board to create an open source USB to Serial converter.


Benito 7b Buildout from Donald Delmar Davis on Vimeo.

The above video was assembled from photos taken by my son Aidan Davis. The entire set is on flikr at http://www.flickr.com/photos/7175086@N05/sets/72157606639780833/

The benito board was designed to allow people with intermediate soldering skills to build their own Atmel AT90usb162 based devices. The processor itself is a tqfp and the remaining components are almost exclusively smd 806 parts. While it is not as easy as working with dip components, it is not too difficult to do by hand and the processor is worth it.

Hardware

PARTS (Digikey, most smd components in 806 package)
# Digikey # Description Price(@1) Price(@25)
2 475-2560-1-ND LEDs 0.14 0.12
1 AT90USB162 usb chip 3.76 3.15
2 RHM10KARCT-ND 10k resistors 0.04 0.03
2 RHM220ACT-ND 220 ohm resitors 0.14 0.08
2 RHM22ACT-ND 22ohm resistors 0.16 0.08
1 631-1099-ND 8 Mhz xtal 0.5 0.5
1 399-1168-1-ND .1uf cap 0.05 0.03
1 399-1284-1-ND 1uf cap 0.1 0.06
2 PCC220CNCT-ND 22pf cap 0.44 0.44
1 PCC2232CT-ND 4.7uf cap 0.33 0.33
1 609-1039-ND USB conn 1.03 0.55
Benito Board http://tempusdictum.com/tdproducts.html
1 Benito7g Benito Board 4 1.6
10.69 6.97

Schematic

Schematic: click for a Larger View

(larger size : http://www.flickr.com/photos/7175086@N05/2693613068/sizes/o/)

Parts Layout

The above lays out the surface mount components on the top of the board. There is also a 10K resistor on the other side of the board.

Software

The firmware is attached in both source and
precompiled binaries.

To build it from source you will need an avr-gcc toolchain such a:

The software was written using Dean Camera’s MyUSB library.

The at90USB162 has a built in bootloader and it shows up as an AT90USB162 DFU. To use the bootloader you will need one of the following.

Populating the board

Tools:

I use a 25 watt weller pencil type iron and i usually sharpen the tip with either a file or a dremel cutting disk. you will want to have the smallest diameter solder you have and some solder wick handy. Since I started doing surface mount I have come to rely on a pair of 3x reading glasses from rite aid. I also have a magnifying glass that sunstone circuits sent me when I ordered these boards.

The Brains of the outfit.

The first thing that needs to be done with the benito board is to align the processor on the board and tack the corners. I usually start with the vcc pin closest to the dot on the processor. There us usually enough tinning on the board to tack the pin in place without needing to add solder

Then I tack the opposite corner fudging the pins to get the best alignment. Once this is done I walk around the pins touching each with the tip of the iron and touching the solder to the joint. If the solder blobs or creates bridges between pins dont worry too much. If its not looking like your getting a zen with it just blob it across all the pins and then clean it up using the solder wick. When you are done inspect your work.

The Blinkin Lights.

I usually do the LEDs next most surface mount LEDs will have a green marking which goes on the negative side of the led. On these ones the mark was on the bottom but the dot in the center is off set towards the same end so you can still tell which is which. The negative side goes toward the pins on the processor. Bracketing the LEDs are the 220 ohm current limiting resistors. Solder these these on and check your work. If you get bridges don’t worry just draw off the excess solder as shown in the photo below.

Next up is the 10k pullup resistor for the reset pin and the 1uf capacitor which is used to create the 3.6v needed to communicate with the usb bus. In this build I only had a 603 size it is harder to work with but it fits on the pads just fine. Follow this with the 22 ohm resistors which help filter the D+ and D- usb signal lines.

The next two componets are the .1 bypass capacitor on the processor and the filter capacitor for the usb power. Atmel recommends a minimum of 1uf with a preference of 10uf. I usually split the difference and put a 4.7 here. In this particular build I only had a 10uf capacitor in a 1206 package.

The 1206 extends past the pad but we were able to solder it to the trace. The last two smt pads are for the 22pf capacitors that are part of the oscillator circuit. Solder these in place and get the 8 mhz crystal ready. Since the crystal sits above the caps and the pins on the side of the processor I usually put a piece of thick paper underneath it to keep it from making contact with anything.

Once the crystal is soldered in place, remove the paper and trim the crystals leads. Then solder the last 10k resistor onto the pads on the bottom of the board, install the 10 pin header, and the USB B connector.

The final step in assembling the benito is to select the voltage that the io will be using. If you are using your benito to talk to a 3-3.6v target you will short the outer jumper and the io portions of the chip will reference the internal 3.6v instead of the usb 5v supply. In this case we are talking to a 5v target and we short the jumper as shown below.

You are now ready to load the software onto your benito. There are pads on the bottom of the Benito for the hwb and reset switches. These are handy if you are going to be using the board for development but are not required. The pads were designed for a relatively expensive switch sold by sparkfun but my favorite switch in this spot is shown digikey part P8090SCT-ND.

Programming the Benito.

The AT90USB162 comes complete with a built in USB bootloader called the Device Firmware Uploader. When you plug your Benito in it will show up in your dmesg logs (on linux) or in your system profiler (for osx). The smoke test for your board will be to see if the DFU shows up when plug the device in. If there is a short it should trigger the overload protection on your usb port. On the macs this port will be powered down until you resolve the issue. If you are concerned about your system not handling this correctly you might consider a cheap hub. And always unplug the device if your system complains or if anything gets hot.

Uploading the firmware.

Assuming that no smoke left the device (jk) the benito should show up as an Atmel AT90USB162 DFU. (on OSX pull up the system profiler by going to “about this mac” in the apple menu and asking for more information. In the system profiler select USB and hit refresh (splat R). On linux type lsusb -v. If it complains that it cant see the descripters you may need to escalate privilages using sudo because DFU-Programmer needs to read them to identify the device.

When you unpack the source code you will find that the “make program” target calls dfu programmer to erase the chip, load the benito2g.a90 file, and reset the chip. If you are an x-code user the source tree includes a project file. Selecting the program target will call the “make program” target in the makefile. Refreshing the system profiler window on OSX or relisting the usb bus on linux should now show you a Benito7.

There will also be a new serial device! on OSX this will be /dev/tty.usbmodemXXXX and on linux /dev/tty.ACMX

Windows users will use the control panel to track the usb changes and will need to use Atmel’s FLIP utility to load the benito firmware. When the new device shows up it will ask for a driver open the Benito7.inf file in the source code folder. This will tell windows to use the drivers that it already has.

Have Fun!

by on Dorkbot

Note: This work is ongoing see the Benito info page for current info…

SPI4 is a MyUSB based firmware for the at90usb family of processors.

This program is the core of a programmer that I am working on which uses the Benito board to do in circuit programming (ISP) on the Atmel AVR and 8X51 microcontrollers. It uses the the a feature of atmels USART module called “Master SPI Mode” as described in Atmel’s Application Note #317 (http://www.atmel.com/dyn/resources/prod_documents/doc2577.pdf) (1). The MegaXX8 family and the at90usb series of chips all support this feature.

Setting up the USART

The USART is configured by setting the Uart Mode SELect bits in the UCSRxC register, setting the TXEN and RXEN bits in UCSRxB, and setting the Baud Rate Register (UBRRx)


/* Setup USART1 in master SPI mode */
UBRR1 = 0; /* apparently this needs to be 0 during setup */
UCSR1B = (1<<RXEN1) | (1<<TXEN1);
UCSR1C = (1<<UMSEL11) | (1<<UMSEL10);
/* Calculated value from appnote code. ((CPUFREQ/(2*BPS))-1) */
UBRR1 = ((F_CPU/(20000))-1);

The USART takes care of setting the direction of the MOSI and MISO pins but you are responsible for putting the Clock pin into output mode.

SPI_CLK_PIN_DDR |= _BV(SPI_CLK_PIN);
// SPI_CLK_PIN_PORT |= _BV(SPI_CLK_PIN); // if a known state is needed

If you are using the slave select mechanism you will also need to assign a pin to do the slave select and set it to output mode. On the slave system the SPI pins will tri-state until SS is pulled low.

SPI_SS_PIN_DDR |= _BV(SPI_SS_PIN);
SPI_SS_PIN_PORT |= _BV(SPI_SS_PIN); // PULL Slave Select HIGH

Writing and Reading the data.

Reading and writing the USART in this mode is almost identical to serial transmission with one exception. As the serial is clocked out of the data register incoming data is clocked in.


/*-----------------------------------------------------------------spiOut(value)
* Moves the a byte to SPI and read one back.
*-----------------------------------------------------------------------------*/


unsigned char spiOut(unsigned char value) {

// Wait for empty transmit buffer.
do {} while( (UCSR1A & (1<<UDRE1)) == 0 );
// Send data.
UDR1 = value;
// Wait for transfer to complete and return received value.
do {} while( (UCSR1A & (1<<RXC1)) == 0 );
return UDR1;
}

SPI4: a USB(serial) to SPI converter

The attached code contains a MyUSB based program called SPI4 it is complete in that it contains copies of the MyUSB library files used. It contains an X-Code project and a make file. If you have an avr-gcc toolchain and dfu-programmer you can “make program” or you can build the xcode project with the program target. It has been tested against the benito at90usb162 board (which you can purchase here or through the dorkbotPDX group order) but should run with minor modifications on the USBKey.

ReadChip: Using the USB to SPI converter.

In the ReadChip directory in the attached code there is an example of reading the signature and fuse bits on an AVR. It is currently built only for the mac but if you bracketed the /* >>> Mac Specific >>>>> */ parts of the code with #ifdefs for your posix platform (anything not redmond based). It should port just fine.

After opening the serial port as a stream write then read a byte at a time. All avr SPI/ISP interactions are done 4 bytes at a time; usually with the second or third return byte being the sync byte and the third and or fourth bytes being the return value.


static int doTheOldInOut (int fileDescriptor, char *inBuff, char *outBuff) {
int i=0;
for (i=0;i<4;i++) {
 if (write(fileDescriptor, outBuff+i, 1)>0) {
  //debug printf(">%02X>n",outBuff[i]&0x000000ff);
  if ((read(fileDescriptor, inBuff+i, 1)>0)){
   //debug printf("<%02X<",inBuff[i]&0x000000ff);
  } else {
   printf("Error reading from Device - %s(%d).n", strerror(errno), errno);
   continue;
  }
 } else {
  printf("Error writing to Device - %s(%d).n", strerror(errno), errno);
  continue;
 }
}
return 1;
}

To read the fuses for example send the four bytes {0×50,0×00,0×00,blah} (where the last byte doesnt matter) and check to make sure that the first byte is echoed back;


doTheOldInOut(fileDescriptor, inBuff, kGetLowFuseBits);
if (inBuff[1]==0x50){
  FuseLow=inBuff[3]&0x000000ff;
}

To wire the benito to the dorkboard or another arduino based board use the following configuration. The center 6 pins of the Benito7(rev g) form a standard atmel 6pin programming header.

Output.

Try #1
Resetting Target
Looking for Sync

Got Sync!

ISP initialized successfully.
Signature[1]=1E
Signature[2]=94
Signature[3]=06
FuseLow=FF
FuseHigh=DD
FuseExtended=F8
LockBits=CF
ISP port closed.

Source

See Also:

Footnotes:

(1) The original benito design exposed the serial pins on portd and the SPI pins from port B. The final rev of the Benito7(g) takes this mode into consideration and exposes all of port D instead.

by on Dorkbot

Missing Links.

One of the joys of the Arduino Cult Induction Sessions is that mistakes and omissions are generally caught on the spot and there is no lag between the steps we forgot to include an the instructions and the person who’s board isn’t working.

One of those steps is the Reset Jumper on the Dorkboard. The jumper is a compromise reached between myself and Brian Riley of Wuflden and Paul Badger of Modern Devices. The programmers that they are working on and the next generation of freeduino boards will have a standard pinout that the dorkboard complies with. In addition they are using the .1uf auto reset capacitor on their boards. In order to maintain compatibility with their boards and programmers I added pads for either a jumper or a small surface mount capacitor between the programming header. If you are using a dorkbotpdx programmer you need to solder this jumper for the programmer to work.

It seems that I also failed to upload a schematic for the final revision of the dorkboard.

(click to view a larger sized image)

I still have not put together a complete set of instructions for building the Dorkboard outside of the induction workshops. Breedx however has started one at http://dorkbotpdx.org/dorkboard_assembly_tutorial.

I did, however, manage to add an updated cable diagram to the cables page.

Moments of Truth.

If you didn’t make it through an induction or decided to go it alone: here is a brief description of what should happen once you have your dorkboard put together.

On your cable if you are looking at the bottom of the benito board the wires will be (from bottom to top) nc,nc,RXD,VCC,nc,TXD,RESET,GND,nc, and nc (where nc is “not connected”).

Power it up.

Plugging your programmer into the usb port and hooking up the power and the ground wires (to the center post and the pin down from it on the programming header) should give you some results on a board whos processor has the dorkbotpdx adaboot lable. These processors were programmed twice: once with the adaboot boot loader, and once with a test program called blink. When you apply power to the board the led should blink erratically to tell you that its in the bootloader and then steadily.

If you are running windows windows will ask you for a driver for the device. Copy the text from http://dorkbotpdx.org/blog/feurig/arduino_cult_induction_rev3_followup into a file called benito7g.inf and select that file. That file tells windows to use its built in drivers. Why it cant figure that out on its own is beyond me.

Download the software.

Download the software from http://www.arduino.cc/en/Main/Software and open the arduino application. In the tools menu select the new serial port and under board select the “Arduino Decimilia”. (If linux doesnt show the serial port check out this thread.) Then, under File->SketchBook->Examples->Digital select the blink program. This is the program that your Dorkboard should be running.

Upload your program.

Once the reset is wired (including the reset jumper) pressing the “upload to io board” button on on the bar above the code will cause the led to blink sporadically to indicate that it is going entering the bootloader. Then, if the serial lines (txd and rxd) are loaded correctly, there should be blinking lights all around followed by a message at the bottom indicating the size of the program that was just loaded.