How can i add a 5ms delay between bytes i send over to a controller?
I have to send 6 bytes in total however in between each byte i need to
have a 5ms delay. 23 6915
cmdolcet69 wrote:
How can i add a 5ms delay between bytes i send over to a controller?
I have to send 6 bytes in total however in between each byte i need to
have a 5ms delay.
I think you can just use Thread.Sleep (5).
So you're code would look like:
SendByteOne()
Thread.Sleep (5)
SendByteTwo()
Thread.Sleep (5)
SendByteThree()
Thread.Sleep (5)
etc...
See http://msdn2.microsoft.com/en-us/lib...ead.sleep.aspx
Cheers,
RB.
On Sep 20, 10:55 am, RB <owmdkbqziki... @mailinator.com wrote:
cmdolcet69 wrote:
How can i add a 5ms delay between bytes i send over to a controller?
I have to send 6 bytes in total however in between each byte i need to
have a 5ms delay.
I think you can just use Thread.Sleep (5).
So you're code would look like:
SendByteOne()
Thread.Sleep (5)
SendByteTwo()
Thread.Sleep (5)
SendByteThree()
Thread.Sleep (5)
etc...
Seehttp://msdn2.microsoft .com/en-us/library/system.threadin g.thread.slee.. .
Cheers,
RB.
RB, I was on the right path in thinking. I have been reading however
that it may be sloppy coding.....anyw ays.... how can i write it were i
use this delay with each byte i send across from a com.ouput command
example: com.output= (byte(1) + thead.sleep(5) + byte(2)+.......
?????
cmdolcet69 wrote:
On Sep 20, 10:55 am, RB <owmdkbqziki... @mailinator.com wrote:
>cmdolcet69 wrote:
>>How can i add a 5ms delay between bytes i send over to a controller? I have to send 6 bytes in total however in between each byte i need to have a 5ms delay.
I think you can just use Thread.Sleep (5).
So you're code would look like:
SendByteOne( ) Thread.Sleep (5) SendByteTwo( ) Thread.Sleep (5) SendByteThree( ) Thread.Sleep (5)
etc...
Seehttp://msdn2.microsoft .com/en-us/library/system.threadin g.thread.slee.. .
Cheers,
RB.
RB, I was on the right path in thinking. I have been reading however
that it may be sloppy coding.....anyw ays.... how can i write it were i
use this delay with each byte i send across from a com.ouput command
example: com.output= (byte(1) + thead.sleep(5) + byte(2)+.......
?????
You could use something similar to :
Dim i as integer
For i = 1 to 6
com.output = byte(i)
Thread.Sleep(5)
Next i
Be aware that this will cause AT LEAST a 5 ms delay per byte sending. It
may be longer - would this cause an issue?
Cheers,
RB.
On Sep 20, 11:05 am, RB <owmdkbqziki... @mailinator.com wrote:
cmdolcet69 wrote:
On Sep 20, 10:55 am, RB <owmdkbqziki... @mailinator.com wrote:
cmdolcet69 wrote: How can i add a 5ms delay between bytes i send over to a controller? I have to send 6 bytes in total however in between each byte i need to have a 5ms delay.
I think you can just use Thread.Sleep (5).
So you're code would look like:
SendByteOne()
Thread.Sleep (5)
SendByteTwo()
Thread.Sleep (5)
SendByteThree()
Thread.Sleep (5)
etc...
Seehttp://msdn2.microsoft .com/en-us/library/system.threadin g.thread.slee.. .
Cheers,
RB.
RB, I was on the right path in thinking. I have been reading however
that it may be sloppy coding.....anyw ays.... how can i write it were i
use this delay with each byte i send across from a com.ouput command
example: com.output= (byte(1) + thead.sleep(5) + byte(2)+.......
?????
You could use something similar to :
Dim i as integer
For i = 1 to 6
com.output = byte(i)
Thread.Sleep(5)
Next i
Be aware that this will cause AT LEAST a 5 ms delay per byte sending. It
may be longer - would this cause an issue?
Cheers,
RB.- Hide quoted text -
- Show quoted text -
RB how can i do the for loop with these bytes
Dim Len As Byte = 6
Dim Cmd As Byte = 7
Dim loPass_byte As Byte = 28
Dim hiPass_byte As Byte = 45
Dim CRClo_byte As Byte = 48
Dim CRChi_byte As Byte = 130
On Sep 20, 11:12 am, cmdolcet69 <colin_dolce... @hotmail.comwro te:
On Sep 20, 11:05 am, RB <owmdkbqziki... @mailinator.com wrote:
cmdolcet69 wrote:
On Sep 20, 10:55 am, RB <owmdkbqziki... @mailinator.com wrote:
>cmdolcet69 wrote:
>>How can i add a 5ms delay between bytes i send over to a controller?
>>I have to send 6 bytes in total however in between each byte i need to
>>have a 5ms delay.
>I think you can just use Thread.Sleep (5).
>So you're code would look like:
>SendByteOne( )
>Thread.Sleep (5)
>SendByteTwo( )
>Thread.Sleep (5)
>SendByteThree( )
>Thread.Sleep (5)
>etc...
>Seehttp://msdn2.microsoft .com/en-us/library/system.threadin g.thread.slee.. .
>Cheers,
>RB.
RB, I was on the right path in thinking. I have been reading however
that it may be sloppy coding.....anyw ays.... how can i write it were i
use this delay with each byte i send across from a com.ouput command
example: com.output= (byte(1) + thead.sleep(5) + byte(2)+.......
?????
You could use something similar to :
Dim i as integer
For i = 1 to 6
com.output = byte(i)
Thread.Sleep(5)
Next i
Be aware that this will cause AT LEAST a 5 ms delay per byte sending. It
may be longer - would this cause an issue?
Cheers,
RB.- Hide quoted text -
- Show quoted text -
RB how can i do the for loop with these bytes
Dim Len As Byte = 6
Dim Cmd As Byte = 7
Dim loPass_byte As Byte = 28
Dim hiPass_byte As Byte = 45
Dim CRClo_byte As Byte = 48
Dim CRChi_byte As Byte = 130
Dump them into an array, collection, list, etc and then do the for
each loop.
Thanks,
Seth Rowe
Use an array of Type byte. E.g.,
Dim Packet(5) As Byte
Packet(0) = 6
Packet(1) = 7
Packet(2) = 28
Packet(3) = 45
Packet(4) = 48
Packet(5) = 130
Then use a loop. Arrays of type Byte are standard for this. For example,
the SerialPort object Write method has an overload for a Byte array (if you
wanted to send all "back-to-back, with no delay).
Dick
--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
On Sep 20, 1:46 pm, "Dick Grier" <dick_grierNOSP AM@.msn.comwrot e:
Use an array of Type byte. E.g.,
Dim Packet(5) As Byte
Packet(0) = 6
Packet(1) = 7
Packet(2) = 28
Packet(3) = 45
Packet(4) = 48
Packet(5) = 130
Then use a loop. Arrays of type Byte are standard for this. For example,
the SerialPort object Write method has an overload for a Byte array (if you
wanted to send all "back-to-back, with no delay).
Dick
--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
Seewww.hardands oftware.netfor details and contact information.
when i do the following loop and code for the initial loop it will
break and give me an error saying "property value is not valid"
Dim i As Integer
Dim Packet(5) As Byte
Packet(0) = 6
Packet(1) = 7
Packet(2) = 28
Packet(3) = 45
Packet(4) = 48
Packet(5) = 130
For i = 0 To 5
comm1.Output = Packet(i)
Thread.Sleep(5)
Next i
cmdolcet69 wrote:
On Sep 20, 1:46 pm, "Dick Grier" <dick_grierNOSP AM@.msn.comwrot e:
>Use an array of Type byte. E.g.,
Dim Packet(5) As Byte Packet(0) = 6 Packet(1) = 7 Packet(2) = 28 Packet(3) = 45 Packet(4) = 48 Packet(5) = 130
Then use a loop. Arrays of type Byte are standard for this. For example, the SerialPort object Write method has an overload for a Byte array (if you wanted to send all "back-to-back, with no delay).
Dick
-- Richard Grier, MVP Hard & Software Author of Visual Basic Programmer's Guide to Serial Communications, Fourth Edition, ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March 2006. Seewww.hardand software.netfor details and contact information.
when i do the following loop and code for the initial loop it will
break and give me an error saying "property value is not valid"
Dim i As Integer
Dim Packet(5) As Byte
Packet(0) = 6
Packet(1) = 7
Packet(2) = 28
Packet(3) = 45
Packet(4) = 48
Packet(5) = 130
For i = 0 To 5
comm1.Output = Packet(i)
Thread.Sleep(5)
Next i
You have 6 elements in your array, but you've only declared it as having
5 elements.
Dim Packet(6) As Byte 'THIS IS THE LINE OF CODE I CHANGED.
Packet(0) = 6
Packet(1) = 7
Packet(2) = 28
Packet(3) = 45
Packet(4) = 48
Packet(5) = 130
For i = 0 To 5
comm1.Output = Packet(i)
Thread.Sleep(5)
Next i
"RB" <ow************ @mailinator.com schrieb
when i do the following loop and code for the initial loop it will
break and give me an error saying "property value is not valid"
Dim i As Integer
Dim Packet(5) As Byte
Packet(0) = 6
Packet(1) = 7
Packet(2) = 28
Packet(3) = 45
Packet(4) = 48
Packet(5) = 130
For i = 0 To 5
comm1.Output = Packet(i)
Thread.Sleep(5)
Next i
You have 6 elements in your array, but you've only declared it as
having 5 elements.
No, his array has 6 elements, indexes 0, 1, 2, 3, 4, 5.
Dim Packet(6) As Byte 'THIS IS THE LINE OF CODE I CHANGED.
Packet(0) = 6
Packet(1) = 7
Packet(2) = 28
Packet(3) = 45
Packet(4) = 48
Packet(5) = 130
For i = 0 To 5
comm1.Output = Packet(i)
Thread.Sleep(5)
Next i
Your array can contain 7 items. You don't fill Packet(6).
Armin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: johnny.karlsson |
last post by:
Hi, I'm working on a project were a need to be able to upload firmware
to a microcontroller based Ethernet device. But because of the memory
constraints the controller can only handle packages of 300 bytes each
time. So therefore the firmware file must be sent in chunks and i need
a header in each file describing which part of the file it is I'm
sending. Could anyone give me some pointer on how a could accomplish
that in python? I'm...
|
by: mfeingold |
last post by:
I am working on a system, which among other things includes a server and a
..net control sitting in an html page and connected to the server. I ran into
a couple of problems, you guys might have some insight about.
1) It takes 20 sec or so to open a tcp socket from the client to the server.
It just sits in the TcpClient.conect waiting for something. When I run the
same control from a windows application it connects right away and works...
|
by: Max |
last post by:
Hi,
I am newbie developing a MailList program in asp.net c#.
To avoid be considered as a span, a would like to process some messages,
stops, process some messages, stops......
What do you recommend ?
Help!!!
|
by: Jochen Müller |
last post by:
Just a short question: With a network sniffer and a hex editor I looked at
the pages coming from my ASP.NET environment and I saw some strange bytes
between header and the page content:
0d 0a 0d 0a ef bb bf 0d 0a
That means that there are two CR/LF , then 3 funny bytes and again a CR/LF.
I also implemented a response filter to look at the byte stream before
sending and the page content starts there just with one CR/LF.
|
by: WhatHappend |
last post by:
I have converted a .Net 1.0 application to .Net 2.0 and the web service
invocations have delay of around 10seconds on each intial access. After the
first access subsequent access are fast (After a whild of inactivity the next
access will be slow agian). Changing the client to static IP address instead
of DHCP makes the initial access about 1 second which is fine.
Monitoring the network of the client computer the cleint is sending out 2...
| |
by: D. Patrick |
last post by:
I need to duplicate the functionality of a java applet, and how it connects
to a remote server. But, I don't have the protocol information or the java
source code which was written years ago. So, I used a packet sniffer and
saw the protocol (TCP), the port, IP address, etc. All is good. I tried 2
different versions of .NET code to duplicate the requests to the remote
server. Again, I used the packet sniffer and my packets seemed...
|
by: clemrock |
last post by:
Help w/ errors.add_to_base between controller and model
Hello,
I'm having trouble in routing some errors between model and
controller. The errors produced in the controller
(invite_controller.rb) are collected and spit out nicely in a
flash method as such:
|
by: danfan46 |
last post by:
Hi!
I have a previous post on the subject that connect takes a long time.
I uninstalled db2 completely.
Installed V9.5
Installed fixpack 1
created das
created an instance
installed database sample.
|
by: Markgoldin |
last post by:
I am sending an XML data from not dontnet process to a .Net via socket
listener.
Here is a data sample:
<VFPData>
<serverdata>
<coderun>updateFloor</coderun>
<area>MD2</area>
<zone>BOXING</zone>
<status>Running</status>
<job>1000139233</job>
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |