Curve to Code tool

Hi all,
Not sure which section to post this, but I have made a small program in HTML5 which allows you to draw/edit a curve on screen and export it to a lookup table in arduino code.
I thought I'd share it eventhough it's a bit quick n dirty so bear with me...
I made this to make a calibration table for a thermistor and it should probably be useful for some other things too.

http://www.neverlab.com/codecurve/
Here's a screenshot to see how it will look like if you have a compatible browser, I've tested on Firefox, Chrome, Safari, there should be one of those on your system to let you use this :*

By default it creates an array which is 512 entries long. So you could use this for e.g. an analogRead() lookup table range.

You can change the curve by moving the control points and check the value by dragging the vertical greyed bar.
Also, on top of the screen you can change the Y value-range or the curve-step to adapt the curve in a different span/range. There's no real check on the values you put in so if you use it I hope you know what you're doing :smiley:

oh, and before I forget; By clicking on 'export' a pop-in will show with the generated array. Select table code will allow you to copy-paste it to your code.

Hope you find it useful!

It seems to work in Opera 12.16 also.

Is it a table of X Y data pairs?

I've been looking for something like this. Are you prepared to share the code that produces the table? I would like to be able to use it to get a table of data from an OpenOffice drawing, for example.

...R

Yes, sure, it's 'plain' html, no external imagery or anything, just save the html and you're done. I initially made it for home use so it's a bit sloppy here and there. :cold_sweat:

I can't seem to change Y values? Using Chrome.

Nice tool!

Would be nice if it could spit out two arrays for multiMap - Arduino Playground - MultiMap -

The only restriction is that the X array should be increasing, it does not even need to be equidistant :).

Multimap interpolates between values making the arrays (RAM Usage) much smaller

Thanks. I've saved a copy, but won't get a chance to study it for a while as I'm busy with another project.

...R

That's nice, I have no immediate application for it but can see it will be useful.


Rob

There are some remnants of a bezier curve in the code which you could use to generate a different kind of curve, I've used the kineticjs javascript library to generate them. In order to scan the points generated by the curve I copy the curve's canvas to a buffer and scan the transparency (any type of image would work in that buffer by the way) For me it was the simplest way to calculate the points but on some browsers it does not read the imagebuffer.

If I took the trouble to read the code I have downloaded I would probably get the answer to the following question - but as I said I'm doing another project now and if I deviate from it I will miss my deadline.

It sounds like the buffer is somewhat equivalent to a bmp file so maybe I could write a piece of code (or adapt yours) to extract the line coordinates from a bmp file of any line image. It seems obvious, but I hadn't thought of that.

I'm thinking of a way to generate G-Code coordinates for a future CNC lathe.

...R

yes, true, my idea was to make a file upload script so you could just upload your own graph and use it as bmpdata to trace, would not be too difficult.
For something which steers a lathe you might consider something else to calculate the points. This tool is not made for high-precision stuff, it generates some INT's so it's not too accurate.

Thanks for the warning. I will bear it in mind when I get round to examining your code. My general idea is to use a large enough .bmp to get sufficient resolution.

...R

generates some INT's so it's not too accurate.

Make them longs and have an array size of say 1,000,000 bytes :slight_smile:


Rob

I am using Google Sketchup and my own Ruby script - example at Myford ML7 lathe using Arduino Due powered DIY CNC and Google Sketchup with Ruby - YouTube

There are thousands of free Ruby scripts for doing things like generating Bezier curves. My script could easily be changed to spit out gcode instead of my own program coordinates