One Wire Bus Data Transmission

For general Flowcode discussion that does not belong in the other sections.
ChrisT66
Posts: 37
http://meble-kuchenne.info.pl
Joined: Mon Dec 07, 2020 12:47 pm
Been thanked: 1 time

One Wire Bus Data Transmission

Post by ChrisT66 »

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!

BenR
Matrix Staff
Posts: 1739
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 440 times
Been thanked: 603 times

Re: One Wire Bus Data Transmission

Post by BenR »

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.

kersing
Valued Contributor
Posts: 157
Joined: Wed Dec 02, 2020 7:28 pm
Has thanked: 64 times
Been thanked: 58 times

Re: One Wire Bus Data Transmission

Post by kersing »

Hi Ben,

Does Flowcode actually provide a one-wire slave? Because that would be required for this use case I think.

Best regards,

Jac

BenR
Matrix Staff
Posts: 1739
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 440 times
Been thanked: 603 times

Re: One Wire Bus Data Transmission

Post by BenR »

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?

ChrisT66
Posts: 37
Joined: Mon Dec 07, 2020 12:47 pm
Been thanked: 1 time

Re: One Wire Bus Data Transmission

Post by ChrisT66 »

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?

chipfryer27
Valued Contributor
Posts: 1147
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 285 times
Been thanked: 412 times

Re: One Wire Bus Data Transmission

Post by chipfryer27 »

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

ChrisT66
Posts: 37
Joined: Mon Dec 07, 2020 12:47 pm
Been thanked: 1 time

Re: One Wire Bus Data Transmission

Post by ChrisT66 »

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.

BenR
Matrix Staff
Posts: 1739
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 440 times
Been thanked: 603 times

Re: One Wire Bus Data Transmission

Post by BenR »

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.

ChrisT66
Posts: 37
Joined: Mon Dec 07, 2020 12:47 pm
Been thanked: 1 time

Re: One Wire Bus Data Transmission

Post by ChrisT66 »

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"?

BenR
Matrix Staff
Posts: 1739
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 440 times
Been thanked: 603 times

Re: One Wire Bus Data Transmission

Post by BenR »

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.

Post Reply