Show Posts
Pages: 1 2 [3] 4 5 ... 8
31  Forum 2005-2010 (read only) / Syntax & Programs / Serial in another class on: November 09, 2007, 02:50:58 pm

is it possible to use the Serial class within a library class i'm designing?  It would really simplify things for development.

32  Forum 2005-2010 (read only) / Syntax & Programs / Re: Freqout on: November 06, 2007, 03:02:32 pm
i dont really know a whole lot about what is happening here, but you might want to try the delayMicroseconds() function.  it seems you may be running into problems with fractions and stuff, and increasing the values you're dealing with by 1000 would probably help alot.
33  Forum 2005-2010 (read only) / Syntax & Programs / double/float + binary math on: November 05, 2007, 01:49:46 pm
I'm trying to create a library that i can use to send simple packets back and forth between my host and my firmware.  part of that is using an overloaded add() function to allow me to simply call packet->add(data) and then have it put it into the buffer to be sent later.

i'm pretty sure i figured out how to do it for all the 'normal' datatypes, but i'm confused when it comes to floats and doubles.  here is a snipped of the code i'm using:

full version here:

boolean PackIt::add(byte b)
      //do we have room left?
      if (this->size < MAX_PACKET_SIZE-1)
            //add it in!
            this->packets[this->size] = b;
            //calculate our crc
            this->crc = this->crc ^ b;
            return true;
            return false;

boolean PackIt::add(double d)
      byte i, b;
      bool result;
      for (i=0; i<8; i++)
            b = d & B11111111;
            result = this->add(b);
            d >>= 8;
      return result;

boolean PackIt::add(long l)
      byte i, b;
      bool result;
      for (i=0; i<4; i++)
            b = l & B11111111;
            result = this->add(b);
            l >>= 8;
      return result;

what do you guys think?
34  Forum 2005-2010 (read only) / Syntax & Programs / Re: Libraries in Libraries? on: November 04, 2007, 08:00:47 pm
yup, that worked!

now, the only thing that i need to figure out is how to do the microsecond resolution for my steppers =)
35  Forum 2005-2010 (read only) / Syntax & Programs / Re: Libraries in Libraries? on: November 02, 2007, 04:35:19 pm
okay, i think i get it...  so basically whats happening is that with that funky syntax, when i do something in my main sketch like this:

LinearAxis x(dir_pin, step_pin, min_pin, max_pin);

it would then internally call the LinearAxis constructor, as well as the stepper, min/max switch constructors, etc?  i'm gonna give that a try!  i'll report back here when/if i can get it working!

thanks mellis!
36  Forum 2005-2010 (read only) / Syntax & Programs / Re: Libraries in Libraries? on: November 02, 2007, 12:54:39 pm
yay!  that worked.

now i have another problem:

 In function 'void setup()':
error: request for member 'x' in 'bot', which is of non-class type 'CartesianBot ()()'

here's the code i'm trying to do:

//init our steppers
      bot.x.stepper = RepStepper(X_DIR_PIN, X_STEP_PIN);
      bot.y.stepper = RepStepper(Y_DIR_PIN, Y_STEP_PIN);
      bot.z.stepper = RepStepper(Z_DIR_PIN, Z_STEP_PIN);

basically, i have a CartesianBot class that contains 3 LinearAxis instances which each contain a RepStepper and 2 LimitSwitch instances.  Any ideas on how I would go about that so I can initialize them at runtime?
37  Forum 2005-2010 (read only) / Syntax & Programs / Libraries in Libraries? on: November 01, 2007, 10:57:13 pm
Hey All,

I'm writing some software to make my Arduino control a 3 axis cartesian bot (think CNC machine).  Anyway, here's the basic setup that is causing me problems:

I have 3 classes:

1. LinearAxis
2. LimitSwitch
3. RepStepper (my version of the stepper class)

i want the LinearAxis class to have a RepStepper instance and two LimitSwitch instances.  I'm getting this error:

LinearAxis.h:18: error: 'RepStepper' does not name a type
LinearAxis.h:20: error: 'LimitSwitch' does not name a type
LinearAxis.h:21: error: 'LimitSwitch' does not name a type

I'm somewhat inexperienced when it comes to C++, but I have tons of experience programming PHP and OO design, so i'm guessing its some sort of syntactical thing I'm missing.

the code is all located here:

the sketch is located here:

thanks in advance for your help.

