Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Migrating project from Arduino to Netduino 2 Plus


  • Please log in to reply
2 replies to this topic

#1 cgozzard

cgozzard

    New Member

  • Members
  • Pip
  • 1 posts

Posted 07 August 2013 - 07:18 PM

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

@cgozzard

 

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); }



#2 Spoon

Spoon

    Member

  • Members
  • PipPip
  • 14 posts
  • LocationFort Collins, CO

Posted 14 August 2013 - 09:44 PM

Hello cgozzard,

 

I guess I am not clear on what you are asking.  Are you asking for someone to convert the code for you or is there a specific question about a line or some functionality that you have?

 

The code in your loop looks pretty simple.  I don't understand what's going on in the setup code though.  Unfortunately I don't know VB but would be glad to help if you wanted to do it in C#.  



#3 nakchak

nakchak

    Advanced Member

  • Members
  • PipPipPip
  • 404 posts
  • LocationBristol, UK

Posted 15 August 2013 - 08:29 AM

The setup loop looks like it is configuring registers.

All of that would be taken care of by the pwm classes in netmf i would have thought.

 

Nak.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.