Show Posts
Pages: 1 2 [3] 4 5
31  Development / Other Software Development / Re: Improved Stepper Library and also a StepperDriver Library on: September 04, 2011, 01:21:27 pm
Hi-

Looks good. I think further additions would include 8-step mode to the stepper.cpp, and acceleration, deceleration to the driver, if possible.

Thanks again,
David

Eight-steps:
0: 1 0 0 0
1: 1 1 0 0
2: 0 1 0 0
3: 0 1 1 0
4: 0 0 1 0
5: 0 0 1 1
6: 0 0 0 1
7: 1 0 0 1

The trick with accel/decel is predicting when to slow down so you hit the target.  One possible method is to record how long (how many steps - accelSteps) it takes to accelerate to speed, and then use that to start the decel (target minus accelSteps).  Of course this fails if you change the speed mid move.  Some math or just a loop to recalculate accelSteps would suffice. 

- D
32  Development / Other Hardware Development / Re: enclosure on: July 25, 2011, 01:39:42 pm
What about http://proto-pic.co.uk/products/Box-for-Arduino.html ?
33  Using Arduino / Networking, Protocols, and Devices / Re: ZeroConf for Arduino on: June 13, 2011, 09:30:31 am
I just Googled for 'zeroconf arduino' and came up with this link:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1262819058

Does that help?

David
34  Development / Other Software Development / Re: Common Lisp cross compiler on: March 25, 2011, 02:57:19 pm
Hey, great addition to 'duino-world! 

I know it is difficult to do the documentation while you are beavering away to actually getting it working -- BUT you need at least a little blurb on the SF site to tell What-it-is and How-it-works, and I always like a screen shot, too ;-)  The blurb should just be a short clear statement "This is Common-Lisp which compiles to the Arduino hardware platform.  It works on xxx OS, and 328, ..., including UNOs.  It mimics the Arduino IDE, and lets you upload using the usual bootloaders.  Its some good!" - or similar. 

Cheers, congrats, keep up the good work!
David
35  Development / Other Hardware Development / Re: XMEGA Xprotolab on: March 25, 2011, 02:46:56 pm
I bought two.  Sent one to my friend.  Its great!  Doesn't replace a proper oscope, but useful for experimenters, and great value for price, and an very nice example of a solid xmega application.  Someone (not me) should be able to turn it into an 'duino.  The screen is small but capable. 

David
36  Forum 2005-2010 (read only) / Syntax & Programs / Re: PWM on pins 5 + 6 on: June 30, 2008, 02:28:45 pm
Efficiency sounds good to me :-) !

I didn't try to make it more efficient initially, as I wanted the algorithm visible.  We can save some cycles by incrementing the long only once, since this will save propagating carries less often.  

David
37  Forum 2005-2010 (read only) / Syntax & Programs / Re: PWM on pins 5 + 6 on: June 30, 2008, 02:56:49 am
I was thinking about how we might make the SIG_OVERFLOW0 routine slightly more efficient.  

For 16MHz Arduinos, using the 64 prescale and 256 counts gets us close to 1 ms per overflow (actually 1024us).  However, we do not need to use an unsigned long for the calulation, *if* we reduce the respective values by their gcd.  So, instead of using 64*256=16384 and 16*100=16000, we could use 256 and 250 instead.  

This has the benefit of only requiring a BYTE accumulator, instead of a long.  

Here is the proposed code:
Code:
volatile unsigned byte timer0_period_count = 0;  // accumulator: 1 byte
volatile unsigned long timer0_millis = 0;        // millis stays at unsigned long
SIGNAL(SIG_OVERFLOW0) {
// timer 0 prescale factor is 64 and the timer overflows at 256
// 64*256=16384, at 16MHz this is 1024us, 1ms=16000 cycles, the common denominator is 128
// 64*256/128=128, and 16000/128=125, so 128/125 = 1 with a remainder of 3.
  timer0_period_count += 3;                      // This is equivalent to +128-125, so ..
  timer0_millis++;                            // .. we are garanteed 1 ms plus a bit, so count it.
  if (timer0_clock_cycles > 125) {                // But, there might be another millisecond, if so ..
    timer0_period_count -= 125;                // .. correct the count, and ..
    timer0_millis++;                             // .. count the millisecond.
 }
}

Phase Correct:
If we changed to phase correct, then we can do similar with a gcc of 40:
Code:
volatile unsigned byte timer0_period_count = 0;     // accumulator: 1 byte
volatile unsigned long timer0_millis = 0;           // millis stays at unsigned long
SIGNAL(SIG_OVERFLOW0) {
// timer 0 prescale factor is 64 and the timer overflows at 510
// 64*510=32640, at 16MHz this is 2040us, 1ms=16000 cycles, the common denominator is 40
// 64*510/40=51, and 16000/40=50, so 51/50 = 1 with a remainder of 1.
  timer0_period_count ++;                         // This is equivalent to +51-50, so ..
  if(timer0_period_count <= 50)   timer0_millis+=2; // Usually step by 2 ms, but...
  else {                                            // ... nned to correct every 50 times
     timer0_period_count = 1;                       // Will only be over by one, so correct the count ...
     timer0_millis+=4;                              // ... and increment by 4 ms
  }
}

This is fun.  If we used a 8MHz clock, then would interrupt every 4080us, with a gcc of 80, which gives 51 and 50, again.  So, the code is almost identical, except we increment millis by 4 or 8.  

8MHz Phase Correct with prescaler=8:
For 8MHz, we might opt for prescaler of 8, which would result in interruts every 510us, with a gcc of 10 and again gives 51 and 50.  The code would change to:

Code:
volatile unsigned byte timer0_period_count = 0;  // accumulator: 1 byte
volatile unsigned long timer0_millis = 0;        // millis stays at unsigned long
SIGNAL(SIG_OVERFLOW0) {
// timer 0 prescale factor is 8 and the timer overflows at 510
// 8*510=4080, at 8MHz this is 510us, the common denominator with 500 is 10
// 8*510/10=51, and 500/10=50, so 51/50 = 1 with a remainder of 1.
  timer0_period_count ++;                        // This is equivalent to +51-50, so ..
                                                 // Usually no step, but...
  if(timer0_period_count >= 100)                 // ... need to correct every 2 times
     timer0_period_count -= 100;                 // Correct the count ...
     timer0_millis++;                            // ... and increment millis
  }                                              // ... and an extra one every 50
}

Food for thought?   :o

Smarter people than I will be needed  to generalize it.   smiley-razz

David


38  Forum 2005-2010 (read only) / Syntax & Programs / Re: PWM on pins 5 + 6 on: June 23, 2008, 09:51:04 pm
I don't know why we couldn't manage with phase-correct.  I think we could handle the timing functions.  

Either, we could we not just just count by twos:  
Code:
SIGNAL(SIG_OVERFLOW0)
{
      timer0_overflow_count++;
      timer0_overflow_count++;
}
This loses dome resolution, but should work as long as comparisons are of the type ">", and not "=", this shouldn't pose a problem.  (This looks like it would require a change in the busy wait in delay microseconds, and other adjustments).  

Or, change the prescaler to 8, and adjust the interrupt routine to:
Code:
SIGNAL(SIG_OVERFLOW0)
{
      int i=0;
        if(i++&0x07==0) timer0_overflow_count++;
}
This has the disadvantage that it interrupts 8x more frequently.  

However, this would have the advantage for letting us accommodate alternate master-clock rates.  For example, I would like to use the RC oscillator, and this would just require a simple change in the code above.  

Cheers,
David

39  Forum 2005-2010 (read only) / Development / Re: ATMEGA328 mutliple serial ports on: May 26, 2010, 01:21:25 pm
Yeah, thanks -- my point was that Google is a useful tool.  

Best to start at: http://www.arduino.cc/playground/

and that leads to: http://www.arduino.cc/playground/Main/InterfacingWithHardware#Communication

And the fourth entry is NewSoftSerial at: http://arduiniana.org/libraries/newsoftserial (!)

 smiley-grin
40  Forum 2005-2010 (read only) / Development / Re: ATMEGA328 mutliple serial ports on: May 25, 2010, 06:47:36 pm
Gee, a Google search for "arduino software serial" gives as it first choice: http://www.arduino.cc/en/Tutorial/SoftwareSerial
which looks like the right place.  

David
41  Forum 2005-2010 (read only) / Development / Re: My Oscillocope on: February 12, 2010, 09:52:01 pm
If you want two decimal points then keep you VoltageValue as V*100, so 0V = 0, 0.5V = 50, 5V=500.  You will have to do a conversion between the A/D value to get the right value.  Then to display:
Code:
int whole=VoltageValue/100;
int fraction=VoltageValue-whole*100;
GLCD.PrintNumber(whole);
GLCD.PrintPutChar('.');
GLCD.PrintNumber(fraction);

David
42  Forum 2005-2010 (read only) / Development / Re: My Oscillocope on: February 12, 2010, 08:19:19 pm
Instead of your:
Code:
GLCD.PrintNumber(VoltageValue);

Perhaps:  

Code:
int whole=VoltageValue/100;
int fraction=VoltageValue-whole*100;
GLCD.PrintNumber(whole);
GLCD.PrintPutChar('.');
GLCD.PrintNumber(fraction);

David
43  Forum 2005-2010 (read only) / Development / Re: Question multiple serial streams on: July 31, 2009, 08:57:40 pm
You might want to look at http://www.piclist.com/techref/microchip/16F84-rs232-8ch-ba.htm  which is 8-serial channels at 9600 baud on a PIC16F84.  

The algorithm is very clever, and uses a vertical register technique, and you may be able to adapt it to your needs on an AVR.  

Do let us know.

David
44  Forum 2005-2010 (read only) / Development / Re: Attiny projects? on: January 20, 2011, 11:47:08 pm
Please tell us more :-)

D
45  Forum 2005-2010 (read only) / Development / Re: ATTiny85 port (work in progress) on: May 25, 2010, 06:44:49 pm
How did you find the http://www.urbanhonking.com/ideasfordozens/2009/05/an_tour_of_the_arduino_intern... , it is dead for me, and the Way-back machine says the last update on that site was in 2008 !?

Thanks, David
Pages: 1 2 [3] 4 5