38  Forum 2005-2010 (read only) / Syntax & Programs / Re: Stepper Motor Driving on: October 11, 2007, 02:31:13 pm
i've dug around some more, and this page is helpful:
39  Forum 2005-2010 (read only) / Syntax & Programs / Re: Stepper Motor Driving on: October 11, 2007, 11:07:48 am
awesome!  that seems like a step in the right direction for me.  where should i go to read more about this timer0 count register and how to access it through the arduino software?  thanks.
40  Forum 2005-2010 (read only) / Syntax & Programs / Stepper Motor Driving on: October 09, 2007, 10:42:27 am
Hey All,

Okay, so I'm wanting to drive some steppers with Arduino, and I've looked at the Stepper library.  The steppers I'm trying to drive are 200 step motors, and I'm pretty sure I can drive them at 30-40 RPM.

Here's the dilemma:  the delay time between steps is calculated like so:  60 seconds * 1000 / 40rpm / 200 steps = 7.5 milliseconds between steps.  Since this value is an integer (or technically, unsigned long??)  It gets rounded to either 7 or 8 (i havent checked the real value)  Also, eventually I'm going to want to do half-stepping.  That doubles the number of steps, and gives me a value of 3.75.  at that point the timing becomes crucial.

What I really need is to store this value as microseconds and then do the calculations based on that:  then it would be 7500 microseconds between steps.  Figuring out how many microseconds between steps to use is the easy part.

The hard part is figuring out how many microseconds have passed.  Arduino only provides the millis() function, and I'm wondering if its possible to get something like micros().  All I really need is just a counter of how many microseconds have elapsed.  Even if it rolls over every few minutes, thats okay with me.  I just need to be able to use it for precise timings.

Is there anything l could do to get that?   Is there a better approach to this?  I've read a tiny bit about interrupt timers, but I don't know much about them.  Any help or suggestions would be appreciated.
41  Forum 2005-2010 (read only) / Syntax & Programs / Re: Reading and writing files on: October 09, 2007, 03:44:34 pm
do you mean opening a file in the arduino?  if so, the file metaphor doesnt really hold up as well.  you can write to EEPROM if you like.  info on reading/writing EEPROM here:

keep in mind the EEPROM is only 512 bytes of storage.  not very much.

if you mean on the host side of things (ie on a real computer talking to the arduino) then there are millions of ways to write to a file.  let us know the language and we can point you in the right direction.
42  Forum 2005-2010 (read only) / Interfacing / Arduino GCode Interpreter on: February 26, 2008, 05:51:05 pm
hey all,

over at the RepRap project, we've got a gcode interpreter for the arduino up and running.  its still in the early stages, but we've implemented the major commands.  basically, it is capable of doing the vast majority of cnc operations you'd need.

more software info here:
and on the driver electronics here:

there are 2 system components that are currently missing:

* a gcode generator, although there are many generators out there that are nice.
* a host software to open a serial connection, and spit the commands out to the Arduino and/or parse the results back.  we have a rough one setup already that is made in processing, but its very hacked together and barely gets the job done.  the major problem is that processing isnt designed to make full apps... you cant create menus, buttons, file dialogs, or any of the nice things like that.

i'm thinking about taking a fork of the arduino software, ripping out the arduino guts and turning it into a gcode host for interfacing with an arduino.  good/bad idea?  similar to the processing -> arduino fork.  i love the interface and it would be really rad to have that sort of shared genealogy.
43  Forum 2005-2010 (read only) / Interfacing / Re: Engraving Software on: February 26, 2008, 05:51:21 pm
hey guys.   hoeken from RepRap here.  i was just going to post about our gcode work and i found this.  i've created a new thread here that talks about the system itself:

basically, if you're building an engraving system which uses cnc style stuff, this is an extremely nice route to go down.

44  Forum 2005-2010 (read only) / Interfacing / Re: Diecimilia Bootloader Help on: January 26, 2008, 06:08:45 pm
thanks ladyada.  unfortunately other people are going to use this and I cant tell all of them to run custom firmware.

however, i did find a decent workaround by looking through the bootloader code.  if you send a string of 10 '0' (ascii zero) characters, then it bails and boots as normal.  still takes about 2 seconds though.
45  Forum 2005-2010 (read only) / Interfacing / Diecimilia Bootloader Help on: January 25, 2008, 10:40:44 am
Hi All,

I'm working on getting the Arduino working as the main electronics platform for the RepRap project, and part of that is emulating our old electronics.  The problem I'm running into is that our software just opens the serial port and starts reading and writing from it.  Right now I get around that with a delay() in the host software, but its not practical long term.

I remember reading somewhere that you can send a command that will tell the bootloader to skip bootloading and start program execution, anyone know what it is?
Pages: 1 2 [3] 4 5 ... 8