CEMETECH
Leading The Way To The Future
Login [Register]
Username:
Password:
Autologin:

Don't have an account? Register now to chat, post, use our tools, and much more.
Latest Headlines
Online Users
There are 114 users online: 3 members, 86 guests and 25 bots.
Members: charlessprinkle.
Bots: VoilaBot (4), Magpie Crawler (2), Googlebot (19).
RSS & Social Media
SAX
You must log in to view the SAX chat widget
Author Message
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55884
Location: Earth, Sol, Milky Way

Posted: 17 Jan 2010 08:16:37 pm    Post subject: Fun with the Arduino Duemilanove

Among my several fun toys from Sparkfun's Free Day is an Arduino Duemilanove. Everyone else seems to be having fun with them as an easy-to-use microprocessor development environment for projects, so I figured I might as well jump on the bandwagon to see what all the fuss is about. I received my Sparkfun freebies today, as noted elsewhere on the Cemetech forum, so I started setting up the Arduino and seeing what programming it is like. The development environment seems pretty intuitive so far, and I like the C++ish syntax. I began by trying to interface the Thumb Slide Joystick from Sparkfun, but unfortunately the product info they had on the pinout of the device incorrect. I did some searching and debugging, and discovered the correct pinout. With the nub up and facing you, and the pins on the bottom away from you and pointing towards your chest, from left (pin 1) to right (pin 4):

1) x-axis output
2) +5V
3) y-axis output
4) gnd

Just to make sure I'm clear, my pin 4 is the one closest to the two screw/mounting holes. When connected to an Arduino, I get a range of about 128 to 775 on each axis, with enough consistency to check if it's at -x, center-x, +x, and -y, center-y, and +y. It has a fairly large range of "nominal" values when centered, but this isn't a problem for me since my application doesn't involve reading a range of values. Here's a random picture of the (very simple) testbed:



More Arduino fun coming soon.

Edit: I pulled out the control board and hardware stack for the VUFan rig out of my closet, hooked it up to the Arduino, coded a 2-minute binary counter, and voila!


Link


Edit #2: After several hours of coding and debugging, I wrote a C++ program to read DiscoLitez-generated information off of the network and pipe it to a serial port, then an Arduino program to read in the serial data and control the fans accordingly. Video follows:


Link


For those who missed the VUfan project the first time, here's how the very first iteration looked:


Link

_________________


Back to top
benryves


Cemetech Expert


Joined: 12 Aug 2008
Posts: 1361
Location: London, United Kingdom

Posted: 19 Jan 2010 06:28:38 am    Post subject:

Looks like you're making rapid progress. Smile Would you say that the ease of use makes the increased cost (and irritating terminology) over a plain AVR worthwhile?
Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55884
Location: Earth, Sol, Milky Way

Posted: 19 Jan 2010 10:00:34 am    Post subject:

benryves wrote:
Looks like you're making rapid progress. Smile Would you say that the ease of use makes the increased cost (and irritating terminology) over a plain AVR worthwhile?
To be honest, yes, although I, like you, have gotten SO SICK of every single project on places like Hackaday using an Arduino in some sense. Last night I was working on implementing TI link routines on the Arduino; I hope to have more dependable transfers done this evening. Smile
_________________


Back to top
benryves


Cemetech Expert


Joined: 12 Aug 2008
Posts: 1361
Location: London, United Kingdom

Posted: 19 Jan 2010 10:53:25 am    Post subject:

Good to hear. I look forwards to seeing what you come up with. Smile

I think most people objected due to the relatively poor quality of the featured projects, not that they were built around an Arduino. It shouldn't matter what platform was used, as long as the result is interesting or useful!

Is it possible to use regular AVR C/assembly code with the Arduino development tools? (For example, I tried to find out of V-USB was usable with the Arduino, but all I could find were USB solutions that required an additional daughterboard - sorry, shield).
Back to top
Tari


Systems Integrator


Joined: 03 Jul 2006
Posts: 2121
Location: Always-winter, Michigan

Posted: 19 Jan 2010 07:37:41 pm    Post subject:

