In the datasheet of the DS1820 it's stated that the data of the master is send, LSB first.
Does the 1-wire component work this way? Does it always send and receives it's data LSB first?
There are macro's for the 1-wire component in Flowcode that handle the data flow to and from the DS1820, but I want to use this temperature sensor in a different way.
If I use the examples from the datasheet I get a weird response in my logic analyser.
Maybe strange, but let's say I need to send 48h and the direction is wrong, (when I use the oo_TX_byte macro), do I need to send 12h instead? 12h is 48h in the other direction.
1-Wire, LSB first
Moderator: Benj
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: 1-Wire, LSB first
Hello,
The "oo_tx_byte" function always sends its data out with the least significant bit first so you do not have to do any manipulation on the data you are sending.
The "oo_tx_byte" function always sends its data out with the least significant bit first so you do not have to do any manipulation on the data you are sending.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: 1-Wire, LSB first
The 1-wire component uses delays so you may want to check that your configuration and clock speed settings are correct in Flowcode otherwise the component will not work correctly. A 1 second flasher program will confirm if you have everything set up correctly.
Also 1-wire requires an external pull up resistor to be fitted to the 1-wire signal wire. I think the value of the pull up may vary depending on the length of your bus and the number of devices connected.
Also 1-wire requires an external pull up resistor to be fitted to the 1-wire signal wire. I think the value of the pull up may vary depending on the length of your bus and the number of devices connected.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
MJU
- Posts: 502
- Joined: Wed Nov 07, 2007 6:51 pm
- Location: Antwerp Belgium
- Has thanked: 121 times
- Been thanked: 108 times
Re: 1-Wire, LSB first
Dear BenJ.
I can read the temperature when I use the DS1820 macro's.
That works fine.
I just want to read the bits of the scratchpad myself.
In the datasheet there are examples of how to address the DS1820
When I try to implement them myself with the oo_TX and the oo_RX macro's they don't work.
In the datasheet I find that first a reset, followed by a presence puls is the start.
Then a SEARCH ROM (0xF0) would return the 64bit ROM code of the DS1820.
When I issue a oo_busreset followed by a oo_ScanBus macro, I see this

Reset, presence,error,unknown,reset,presence,0XFO and then strange 24 * 8 bits.
Normally the 0XF0 should be followed by 64bits?

Strange, not what I expected.
Is there something more Matrix does in it's macro's?
The part where the line is pulled down (= ERROR) approx 620µs, followed by 620µs high (= unknown), where does this come from?
Why does the bus contain 24byte instead of 64bits?
The DS1820 family code in the ROM (10h) is nowhere to be found..
Strange :-s
I can read the temperature when I use the DS1820 macro's.
That works fine.
I just want to read the bits of the scratchpad myself.
In the datasheet there are examples of how to address the DS1820
When I try to implement them myself with the oo_TX and the oo_RX macro's they don't work.
In the datasheet I find that first a reset, followed by a presence puls is the start.
Then a SEARCH ROM (0xF0) would return the 64bit ROM code of the DS1820.
When I issue a oo_busreset followed by a oo_ScanBus macro, I see this

Reset, presence,error,unknown,reset,presence,0XFO and then strange 24 * 8 bits.
Normally the 0XF0 should be followed by 64bits?

Strange, not what I expected.
Is there something more Matrix does in it's macro's?
The part where the line is pulled down (= ERROR) approx 620µs, followed by 620µs high (= unknown), where does this come from?
Why does the bus contain 24byte instead of 64bits?
The DS1820 family code in the ROM (10h) is nowhere to be found..
Strange :-s
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: 1-Wire, LSB first
Hello,
If you look at the contents of the DS1820 functions using the custom code feature then you can see that the functions are simply referencing the generic 1-wire function calls. You should be able to copy the function calls and syntax directly into Flowcode if you wish using component macros etc.
Here is the DS1820_start_conversion function as an example.
Defines such as OO_SKIPROM can be found in the defines section in the custom code window.
If you look at the contents of the DS1820 functions using the custom code feature then you can see that the functions are simply referencing the generic 1-wire function calls. You should be able to copy the function calls and syntax directly into Flowcode if you wish using component macros etc.
Here is the DS1820_start_conversion function as an example.
Code: Select all
char in = 0;
char counter = 0;
oo_busreset();
oo_tx_byte(OO_SKIPROM); // Command all temp sensors on the bus to start a conversion
oo_tx_byte(OO_CONVERTT); // Convert temperature
while (in == 0)
{
in = oo_rx_byte();
delay_ms(4);
counter++;
if (counter == 0xFF) // Security: if the conversion is not completed
return 1; // after > 1 sec -> break.
}
return 0;Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel