Shop OBEX P1 Docs P2 Docs Learn Events
Is Javalin fast enough for 3ph AC PWM? — Parallax Forums

Is Javalin fast enough for 3ph AC PWM?

Ali E.Ali E. Posts: 23
edited 2007-02-19 22:49 in General Discussion
I have been trying to use PWM function and generate AC signal by using pwm.update(). I have to be running at least 3 PWM PVs and update them at least 12 times in one 60Hz cycle to get the desired output.
I'm just trying to come up with the Java code for the simplest and fastest method of doing that, but my gut tells me Javalin is not fast enough to handle all 3 of them at the same time.

here is what it will look like for one phase:
PWM phase1 = new PWM(some_pin);
timer tmr=new timer();
...
byte i=0;
while (true) {
       if (timer.timeout(slot-time)) {
                 lowtime = table[noparse][[/noparse]i++];
                 phase1.update(max - lowtime, lowtime);
       if (i==n_slots) i=0;
}




the phases 2 and 3 are going to be the same way, but they will be updated with a 120 degree angle apart from phase1 (possibly using a timer).

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
GAME OF FUTURE INC.

Unleas Your Imagination, See the Future

www.gameoffuture.com

Post Edited (Ali E.) : 2/14/2007 2:46:24 AM GMT

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-02-14 20:13
    Are you trying to generate 60Hz signals?
    The pwm frequency is defined by a high period and low period (both in 8.68usec units).
    Minimum period is 2*8.68usec = 17.36 usec ->fmax =·57604 Hz
    Maximum period is 2*255*8.68usec = 4426.8 usec -> fmin = 226 Hz

    regards peter
  • Ali E.Ali E. Posts: 23
    edited 2007-02-14 22:55
    We are going to be generating a Variable Frequency with 60Hz as the highest value (from about 2Hz to 60Hz Sin Wave for our induction motor). the ideal case is to get the required "increase_freq" and "decrease_freq" from PC through UART and generate the right PWM for AC, as the result we can control the speed of induction motor on the computer and later on over the internet and make some sort of GUI for it too.

    All the power circuit is taken care of (and is already built) using International Rectifier's IR2233 and a 3phase IGBT. All we need are PWM and PWM inverted signals with a little dead-time in between (I'm thinking of using an inverter and a buffer for the delay, so we don't have to generate 6 PWMs on the microcontroller).

    There is a fault detection and shutdown signal coming from IR2233 and we can arrange something for that after we got our PWM working.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    GAME OF FUTURE INC.

    Unleas Your Imagination, See the Future

    www.gameoffuture.com
  • Ali E.Ali E. Posts: 23
    edited 2007-02-14 23:10
    Peter Verkaik said...
    Are you trying to generate 60Hz signals?
    The pwm frequency is defined by a high period and low period (both in 8.68usec units).
    Minimum period is 2*8.68usec = 17.36 usec ->fmax = 57604 Hz
    Maximum period is 2*255*8.68usec = 4426.8 usec -> fmin = 226 Hz


    regards peter

    Oh I see what you mean. Let me explain a little more.

    Our PWM will be updated using PWM.update(high, low); and the high and low need to be varying by Sine function. Since we cannot process Sine on Javalin (or in fact any Microcontroller that i have ever used before) we can use a lookup table. Just to make that even more optimized we are trying to use the timer function and update pwm... eyes.gif "when the time comes". so we have decided to have constant number for High_time+Low_time and vary the duty cycle (from 50% to 100% at angles between 0 to 90 degree, from 100% to 50% between 90 and 180 and so on to get sin).

    Here is our approach:
    - we have a lookup table of times to change the duty cycle depending on the frequency in an array (for example we have an array of 60 elements from table[noparse][[/noparse]0] to table [noparse][[/noparse]60] corresponding to the delay before changing the duty cycle for each frequency from 0Hz to 60Hz.
    - the frequency we want to generate is known. so we have a while loop, we have a timer, and we update when the timer reaches the value for that frequency.
    - delay a little bit before generating the same signal for phase 2 (120 degree difference for phase) and then delay a bit more then start generating Phase 3. I think theoratically this should work if implemented.

    But looking at the sample code fragment at the top I'm thinking that Javalin will be really busy doing that. we need real-time performance or we will run into trouble with the induction motor.

    I hope that clear things up a bit... This is so hard to explain in writing...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    GAME OF FUTURE INC.

    Unleas Your Imagination, See the Future

    www.gameoffuture.com
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-02-14 23:15
  • Ali E.Ali E. Posts: 23
    edited 2007-02-15 17:13
    Thanks Peter
    I have some majour understanding issues about Javalin and Java on it... I just have trouble understanding what does what. I guess for an average guru that does not matter as long as it works, but when it comes to optimization ??? I guess an average user will not need to care.

    Is Javalin's timer() invoke an interrupt routine or something?

    I still have trouble understanding how 6 VP's can be loaded at the same time and if they require CPU time does that mean they are time sharing? Is there some sort of OS on Javalin that takes care of that? (am i thinking about it too much?)

    Is there a tool that can convert JAVA to Assembly for Javalin (not that I care to program in asm, but just to have an idea of how many clock cycles things take to run). Or is there a way that i can analyze the speed for running the code or CPU utilization or something that can help optimize the Java code?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    GAME OF FUTURE INC.

    Unleas Your Imagination, See the Future

    www.gameoffuture.com
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-02-15 17:37
    All VP's have native code that executes inside the interrupt service routine (ISR).
    This ISR is executed·once every·8.68usec. For the Timer VP, a 32bit counter is
    simply incremented.
    VP's native code do require time. The maximum time spend inside the ISR is 217 cycles
    out of 256 cycles. (25MHz*8.68usec = 217, Crystal frequency is 25MHz).
    The more VP's you execute simultaneously, the more time is spent inside the ISR,
    with a maximum of 217 cycles (each cycle is 40 nanoseconds).

    When you use t.mark() the current value of the 32bit timer count is stored privately
    for the object t.·When you use t.timeout(msvalue) the method timeout() calculates
    the stop count based on the stored count and the msvalue. It returns true if
    the·current count is beyond the stop count.·This calculation is done everytime
    you use t.timeout(), which is frequently.
    Consider my ScaledTimerTimer16 class. It·has a mark(msvalue) method. This also stores
    the current count but also calculates the stop count. The timeout() method now
    just compares the current count against the calculated stop count which saves
    quite a bit of time considered mark() is called less frequently than timeout().

    There is no tool to run your own native code.

    regards peter
  • Ali E.Ali E. Posts: 23
    edited 2007-02-16 21:27
    Thanks Peter, that helps a lot.
    Where can I find ScaledTimerTimer16 class?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    GAME OF FUTURE INC.

    Unleas Your Imagination, See the Future

    www.gameoffuture.com
  • Ali E.Ali E. Posts: 23
    edited 2007-02-17 21:31
    Ok... so I have some code and it seems like it works (at least i get some regular noise on the oscil. tongue.gif )

    However I have to implement the phases 2 and 3 as well and use a timer to have them started 120 degree apart from each other. On the other hand the way it is implemented now i will need two more timers for phases 2 and 3 as well. That leaves me with no more resources and VP's left. Is there a better way of doing it instead of the way it is done here?

    import stamp.math.*;
    import stamp.core.*;
    
    public class PWMcontrol {
      static int[noparse][[/noparse]] TimeDelay = {24543, 1098, 6136, 3927, 2727, 2003, 1534, 1212,
                               982, 811, 682, 581, 501, 436, 383, 340, 303, 272, 245,
                               223, 203, 186, 170, 157, 145, 135, 125, 117, 109, 102,
                               96, 90, 85, 80, 76, 72, 68, 65, 61, 58, 56, 53, 51, 48,
                               46, 44, 43, 41, 39, 38, 36, 35, 34, 32, 31, 30, 29, 28,
                               27}; //these are the time delays before PWM needs to be updated for
                                    // frequencies from 2Hz [noparse][[/noparse]0] to 60Hz [noparse][[/noparse]58]
      static byte[noparse][[/noparse]] HighTime = {13, 17, 21, 24, 25};
      static PWM phase1 = new PWM(CPU.pin1);
      static PWM phase2 = new PWM(CPU.pin2);
      static PWM phase3 = new PWM(CPU.pin3);
      static ScaledTimer16 time = new ScaledTimer16(24543, 1);
    
      public static void main() {
        //int i=0;
        byte f = 20; //this is the input frequency in Hz(just for now)
    
        phase1.update(13, 13);
        phase2.update(13, 13);
        phase3.update(13, 13);
        phase1.start();
        time.mark(TimeDelay[noparse][[/noparse]f-2]);
        // From 0 t0 90 degree angle (from 0 to 4)
        while (true) {
        for (int i=0; i<5; i++) {
          if (time.timeout()) {
               phase1.update(HighTime[i], 26-HighTime[i]);
               time.mark();
          }
        }
         //From 90 to 180 degree (from 4 to zero)
        for (int i=4; i>=0; i--) {
          if (time.timeout()) {
               phase1.update(HighTime[i], 26-HighTime[i]);
               time.mark();
          }
        }
        // From 180 t0 270 degree angle (from 0 to 4)
        for (int i=0; i<5; i++) {
               if (time.timeout()) {
                phase1.update(26-HighTime[i], HighTime[i]);
                time.mark();
               }
        }
        // From 270 t0 360 degree angle (from 4 to 0)
        for (int i=4; i >=0; i--) {
          if (time.timeout()) {
               phase1.update(26-HighTime[i], HighTime[i]);
              time.mark();
          }
        }
        } //while
      } //main
    }
    [/i][/i][/i][/i][/i][/i][/i][/i]
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    GAME OF FUTURE INC.

    Unleas Your Imagination, See the Future

    www.gameoffuture.com

    Post Edited (Ali E.) : 2/17/2007 9:36:11 PM GMT
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-02-17 21:42
    All timer objects occupy the same·vp slot, no matter how many timers you have.
    So you can have timers plus 5 other type of vp running.

    Edit: don't you mean hightime[noparse][[/noparse]i] in your code, as hightime is an array?
    Also better to define hightime as an array of int, to prevent possible
    sign extensions to int during calculations.

    regards peter


    Post Edited (Peter Verkaik) : 2/17/2007 9:52:39 PM GMT
  • Ali E.Ali E. Posts: 23
    edited 2007-02-17 22:51
    now.... We got it to work... but really slow and then it freezes!!!

    import stamp.math.*;
    import stamp.core.*;
    
    public class PWMcontrolv2 {
      static int[noparse][[/noparse]] TimeDelay = {2500, 1667, 1250, 1000, 833, 714, 625, 556, 500, 455,
                                417, 385, 357, 333, 313, 294, 278, 263, 250, 238, 227,
                                217, 208, 200, 192, 185, 179, 172, 167, 161, 156, 152,
                                147, 143, 139, 135, 132, 128, 125, 122, 119, 116, 114,
                                111, 109, 106, 104, 102, 100, 98, 96, 94, 93, 91, 89,
                                88, 86, 85, 83};
      static int[noparse][[/noparse]] StartTime = {1667, 1111, 833, 667, 556, 476, 417, 370, 333, 303,
                                278, 256, 238, 222, 208, 196, 185, 175, 167, 159, 152,
                                145, 139, 133, 128, 123, 119, 115, 111, 108, 104, 101,
                                98, 95, 93, 90, 88, 85, 83, 81, 79, 78, 76, 74, 72, 71,
                                69, 68, 67, 65, 64, 63, 62, 61, 60, 58, 57, 56, 56};
      static byte[noparse][[/noparse]] HighTime = {13, 17, 21, 24, 25, 25, 24, 21, 17, 13, 13, 9, 5, 2, 1,
                                1, 2, 5, 9, 13};
      static PWM phase1 = new PWM(CPU.pin1);
      static PWM phase2 = new PWM(CPU.pin2);
      static PWM phase3 = new PWM(CPU.pin3);
      static ScaledTimer16 time1 = new ScaledTimer16(2500, 1);
      static ScaledTimer16 time2 = new ScaledTimer16(2500, 1);
      static ScaledTimer16 time3 = new ScaledTimer16(2500, 1);
      static ScaledTimer16 StartTimer = new ScaledTimer16(24543, 10);
    
      public static void main() {
        int i1=0;
        int i2 = 0;
        int i3 = 0;
        byte f = 20;
        boolean ph2start = false;
        boolean ph3start = false;
    
        phase1.update(13, 13);
        phase2.update(13, 13);
        phase3.update(13, 13);
        phase1.start();
        time1.mark(TimeDelay[noparse][[/noparse]f-2]);
        StartTimer.mark(StartTime[noparse][[/noparse]f-2]);
        time3.mark(TimeDelay[noparse][[/noparse]f-2]);
    
        while (true) {
          //phase 1
          if (time1.timeout()) {
               phase1.update(HighTime[noparse][[/noparse]i1], 26-HighTime[noparse][[/noparse]i1]);
               time1.mark();
               i1++;
          }
          if (i1 == 19) i1=0;
          //phase 2
          if (StartTimer.timeout()) {
                phase2.start();
                time2.mark(TimeDelay[noparse][[/noparse]f-2]);
                ph2start = true;
                StartTimer.mark();
          }
          if (time2.timeout() && ph2start ) {
               phase2.update(HighTime[noparse][[/noparse]i2], 26-HighTime[noparse][[/noparse]i2]);
               time2.mark();
               i2++;
          }
          if (i2 == 19) i2=0;
          //phase 3
           if (StartTimer.timeout() && ph2start) {
                phase3.start();
                time3.mark(TimeDelay[noparse][[/noparse]f-2]);
                ph3start = true;
          }
          if (time3.timeout()&& ph3start) {
               phase3.update(HighTime[noparse][[/noparse]i3], 26-HighTime[noparse][[/noparse]i3]);
               time3.mark();
               i3++;
          }
          if (i3 == 19) i3=0;
    
        } //while
      } //main
    }
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    GAME OF FUTURE INC.

    Unleas Your Imagination, See the Future

    www.gameoffuture.com
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-02-17 23:52
    There are some obvious optimizations possible.

    for example
    ······if·(time1.timeout())·{
    ···········phase1.update(HighTime[noparse][[/noparse]i1],·26-HighTime[noparse][[/noparse]i1]);
    ···········time1.mark();
    ···········i1++;
    ······}
    ······if·(i1·==·19)·i1=0;
    can be replaced by
    ······if·(time1.timeout())·{
    ···········phase1.update(HighTime[noparse][[/noparse]i1],·26-HighTime[noparse][[/noparse]i1]);
    ···········time1.mark();
    ···········i1++;
    ·········· if·(i1·==·19)·i1=0;
    ······}
    or
    ······if·(time1.timeout())·{
    ···········phase1.update(HighTime[noparse][[/noparse]i1%=19],·26-HighTime[noparse][[/noparse]i1]);
    ···········time1.mark();
    ···········i1++;
    ······}
    so you don't need to test for i out of range each loop, but only when i increments.


    regards peter


    Post Edited (Peter Verkaik) : 2/17/2007 11:58:09 PM GMT
  • Ali E.Ali E. Posts: 23
    edited 2007-02-18 04:04
    wow Peter... I didn't think of that!! you're a genius!!!
    I'll be back to the lab tomorrow morning and give it a shot right away. However I've got to see why Javalin goes non-responsive after about 30sec or so. Is it because it heats up? I dared to touch the chip to see if it was hot... it did feel worm, but not particularly hot. Is there a possible memory leak or something in my program with all the variables being tossed around?
    That is aside from the fact that I did get the perfect 3phase output... It was absolutely clean and noise free signal. It was so beautiful on the digital oscilloscope that almost brought tears to my eyes!!! lol.gif even thou it was running at around 2Hz instead of 20Hz I could feel it. I had never had a microcontroller working so predictably and with no pain!!! The last Motorola 68HC11 garbage i worked with gave me so much grief!!! I love this thing roll.gif
    I wish Javalin was about 200Mhz faster and had more ram tho (maybe I'll give the new Propeller things a shot, even thou that is going to be a majour overkill and waste of money and time for this project). Is there going to be a Java Interpreter for Propeller? sometime in the future maybe? or in someone's head at least? turn.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    GAME OF FUTURE INC.

    Unleas Your Imagination, See the Future

    www.gameoffuture.com
  • Ali E.Ali E. Posts: 23
    edited 2007-02-18 18:27
    import stamp.math.*;
    import stamp.core.*;
    
    public class PWMcontrolv2 {
      static int[noparse][[/noparse]] TimeDelay = {2500, 1667, 1250, 1000, 833, 714, 625, 556, 500, 455,
                                417, 385, 357, 333, 313, 294, 278, 263, 250, 238, 227,
                                217, 208, 200, 192, 185, 179, 172, 167, 161, 156, 152,
                                147, 143, 139, 135, 132, 128, 125, 122, 119, 116, 114,
                                111, 109, 106, 104, 102, 100, 98, 96, 94, 93, 91, 89,
                                88, 86, 85, 83};
      static int[noparse][[/noparse]] StartTime = {1667, 1111, 833, 667, 556, 476, 417, 370, 333, 303,
                                278, 256, 238, 222, 208, 196, 185, 175, 167, 159, 152,
                                145, 139, 133, 128, 123, 119, 115, 111, 108, 104, 101,
                                98, 95, 93, 90, 88, 85, 83, 81, 79, 78, 76, 74, 72, 71,
                                69, 68, 67, 65, 64, 63, 62, 61, 60, 58, 57, 56, 56};
      static byte[noparse][[/noparse]] HighTime = {13, 17, 21, 24, 25, 25, 24, 21, 17, 13, 13, 9, 5, 2, 1,
                                1, 2, 5, 9, 13};
      static PWM phase1 = new PWM(CPU.pin1);
      static PWM phase2 = new PWM(CPU.pin2);
      static PWM phase3 = new PWM(CPU.pin3);
      static ScaledTimer16 time1 = new ScaledTimer16(2500, 1);
      static ScaledTimer16 time2 = new ScaledTimer16(2500, 1);
      static ScaledTimer16 time3 = new ScaledTimer16(2500, 1);
      static ScaledTimer16 StartTimer = new ScaledTimer16(1667, 10);
    
      public static void main() {
        int i1=0;
        int i2 = 0;
        int i3 = 0;
        byte f = 6;
        boolean ph2start = false;
        boolean ph3start = false;
    
        phase1.update(13, 13);
        phase2.update(13, 13);
        phase3.update(13, 13);
        phase1.start();
        time1.mark(TimeDelay[noparse][[/noparse]f-2]);
        StartTimer.mark(StartTime[noparse][[/noparse]f-2]);
        time3.mark(TimeDelay[noparse][[/noparse]f-2]);
    
        while (true) {
          //phase 1
          if (time1.timeout()) {
               phase1.update(HighTime[noparse][[/noparse]i1], 26-HighTime[noparse][[/noparse]i1]);
               time1.mark();
               i1++;
               if (i1 == 19) i1=0;
          }
    
          //phase 2
          if (StartTimer.timeout()) {
                phase2.start();
                time2.mark(TimeDelay[noparse][[/noparse]f-2]);
                ph2start = true;
                StartTimer.mark();
          }
          if (time2.timeout() && ph2start ) {
               phase2.update(HighTime[noparse][[/noparse]i2], 26-HighTime[noparse][[/noparse]i2]);
               time2.mark();
               i2++;
               if (i2 == 19) i2=0;
          }
    
          //phase 3
           if (StartTimer.timeout() && ph2start) {
                phase3.start();
                time3.mark(TimeDelay[noparse][[/noparse]f-2]);
                ph3start = true;
          }
          if (time3.timeout()&& ph3start) {
               phase3.update(HighTime[noparse][[/noparse]i3], 26-HighTime[noparse][[/noparse]i3]);
               time3.mark();
               i3++;
               if (i3 == 19) i3=0;
          }
    
    
        } //while
      } //main
    }
    
    



    ok... now Javalin is running, but with lots of glitches. It actually stops working after a while. There seem to be no pattern to it. Sometimes it runs for 2 to 3 min, sometimes it craps out after 10 to 15 sec.

    Another issue is that the output frequency is not even up to speed. In fact Pase 1 and Pase 3 (pins 1 and 3) are faster than phase 2 (pin 2). I don't seem to get what is going on. Is there really no hope of having this done on Javalin?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    GAME OF FUTURE INC.

    Unleas Your Imagination, See the Future

    www.gameoffuture.com
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-02-18 22:49
    The problem is that you want to update a pwm the moment a timer expires.
    You don't know when a timer has expired until you call timeout(), so basically
    you are always too late with updating. You could be busy updating the pwm for phase1
    when the timer for phase3 expires, but you won't know that until you reach
    the code for phase3.

    The following approach may be more useful.

    static int[noparse]/noparse sine = new int[noparse][[/noparse]360]; //table with sinevalues for whole degrees
    //128 equals sin(0), 128+120 equals sin(90), 128 equals sin(180), 128-120 equals sin(270)
    //the table holds a sine with dc offset 128 and amplitude 120

    static·DAC phase1·=·new·DAC(CPU.pin1);
    static·DAC·phase2·=·new·DAC(CPU.pin2);
    static·DAC phase3·=·new·DAC(CPU.pin3);
    static int angle=0;
    static int p1=0; //phase1 start angle
    static int p2 = 120; //phase2 start angle
    static int p3 = 240; //phase3 start angle
    static void main() {
    · while (true) {
    ·· ·phase1.update(sine[noparse][[/noparse](angle+p1)%360]);
    ··· phase2.update(sine[noparse][[/noparse](angle+p2)%360]);
    ··· phase3.update(sine[noparse][[/noparse](angle+p3)%360]);
    ····angle = (angle+1)%360;
    ··· CPU.delay(160); //delay determines time to advance 1 degree, ie. sine frequency
    · }
    }

    The above has the advantage that the while (true) loop has a constant loop time
    which ensures the DACs are updated at regular time intervals.
    Check the waveforms at pins 1 to 3 on a scope and find out the appropiate delay values
    for the frequencies you desire. If you assume the updates take no time, then you
    can calculate the delay from the desired frequency.
    F = 1/(360*Tdelay) or Tdelay = 1/(360*F)
    Ndelay = Tdelay/8.68usec = 1000000/(8.68*360*F) with F in Herz
    use CPU.delay(Ndelay) in the code above


    regards peter
  • Ali E.Ali E. Posts: 23
    edited 2007-02-19 22:20
    hi Peter

    thanks a lot for the reply. The program actually works but the output signal is not PWM (Pulse Width Modulation) but it is Frequency Modulation. PWM has constant period but duty cycle changes. FM has variable period. I can generate the perfect Sine wave using DAC circuit thou. This program works very accurately if you need a low voltage, slow, and low power 3-phase sine output.

    But that sine wave is till neither fast nor powerful enough to run an induction motor. The fastest sine frequency output i got (without the delay line) was about 0.5Hz.

    This means that Javalin needs to be more than 100 times faster to get 50Hz output to make that somewhat useful in Europe and Asia? It needs to be even faster to make that run 60Hz at no delay.

    Javalin seems to run for at least 30min without crapping out!!! that is some good news for me since i was worried there might have been some hardware problems with the Javalin that caused it to freeze and the output stopped after some random period of time. I think out program is just too much for Javalin to process.

    I need another microcontroller fast!!! jumpin.gif any ideas?

    Any good Java programmers here that could tell me if it was possible to generate that kind out output from parallel port on a PC? (That is the fastest microcontroller that i have right now, that I may turn into using). Oh man... my partners won't like this!!! I'm dead!!! smhair.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    GAME OF FUTURE INC.

    Unleas Your Imagination, See the Future

    www.gameoffuture.com
  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2007-02-19 22:49
    You can increase the frequency easily by using less sine values.
    I used 360 entries, but even 20 or 10 would do. Each loop then advances 18 degrees
    instead of 1.
    You could replace the DAC by PWM. The point I tried to make is that you
    need a constant loop time. So instead of your table with time delays when to do
    a next update, use a table with dutycycle change for a fixed time to update (eg. the looptime).
    That way you don't neeed all the timers and don't need to check for conditions.

    regards peter

    Post Edited (Peter Verkaik) : 2/19/2007 10:54:00 PM GMT
Sign In or Register to comment.