Showing posts with label videos. Show all posts
Showing posts with label videos. Show all posts

Thursday, September 8, 2011

Task 20a - Motor spinning at different rates using digital PWM: software & video

This version of Task-20 is slightly different, in that the motor speeds up, then slows down again, speeds up, slows down..

The variation in software is shown below:

void loop()                    
{
  for (int j=100; j>=0; j--)        // slowly decrease mark-space ratio, increasing speed
  {
    Serial.print("Mark-space ratio is 4 - ");
    Serial.println(j);
    RotateMotor(1,0,1,j);        // rotate motor Right @ set speed..
  }//for()  
 
    for (int j=0; j<=100; j++)   // slowly increase mark-space ratio, decreasing speed
  {
    Serial.print("Mark-space ratio is 4 - ");
    Serial.println(j);
    RotateMotor(1,0,1,j);       // rotate motor Right @ set speed..
  }//for()
}//end loop()


Wednesday, September 7, 2011

Task 20 - Motor spinning at different rates using PWM

To the right is an image of the Fritzing diagram (breadboarding) - the same as Tasks 18 & 19.



 


 Below it is an image of the actual ET-MINI DC-MOTOR board.
On it is mounted the motor (which is bidirectional), circuitry known as an H-Bridge (for protecting the circuitry connected to it from any induction spikes), 2 direction-indicating LEDs
(L & R), & 2 photo-interrupters labelled 

OPA & OPB (for detecting pulses for measuring motor speed etc).



 




IN this task, we attempt to regulate the motor speed using Pulse Width Modulation (PWM).

This will involve inputting a pulse at varying intervals - the longer the interval the slower the speed.
Clearly, the input pulses must be frequent enough to keeping the motor spinning, but not so frequent as to cause the motor to hit its maximum speed.






The video shows the motor in action, starting slowly & speeding up.

Tuesday, August 30, 2011

Project 2 - Arduino Motor Project - Serial input speed & direction control

Here's the Fritzing diagram, showing pins 9 & 10 used since they have the Pulse Width Modulation (PWM) option enabled on them.


/*
 * Project:      MotorSpin_621project02_1
 * Author:      Jane-Maree Howard
 * Date:         Tuesday 11/10/2011
 * Platform:   Arduino 22
 * Purpose:    To demonstrate Serial input motor control
 * Operation:  Description: The ET-MINI DC-MOTOR board has an H-bridge & a DC motor
 -                          The board's terminals are:
 -                          EN - Enable, must be set at logic "1" for operation.
 -                          IN1- With EN @ "1", IN1 @ "1" rotates the motor to the Right.
 -                          IN2- With EN @ "1", IN2 @ "1" rotates the motor to the Left
 -            
Arduino Libraries: LIB04_KeypressInput; LIB06_PWMmotorSpeed_ETMINI;  
 -            
Setup(): Serial @ 9600 baud; Print heading;            
 -            
Loop():  Via Serial Monitpr, input a PAIR of characters, e.g. r7, ss, L9;
 -                      Press 'Enter' or 'Send';
 -                      Motor direction & speed range are outputted &..
 -                      ..PWMmotorControl(bRight, bLeft, bEnable, bMotor, bSpeed) operates
 -                      the motor according to instruction-pair;

 */
int  iKeyPress = 0;      // for incoming serial data
char chInput;              // for 'char' parameters
// digital control pins for ET-MINI DC-MOTOR
byte bRight    = 10;    // IN1 is pin 10 - rotate Right
byte bLeft     = 9;       // IN2 is pin 9  - rotate Left
byte bEnable   = 13;  // EN  is pin 13 - Enable rotation, must = '1'
byte bMotor    = 0;    // in LIB06_PWMmotorControl(), '0'=STOP, '1'=RIGHT, '11'=LEFT
byte bSpeed    = 0;    // in ditto, PWM duty cycle parameter - initialised to "stop"

void setup()  
{
  Serial.begin(9600);                      //SM @ 9600 baud
  pinMode(bEnable, OUTPUT);   // EN - ENable pin on motorboard
  pinMode(bRight, OUTPUT);     // IN1 - 'RIGHT' pin on motorboard
  pinMode(bLeft, OUTPUT);       // IN2 - 'LEFT' pin on motorboard
  Serial.println("\nEnter your control characters in pairs e.g.: R5, ss");
}//end setup()

void loop()                    
{
  // first input Motor Direction, STOP, RIGHT, or LEFT
  iKeyPress = KeypressInput();
  if (iKeyPress !=0)
  {
    Serial.print("\nInput direction\t");
    chInput   = (char)iKeyPress;
    Serial.println(chInput, BYTE);
    switch (chInput)
    {
      case ('s'):
        bMotor    = 0;
        break;
      case ('S'):
        bMotor    = 0;         
        break;
      case ('r'):
        bMotor    = 1;
        break;
      case ('R'):
        bMotor    = 1;
        break;
      case ('l'):
        bMotor    = 11;
        break;
      case ('L'):
        bMotor    = 11;
        break;     
      default: bMotor    = 0;    
    }//switch()

    // now input Motor Speed on a scale of 1-9
    iKeyPress = KeypressInput();
    Serial.print("Input speed\t");
    chInput   = (char)iKeyPress;
    Serial.println(chInput, BYTE);
    switch (chInput)
    {
      case ('1'):
        bSpeed    = 50;
        break;
      case ('2'):
        bSpeed    = 75;
        break;
      case ('3'):
        bSpeed    = 100;
        break;  
      case ('4'):
        bSpeed    = 125;
        break;
      case ('5'):
        bSpeed    = 150;
        break;
      case ('6'):
        bSpeed    = 175;
        break;    
      case ('7'):
        bSpeed    = 200;
        break; 
      case ('8'):
        bSpeed    = 225;
        break;        
      case ('9'):
        bSpeed    = 255;
        break;     
      default: bMotor    = 0;    
    }//switch()
  }//if()
  /* now that control characters have been entered e.g.L7,
     call PWMmotorControl with all parameters present
  */

  PWMmotorControl(bRight, bLeft, bEnable, bMotor, bSpeed);
}//end loop()
//END


The control characters must be entered as a pair,
otherwise it will not function.

The direction can be upper or lower case.

The duty cycle (input speed 1-9) can in theory range from 0-255, but in practice, anything < 50 won't fire the motor up.
255 represents 100%, or full-speed.







/*
 * Project:    LIB06_PWMmotorSpeed_ETMINI
 * Author:       Jane-Maree Howard
 * Date:          Tuesday 11/10/2011
 * Platform:     Arduino 22
 * Purpose:     To use PWM speed-control for an ET-MINI DC-MOTOR board
 * Operation:  The ET-MINI DC-MOTOR board has an H-bridge & a DC motor
 -                          The board's terminals are:
 -                          EN - Enable, must be set at logic "1" for operation.
 -                          IN1- With EN @ "1", IN1 @ "1" rotates the motor to the Right.
 -                          IN2- With EN @ "1", IN2 @ "1" rotates the motor to the Left  
 -             Declare:     NONE - MUST BE DECLARED IN CONJOINING SKETCH(ES)
 -             Setup():     NONE - MUST BE USED ONLY IN CONJOINING SKETCH(ES)
 -                          (used  only in testing)
 -             Procedure(): void PWMmotorControl(byte,byte,byte,byte,byte);     
 -             Loop():      NONE - MUST BE USED ONLY IN CONJOINING SKETCH(ES)
 -                          (used  only in testing)   
         
 */
//   RotateMotor - CALLED IN MAIN SKETCH
void PWMmotorControl(byte bR, byte bL, byte bEN, byte bMO, byte bSPEED)
{
  /* 
  Rotate ET-MINI DC-MOTOR: bR,bL,bEN are Pins; bMO en/dis-ables;
 
  bSPEED takes values 0-255 as part of the PWM duty cycle;
  analogWrite() is a PWM operation on a Digital pin,
  .            
& has nothing to do with Analog pins or AnalogRead()
  */
  // pause motor to allow change of direction

  delay(20);                        // delay 20 milliseconds
  digitalWrite(bEN,1);      // write '1' to motorboard pin EN - enable motor
  switch (bMO)
  {
    case 0:                          // STOP  - disable motor
      digitalWrite(bEN,0);  // write '0' to motorboard pin EN
      break;
    case 1:                          // rotate RIGHT @
      digitalWrite(bL,0);    // write '0' to motorboard pin IN2 - no rotation left
      analogWrite(bR,bSPEED);   // write to motorboard pin IN1
      break;
    case 11:                       // rotate LEFT @ 
      digitalWrite(bR,0);   // write '0' to motorboard pin IN1 - no rotation right
      analogWrite(bL,bSPEED);   // write to motorboard pin IN2   
      break;
    default:                           // STOP - disable motor
      digitalWrite(bEN,0);    // write '0' to motorboard pin EN - disable motor
  }//switch()case
}//PWMmotorControl()
//END


