Combining Excel and Arduino

Hi all,

I'm working on a project where a stepper motor will be used to drive a piston pump. The stepper motor transfers rotary motion to the crack, which is joined to a connection rod and then onto a piston in a cylinder. The volume of air output by the pump is dependent on the angle of rotation of the stepper. I have a working code however I am using excel to calculate this angle. I input the desired volume of air and the desired number of cycles per minute and the spreadsheet outputs the stepper angle input and the delay between steps to achieve this number of cycles per minute.

the spreadsheet uses the volume to find the stroke used then calculates the angle using this length, the length of the conrod and the length of the crank so nothing too complicated.

Is there any way to simply incorporate this into the code so I can input the end volume as opposed to the angle needed to achieve this volume. I'm still very new to coding and Arduino so apologies if this is ridiculous!!

Thanks,
Shane

A few basics:

Please avoid posting code as images. Instead, post code using code tags, which you can get by clicking the </> symbol.

You are declaring pos as an int (integer), but then you are trying to set it to 83.6, which is not an integer. Presumably, the compiler is truncating the 83.6 to 83, or something of that sort.
See:

delay() requires an integer as its argument. So delay(20) will work, as will delay(21). My guess is that delay(20.7) will be treated by the compiler as delay(20).

The answer to your question is probably yes. If you have the necessary mathematical formulas in an Excel spreadsheet, then you can very probably put those same mathematical formulas into an Arduino sketch to have the Arduino perform the calculations. But, in order for us to be able to help you, we will need to be able to see those formulas! That is, in order to help you "incorporate this into the code", we need more information on what exactly the "this" is and how it works.

Hi Odometer

Thanks for the quick and detailed reply!
Yes your point about defining position makes sense, don't know how I didn't spot it. Good news is that a fraction of a degree or millisecond won't have any negative impact on the output and initial trials looked good, but I do understand it's bad practice.
Apologies for not posting the spread sheet. It only contains a handful of equations, the majority of which are basic arithmetic. other than that it contains one trig function - the inverse cosine function.

That should be enough to get me started anyways, Thanks again!

Just remember that the C++ acos() (Arc Cosine) function returns an angle in radians and not degrees.

Thanks John. So does Excel, learned that the hard way!!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.