Square wave calculator