Archive for July, 2008

Arduino Cult Induction Rev3 Followup

Monday, July 28th, 2008

This group got further along than any induction so far. I was really happy and thank every one who came out. I have a couple of things here as a follow up that might be helpfull and if you leave comments or email me I can follow up here as well.

First here is a map of the dorkboard pins using the arduino pin numbering system.

Also here is the .inf file which makes the Benito use the built in windows drivers.


; Windows MyUSB USB to Serial Setup File
; Copyright (c) 2000 Microsoft Corporation

[Version]
Signature="$Windows NT$"
Class=Ports
ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318}
Provider=%COMPANY%
LayoutFile=layout.inf
DriverVer=06/06/2006,1.0.0.0

[Manufacturer]
%MFGNAME% = ManufName

[DestinationDirs]
DefaultDestDir=12

[ManufName]
%Modem3% = Modem3, USB\VID_03EB&PID_204B

;------------------------------------------------------------------------------
; Windows 2000/XP Sections
;------------------------------------------------------------------------------

[Modem3.nt]
CopyFiles=USBModemCopyFileSection
AddReg=Modem3.nt.AddReg

[USBModemCopyFileSection]
usbser.sys,,,0x20

[Modem3.nt.AddReg]
HKR,,DevLoader,,*ntkern
HKR,,NTMPDriver,,usbser.sys
HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider"

[Modem3.nt.Services]
AddService=usbser, 0x00000002, DriverService

[DriverService]
DisplayName=%SERVICE%
ServiceType=1
StartType=3
ErrorControl=1
ServiceBinary=%12%\usbser.sys

;------------------------------------------------------------------------------
; String Definitions
;------------------------------------------------------------------------------

[Strings]
COMPANY="Tempus Dictum, Inc"
MFGNAME="Donald Delmar Davis"
Modem3="USB Virtual Serial Port"
SERVICE="USB Virtual Serial Port CDC Driver"

Arduino Cult Induction release3 — Introducing the DORKBOARD!!!

Saturday, July 12th, 2008


http://dorkbotpdx.org/Workshops/ACI3

They're HERE! (the Dorkboards have arrived)

Thursday, July 10th, 2008

And if you want to build one out you can get to the next arduino cult induction on the 27th of this month.

Stepper Motor Control With Arduino/Wiring

Thursday, July 10th, 2008

Here is a small example of using the arduino/wiring platform to control things in the real world.

A pretty good reference for the controlling stepper motors can be found at.

http://en.nanotec.com/steppermotor_animation.html

The following Circuit fleshes out the sketch at the site above.

And finally here is the sketch to make it go.

/* Rapha Roller Race Controller.
 * The Rapha Roller Race Controller is for a 4 bike 500 meter race The bikes are on rollers which
 * produce pulses. The pulses are used to drive a dial per bicycle which is controlled by
 * a unipolar stepper motor, the dials are geared such that two pulses two each one
 * motor half "step" results in 500 meters per complete revolution.
 *
 * This program uses wirings External Interrupt Mechanism. The program loop is used to
 * watch the control panel and move the dials to a starting position.
 *
 * NOTE: RABBID PROTOTYPE! This was done in a very make it work NOW mode.
 * I am certain there are more elegant solutions.
 *
 * Author Donald Delmar Davis, Tempus Dictum Inc.
 */

#define NMOTORS 4
#define NPINS 4
#define NSTATES 8
#define HALFSTEP 1
#define FULLSTEP 0
#define FORWARDSTEP  1
#define BACKWARDSTEP 0

/*------------------------------------------------------------------------------------
 * Pin Mapping
 */

#define SWITCH1PIN  34
#define SWITCH2PIN  35
#define SWITCH3APIN 49
#define SWITCH3BPIN 50
#define LEDPIN 48
#define BIKE1 36
#define BIKE2 37
#define BIKE3 38
#define BIKE4 39

int motorPins[NMOTORS][NPINS]= {
  { 11,  9, 10,  8  } , // ccw is forward
  { 15, 13, 14, 12  },
  { 20, 22, 21, 23  },
  { 16, 18, 17, 19  },
  //  { 8, 10,  9, 11}, // cw is forward
  //  {12, 14, 13, 15},
  //  {23, 21, 22, 20},
  //  {19, 17, 18, 16},
};

int pulsesPerStep=2;
volatile int pulseCount[4]={0,0,0,0};
volatile int pulseMod[4]={2,2,2,2};
int ledState = HIGH;
int switchState=LOW;
int delayTime = 10;

int motorState [NMOTORS] = {0,0,0,0};

