Lsbfirst
SteveD
Posts: 64
I need some help with this command and how it works in Jon Williams DS1620_HR.BS2 program.
·
SHIFTOUT DsDQ, DsClk, LSBFIRST, [noparse][[/noparse]WrCfg, %11]
If this line of code is sent to the DS1620 what would the 8 bit configuration register look like (00000011)?· This is with CPU.
·
What if you change the above code to (SHIFTOUT DsDQ, DsClk, LSBFIRST, [noparse][[/noparse]WrCfg, %01])?· Would the register look like this 00000001 or 00000010?· I am hoping you will say the latter one.·
·
SHIFTOUT DsDQ, DsClk, LSBFIRST, [noparse][[/noparse]WrCfg, %11]
If this line of code is sent to the DS1620 what would the 8 bit configuration register look like (00000011)?· This is with CPU.
·
What if you change the above code to (SHIFTOUT DsDQ, DsClk, LSBFIRST, [noparse][[/noparse]WrCfg, %01])?· Would the register look like this 00000001 or 00000010?· I am hoping you will say the latter one.·
Comments
If you're wanting to use the DS1620 for hi-res measurements, you need to put it into one-shot mode.· Note, too, that you need to recycle power the first time you program the DS1620 for this mode.· I've attached my DS1620 high res program (with thanks to my pal Dr. Tracy Allan for setting me straight on initialization) and an image of what the output looks like.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
To the DS1620, "stand-alone" means you're using the TH, TL, and TC outputs. If you're going to be reading the temp from the device using the BASIC Stamp, keep the CPU bit set to 1, and for high res use, it must be put in one-shot mode (set that bit too) -- so you're going to initialize it with %11. The code I attached earlier does exactly what you want to do.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
The real question here is NOT how the device sees them, as that will always be the same for any serial protocal. The device will see the data bit-by-bit, as it is transmitted from the host. The real question is, how is the host SENDING them, since that's how the device will see them?
In this case it apparently wants to SEE LSBFIRST, and thus the first digit it sees is the 1 which is the least significant bit (LSB). If you were to send the data MSBFIRST then the device would see the 0, the most significant bit (MSB) first, and then the 1.
To be clear here, one must send the data in the order that the DEVICE expects, otherwise the data will be interpreted incorrectly. Some devices want to see MSB first and others want to see LSB first. Generally speaking, how the device deals with it internally is entirely insignificant to the user and the program.
In summary MSB is the leftmost digit visually, in a binary number. The LSB is the rightmost digit visually, in a binary number. If you want to think of it it terms of value (if that's an easier concept) think in terms of powers of two as to which is MOST and which is LEAST:
2^3 2^2 2^1 2^0
Example 1 1 1 1
Regards,
Bruce Bates
%00000001 if I were sending LSBFIRST would I be sending 1 then seven zeros?
By changing your code %11 to %01 have I turned off the CPU or ONE SHOT mode?
I am currently using your code and it works great I will not be leaving the DS1620 connected to the stamp it is a seperate circuit but should the need arise I would like to be able to plug my stamp to the circuit change a few dip switches which would simulate the way it would be connected to the stamp (DQ pin 0, clock pin 1, rst pin 3. I have it working. It works great. I thought that when I disconnected the DS1620 from the stamp pins (just like they would be in my other circuit) recycled the power the Th pin never went high again (it should have the set temp was plenty low enough and it did go high with pins 0,1,2 connected). I will try again maybe I did not do what I thought I did.
Jon I really appreciate you helping me. I know nothing about this stuff. To prove how stupid I am I was asked to automate the HVAC system where I work (I am a Maintenance man for a printing company Stuck in relay logic land) I said yeah I would like to try to use the BS2 they said great, price difference between BS2, electronics and relays was the big seller. I have already purchased some of the things from Parallax now I have to make it work. I can get the DS6201 to operate well enough that hopfully it will but me some time to learn more.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
For your application where you want to leave the DS1620 standing, but plug a micro into it to read temperature in high-resolution you need %11; this specifies use with a CPU (that BASIC Stamp you're going to plug in), and one-shot mode.· You must use the one-shot mode if you're going to do high-res measurements.· One-shot will not start a temperature conversion until commanded to do so.· After the conversion you can read the counts remaining and slope registers to do the hi-res calculation.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Post Edited (Jon Williams (Parallax)) : 7/1/2005 12:51:36 PM GMT
My DS1620 circuit has a different power source I don’t know if I stressed that earlier or if it makes a difference to you.
Again if I change the config to %01 I can unplug the stamp the Thi pin responds to temp, I can remove power to the DS1620 circuit reapply power the Thi pin responds as it should to temp as though it never lost power, I can reconnect stamp and it displays on the screen as though it was never taken out of the circuit.
I have read and studied the DS1620 data sheet and understand as much as my limited knowledge will allow. I would never intentionally expect someone to answer a question without first trying to figure it out for myself. The way I understand the data sheet if you are not relying on a CPU to control the CLK and RST then drive them both low and continuous conversions will occur, but CPU must be set to 0. By doing this the CLK pin will override the 1 SHOT bit even when set to 1 (it still seems to be reading temp in high resolution). “Note that the CPU bit must be set to 0 in the configuration register to use this mode of operation stand-alone mode. Whether CPU=0 or 1, the 3–wire port is active. Setting CPU=1 disables the stand–alone mode.” This is what I thought I was doing by writing %01 to the config register.
"Stand alone" mode means that the DS1620 can affect its TH and TL outputs.· You never mentioned this as a requirement of your project (did you?).· Do you need to do something with these outputs as well?· If yes, then I'm not sure you'll be able to use high-res mode because that requires the master (Stamp in this case) to initiate the temperature measurement cycle in one-shot mode; stand-alone mode usually means that the DS1620 is free running and continually taking measurements.
So the question is... What do you want your DS1620 to do when you are NOT connected to it?
And the suggestion is: Play, play, play.· You've been given lots of code.· Why not try it and see what happens.· It's one thing to read the data sheet, it's quite another to actually use the material you read.· That's really what it's going to take to understand what you're reading.· Don't take my word for anything... just hook-up your circuit and play.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
The following is just information. I should have plenty of opportunity to play with this project.
For the time being several DS1620 circuits, approx 30 will be replacing all existing thermostats (removing controls from other employees). I want the DS1620 to act as a thermostat, controlling the HVAC equipment. I want to plug the stamp in from time to time for troubleshooting purposes. I hope to eventually network the heating and cooling equipment per zone using the LM134 temp sensor, stamp and real time clock that will be controlled from my computer.
What you really *should* do is connect a DS1620 on a breadboard and experiment. You can see the TH and TL outputs by connecting LEDs (don't forget current limiters). A great platform for these kinds of experiments is our PDB.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax