yes. I' work around. Richard Andrew x64,thanks for your attentions.
khomeyni
Posts
-
serial port writing and reading -
serial port writing and readingso what is the cause of the interrupt? is it relative to system(pc) or to serial port or my code? the interrupt (not sending data for some millisecond) can be seen by comwizard , also I must send data for a motor and also the motor shows such interrupt.
-
serial port writing and readingif the STOPByte is read there just poor out the data until new pack of correct data comes.(until STARTByte be found). also notice that I'm sending data in turn so if one pack of data is received then if no noise all data packs can be received in turn.
-
serial port writing and readingsee above edited post. yes data comes eventually.
-
serial port writing and readingyes . excuse me. I'm decreasing it. and this is the code for reading bytes:
public void ThreadMain()
{
int i = 0;
while (port.IsOpen)//while (port != null && port.IsOpen)
{
try
{
var b1 = port.ReadByte();if (b1 == ReadSignal.STARTByte) { //read location b1 = port.ReadByte(); ... if (b1 == ReadSignal.STOPByte) { RSignal.isValid = true; } } if (RSignal.isValid) { RSignal.ExtractLocatoins(); if (DataReceived != null) DataReceived.Invoke(RSignal); } } catch (Exception ex) { //MessageBox.Show("1:"+ex.ToString()); } } }
and code for writing:
public void SendCommand(SerialPort port,byte[] command)//public void SendCommand(byte[] command)
{if (port != null && port.IsOpen) { port.Write(command, 0, command.Length); } else { MessageBox.Show("port is not open!"); } }
-
serial port writing and readinganother problem I've with this code and writing to port: when I see the data which I'm sending in Comwizard ,sometimes I see an interrupt in the data received by comwizard. it is randomly and when I increase the frequency of sending(3 ms to 10ms ...) it appears in longer time and less than before. I checked all things but I cannot find any mistake in my code . is it possible to be relative to serial port class and functions of c#?can you suggest what is the mistake?
-
depicting data in c# in realtimethere is one another question: why can Matlab depict these charts so faster than c# ?
-
depicting data in c# in realtimeI've this simple code but it takes about 20sec to be depicted!
private void button1_Click(object sender, RoutedEventArgs e)
{
ObservableCollection<ChartItem> InputItems = new ObservableCollection<ChartItem>();
for (int i = 0; i < 6000; i++)
{
InputItems.Add(new ChartItem(i, i));
}
InputLine.ItemsSource = InputItems;}
}
public class ChartItem : INotifyPropertyChanged
{
public ChartItem(double t, double v)
{
time = t;
myVar = v;
}private double time; public double Time { get { return time; } set { time = value; OnPropertyChanged("Time"); } } private double myVar; public double Value { get { return myVar; } set { myVar = value; OnPropertyChanged("Value"); } } public event PropertyChangedEventHandler PropertyChanged; protected virtual void OnPropertyChanged(string propertyName) { if (this.PropertyChanged != null) { this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } }
}
with using : System.Windows.Controls.DataVisualization.Toolkit and System.Windows.Controls.DataVisualization.Toolkit
-
serial port writing and readingyes . the data received is what is sent on the other COM port.
Quote:
The DataReceived function is invoked any time there is data available, not just when the data is complete. So it is conceivable that it could be raised after each byte is received, hence the greater frequency.
so how can I change it to be raised every 3 millisecond? I want to create a match between sending and receiving. for example when I depict the chart of both send and receive in realtime, for comparison of data ,the data must be matched.
-
serial port writing and readingI've created a program to send data to a serial port(rs 232,sr 485) every 3 millisecond . and receiving data on the other port. sending works fine but receiving is not logical,see results at the end of this post. codes:
int _counter = 0;
public delegate void TimerEventHandler(UInt32 id, UInt32 msg, ref UInt32 userCtx, UInt32 rsv1, UInt32 rsv2);\[DllImport("winmm.dll", SetLastError = true, EntryPoint = "timeSetEvent")\] static extern UInt32 timeSetEvent(UInt32 msDelay, UInt32 msResolution, TimerEventHandler handler, ref UInt32 userCtx, UInt32 eventType); \[DllImport("winmm.dll", SetLastError = true)\] static extern void timeKillEvent(UInt32 uTimerID); TimerEventHandler tim;//TimerEventHandler tim = new TimerEventHandler(this.Link); public void Link(UInt32 id, UInt32 msg, ref UInt32 userCtx, UInt32 rsv1, UInt32 rsv2) { \_counter++; if ((\_counter % interval) == 0) //if ((\_counter % 10) == 0) { timer\_Elapsed3(); } if (\_counter > 1000.0\*EndTime)//if (\_counter>EndTime / interval) { Stop();//timekillevent must be called in Stop } } #endregion public void StartSendingLocations() { EndIndex = setEndIndex(); if (port==null) { port = new SerialPort(portName, rate); reader.port = new SerialPort("COM4", rate);//rate is 115200 reader.port.Open(); writer.port = port; if (!port.IsOpen) { port.Open(); } reader.mythread.Start(); } tim = new TimerEventHandler(this.Link); uint rsv = 0; timerId = timeSetEvent(1, 1, tim, ref rsv, 1); }
and timerElapsed3:
void timer_Elapsed3()
{
Index++;
ConstructSignal();
CreateCommand();
writer.SendCommand(port, command);if (IsChartEnabled) { SignalWriter\_DataSent(writer.WSignal); } if (SentFileLogger==null) { return; } SentFileLogger.Write(true, writer.WSignal.PitchLocation, writer.WSignal.PitchAngularVelocity, writer.WSignal.RollLocation, writer.WSignal.Ro
-
depicting data in c# in realtimehello I want to depict a chart dynamically and every 3 millisecond a point is send to the chart . when I run my program about 8sec it will be executed very more than 8sec( about 3 mins or more).(i used wpftoolkit charting, dynamic data display , ... but none of them works well). also when I want to depict 6000 point in offline mode(storing data in an array and at last depicting it on a chart) ,yet there is a such problem. Matlab depicts these data very rapidly . is there any way to depict these data in c#?
-
vs 11 wpf New Widgets Added Old Widgets DisappearIn visual studio 2012 wpf , when I add new widget to wpf , old widgets disappear!!! for example when I add a label , then I push a button on the grid label will be removed. how I can fix it? thnx.
-
fast division algoirthmactually I don't know anymore about it's implementation , my project manager say's something to me and I must do the desired algorithm. also I don't study anything about fpga and hardware implementations. some thing that I know is that he wants to speed up his program by writing it in C , for example 6*6 inversion program which in it there is some 1/d where d is float(we can convert it to integer by multiplying it with 2^n) . he has wrote his code in labveiw and wants to convert it to C language. then it will be implemented on fpga.
-
fast division algoirthmthanks harold for your complete and good reply I cannot add a hardware to the FPGA (the program will be complicated) and don't have any reciprocal support. I wrote some algorithms as follows( from the pages you send to me and from others):
void test1(){
const long MAX_Iter=10000000;//10^7
int *ar1=new int [MAX_Iter];/// array of integers to find the reciprocal
double *R=new double [MAX_Iter];//array of double for saving the regular division 1/x
double *R2=new double [MAX_Iter];//array of double for saving the algorithms division 1/x
double *ERROR=new double [MAX_Iter];
double max_error=pow(10,-100.0);;/\* \* generate some number bigger than 2 \*/ for(int i=0;i
-
fast division algoirthmI,m writing a bit of a large programme and within it there is some divisions, the programme must be implemented on fpga and in fpga there is no division.so I must write a fast algorithm for all divisions , I don't have any access to hardware and I must implement it on software level. I have read some algorithm from here , but I don't know which one to use.
-
fast division algoirthmhello I want to find a fast algorithm for computing 1/d , where d is double ( albeit it can be converted to integer) what is the best algorithm for this case of many algorithms(SRT , goldschmith,newton raphson, ...)?I'm writing my program in c language. thanks in advance.
-
compressionhello i have a file with only entry of 0..9 (numbers only) without any other thing even space , what is the most efficient algorithm to compress it? thanks in advance.
-
renaming filesthanks a lot.
-
renaming filescan you write the code of it here?
-
renaming fileshello i want to see all files in directory dir that have .txt and rename them to directory dir2 with suffix .cpp how i can do this??