Shop OBEX P1 Docs P2 Docs Learn Events
Code examples, omg — Parallax Forums

Code examples, omg

ManuelManuel Posts: 105
edited 2006-04-20 06:06 in General Discussion
Hey!
I was going through the code examples (of the Thermocouple DS2760 w/e) , to make my own code. I realized that in the advanced code zip there are two tables and one code for the bs2p. I haven't had yet very much experience with lot of memory usage, but I realized that one table uses all the eeprom. How am I going to use my bs2p with the code that uses half eeprom and the table that uses full eeprom? Does this mean I'm only able to use a limited range of values?
Manuel C Reinhard

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Best Regards

Manuel C. Reinhard

Post Edited (Manuel) : 4/14/2006 5:11:59 AM GMT

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-04-14 08:56
    Nope -- if you look at the main program $STAMP directive you'll see the tables listed there; this means they get loaded up in other slots. The nice thing about the BS2p family is that READ and WRITE can work across slot boundaries by using the STORE instruction.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • ManuelManuel Posts: 105
    edited 2006-04-14 16:50
    Oh yes, I see they are listed there. I was reading the bs manual and saw there can be a slot switching. But what does that mean? what are the slots and how many do I have? Is it that it has eight times the 2k memory?
    Sorry for all these questions, but I'm still in highschool. I'm a beginner.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Best Regards

    Manuel C. Reinhard

    Post Edited (Manuel) : 4/14/2006 4:54:09 PM GMT
  • ManuelManuel Posts: 105
    edited 2006-04-14 17:22
    Something else... I was checking the code and there are some I/O pins defined, but they seem to not appear anymore on the code...
    E PIN 1 ' LCD Enable (1 = enabled)
    RW PIN 2 ' Read/Write\
    RS PIN 3 ' Reg Select (1 = char)

    LcdDirs VAR DIRB ' dirs for I/O redirection
    LcdBusOut VAR OUTB

    this is a part of the code DS2760CAdv.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Best Regards

    Manuel C. Reinhard
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-04-14 17:32
    Everything from the BS2e and higher has eight program slots, though the BS2p family makes them easiest to use for data storage.· See the RUN command in the manual/help file for slot switching, and this article will help:

    http://www.parallax.com/dl/docs/cols/nv/vol3/col/nv87.pdf

    The RW and RS pins are dealt with using the LCDCMD, LCDOUT, and LCDIN instructions -- I put those definitions in the program so that people using it would be aware of each pin function.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • ManuelManuel Posts: 105
    edited 2006-04-15 18:03
    Hey Jon.
    I have some few more questions. As I have worked with many different basic stamps (BS2, BS2SX and now the BS2P), I have seen that sometimes constants change from one type of BS to another. Why is that? What defines the constant? for example the constants for the Baud Rate mode. For the Thermocouple code, does the constants change from the BS2PE to the BS2P?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Best Regards

    Manuel C. Reinhard
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-04-15 19:07
    Different Stamp modules run at different speeds, so this is accommodated in many cases with a different parameter value for a given instruction (SERIN and SEROUT are the instructions that get most into trouble). Some instructions, like PAUSE, are constant across all Stamps. Why do we do this (allow different parameter values)? To let you take advantage of the higher speed (= greater resolution in timing-oriented instructions).

    The BS2pe runs at the same speed as the BS2, the BS2p is 2.5x faster. That said, the 1-Wire protocol, used by the thermocouple (DS2760) module, has defined timing and is preadjusted in all BS2p-family Stamps. That said, the BS2pe is not fast enough for turbo mode 1-wire, but the BS2p is. FWIW, I've never found turbo mode useful as typical 1-Wire systems don't move a lot of data.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • ManuelManuel Posts: 105
    edited 2006-04-15 22:16
    Hey again!
    I was looking at your code again and saw that you use a OWIN command to retrieve the serial number , at least that's what I think, from the DS2760. Can I, instead of doing that, just retrieve the serial number once and then use it directly? What I mean is debuging the variable "char", and then writing it down... Because that way I think that I may be able to have many DS2760 in one pin, am I right?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Best Regards

    Manuel C. Reinhard

    Post Edited (Manuel) : 4/15/2006 10:23:21 PM GMT
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-04-15 22:31
    If you're going to use multiple devices then yes, you will have to know the serial number of each and address it accordingly. The check in that demo program simply ensures that the 1-Wire device is indeed a DS2760.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • ManuelManuel Posts: 105
    edited 2006-04-15 22:42
    Oh, so I could just retrieve once the serial number and forget about checking if it is a DS2760, right?
    I have a LCD related question. What takes less time for the stamp to dispay stuff, a parallel or a serial LCD? (Comparing two 16x2 LCDs). Also, Can I use a Scratchpad Ram value without storing it to a variable? Does SPRAM have a limited number of PUT's ? like the eeprom...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Best Regards

    Manuel C. Reinhard

    Post Edited (Manuel) : 4/15/2006 10:47:45 PM GMT
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-04-15 22:59
    (Note: It's easier for others to support your technical questions when you separate items into different threads)

    Parallax LCD access is faster, but uses seven pins.

    You can use the Scratchpad, but not like named variables; you need to use PUT and GET with an address, and the Word modifier for 16-bit values.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • ManuelManuel Posts: 105
    edited 2006-04-15 23:16
    That means that I cannot include a value stored in SPRAM direclty into an operation?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Best Regards

    Manuel C. Reinhard
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-04-15 23:18
    No, you cannot -- see GET and PUT for accessing the Scratchpad.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • ManuelManuel Posts: 105
    edited 2006-04-15 23:37
    Ohhh, that's sad to hear. BTW in your code i got lost a little bit. The second subroutine is "Read_Vin", but I couldn't find anywhere in the whole code where that subroutine is called. Am I missing something?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Best Regards

    Manuel C. Reinhard
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-04-16 00:07
    The DS2760 is not a thermocouple monitor -- it's simply being used in that application. One of its features is to read Vin so I included that subroutine for those who may need to use the DS2760 in other applications.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • ManuelManuel Posts: 105
    edited 2006-04-16 00:12
    That subroutine is to read voltages? like if someone wants to adapt the kit to monitor the bs battery pack?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Best Regards

    Manuel C. Reinhard
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-04-16 00:15
    Yes. Please consult the Dallas/Maxim·DS2760 documentation; I simply took those docs and created a useful subroutines, most are used in the DS2760 thermocouple module.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • ManuelManuel Posts: 105
    edited 2006-04-16 03:12
    That documentation is a little bit confusing. Do you know where I should send the serial in order to have the answer of the device I want?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Best Regards

    Manuel C. Reinhard
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-04-16 03:18
    Here's the thing: there's no way around understanding that stuff if you really want to write custom code for it. Give yourself some time -- those docs are a bit tough at first and you just need to grind it out; there is no magic, easy aswers (1-Wire is tough). Compare our DS2760 demo code with the docs to see how things operate.

    You'll also find a bunch of 1-Wire programs in our BS2p Plus Pack: http://www.parallax.com/detail.asp?product_id=45184. Again, compare those programs to the docs for the various parts and -- after a while -- you'll get the hang of it. None of demo programs were written in one sitting; we had to work at them.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • ManuelManuel Posts: 105
    edited 2006-04-20 03:44
    Hey!
    I kind of made it work, after fixing my mistakes like thousand times, lol. (I don't have yet tried many DS2760 on the same line, cuz I just own 1 right now, lol.) I just have a simple question. Am I right that the DS2760 can not give me values in a smaller meassure, so that I can meassure more accurately my K-junction temperature?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Best Regards

    Manuel C. Reinhard
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-04-20 06:06
    Check the DS2760 docs for resolution specs.

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