Hi all. I have been using Arduino for a long but have hit a bit of a brick wall in terms of processing power and the fact that it is 8-bit. I have recently bought a netduino 2 plus as I was hoping to move a project from my arduino to the netduino but I am very lost in the code. My project was to simulate a chau-chaos circuit and display the output on an oscilloscope in X-Y mode (using PWM on the arduino with smoothing capacitors) see https://www.youtube....h?v=YpCZdjDHc_M. I would be very grateful to all concerned for some guidance.
Chris
Arduino code below
/* Chaos Theory on your Scope! Displays the lorenz attractor on your Oscilloscope. Author: Chris Gozzard (cgozzard@yahoo.com) Created: 25-5-13 License: This code CC-BY-SA 3.0 and is unsupported. (see creativecommons.org/licenses for info)
the following circuit is on both PWM ports (5 and 6)
R PWM OUT ----///-----+------------ OUTPUT | === C | GND
R = 10k C = 0.1uF
Many thanks to John M. De Cristofaro for the original idea (based on his Oscilloscope Christmas Tree circuit) */ float x_pos; float y_pos; int x_out = 5; int y_out = 6; float x = 0.7; float y = 0; float z = 0;
float alpha = 15.6; int beta = 28; float m0 = -1.143; float m1 = -0.714; float xdot; float ydot; float zdot; float h; float dt = 0.01;
void setup() {
pinMode(x_out, OUTPUT); pinMode(y_out, OUTPUT); // this next section changes the PWM frequency - don't mess with it! TCCR0A = ( 1<<COM0A1 | 0<<COM0A0 | // clear OC0A on compare match (hi-lo PWM) 1<<COM0B1 | 0<<COM0B0 | // clear OC0B on compare match (hi-lo PWM) 1<<WGM01 | 1<<WGM00); // set PWM lines at 0xFF
TCCR0B = ( 0<<FOC0A | 0<<FOC0B | // no force compare match 0<<WGM02 | // set PWM lines at 0xFF 0<<CS02 | 0<<CS01 | // use system clock (no divider) 1<<CS00 );
TIMSK0 = ( 0<<OCIE0B | 0<<TOIE0 | 0<<OCIE0A ); }
void loop() {
xdot = alpha*(y-x-h); ydot = x - y + z; zdot = (-beta)*y; h = (m1*x)+(0.5*(m0-m1))*(abs(x+1)-abs(x-1)); x = x + (xdot*dt); y = y + (ydot*dt); z = z + (zdot*dt);
x_pos = 128+(50 * x); y_pos = 128+(50 * y);
analogWrite(x_out, x_pos); analogWrite(y_out, y_pos); }