Go to the following link for the operating software
/*
 * Project:       LIB04_KeypressInput
 * Author:       Jane-Maree Howard
 * Date:           Saturday 08/10/2011
 * Platform:     Arduino 22
 * Purpose:     To make a library function for inputting a key-press via Serial comm link
 * Operation:  Description: inputs a key-press & returns an Integer

.

Saturday, July 30, 2011

Task 1 - finding the YouTubes

Simple Arduino Robot - about as simple as you can get: 2 driving wheels, front idler, breadboard mounting - on ours we'd put the H-bridge there..






Easy Arduino Robot - also fairly simple; a bit fuzzy but if you check out the video, it's clearer: this one has an IR sensor (i think) for detecting obstacles so i guess it has software to do this..






Arduino Robot controlled by Neural Network - i threw this one in, because i'm fascinated by Neural Networks & what they can do.  more here..
i have a few very basic C programs @home which i hope to translate into "Arduino-ese"..
This thing actually learns, & it's funny to watch its bumbling first attempts & then see it 'get the idea' & learn to avoid the obstacles.  it also learn how to avoid new obstacles once it knows how to navigate round the old ones..
  PlanMix says:   
" My first attempt in neural networks. I connected
  - 1 adruino mega,
  - 3 servos,
  - 1 analog infrared receiver,
  - 3 contacts and
  - 2 encoders from an old printer.
  I use a genetic algorithm that trains the 5-7-2 neural network
  (5 inputs, 7 neurons in the hidden layer and 2 in output).
  The 5 inputs are the 5 areas that the IR scans using the third servo, and
   the 2 outputs are the speed of each wheel servo."[03 dec 2009]
(Unfortunately for me, his website's in Greek :-?, so that's all i have)


Thursday, August 19, 2010

Task unspecified - a whinge..

Yes, a whinge.  About schlepping round the Net.

I'm not going to sprinkle my ID details all over the Net like confetti, not least because i'm a sh*t liar, & can't be doing with having to recall what i told A, B, & C when signing up to D.

So what do i do when Megaglomerus-dotcom asks me more questions than a Nigerian scam site (i actually collect those purely for their amusement value) before letting me register to have my gold half-crowns ripped out without anasthetic (or whatever!)?

It's idiot-o'clock in the morning & i'm going home.
I'm too tired to do any more..
I can't see a 3-slide PowerPoint happening in a hurry either,
but i'm more than happy to talk ad-lib on the Neural Network Arduino robot - that really impressed me.

{sigh} where's my {sigh} icon people, you know i'm a klutz at graphics..

Thursday, July 29, 2010

Task 1- Arduino Robot YouTube videos

Here are some YouTube videos:

1. Easy Arduino Robot

   ArduinoFun | July 03, 2009says:  
   "Easy autonomous arduino robot. 
   Can be built in a short amount of time. 
   Great learning project. 
   More Arduino Fun at: http://www.ArduinoFun.com"
 It has a scanning proximity or IR sensor that seems to control the steering, enabling it to avoid obstacles before actually running into them (& having to back away, or whatever).
 Steering & power seem to be by independent motors powering the two rear wheels. 

 I think the single front wheel is just a caster.
 I could use that arrangement; looks nice & simple.
I've just realised that if you gently alternate the advance of the L- & R-hand wheels, you can make the caster sweep to-&-fro, with the scanner mounted on it!
Even better than i first thought..

2. Arduino robot controlled by Neural Network

planmix | December 03, 2009 says: 
"My first attempt in neural networks. I connected 1 adruino mega,
3 servos, 1 analog infrared receiver, 3 contacts and 2 encoders
from an old printer.
I use a genetic algorithm that trains the 5-7-2 neural network (5 inputs,
7 neurons in the hidden layer and 2 in output).
The 5 inputs are the 5 areas that the IR scans using the third servo,
and the 2 outputs are the speed of each wheel servo."


I'm actually quite interested in Neural Networks.  
 planmix has given a fairly complete description.
 I'd like to know more about the NN but i can't read Greek!


 I understand the basics of NNs: planmix has 5 inputs 
from a scanning IR sensor & some contact sensors 
(watch it backing into the walls), 
generates its own NN algorithms, 
evidently has a selection-of-the-best process,
& outputs speeds (+fwd/rev) to its 2 wheels.
Its behaviour looks bizarre, even idiotic, at first,
but it does learn!
The video's been speeded up AFAICS, but go to the 6th minute to see its "trained" actions.

 The point about the NN is, it hasn't a blue's clue what it's doing at first; every time a contact sensor sends an input, the NN being currently tested gets a message to 'avoid'.
Watch for the blue LED on top - when it flashes, testing of a new NN variation has begun.

I'd really like to know more about this, especially the mutation/genetic-mixing process, because that's what generates the New Improved versions of the algorithm.
Must have another look @ "Blondie 24" - a checkers-playing NN that 'learned' its way up to Expert rank.  Its makers gave it a fictitious online ID (a 24-year-old California blonde student), & set it playing against online opponents.  Great stuff!

3. Simple Arduino Robot
BatistLeman | April 25, 2008 says:
http://www.coded.be
"This device just goes forward, turns and so on. (in a loop)"
This is dead simple!  I like it.
BatistLeman has mounted  a breadboard on a wooden base, 
 which has the wheels mounted underneath, & the rest is all done on the breadboard.
 It's another tricycle, but it's movements are controlled by a PS2 mouse!  Not as sophisticated as the NN-controlled tricycle above.

4. Arduino Robot

retardokiddo | August 28, 2009 says: 
"Biped robot using arduino, r/c micro servos and icecream sticks
Visit http://retardokiddo.blogspot.com/ for details and view/leave comments!
Also on : http://www.instructables.com/member/c..."
This is a bit of hoot, but it's too complicated for me.
 Building something like this takes more dedication than i can muster, but if you're doing it for fun, just to see if you can make it work, then the motivation'd be there, for sure!

5. My First Arduino Robot

themattmitch | December 08, 2008 says: 
"this is a short vid of my first arduino robot."
Seems to be another tricycle-movement, scanning-proximity-sensor machine, but the video's too short to learn anything about how it works..
One thing i DO like: it seems to have been built into one of those plastic snap-lock boxes.  I'd definitely try that!