Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Drawing waveform using turbo c not prefect!!

Status
Not open for further replies.

Superm7

Newbie level 3
Joined
May 2, 2011
Messages
4
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
1,325
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!
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top