Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: jonolilley on December 08, 2010, 07:45:07 AM

Title: Need help to generate a sine wave
Post by: jonolilley on December 08, 2010, 07:45:07 AM
I am running mach 3 to control two stepper motors in the x and y planes. I have calibrated and am now trying to input a sine wave on one axis at a time.

I am not sure how to do this, would a while loop within a subroutine be the best way....?, i am having difficulty with the syntax and not really getting anywhere.

Ideally i want a loop that has variables defined so i can alter the frequency and amplitude of the wave input.

So how can i input for example

Maximum wave amplitude x sin(wave frequency x t)

so i can change these parameters and loop them.

I am a complete noob, and using mach for a university project.

Thanks in advance
 
Jono
Title: Re: Need help to generate a sine wave
Post by: Graham Waterworth on December 08, 2010, 07:56:58 AM
The best way is to write it as VB macro and save it as an M code so you can call it from g-code.

Search the forum there are many examples of creating macros.

Graham
Title: Re: Need help to generate a sine wave
Post by: jonolilley on December 08, 2010, 08:01:09 AM
Thanks for your speedy response!!

I will give that a go.

Jono