Shop OBEX P1 Docs P2 Docs Learn Events
Lsbfirst — Parallax Forums

Lsbfirst

SteveDSteveD Posts: 64
edited 2005-07-05 15:01 in BASIC Stamp
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.·

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-06-30 12:39
    %00000001 is the same as %01.· It does not matter which bit goes first, the bit alignment within the value is to the LSB.

    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
  • SteveDSteveD Posts: 64
    edited 2005-06-30 13:50
    Yes Jon I understand that %00000001 and %01 are the same. I figured out that I could change the portion of your code to WrCfg, %01 and run the DS1620 as a stand alone high res thermostat and also read the temp in the debug window (so I can carry one BS2 to several different locations for monitoring only). I thought I needed to put a 0 in the CPU portion of the register. So I was wondering if the DS1620 seen the 0 then the 1. Just for the purpose of my understanding if %01 were to be sent out MSBFIRST would the DS1620 see the 1 then the 0? I just assume the 1620 gets the bits 1 by 1 and moves them from bit 0 to bit 7 as they are received. Am I way off?
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-06-30 14:15
    You're off in your understanding of MSB (Most Signifcant Bit -- which is the leftmost bit in a value). In the byte %00000001, the one is the LSB (least significant bit), a zero is in the MSB position. So, technically, you're sending seven zeros and then a one -- that's just how the DS1620 wants it.

    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
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-06-30 14:28
    SteveD -

    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
  • SteveDSteveD Posts: 64
    edited 2005-06-30 14:54
    I am so sorry I know you are right about my understanding MSB. Please let me try once more. In your above example
    %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 WilliamsJon Williams Posts: 6,491
    edited 2005-06-30 15:38
    Leave the DS1620 in CPU and ONE-SHOT mode.· If you're going plug in from time-to-time, then you must must pull the RST line high (it controls things), and I suggest you pull the data and clock lines low.· This will prevent them from "floating" and causing possible problems when the BASIC Stamp is not connected.· The CPU mode has to do with the way RST functions with the chip, and you want it that way so that when the Stamp is plugged in you can retrieve data.· See the attached schematic.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    1162 x 649 - 100K
  • SteveDSteveD Posts: 64
    edited 2005-07-01 12:10
    I really need to understand what the DS1620 does with the bits that are sent to it.· I still do not understand what effect %11 vs. %01 has on the DS1620.· I can see that I have made some changes but without understanding how the DS1620 handles or stores them I do not understand what it is exactly that I am changing.· Please help with this part.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-07-01 12:46
    Yes, you should definitely download and study the DS1620 data.· Get that latest from Maxim-Dallas.

    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
  • SteveDSteveD Posts: 64
    edited 2005-07-05 12:20
    Jon, you are the master and I am the student and I was excited when you replied to my post so please forgive me for pestering with the same question. I spent the entire weekend wiring and rewiring per your plug and play diagram assuming that I have to be doing something wrong, but every time I remove the stamp from the DS1620 circuit the state of the Thi pin was non responsive.

    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.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-07-05 13:29
    You've asked the same question so many times I'm now lost ... what is it you want to do?· I think you want to be able to approach a DS1620, connect to it, and read its temperature in high-resolution mode.· Right?· That question has been answered and the schematic I drew has a common Vss connection so that this is possible.

    "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
  • SteveDSteveD Posts: 64
    edited 2005-07-05 14:13
    I appologize I think I got lost as well. I was and still am seeking conformation as to whether or not I was turning the CPU off when I write %01 to the config register.

    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.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-07-05 14:27
    Okay, you can do that, but you won't be able to use one-shot mode which allows high-res temperature measurement -- probably not a big issue as 0.5 degrees C is usually plenty for most people. You will use with CPU in continuous conversion mode (%10), with the one-shot bit cleared to 0 the DS1620 will do continuous conversions after the receipt of the STARTC command. The other thing you need to do is set the TH and TL values.

    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
  • SteveDSteveD Posts: 64
    edited 2005-07-05 14:42
    I have been playing with breadboard and LED using MOSFET as buffer. I have it functioning I was just confused on the CPU and 1 SHOT mode. Thank you for clearing it up for me. I hope I have not irritated you so much that you will not respond to my posts in the future.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-07-05 15:01
    Not irritated at all. I just hope that you'll value experimentation as much as input from forum users in the future -- experience is a far better teacher than anything I could tell you.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.