Shop OBEX P1 Docs P2 Docs Learn Events
EMIC Sound/DS1620 Digital Thermometer Help! — Parallax Forums

EMIC Sound/DS1620 Digital Thermometer Help!

GeraldGerald Posts: 10
edited 2005-11-29 21:32 in BASIC Stamp
I'm a newbie, so apologies up front for asking questions with obvious (to everyone but me) answers.

I have an EMIC text to sound module and a DS1620 IC.· I also have a Homework Board and a Boad of Education along with some experimenter breadboards.·

I've assembled both modules separately up till now but would like to combine the modules on a single breadboard with the ultimate goal of having the EMIC module announce the temperature.

My first task is to combine the circuitry on one board.· Is this a simple matter of combining the two modules using the attached diagrams on one board?· I notice that both share pin P0.· Is this a problem?· My goal, of course, is to combine the two on one board safely so I don't zap any components.

I'll then try to tackle the programming issues which I will obviously need some help with here.·

Is there any documentation that has already been developed to accomplish this project? I'm aware of the "DS1302 Real Time Clock with SX Video module display modification"·project in the project forum, but it's a bit too daunting for me to make the translation.

Any help would be greatly appreciated.

Thanks in advance,
Gerald
Amateur Radio Operator KD4EQZ
274 x 259 - 3K
548 x 341 - 6K

Comments

  • Mike CookMike Cook Posts: 829
    edited 2005-11-22 17:39
    Should be fairly simple if you take the development in small steps, if I was going to tackle this project I would do it this way:

    1. Using the DS1620 example code, build the circuit as described and get that working. Then move the speaker to a different I/O pin, for example 12, and modify the program so it works like the original. You didn't post any of the code, or a link to it, so your on your own in that respect.

    2. Leave all of the DS1620 stuff connected and move on to the EMIC module. Connect this up and get the EMIC only code to work.

    3. Now that you have both separate programs working, now comes the task of merging the two code chunks together in a way that you want the project to work.

    Mike

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "OEM NMEA GPS Module" Now available on ebay for only $19.99

    Product web site: http://www.allsurplus.net/Axiom/
  • Mike CookMike Cook Posts: 829
    edited 2005-11-22 17:57
    As a side note, I'm assuming that you are working with Parallax generated sample code for these two devices. Try your best to use the same "Coding Style" they have used in their·examples. This will make it easer for others to help, if you later post code that you are having problems with. Here's a link to the suggested coding style:

    http://www.parallax.com/dl/docs/prod/stamps/pbasicstyle.pdf

    Also remember that too many comments are better than none. I usually comment every line of my code as a "proof reading" exercise, this usually points out bone headed mistakes so I can make corrections if I'm having difficulties making something work.

    Mike

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "OEM NMEA GPS Module" Now available on ebay for only $19.99

    Product web site: http://www.allsurplus.net/Axiom/
  • GeraldGerald Posts: 10
    edited 2005-11-22 18:57
    Mike,

    Thanks for your suggestions.

    Yes, I'm intend to start with the code for the EMIC module here: http://www.parallax.com/dl/src/prod/3rd/EasyEmic.BS2

    and the code found on page 17 of the Applied Sensors student guide here:
    http://www.parallax.com/dl/docs/books/edu/AppliedSensors1_3.pdf

    I'll update my progress.

    Thanks,
    Gerald
  • GeraldGerald Posts: 10
    edited 2005-11-22 21:49
    Ok,

    Here's my progress so far.· I have repositioned each component (EMIC TTS and DS1620) on to two separate breadboards.· I have attached diagrams of the wiring showing the connections to the BS2.· Each of these two components are working correctly, when run separately, using the programs referenced in a previous post.

    Now, I will try to merge the two components on to a single breadboad.

    Mike, when you say "move the speaker to a different I/O pin, for example 12, and modify the program so it works like the original" are you referring to the EMIC speaker or the DS1620 Piezo "speaker"?· I assume you mean the piezo.

    Thanks,

    Gerald
    2520 x 1389 - 258K
  • Mike CookMike Cook Posts: 829
    edited 2005-11-22 22:09
    Piezo on the DS1620 Circuit & Code

    Mike

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "OEM NMEA GPS Module" Now available on ebay for only $19.99

    Product web site: http://www.allsurplus.net/Axiom/
  • GeraldGerald Posts: 10
    edited 2005-11-22 23:14
    I modified the DS1620 circuitry and assigned the Piezo to P12 and changed the code accordingly.· At this point, both modules are on the same breadboard and are connected to a common BS2.

    When I run the sample program found on page 17 of the Applied Sensors (Student Manual), everything works OK.

    Also, when I run the Simple Code Example found here http://www.parallax.com/dl/src/prod/3rd/EasyEmic.BS2, it runs OK.

    I have next tried to get both the EMIC module and the DS1620 to work within one program.· So, I combined some code (I know--a dangerous thing to do). See attached as EMICDS1620.bs2.

    What I was trying to achieve at this step was this:
    1: have the EMIC say, "Hello, Gerald, hear me roar".
    2: have the DS1620 display the temperature.

    I get #2 ok but not #1.

    Thanks for any help and for your patience with a newbie!

    Gerald
  • Mike CookMike Cook Posts: 829
    edited 2005-11-23 00:37
    Change:
    OUTS=%0000000000000100                    ' Define the initial state of all pins
         'FEDCBA9876543210
    DIRS=%1111111111111111                    ' as low outputs.
     
     
    to
     
     
    OUTS=%0000000000000110                     ' Define the initial state of all pins
        ' FEDCBA9876543210
    DIRS=%1111111111110000                     ' as low outputs.
    
    

    Mike

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "OEM NMEA GPS Module" Now available on ebay for only $19.99

    Product web site: http://www.allsurplus.net/Axiom/

    Post Edited (Mike Cook) : 11/23/2005 12:45:49 AM GMT
  • GeraldGerald Posts: 10
    edited 2005-11-23 07:34
    Mike,

    Your code corrections worked perfectly.· I will study up on OUTS, INS, DIRS, etc. It's pretty hard reading for me at this point, but important.

    I can now reliably run both modules on the same breadboard and from the same code.

    From all the sample EMIC BS2 programs I've looked at so far, the programmer stores all the possible·text to be generated as DATA·in EEPROM and then retrieves it when needed.· For example:

    ' -----[noparse][[/noparse] EEPROM Data ]----------------------------------------------------- 
    Demo1 DATA Say, "I love BASIC Stamps!", EOM 
    Demo2 DATA Say, "The time is 12:45", EOM 
    UseAbbr DATA Say, "Your current speed is 65 MPH", EOM
    Dial DATA Say, "Dialing", EOM 
    Phone DATA Say, "1-916-624-8333", EOM
    
    

    At some appropriate point in the code, the ASCII phrases, etc. are retrieved for EMIC as in the following subroutine Say_String:
    Say_String:
    
    DO 
    READ eePntr, char ' get char from EEPROM
    SEROUT Tx, Baud, [noparse][[/noparse]char] ' send it to Emic
    eePntr = eePntr + 1 ' point to next 
    LOOP UNTIL (char = EOM) ' stop when EOM found 
    RETURN
    

    Thus far, I've not seen any examples of using EMIC to speak text which changes constantly such as reading a news or stock ticker.· In the case of temperature, the variables which I have created (degC, degFA, and degFB) cannot be pronounced using the SEROUT Tx, Baud, [noparse][[/noparse]Say, "The temperature is...", EOM] syntax.· It would not make sense here to pre-store all the possible degrees for later retrieval since EMIC can already pronounce "57", "72", etc.

    So, it would seem to me that my code would need to derive the temperature from DS1620 and store that value as the temperature variable in EEPROM.··That variable would then be retrieved as in the above example (Say_String[noparse]:)[/noparse] for EMIC.· Am I heading in the right direction here?

    Also, I will wait until later the problem of which temperature formula to settle on. Right now I have not solved the problem of fractional degrees either.· The code I'm using only shows temperature in whole numbers.

    Any hints for me would be greatly appreciated.

    Thanks,
    Gerald
  • Mike CookMike Cook Posts: 829
    edited 2005-11-23 12:47
    Check out these links, they may help you with pronouncing numbers:

    http://forums.parallax.com/showthread.php?p=464293

    http://forums.parallax.com/showthread.php?p=464383

    http://www.parallax.com/dl/docs/cols/nv/vol5/col/nv108.pdf


    Now I would convert the DS1620 & EMIC into subroutines, this will make your main program loop simpler and also makes for code that is re-usable in other programs that use these items. Not to harp on the subject but give this a good read:

    http://www.parallax.com/dl/docs/prod/stamps/pbasicstyle.pdf

    I know it does not seem real important now but if you get into the habit of using these techniques it will make life easier later on when your debugging a complicated program.

    Mike

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "OEM NMEA GPS Module" Now available on ebay for only $19.99

    Product web site: http://www.allsurplus.net/Axiom/

    Post Edited (Mike Cook) : 11/23/2005 12:54:39 PM GMT
  • denodeno Posts: 242
    edited 2005-11-23 13:07
    Hello...just a a "another" foot note...you can send the EMIC device up to 128 bytes of data at once to its buffer. This is a average sentance.· The EMIC will then speak the phrase that you sent to it, and the stamp will continue on with it's program.·

    The EMIC will "do it's thing"...speak the phrase which might be 25 to 30 seconds long, depending on the length of the·sentance data·you have sent to it.

    The stamp on the other hand will continue running it's program doing other things while the EMIC is speaking...so don't have the stamp send the EMIC anymore sentence data until the EMIC is finished speaking what you have sent to it, or it will miss it.

    Be careful and don't get lost in setting up your DATA statements by mixing up the EEPROM address and the label for that address other wise you will speak the wrong sentancek or number.·

    If you are going to send the EMIC individual numbers for the correct temp, "build the whole sentance first then send it out to the EMIC serially.· It will sound better then sending one number/number/"point"(deciamal)/number at a time to the EMIC
    .
    My two cents worth....\

    deno
  • GeraldGerald Posts: 10
    edited 2005-11-23 13:49
    Thanks, Deno.

    I also just discovered this bit of code from Mike's references that will alleviate the EEPROM DATA writes:

    SEROUT Tx, Baud, [noparse][[/noparse]Say, "The temperature is ", DEC degFB," degrees Farenheit.", EOM

    I didn't know the syntax well enough to realize that you could concatenate stuff like this.

    Now, I'm working on computing/displaying/saying the fractional portion of the temperature calculation. I will also work on subroutines as Mike suggested and post my updated *.BS2 program soon.

    Any references here to how to compute the temperature to the nearest 10th would be helpful.

    Thus far my code for temperature calculations with the DS1620 are:

    degC = x / 2····························· ' Convert the data to degrees C.··

    degFA = degC * 9 / 5 + 32················ ' Convert the data to degrees F formula A.

    degFB = x * 9 / 10 + 32·················· ' Convert the data to degrees F formula B.

    Formula B seems to give a better temperature resolution than Formula A.

    Thanks All,

    Gerald
  • Mike CookMike Cook Posts: 829
    edited 2005-11-23 16:32
    This post hast some information on doing measurements down to .01 with the DS1620:

    http://forums.parallax.com/showthread.php?p=548617

    Check out Tracy's web site:

    www.emesystems.com

    He has some valuable information there for measurements and other techniques for the Basic Stamp.

    Mike

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "OEM NMEA GPS Module" Now available on ebay for only $19.99

    Product web site: http://www.allsurplus.net/Axiom/
  • GeraldGerald Posts: 10
    edited 2005-11-23 19:23
    Mike,

    These are great resources! What I really need to do is start with page 1 of "What is a Microcomputer." As you can imagine, my enthusiasm to do something "big" or "real" overtook my being a novice. Anyway, I'm having fun and learning a lot.

    Thanks,
    Gerald
  • Tom WalkerTom Walker Posts: 509
    edited 2005-11-23 19:35
    "Recognizing that you have a problem is the first step to curing it" [noparse]:)[/noparse]

    Wanting to get something "real" accomplished without learning the basics first is probably one of the most prevalent of the hacker mentality traits, but it sounds like you have acquired the "wisdom" necessary to continue in this glorious hobby.

    You may pass :^)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Truly Understand the Fundamentals and the Path will be so much easier...

    Post Edited (Tom Walker) : 11/23/2005 7:39:12 PM GMT
  • GeraldGerald Posts: 10
    edited 2005-11-28 14:00
    Before I quit this project and start over on page 1 of What is a Microcomputer, I'd like to ask a final question.

    Here is some code I found at www.emesystems.com which displays degrees C to two decimal places using the DS1620.··

    I'd like it to be able to show degrees Farenheit to two decimal places.·

    Any help here would be greatly appreciated.

    Thanks,
    Gerald

    ' {$STAMP BS2}
    ' DS1620 high resolution version
    ' gets data to +/- 0.01 degree Celsius resolution
    ' this routine covers the -55.00 to +125.00 range
    ' Tracy Allen, [url=http://www.emesystems.com/]http://www.emesystems.com[/url]
    ' P13=chip select
    '    high activates the DS1620 to receive data
    ' P14=serial data clock
    ' P15=serial SPI data in and out
    ' P0 is an optional piezo xducer for feedback
    

    j                      VAR Byte
    i                      VAR Nib
    x                      VAR Word
    remain                 VAR Word
    slope                  VAR Word
    degC                   VAR Word
    degFA                  VAR Byte               ' Variable to hold degrees Farenheit 1st formula
    degFB                  VAR Byte               ' Variable to hold degrees Farenheit 2nd formula
     
    OUTS=%0000000000000000
         'fedcba9876543210
    DIRS=%1111111111111101
    ' the following setting in eeprom needs to be done only once
    ' be sure to cycle the power to the DS1620 after changing!
    'high 13
    '  shiftout 15,14,lsbfirst,[noparse][[/noparse]$C,$3]
    'low 13
    PAUSE 100  ' allow time
    'DEBUG"testing DS1620 in hi res mode",CR
    DO
      'DEBUG "I'm going to subroutine ds1620...", CR
      GOSUB ds1620
      'DEBUG "I'm going to subroutine busy...", CR
      GOSUB busy
      'PAUSE 5000
    Loop
    
    ' main loop of this test program
    ds1620:        ' start a conversion
      HIGH 13
        SHIFTOUT 15,14,LSBFIRST,[noparse][[/noparse]$EE]
      LOW 13
      'DEBUG CR,"back from ds1620...", CR
      RETURN
      busy:                            ' wait for data to be ready (up to one second!)
      HIGH 13
        SHIFTOUT 15,14,LSBFIRST,[noparse][[/noparse]$AC]
        SHIFTIN 15,14,LSBPRE,[noparse][[/noparse]x]
      LOW 13
    
      HIGH 13                          ' request data byte and get it
        SHIFTOUT 15,14,LSBFIRST,[noparse][[/noparse]$AA]
        SHIFTIN 15,14,LSBPRE,[noparse][[/noparse]x\9]
      LOW 13
      x.BYTE1 = -x.BIT8                ' extend sign
      degC=x*5                         ' compute to 10ths, +/- 0.5 degree C
      'DEBUG REP "-"\degC.BIT15,DEC ABS degC/10,".",DEC1 ABS degC
      'FREQOUT 0,20,3800               ' signal result ready on piezo beeper
      HIGH 13                          ' get the count remaining DS1620
        SHIFTOUT 15,14,LSBFIRST,[noparse][[/noparse]$A0]
        SHIFTIN 15,14,LSBPRE,[noparse][[/noparse]remain\9]
      LOW 13
      HIGH 13                            ' get the counts per degree
        SHIFTOUT 15,14,LSBFIRST,[noparse][[/noparse]$A9]
        SHIFTIN 15,14,LSBPRE,[noparse][[/noparse]slope\9]
      LOW 13
      x=slope-remain*100/slope           ' compute 1/100ths degree
      degC=degC+550/10*100+x-5525        ' adjust temperature to 1/100ths
      DEBUG TAB,REP "-"\degC.BIT15,DEC ABS degC/100,".",DEC2 ABS degC
      'DEBUG TAB,DEC remain,32,DEC slope,CR  ' show the special values
     
      PAUSE 500
      DEBUG CR
      RETURN
    END
    
  • Tracy AllenTracy Allen Posts: 6,658
    edited 2005-11-28 20:26
    Sure. Once the program has degC to a resolution of 0.01 degree, the Stamp can convert it to degF with a resolution of 0.02 degree. Make degF a word variable

    ' enter with degC a twos complement number from -4000 to +12380
    ' representing temperatures from -40.00 to +123.80 degrees Celsius
    degC=degC + 4000 ' add an offset to make the number positive
    degF = degC ** 52429 + degC + 3200 - 7200 ' convert to Fahrenheit
    degC = degC - 4000 ' restore Celsius if necessary
    DEBUG TAB,REP "-"\degF.BIT15,DEC ABS degF/100,".",DEC2 ABS degF

    Why that funny formula? The formula works on positive numbers, so adding 4000 to degC and at the end subtracting 7200 from degF makes the offset and then restores it, so degC and degF are both twos complement numbers that can report negative temperatures. Note that 7200 = 4000 * 9/5.

    The operation **52429 is also a way to multiply by 0.8. What the **52429 does internally is multiply times the fraction 52429/65536, which is the same as 0.8. Then adding in degC again makes it 1.8, which is the conversion ratio for C to F.

    Be sure to follow the instructions in the program. The DS1620 has to be configured for single shot operation, and you have to cycle the power for the configuration to take effect. Once in that mode it will stay there, because the configuration is stored in eeprom.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
  • GeraldGerald Posts: 10
    edited 2005-11-28 20:45
    Thanks, Tracy! I'll try your approach!

    Gerald
  • GeraldGerald Posts: 10
    edited 2005-11-29 21:32
    A big·thanks to all who helped me in this my first BS2 project!

    I am attaching the final code. Temperature in C and F is announced to two decimal places.

    Previously, I posted diagrams of the DS1620 and EMIC breadboard wiring.

    It works!

    Gerald (KD4EQZ)
Sign In or Register to comment.