Click here to Skip to main content
15,887,214 members
Home / Discussions / C#
   

C#

 
AnswerRe: Codeplex D3 chart Pin
Bernhard Hiller16-Sep-14 21:24
Bernhard Hiller16-Sep-14 21:24 
AnswerRe: Codeplex D3 chart Pin
Pete O'Hanlon16-Sep-14 22:20
mvePete O'Hanlon16-Sep-14 22:20 
Questionwhy my graph error??? Pin
rikiz16-Sep-14 19:30
rikiz16-Sep-14 19:30 
AnswerRe: why my graph error??? Pin
Pete O'Hanlon16-Sep-14 19:56
mvePete O'Hanlon16-Sep-14 19:56 
GeneralRe: why my graph error??? Pin
rikiz18-Sep-14 18:42
rikiz18-Sep-14 18:42 
GeneralRe: why my graph error??? Pin
Pete O'Hanlon18-Sep-14 19:37
mvePete O'Hanlon18-Sep-14 19:37 
GeneralRe: why my graph error??? Pin
rikiz1-Oct-14 9:02
rikiz1-Oct-14 9:02 
GeneralRe: why my graph error??? Pin
rikiz3-Oct-14 17:57
rikiz3-Oct-14 17:57 
I tried to connect the data adc atmega 16 microcontroller application to C # that has been created with the help of the code that you help ..
private void timer1_Tick (object sender, EventArgs e)
         {
             double coordinate;
             b ++;
             if (double.TryParse (txtDataTerima.Text, out coordinate))
             {
                 axMathworks_Strip1.AddXY (0, b, coordinate);
             }
         }

This code can only display data manually ..
I try to make it automatically with the help of serial ports
but in a textbox that I created
the data that I received with the help of data reception code:
string a;
  private void serialPort_DataReceived (object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
         {
             txtDataTerima.BeginInvoke (new myDelegate (updateTextBox));
         }
         public delegate void myDelegate ();
         public void updateTextBox ()
         {
             a = serialPort.ReadExisting ();
        
           
             txtDataTerima.AppendText (a);
             txtDataTerima.ScrollToCaret ();
         }
textboxt data displayed through serial communication, data updates down when there are changes in the value of adc input of the microcontroller
I try again to change the code
acceptance of data updates

full program
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GrafikADC
{
public partial class Form1 : Form
{
double b;

double apa;
string a;
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
//—menset event handler untuk DataReceived event—
// serialPort.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler();
//—menampilkan nama serialport yang tersedia pada
// komputer—
string[] portNames = System.IO.Ports.SerialPort.GetPortNames();
for (int i = 0; i <= portNames.Length - 1; i++)
{
cbbCOMPorts.Items.Add(portNames[i]);
}
btnDisconnect.Enabled = false;
}

private void btnConnect_Click(object sender, EventArgs e)
{
//—menutup akses serialport apabila akses serialport terbuka—
if (serialPort.IsOpen)
{
serialPort.Close();
}
try
{
//—mengatur beberapa parameter untuk koneksi serial
// port—
serialPort.PortName = cbbCOMPorts.Text;
serialPort.BaudRate = 9600;
serialPort.Parity = System.IO.Ports.Parity.None;
serialPort.DataBits = 8;
serialPort.StopBits = System.IO.Ports.StopBits.One;
//—buka serial port—
serialPort.Open();
//—menampilkan status dari serial port dan
// enable/disable -kan tombol—
lblMessage.Text = cbbCOMPorts.Text + " connected.";
btnConnect.Enabled = false;
btnDisconnect.Enabled = true;
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}

private void btnDisconnect_Click(object sender, EventArgs e)
{
try
{
//—tutup serial port—
serialPort.Close();
//—menampilkan status dari serial port dan
// enable/disable -kan tombol—
lblMessage.Text = serialPort.PortName + " disconnected.";
btnConnect.Enabled = true;
btnDisconnect.Enabled = false;
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}


private void serialPort_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
txtDataTerima.BeginInvoke(new myDelegate(updateTextBox));
}
public delegate void myDelegate();
public void updateTextBox()
{
a = serialPort.ReadExisting();


txtDataTerima.AppendText(a);
txtDataTerima.ScrollToCaret();
txtDataTerima.Clear();





}

private void button3_Click(object sender, EventArgs e)
{
timer1.Start();
button3.Enabled = false;
}

private void timer1_Tick(object sender, EventArgs e)
{
double coordinate;
b++;
if (double.TryParse(txtDataTerima.Text, out coordinate))
{
axMathworks_Strip1.AddXY(0, b, coordinate);
}
}





}
}

This is a program I created delivery microcontroller :
#include <mega16.h>

#include <delay.h>

int a,b;
char riki[33];

// Alphanumeric LCD functions
#include <alcd.h>

// Standard Input/Output functions
#include <stdio.h>

#define ADC_VREF_TYPE 0x00

// Read the AD conversion result
unsigned int read_adc(unsigned char adc_input)
{
ADMUX=adc_input | (ADC_VREF_TYPE & 0xff);
// Delay needed for the stabilization of the ADC input voltage
delay_us(10);
// Start the AD conversion
ADCSRA|=0x40;
// Wait for the AD conversion to complete
while ((ADCSRA & 0x10)==0);
ADCSRA|=0x10;
return ADCW;
}
while (1)
{
// Place your code here
a = read_adc(2);
lcd_gotoxy(0,0);
sprintf(riki, "adc1=%d",a);
lcd_puts(riki);
delay_ms(50);
lcd_clear();

printf("%d\n", a);delay_ms(100);
}
}
AnswerRe: why my graph error??? Pin
V.16-Sep-14 23:18
professionalV.16-Sep-14 23:18 
GeneralRe: why my graph error??? Pin
rikiz18-Sep-14 18:45
rikiz18-Sep-14 18:45 
GeneralRe: why my graph error??? Pin
V.18-Sep-14 19:29
professionalV.18-Sep-14 19:29 
GeneralRe: why my graph error??? Pin
rikiz1-Oct-14 9:01
rikiz1-Oct-14 9:01 
QuestionHow do I select, drag and align the controls like Visual Studio at the running time ? Pin
Javafree16-Sep-14 15:31
Javafree16-Sep-14 15:31 
AnswerRe: How do I select, drag and align the controls like Visual Studio at the running time ? Pin
Pete O'Hanlon16-Sep-14 19:58
mvePete O'Hanlon16-Sep-14 19:58 
AnswerRe: How do I select, drag and align the controls like Visual Studio at the running time ? Pin
BillWoodruff17-Sep-14 0:54
professionalBillWoodruff17-Sep-14 0:54 
QuestionMaximizing Scalability and Cost Effectiveness of Queue-Based Messaging SMPP Pin
mackmacwan16-Sep-14 9:58
mackmacwan16-Sep-14 9:58 
QuestionRe: Maximizing Scalability and Cost Effectiveness of Queue-Based Messaging SMPP Pin
ZurdoDev16-Sep-14 10:28
professionalZurdoDev16-Sep-14 10:28 
AnswerRe: Maximizing Scalability and Cost Effectiveness of Queue-Based Messaging SMPP PinPopular
Ravi Bhavnani16-Sep-14 12:21
professionalRavi Bhavnani16-Sep-14 12:21 
GeneralRe: Maximizing Scalability and Cost Effectiveness of Queue-Based Messaging SMPP Pin
Bernhard Hiller16-Sep-14 21:35
Bernhard Hiller16-Sep-14 21:35 
GeneralRe: Maximizing Scalability and Cost Effectiveness of Queue-Based Messaging SMPP Pin
Dave Kreskowiak17-Sep-14 5:01
mveDave Kreskowiak17-Sep-14 5:01 
GeneralRe: Maximizing Scalability and Cost Effectiveness of Queue-Based Messaging SMPP Pin
Ravi Bhavnani17-Sep-14 5:12
professionalRavi Bhavnani17-Sep-14 5:12 
GeneralRe: Maximizing Scalability and Cost Effectiveness of Queue-Based Messaging SMPP Pin
Dave Kreskowiak17-Sep-14 5:31
mveDave Kreskowiak17-Sep-14 5:31 
GeneralRe: Maximizing Scalability and Cost Effectiveness of Queue-Based Messaging SMPP Pin
mackmacwan17-Sep-14 8:01
mackmacwan17-Sep-14 8:01 
GeneralRe: Maximizing Scalability and Cost Effectiveness of Queue-Based Messaging SMPP Pin
Pete O'Hanlon17-Sep-14 8:10
mvePete O'Hanlon17-Sep-14 8:10 
GeneralRe: Maximizing Scalability and Cost Effectiveness of Queue-Based Messaging SMPP Pin
mackmacwan17-Sep-14 8:26
mackmacwan17-Sep-14 8:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.