I'll begin this by saying I've never attempted to use an Arduino, but..
I believe you can at least load your own code (c/assembly/whatever) through the Arduino bootloader. Whether their tools will actively help you write/debug said code, I have no idea.

If all else fails, you can reflash the thing yourself, and maybe without a programmer if you're clever.
_________________


Ask questions the smart way · タリ
Back to top
Ultimate Dev'r


Join us on #cemetech-vaporware


Joined: 16 Mar 2005
Posts: 7297

Posted: 19 Jan 2010 09:30:25 pm    Post subject:

benryves wrote:
Good to hear. I look forwards to seeing what you come up with. Smile

I think most people objected due to the relatively poor quality of the featured projects, not that they were built around an Arduino. It shouldn't matter what platform was used, as long as the result is interesting or useful!


I think it has more to do with the fact that the Arduino is more of a "beginner's board" than say a Xilinx Spartan-3E board, so you're going to find a lot more "easy" and slightly unimaginative projects for the Arduino than you would for an FPGA platform.

benryves wrote:
Is it possible to use regular AVR C/assembly code with the Arduino development tools? (For example, I tried to find out of V-USB was usable with the Arduino, but all I could find were USB solutions that required an additional daughterboard - sorry, shield).


Yes, you can inline AVR C/assembly within an Arduino "sketch" ("source code" is too hard to say Razz)

As for the V-USB you'd have to wire a separate USB connector to the Arduino to use it because the one already on the board is attached to a FT232RL chip, which is basically just a USB -> TTL chip (but still perfectly usable with libusb).

The Tari wrote:
I'll begin this by saying I've never attempted to use an Arduino, but..
I believe you can at least load your own code (c/assembly/whatever) through the Arduino bootloader. Whether their tools will actively help you write/debug said code, I have no idea.

If all else fails, you can reflash the thing yourself, and maybe without a programmer if you're clever.


Part of the reason why I picked the Arduino; with this hack you can reprogram the ATmega328 on the board without using the Arduino bootloader.
_________________



Back to top
Ultimate Dev'r


Join us on #cemetech-vaporware


Joined: 16 Mar 2005
Posts: 7297

Posted: 20 Jan 2010 11:10:54 pm    Post subject:

Some more fun:


Link

_________________



Back to top
rivereye


Future Admin


Joined: 16 Mar 2005
Posts: 5450
Location: Out Fishing

Posted: 21 Jan 2010 01:15:56 am    Post subject:

hmm, I guess I am going to have to figure out what I did with my Arduino board and start playing around with it again
_________________
I am the eye of the river
>(<')


Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55884
Location: Earth, Sol, Milky Way

Posted: 21 Jan 2010 01:33:21 am    Post subject:

rivereye wrote:
hmm, I guess I am going to have to figure out what I did with my Arduino board and start playing around with it again
Definitely! I'm afraid I got sidetracked from working on my Arduino-calculator communication (and Freebuild map development, for what it's worth) by getting a certain amount of stuff done on my thesis for my meeting this Thursday, but I hope to be able to pick it up again tomorrow.
_________________


Back to top
rivereye


Future Admin


Joined: 16 Mar 2005
Posts: 5450
Location: Out Fishing

Posted: 21 Jan 2010 01:44:32 am    Post subject:

