Shop OBEX P1 Docs P2 Docs Learn Events
myrOBOT Library — Parallax Forums

myrOBOT Library

ReinhardReinhard Posts: 489
edited 2011-12-04 10:52 in Propeller 1
Hi All,
how posted in another thread, I work on an robot library, with the aim to replace the Lego Mindstorm Brain, but use all
the Lego Motors and Sensors included in the Lego Package.

The software grows faster than the hardware and mechanical stuff .

The software frontend looks like this:
/****************************************
     Propeller replace mindstorm brick
     codename: myrOBOT
     Author  : Reinhard Mayer
     Date    : 2011 - DEC - 03
     Version : 0.0.1
     Compiler: propgcc

              ._____    _____.
              |     \__/     |
       Button1|  1        40 |TXD
       Button2|  2        39 |RXD
     Sound.out|  3        38 |SDA
    Analog.out|  4        37 |SCL
    MotorB dir|  5        36 |ADC_FAST.SCLK
    MotorA dir|  6        35 |ADC_FAST.nCS
  MotorB Power|  7        34 |ADC_FAST.DIN
  MotorA Power|  8        33 |ADC_FAST.DOUT
           Vss|  9        32 |VDD
          nBOE| 10        31 |XO
          nRES| 11        30 |XI
           Vdd| 12        29 |Vss
 SigmaDelta.in| 13        28 |LCD.DB7
 SigmaDelta.fb| 14        27 |LCD.DB6
         spare| 15        26 |LCD.DB5
         spare| 16        25 |LCD.DB4
         spare| 17        24 |LCD.DB3
        LCD.RS| 18        23 |LCD.DB2
        LCD.RW| 19        22 |LCD.DB1
        LCD.EN| 20        21 |LCD.DB0
              |______________|

*****************************************/

#include <propeller.h> 
#include <stdio.h>

#include "kernel.h"
#include "motor.h"
#include "analog_out.h"
#include "max147.h"



// this is the mailbox for Sigma Delta ADC
// it is important to place declaration here !
unsigned int value; 

#define Teststub
//////////////////////////////////////////////////////////
void main ()
{
int percent;
unsigned short adc_fast;
    
    kernel_init();


#ifdef Teststub    
    DIRA |= 1 << 16;     // Sigma Delta Limit Indicator LED
    
    while(1)
    {
      for(percent = 0; percent <= 100;percent++)
      {
        
        //motor pwm and direction, for this test of course no common motor - axis ;-)
        setMotorA(percent,fwd);
        setMotorB(100 - percent,rev);
        
        //analog out
        setAnalogOut(percent);
        
        // delay before next pwm delta
        msleep(100);

        //Sigma Delta ADC
        if(value > 300)
        {
          //pulse LED if sigma delta value exceeds a limit
          OUTA |= 1 << 16;
          msleep(500);
          OUTA &= ~(1 << 16);
        }
        
        //buttons
        if( CLOSE == getButtonState(1) )
            swapMotorADirection ();
        
        if( CLOSE == getButtonState(2) )
            swapMotorBDirection ();

        //adc_fast, for more info read max147 datasheet
        adc_fast = readMAX147(0xFF);
        
      }
      
      percent = 0;
      msleep(500);
    } 
#endif 
}


if any is interest for full open source here is the path:
http://home.mnet-online.de/reimay/Projects/myrOBOT/

cheers
Reinhard

