Grasshopper

algorithmic modeling for Rhino

Hi.

So my definition in grasshopper is working fine with the arduino connected. Only problem i have now is exporting the code, so the arduino can stand alone without a computer attached to it. The arduino code generator works fine, but when exporting, it doesn't seem to work? Could some one please tell me what is FFcasts.h, and if that could be effecting my code? Or if there is anything wrong in general with the export.

{0}

0. /*
Firefly Code Generator by Andy Payne
Copyright 2011 All Rights Reserved
Code Generated on 03/04/2013 20:46:37
Special thanks to Panagiotis Michalatos.
For more information visit: www.fireflyexperiments.com
*/

#include "FFCasts.h"
#include <Servo.h>

//******************* Begin Function Definitions *******************

//Remap Number Function: Remap a value into a new numeric domain.
double Remap_Numbers(double x, Interval _in, Interval _out) {
return (x - _in.t0) * (_out.t1 - _out.t0) / (_in.t1 - _in.t0) + _out.t0;
}

//Constrain Function: Constrains a number to a specific numeric range.
double Constrain(double _v1, Interval _in){
double _min, _max, result;
if (_in.t0 < _in.t1){
_min = _in.t0;
_max = _in.t1;
}else{
_min = _in.t1;
_max = _in.t0;
}
if (_v1 < _min){
result = _min;
}else if (_v1 > _max){
result = _max;
}else{
result = _v1;
}return result;
}

double Smoothing_pval_0 = 0;

//Smoothing Function: Returns a smoothed value that is the sum of the weighted average of the previous observations and the current value.
double Smoothing_Temporal(double _v1, double _sf, double *_pval){
*_pval *= _sf;
return *_pval += _v1 *(double)(1.0 - _sf);
}

//******************** End Function Definitions ********************

Servo servo9;

void setup() {
servo9.attach(9);
}

void loop() {
int APin0 = analogRead(0);
servo9.write(Smoothing_Temporal(Remap_Numbers(Constrain(APin0,Interval(10,130)),Interval(10,130),Interval(0,180)),5.0, &Smoothing_pval_0));
}

Views: 636

Replies to This Discussion

Hi Mark,

What is the file path that you're using to save this file?  The Arduino naming system specifies that the name of the .ino file has to be in a folder with the same name.  So for example, C:\Users\Andy\Documents\Arduino\CodeGen\CodeGen.ino would be a suitable file path.  I don't think it has anything to do with the FFcasts.h file.  I copied your code into a new document and saved it to my sketchbook folder.  I then copied the FFcast.h (it should pretty much always be the same... it's just a utility class that Firefly exports to handle casting different data types that GH has but Arduino doesn't by default)...into the same folder I just saved the file and then re-opened your sketch.  I compiled it and everything worked just fine.  So, my guess is that you're having an issue with the naming convention.

-Andy

Where to find FFcast.h?

I was able to solve this problem in what I am guessing is a rather round about way. First, creating a folder with proper naming convention eg: C:\Users\Andy\Documents\Arduino\CodeGen\CodeGen.ino , at this point the code will not upload to the board as it does not find FFCasts.h. Once the proper folder is there, it can be referenced as a path for the code generator component, right click on the component and open in firefly code editor, save this file over the previously created file in the libraries, FFCasts.h now loads, needs additional Serial.begin line in .ino

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service