Superm7
Newbie level 3
Hello,
I am trying to draw a wave form using turbo c .. I am reading the input using an ADC card and plotting the input from -10 to +10 .. the code work fine, but if the input increases or try to change my constant .. the line will draw out of the screen of this wave form on the vertical axis?
I don't know if anyone understand what I just wrote!! :shock:
but this is the code that I wrote:
#include <stdio.h>
#include <stdlib.h>
#include <graphics.h>
#define DAQ1 0x0000 //Channel 1 from ADC card
int graphdriver = DETECT,
graphmode,
linein,dev,xaxis,yaxis,key,time;
unsigned int data,data1,data2;
float Constant = 546.133, zeroline=190;
void Display (void)
{
cleardevice();
for(dev=50;dev<530;dev=dev+6)
{
setcolor( 8 ) ;
line(dev,10,dev,250);
}
for(dev=10;dev<255;dev=dev+6)
{
setcolor( 8 ) ;
line(50,dev,530,dev);
}
setcolor(GREEN);
for(yaxis=10; yaxis<260; yaxis=yaxis+30)
{
line(50,yaxis,530,yaxis);
}
for(xaxis=50; xaxis<550; xaxis=xaxis+30)
{
line(xaxis,10,xaxis,250);
}
}
void waveform (void)
{
float SaveData;
outport(DAQ1);
delay(1);
data=inport(DAQ1);
SaveData =data/Constant;
data2=zeroline- SaveData;
setcolor(YELLOW);
for(linein=50; linein<541; linein++)
{
outport(DAQ1);
delay(1);
data=inport(DAQ1);
SaveData =data/Constant;
data2=zeroline- SaveData;
line(linein,data1,linein,data2);
data1=data2;
}
}
void main (void)
{
initgraph(&graphdriver,&graphmode,"c:");
for(;
{
Display ();
waveform ();
}
}
can't figure out how to limit the vertical axes on the line!
I am trying to draw a wave form using turbo c .. I am reading the input using an ADC card and plotting the input from -10 to +10 .. the code work fine, but if the input increases or try to change my constant .. the line will draw out of the screen of this wave form on the vertical axis?
I don't know if anyone understand what I just wrote!! :shock:
but this is the code that I wrote:
#include <stdio.h>
#include <stdlib.h>
#include <graphics.h>
#define DAQ1 0x0000 //Channel 1 from ADC card
int graphdriver = DETECT,
graphmode,
linein,dev,xaxis,yaxis,key,time;
unsigned int data,data1,data2;
float Constant = 546.133, zeroline=190;
void Display (void)
{
cleardevice();
for(dev=50;dev<530;dev=dev+6)
{
setcolor( 8 ) ;
line(dev,10,dev,250);
}
for(dev=10;dev<255;dev=dev+6)
{
setcolor( 8 ) ;
line(50,dev,530,dev);
}
setcolor(GREEN);
for(yaxis=10; yaxis<260; yaxis=yaxis+30)
{
line(50,yaxis,530,yaxis);
}
for(xaxis=50; xaxis<550; xaxis=xaxis+30)
{
line(xaxis,10,xaxis,250);
}
}
void waveform (void)
{
float SaveData;
outport(DAQ1);
delay(1);
data=inport(DAQ1);
SaveData =data/Constant;
data2=zeroline- SaveData;
setcolor(YELLOW);
for(linein=50; linein<541; linein++)
{
outport(DAQ1);
delay(1);
data=inport(DAQ1);
SaveData =data/Constant;
data2=zeroline- SaveData;
line(linein,data1,linein,data2);
data1=data2;
}
}
void main (void)
{
initgraph(&graphdriver,&graphmode,"c:");
for(;
{
Display ();
waveform ();
}
}
can't figure out how to limit the vertical axes on the line!