yep, I think the minor issue though is I have an older Arduino board, the Diecimila. I don't know too much on the differences, but could be an issue trying to recreate each others projects.
_________________
I am the eye of the river
>(<')


Back to top
Ultimate Dev'r


Join us on #cemetech-vaporware


Joined: 16 Mar 2005
Posts: 7297

Posted: 21 Jan 2010 02:37:24 am    Post subject:

rivereye wrote:
yep, I think the minor issue though is I have an older Arduino board, the Diecimila. I don't know too much on the differences, but could be an issue trying to recreate each others projects.


Basically you don't have a built-in LED on digital output pin 13 and you have an ATmega168 instead of an ATmega328; very few Arduino projects are ATmega328-only.
_________________



Back to top
Ultimate Dev'r


Join us on #cemetech-vaporware


Joined: 16 Mar 2005
Posts: 7297

Posted: 24 Jan 2010 02:51:19 am    Post subject:

From the guy(s) at 4ms studio:


Link

_________________



Back to top
Ultimate Dev'r


Join us on #cemetech-vaporware


Joined: 16 Mar 2005
Posts: 7297

Posted: 27 Jan 2010 04:00:10 pm    Post subject:

Sound and an LCD!


Link

_________________



Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55884
Location: Earth, Sol, Milky Way

Posted: 28 Jan 2010 01:16:02 pm    Post subject:

Finally got my link routines working. Here's a video of using my thumb-slide joystick to send arrow key codes to the calculator; sorry the video quality is quite poor. Code follows.


Link



Code:
/*
    Arduino-to-TI Linking Routines
    (c) 2010 Christopher Mitchell
 */

const int TIring = 2;
const int TItip = 3;
const int xAxis = 0;
const int yAxis = 1;

const int ledb = 8;
const int ledg = 9;
const int ledr = 10;

#define TIwhite TIring
#define TIred TItip
#define ERR_READ_TIMEOUT 1000
#define ERR_WRITE_TIMEOUT 2000
#define TIMEOUT 4000
#define GET_ENTER_TIMEOUT 30000

uint8_t data[20];
void setup() {
 
   //Initialize pins
   resetLines();
   
   //debugging
   pinMode(ledr,OUTPUT);
   pinMode(ledg,OUTPUT);
   pinMode(ledb,OUTPUT);
   
   Serial.begin(115200);
}

void loop() {
   int i,j;

   resetLines();
   digitalWrite(ledr,LOW);
   digitalWrite(ledg,LOW);
   digitalWrite(ledb,LOW);
   
   i = 0;
   j = analogRead(xAxis);
   if (j < 250) i = 1;      //keyleft
   if (j > 650) i = 2;      //keyright
   j = analogRead(yAxis);
   if (j < 250) i = 4;      //keyup
   if (j > 650) i = 3;      //keydown
   if (i == 0) return;
   
   data[0] = 0x23;
   data[1] = 0x87;
   data[2] = i;
   data[3] = 0x00;
   if (0 != (i = par_put(data,4))) { Serial.print(i,DEC); Serial.println("[!]"); return; }
   Serial.print("-");
   digitalWrite(ledr,HIGH);
   if (0 == par_get(data,4)) { digitalWrite(ledg,HIGH); } else { resetLines(); }
   //for(i=0;i<3;i++) { Serial.print(data[i],HEX); Serial.print(", "); } Serial.println(data[3],HEX);
   if (data[1] != 0x56) { return; }
   if (0 == (i = par_get(data,4))) { digitalWrite(ledb,HIGH); } else { resetLines(); Serial.println(i,DEC); }
   //resetLines();
   for(i=0;i<3;i++) { Serial.print(data[i],HEX); Serial.print(", "); } Serial.println(data[3],HEX);
}

void resetLines() {
   pinMode(TIring, INPUT);           // set pin to input
   digitalWrite(TIring, HIGH);       // turn on pullup resistors
   pinMode(TItip, INPUT);            // set pin to input
   digitalWrite(TItip, HIGH);        // turn on pullup resistors
}

static int par_put(uint8_t *data, uint32_t len) {
    int bit;
    int i, j;
    long previousMillis = 0;
    uint8_t byte;   

    for(j=0;j<len;j++) {
        byte = data[j];
   for (bit = 0; bit < 8; bit++) {
            previousMillis = 0;
       while ((digitalRead(TIring)<<1 | digitalRead(TItip)) != 0x03) {
           if (previousMillis++ > TIMEOUT)
               return ERR_WRITE_TIMEOUT+j+100*bit;
            };
       if (byte & 1) {
                pinMode(TIring,OUTPUT);
                digitalWrite(TIring,LOW);
                previousMillis = 0;
      while (digitalRead(TItip) == HIGH) {
          if (previousMillis++ > TIMEOUT)
         return ERR_WRITE_TIMEOUT+10+j+100*bit;
      };
      
                resetLines();
                previousMillis = 0;
      while (digitalRead(TItip) == LOW) {
          if (previousMillis++ > TIMEOUT)
         return ERR_WRITE_TIMEOUT+20+j+100*bit;
      };
       } else {
                pinMode(TItip,OUTPUT);
                digitalWrite(TItip,LOW);      //should already be set because of the pullup resistor register
                previousMillis = 0;
      while (digitalRead(TIring) == HIGH) {
          if (previousMillis++ > TIMEOUT)
         return ERR_WRITE_TIMEOUT+30+j+100*bit;
      };
      
                resetLines();
                previousMillis = 0;
      while (digitalRead(TIring) == LOW) {
          if (previousMillis++ > TIMEOUT)
         return ERR_WRITE_TIMEOUT+40+j+100*bit;
      };
       }
       byte >>= 1;
   }
        //delayMicroseconds(6);
    }
    return 0;
}

static int par_get(uint8_t *data, uint32_t len) {
    int bit;
    int i, j;
    long previousMillis = 0;

    for(j = 0; j < len; j++) {
   uint8_t v, byteout = 0;
   for (bit = 0; bit < 8; bit++) {
       previousMillis = 0;
       while ((v = (digitalRead(TIring)<<1 | digitalRead(TItip))) == 0x03) {
      if (previousMillis++ > GET_ENTER_TIMEOUT)
          return ERR_READ_TIMEOUT+j+100*bit;
       }
       if (v == 0x01) {
      byteout = (byteout >> 1) | 0x80;
                pinMode(TItip,OUTPUT);
                digitalWrite(TItip,LOW);      //should already be set because of the pullup resistor register
                previousMillis = 0;
      while (digitalRead(TIring) == LOW) {            //wait for the other one to go low
          if (previousMillis++ > TIMEOUT)
         return ERR_READ_TIMEOUT+10+j+100*bit;
      }
                //pinMode(TIring,OUTPUT);
                digitalWrite(TIring,HIGH);
       } else {
      byteout = (byteout >> 1) & 0x7F;
                pinMode(TIring,OUTPUT);
                digitalWrite(TIring,LOW);      //should already be set because of the pullup resistor register
                previousMillis = 0;
      while (digitalRead(TItip) == LOW) {
          if (previousMillis++ > TIMEOUT)
         return ERR_READ_TIMEOUT+20+j+100*bit;
      }
                //pinMode(TItip,OUTPUT);
                digitalWrite(TItip,HIGH);
       }
            pinMode(TIring, INPUT);           // set pin to input
            digitalWrite(TIring, HIGH);       // turn on pullup resistors
            pinMode(TItip, INPUT);            // set pin to input
            digitalWrite(TItip, HIGH);        // turn on pullup resistors
   }
        data[j] = byteout;
        //delayMicroseconds(6);
    }
    return 0;
}

_________________


Back to top
elfprince13


OVER NINE THOUSAND!


Joined: 23 May 2005
Posts: 10248
Location: A galaxy far far away......

Posted: 28 Jan 2010 03:36:43 pm    Post subject:

Cool Smile
_________________
StickFigure Graphic Productions || VSHI: Vermont Sustainable Heating Initiative


Back to top
tifreak8x


Guru


Joined: 16 Mar 2005
Posts: 9104
Location: Sol System

Posted: 29 Jan 2010 06:44:42 pm    Post subject:

very interesting bit of work there, mr Kerm. =]
_________________
Projects: AOD Series: 70% | FFME: 80% | Pokemon: 18% | RPGSK: 60% | Star Trek: 70% | Star Trek 83+: 40% | TI-City: 5%

Look here for Assembly Resources.
Back to top
KermMartian


Site Admin


Joined: 14 Mar 2005
Posts: 55884
Location: Earth, Sol, Milky Way

Posted: 29 Jan 2010 06:46:07 pm    Post subject:

tifreak8x wrote:
very interesting bit of work there, mr Kerm. =]
Thanks! And with that bit of fun all worked out, I will fairly painlessly be able to fake all the getKey keypresses from my remapped keyboard in translation mode, huzzah.
_________________


Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are GMT - 5 Hours

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© Copyright 2000-2013 Cemetech & Kerm Martian :: Page Execution Time: 0.053105 seconds.