int pinStates[NSTATES][NPINS]= {
  { HIGH,LOW ,LOW ,LOW   } ,
  { HIGH,HIGH,LOW ,LOW   },
  { LOW ,HIGH,LOW ,LOW   },
  { LOW ,HIGH,HIGH,LOW   },
  { LOW ,LOW ,HIGH,LOW   },
  { LOW ,LOW ,HIGH,HIGH  },
  { LOW ,LOW ,LOW ,HIGH  },
  { HIGH,LOW ,LOW ,HIGH  }
};

/* -------
*/
void stepit (int motorNum, int stepDir, int stepSize) {
  int stateSkip=2;
  int pin;

  if (stepSize==HALFSTEP) stateSkip=1;

  if (stepDir==FORWARDSTEP) {
    motorState[motorNum] += stateSkip;
    if (motorState[motorNum] >= NSTATES) {
      motorState[motorNum]=0;
    }
  }
  else {
    if (motorState[motorNum] < stateSkip){
      motorState[motorNum] = NSTATES-1;
    }
    else {
      motorState[motorNum] -= stateSkip ;
    }
  }

  for (pin=0 ; pin < NPINS ; pin++) {
    digitalWrite(motorPins[motorNum][pin], pinStates[motorState[motorNum]][pin]);
  }
}
/*---------------------------------------------------------------------------------setup()
 *
 *
 *
 */
void setup() {
  int motor;
  int pin;
  for (motor=0;motor<NMOTORS; motor++){
    for (pin=0; pin<NPINS; pin++){
      pinMode(motorPins[motor][pin],OUTPUT);
      digitalWrite(motorPins[motor][pin],pinStates[motorState[motor]][pin]);
    }
  }
  pinMode(LEDPIN,OUTPUT);
  pinMode(BIKE1,INPUT);
  pinMode(BIKE2,INPUT);
  pinMode(BIKE3,INPUT);
  pinMode(BIKE4,INPUT);
  pinMode(SWITCH1PIN,INPUT);
  pinMode(SWITCH2PIN,INPUT);
  pinMode(SWITCH3APIN,INPUT);
  pinMode(SWITCH3BPIN,INPUT);

  attachInterrupt(4, bike1, RISING); //
  attachInterrupt(5, bike2, RISING); //
  attachInterrupt(6, bike3, RISING); //
  attachInterrupt(7, bike4, RISING); //
//  Serial.begin(9600);             // Starts Serial to print data

}

/*-----------------------------------------------------------------------------------------
 ************************************* Interrupt Handlers *********************************

 */
/*----------------------------------------------------------------------------------bike1()
 */
void bike1() {
  //Serial.print("bike1 ");
  ++pulseCount[0];
  if ((--pulseMod[0]) == 0 ){
    stepit(0,FORWARDSTEP,HALFSTEP);
    pulseMod[0]=pulsesPerStep;
  }
}
/*-----------------------------------------------------------------------------------------
 */
void bike2() {
  //Serial.print("bike2 ");
  ++pulseCount[1];
  if ((--pulseMod[1]) == 0 ){
    stepit(1,FORWARDSTEP,HALFSTEP);
    pulseMod[1]=pulsesPerStep;
  }
}
/*-----------------------------------------------------------------------------------------
 */
void bike3() {
  //Serial.print("bike3 ");
  ++pulseCount[2];
  if ((--pulseMod[2]) == 0 ){
    stepit(2,FORWARDSTEP,HALFSTEP);
    pulseMod[2]=pulsesPerStep;
  }
}
/*-----------------------------------------------------------------------------------------
 */
void bike4() {
  //Serial.print("bike4 ");
  ++pulseCount[3];
  if ((--pulseMod[3]) == 0 ){
    stepit(3,FORWARDSTEP,HALFSTEP);
    pulseMod[3]=pulsesPerStep;
  }
}
/*-----------------------------------------------------------------------------------------
 ************************************* Main Loop ******************************************
 *---------------------------------------------------------------------------------------*/

/*-----------------------------------------------------------------------------------------
 *
 */

void loop() {
  int currentMotor;
  currentMotor=(digitalRead(SWITCH1PIN)*2)+digitalRead(SWITCH2PIN) ;
  switchState=digitalRead(SWITCH3BPIN);
  if (switchState==HIGH) {
     stepit(currentMotor,FORWARDSTEP,HALFSTEP);
   }
   switchState=digitalRead(SWITCH3APIN);
   if (switchState==HIGH) {
     stepit(currentMotor,BACKWARDSTEP,HALFSTEP);
   }
   ledState=!ledState;
   digitalWrite(LEDPIN,ledState);
   delay(delayTime);
}