Comments

  • mindrobotsmindrobots Posts: 6,506
    edited 2011-12-03 07:58
    Reinhard,

    This is fantastic! I have an old Mindstorm 1.0/1.5 set that is mechanically and electrically perfect but we've been having trouble finding software that works on a moder PC to run the brick. Now I can just replace the brick with a propeller!

    I'm going to be following this project closely!

    Excellent work!
  • ReinhardReinhard Posts: 489
    edited 2011-12-03 08:44
    mindrobots,

    Thank you for the comment, I think for the predicat "Excellent work" I have even more to do.

    I guess I run not into problems with the software, but any hardware concept is still uncleared today.

    Actually I use an MOS-FET for the MotorDriver and 2 Relays for each Motordirection, because they are the components I found in my tinker box.

    Maybe it is better to use a standard Driver IC, but I think the signal for this IC (PWM and Digital IO ) will remain unchanged.

    Unclear is also how I integrate the Propeller PCB with Lego stuff.

    So it can be there are different hardware solutions and this will adapt with minor software changes.

    However the next thing is to write a driver for the hitachi LCD, also found in my tinker box.
    And a diver for play a melody is also a nice to have.

    cheers
    Reinhard
  • jazzedjazzed Posts: 11,803
    edited 2011-12-03 09:43
    Looks great so far! This will be a candidate for hackaday.
  • ReinhardReinhard Posts: 489
    edited 2011-12-03 10:28
    jazzed

    Thanks !

    Since english is not my native language, what is hackaday :smile:

    cheers
    Reinhard
  • jazzedjazzed Posts: 11,803
    edited 2011-12-03 10:37
    Reinhard wrote: »
    Since english is not my native language, what is hackaday :smile:

    http://hackaday.com/

  • ReinhardReinhard Posts: 489
    edited 2011-12-03 10:47
    :cool: ..............
  • ReinhardReinhard Posts: 489
    edited 2011-12-04 10:52
    Hi,

    now the LCD Driver and PlaySound are added to the myrOBOT Library.
    /****************************************
         Propeller replace mindstorm brick
         codename: myrOBOT
         Author  : Reinhard Mayer
         Date    : 2011 - DEC - 03
         Version : 0.0.1
         Compiler: propgcc
    
                  ._____    _____.
                  |     \__/     |
           Button1|  1        40 |TXD
           Button2|  2        39 |RXD
         Sound.out|  3        38 |SDA
        Analog.out|  4        37 |SCL
        MotorB dir|  5        36 |ADC_FAST.SCLK
        MotorA dir|  6        35 |ADC_FAST.nCS
      MotorB Power|  7        34 |ADC_FAST.DIN
      MotorA Power|  8        33 |ADC_FAST.DOUT
               Vss|  9        32 |VDD
              nBOE| 10        31 |XO
              nRES| 11        30 |XI
               Vdd| 12        29 |Vss
     SigmaDelta.in| 13        28 |LCD.DB7
     SigmaDelta.fb| 14        27 |LCD.DB6
             spare| 15        26 |LCD.DB5
             spare| 16        25 |LCD.DB4
             spare| 17        24 |LCD.DB3
            LCD.RS| 18        23 |LCD.DB2
            LCD.RW| 19        22 |LCD.DB1
            LCD.EN| 20        21 |LCD.DB0
                  |______________|
    
    *****************************************/
    
    #include <propeller.h> 
    #include <stdio.h>
    
    #include "kernel.h"
    #include "motor.h"
    #include "analog_out.h"
    #include "max147.h"
    #include "lcd.h"
    #include "sound.h"
    
    // this is the mailbox for Sigma Delta ADC
    // it is important to place declaration here !
    unsigned int value; 
    
    // sound
    note_t song[] = 
    {
        {_C6,1},  // note = C6, duration = 100ms
        {_D6,1},
        {_E6,1},
        {_F6,1},
        {_G6,2},  // note = G6, duration = 200ms
        
        {END,0}
    
    };
    
    #define Teststub
    //////////////////////////////////////////////////////////
    void main ()
    {
    int percent;
    unsigned short adc_fast;
        
        kernel_init();
    
    
    #ifdef Teststub    
        DIRA |= 1 << 16;     // Sigma Delta Limit Indicator LED
        
        // lcd putchar
        lcd_putchar(':');
        lcd_putchar('-');
        lcd_putchar(')');
        
        while(1)
        {
          for(percent = 0; percent <= 100;percent++)
          {
            
            //motor pwm and direction, for this test of course no common motor - axis ;-)
            setMotorA(percent,fwd);
            setMotorB(100 - percent,rev);
            
            //analog out (normaly lowpass filtered with RC)
            setAnalogOut(percent);
            
            // delay before next pwm delta
            msleep(100);
    
            //Sigma Delta ADC
            if(value > 300)
            {
              //pulse LED if sigma delta value exceeds a limit
              OUTA |= 1 << 16;
              msleep(500);
              OUTA &= ~(1 << 16);
            }
            
            //buttons and lcd puts
            if( CLOSE == getButtonState(1) )
            {
                swapMotorADirection ();
                lcd_puts("Button 1 close");
                playSound(song);
            }
            else
                lcd_puts("Button 1 open ");
            
            if( CLOSE == getButtonState(2) )
                swapMotorBDirection ();
    
            //adc_fast, for more info read max147 datasheet
            adc_fast = readMAX147(0xFF);
            
          }
          
          percent = 0;
          msleep(500);
        } 
    #endif 
    }
    

    Of course some functions are not only special for roboting, but also usable for general purpose.

    In the path above now is a zip archive, for easy download.

    cheers
    Reinhard
Sign In or Register to comment.