Hello, I am new to the topic of bus communication. I want to use the One Wire Bus to transfer three data packets.
So I send with the TransmitByte command. How do I identify my individual packets at the other end?
The ReceiveByte command always reads 255 as result when nothing is transmitted. How do I filter out my three data packets?
Probably all stupid questions, sorry. But I don't know what to do...
Thanks a lot!
One Wire Bus Data Transmission
-
- Posts: 103
- http://meble-kuchenne.info.pl
- Joined: Mon Dec 07, 2020 12:47 pm
- Been thanked: 1 time
-
- Matrix Staff
- Posts: 1926
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 503 times
- Been thanked: 686 times
Re: One Wire Bus Data Transmission
Hello,
If you're not too bothered about following the one wire specification then you could simply send additional bytes as sync markers.
For example if you sent five bytes with the first and last bytes being known values then the receiver can listen for bytes until it receives the first known value, then receive another four bytes and if the last byte also matches the expected value then you know the three bytes in the middle are the data you've sent.
You could then improve this further by having the last byte be a checksum for example adding the values of each of the three bytes together. Then you know that the data you have received is indeed valid.
If you're not too bothered about following the one wire specification then you could simply send additional bytes as sync markers.
For example if you sent five bytes with the first and last bytes being known values then the receiver can listen for bytes until it receives the first known value, then receive another four bytes and if the last byte also matches the expected value then you know the three bytes in the middle are the data you've sent.
You could then improve this further by having the last byte be a checksum for example adding the values of each of the three bytes together. Then you know that the data you have received is indeed valid.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
-
- Matrix Staff
- Posts: 1926
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 503 times
- Been thanked: 686 times
Re: One Wire Bus Data Transmission
Hi Jac,
Yes to do it properly to the one wire standard you would need a one-wire slave component which we don't currently have. I'm not sure that's worth doing as I think Dallas controls all the one wire slave devices to ensure everything has unique ID codes.
If the user is just interested in one way data via a single pin then a UART might be more appropriate?
Yes to do it properly to the one wire standard you would need a one-wire slave component which we don't currently have. I'm not sure that's worth doing as I think Dallas controls all the one wire slave devices to ensure everything has unique ID codes.
If the user is just interested in one way data via a single pin then a UART might be more appropriate?
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Re: One Wire Bus Data Transmission
Thanks for the feedback!
I thought the ReceiveByte command is the slave function?
I have already tried to send a start byte with. However, the ReceiveByte command reads the value 255 continuously, so even after the received start byte until the first "correct" byte is received. I.e. until the two bytes are transmitted the command has already received hundreds of "empty" bytes...
(I send and receive in an endless loop).
But if this is not a slave at all, I guess I would have to switch to UART. Does it run there more simply with the planned transmission?
I thought the ReceiveByte command is the slave function?
I have already tried to send a start byte with. However, the ReceiveByte command reads the value 255 continuously, so even after the received start byte until the first "correct" byte is received. I.e. until the two bytes are transmitted the command has already received hundreds of "empty" bytes...
(I send and receive in an endless loop).
But if this is not a slave at all, I guess I would have to switch to UART. Does it run there more simply with the planned transmission?
-
- Valued Contributor
- Posts: 1528
- Joined: Thu Dec 03, 2020 10:57 am
- Has thanked: 353 times
- Been thanked: 549 times
Re: One Wire Bus Data Transmission
Hi
Can you tell us more about your intended application? What exactly are you trying to get talking to each other and over what distance?
Regards
Can you tell us more about your intended application? What exactly are you trying to get talking to each other and over what distance?
Regards
Re: One Wire Bus Data Transmission
I want to transmit three variable PWM signals (300Hz) over one line and process them again as pulse width at the receiver.
In the transmitter I currently measure the pulse width of the three signals and store it as ULONG variable. The values are between 100-1000.
I want to send this variable permanently to 2-3 receivers in a continuous loop. The distance is about 50cm.
In the transmitter I currently measure the pulse width of the three signals and store it as ULONG variable. The values are between 100-1000.
I want to send this variable permanently to 2-3 receivers in a continuous loop. The distance is about 50cm.
-
- Matrix Staff
- Posts: 1926
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 503 times
- Been thanked: 686 times
Re: One Wire Bus Data Transmission
Yes I would use UART, it should then work as you're expecting and my suggested approach of having a start and end byte should allow you to reliably receive the three variables.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Re: One Wire Bus Data Transmission
Ok, let's see if I can make this work 
With only one line, do I have to use a diode between TX and RX and use only RX?
Or, if I choose the software UART, I must then set the transmitter "use RX" to "no" and the receiver "use TX" to "no"?

With only one line, do I have to use a diode between TX and RX and use only RX?
Or, if I choose the software UART, I must then set the transmitter "use RX" to "no" and the receiver "use TX" to "no"?
-
- Matrix Staff
- Posts: 1926
- Joined: Mon Dec 07, 2020 10:06 am
- Has thanked: 503 times
- Been thanked: 686 times
Re: One Wire Bus Data Transmission
If you can I would recommend using the hardware channels as these will probably be more reliable.
Otherwise yes use the software channels as you mentioned.
You just need to run a wire from the transmitter TX pin to the Receiver RX pin and they will also need to share a ground.
Otherwise yes use the software channels as you mentioned.
You just need to run a wire from the transmitter TX pin to the Receiver RX pin and they will also need to share a ground.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel